001
014
015 package com.liferay.portlet.mobiledevicerules.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
019 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
020 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderPath;
022 import com.liferay.portal.kernel.dao.orm.Query;
023 import com.liferay.portal.kernel.dao.orm.QueryPos;
024 import com.liferay.portal.kernel.dao.orm.QueryUtil;
025 import com.liferay.portal.kernel.dao.orm.Session;
026 import com.liferay.portal.kernel.exception.SystemException;
027 import com.liferay.portal.kernel.log.Log;
028 import com.liferay.portal.kernel.log.LogFactoryUtil;
029 import com.liferay.portal.kernel.util.GetterUtil;
030 import com.liferay.portal.kernel.util.InstanceFactory;
031 import com.liferay.portal.kernel.util.OrderByComparator;
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
053
065 public class MDRActionPersistenceImpl extends BasePersistenceImpl<MDRAction>
066 implements MDRActionPersistence {
067
072 public static final String FINDER_CLASS_NAME_ENTITY = MDRActionImpl.class.getName();
073 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074 ".List1";
075 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076 ".List2";
077 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
078 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
079 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
080 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
081 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
082 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
083 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
084 MDRActionModelImpl.FINDER_CACHE_ENABLED, Long.class,
085 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
086 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
087 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
088 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
089 new String[] {
090 String.class.getName(),
091
092 Integer.class.getName(), Integer.class.getName(),
093 OrderByComparator.class.getName()
094 });
095 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
096 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
097 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
098 new String[] { String.class.getName() },
099 MDRActionModelImpl.UUID_COLUMN_BITMASK);
100 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
101 MDRActionModelImpl.FINDER_CACHE_ENABLED, Long.class,
102 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
103 new String[] { String.class.getName() });
104
105
112 public List<MDRAction> findByUuid(String uuid) throws SystemException {
113 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
114 }
115
116
129 public List<MDRAction> findByUuid(String uuid, int start, int end)
130 throws SystemException {
131 return findByUuid(uuid, start, end, null);
132 }
133
134
148 public List<MDRAction> findByUuid(String uuid, int start, int end,
149 OrderByComparator orderByComparator) throws SystemException {
150 boolean pagination = true;
151 FinderPath finderPath = null;
152 Object[] finderArgs = null;
153
154 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
155 (orderByComparator == null)) {
156 pagination = false;
157 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
158 finderArgs = new Object[] { uuid };
159 }
160 else {
161 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
162 finderArgs = new Object[] { uuid, start, end, orderByComparator };
163 }
164
165 List<MDRAction> list = (List<MDRAction>)FinderCacheUtil.getResult(finderPath,
166 finderArgs, this);
167
168 if ((list != null) && !list.isEmpty()) {
169 for (MDRAction mdrAction : list) {
170 if (!Validator.equals(uuid, mdrAction.getUuid())) {
171 list = null;
172
173 break;
174 }
175 }
176 }
177
178 if (list == null) {
179 StringBundler query = null;
180
181 if (orderByComparator != null) {
182 query = new StringBundler(3 +
183 (orderByComparator.getOrderByFields().length * 3));
184 }
185 else {
186 query = new StringBundler(3);
187 }
188
189 query.append(_SQL_SELECT_MDRACTION_WHERE);
190
191 if (uuid == null) {
192 query.append(_FINDER_COLUMN_UUID_UUID_1);
193 }
194 else {
195 if (uuid.equals(StringPool.BLANK)) {
196 query.append(_FINDER_COLUMN_UUID_UUID_3);
197 }
198 else {
199 query.append(_FINDER_COLUMN_UUID_UUID_2);
200 }
201 }
202
203 if (orderByComparator != null) {
204 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
205 orderByComparator);
206 }
207 else
208 if (pagination) {
209 query.append(MDRActionModelImpl.ORDER_BY_JPQL);
210 }
211
212 String sql = query.toString();
213
214 Session session = null;
215
216 try {
217 session = openSession();
218
219 Query q = session.createQuery(sql);
220
221 QueryPos qPos = QueryPos.getInstance(q);
222
223 if (uuid != null) {
224 qPos.add(uuid);
225 }
226
227 if (!pagination) {
228 list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
229 start, end, false);
230
231 Collections.sort(list);
232
233 list = new UnmodifiableList<MDRAction>(list);
234 }
235 else {
236 list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
237 start, end);
238 }
239
240 cacheResult(list);
241
242 FinderCacheUtil.putResult(finderPath, finderArgs, list);
243 }
244 catch (Exception e) {
245 FinderCacheUtil.removeResult(finderPath, finderArgs);
246
247 throw processException(e);
248 }
249 finally {
250 closeSession(session);
251 }
252 }
253
254 return list;
255 }
256
257
266 public MDRAction findByUuid_First(String uuid,
267 OrderByComparator orderByComparator)
268 throws NoSuchActionException, SystemException {
269 MDRAction mdrAction = fetchByUuid_First(uuid, orderByComparator);
270
271 if (mdrAction != null) {
272 return mdrAction;
273 }
274
275 StringBundler msg = new StringBundler(4);
276
277 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
278
279 msg.append("uuid=");
280 msg.append(uuid);
281
282 msg.append(StringPool.CLOSE_CURLY_BRACE);
283
284 throw new NoSuchActionException(msg.toString());
285 }
286
287
295 public MDRAction fetchByUuid_First(String uuid,
296 OrderByComparator orderByComparator) throws SystemException {
297 List<MDRAction> list = findByUuid(uuid, 0, 1, orderByComparator);
298
299 if (!list.isEmpty()) {
300 return list.get(0);
301 }
302
303 return null;
304 }
305
306
315 public MDRAction findByUuid_Last(String uuid,
316 OrderByComparator orderByComparator)
317 throws NoSuchActionException, SystemException {
318 MDRAction mdrAction = fetchByUuid_Last(uuid, orderByComparator);
319
320 if (mdrAction != null) {
321 return mdrAction;
322 }
323
324 StringBundler msg = new StringBundler(4);
325
326 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
327
328 msg.append("uuid=");
329 msg.append(uuid);
330
331 msg.append(StringPool.CLOSE_CURLY_BRACE);
332
333 throw new NoSuchActionException(msg.toString());
334 }
335
336
344 public MDRAction fetchByUuid_Last(String uuid,
345 OrderByComparator orderByComparator) throws SystemException {
346 int count = countByUuid(uuid);
347
348 List<MDRAction> list = findByUuid(uuid, count - 1, count,
349 orderByComparator);
350
351 if (!list.isEmpty()) {
352 return list.get(0);
353 }
354
355 return null;
356 }
357
358
368 public MDRAction[] findByUuid_PrevAndNext(long actionId, String uuid,
369 OrderByComparator orderByComparator)
370 throws NoSuchActionException, SystemException {
371 MDRAction mdrAction = findByPrimaryKey(actionId);
372
373 Session session = null;
374
375 try {
376 session = openSession();
377
378 MDRAction[] array = new MDRActionImpl[3];
379
380 array[0] = getByUuid_PrevAndNext(session, mdrAction, uuid,
381 orderByComparator, true);
382
383 array[1] = mdrAction;
384
385 array[2] = getByUuid_PrevAndNext(session, mdrAction, uuid,
386 orderByComparator, false);
387
388 return array;
389 }
390 catch (Exception e) {
391 throw processException(e);
392 }
393 finally {
394 closeSession(session);
395 }
396 }
397
398 protected MDRAction getByUuid_PrevAndNext(Session session,
399 MDRAction mdrAction, String uuid, OrderByComparator orderByComparator,
400 boolean previous) {
401 StringBundler query = null;
402
403 if (orderByComparator != null) {
404 query = new StringBundler(6 +
405 (orderByComparator.getOrderByFields().length * 6));
406 }
407 else {
408 query = new StringBundler(3);
409 }
410
411 query.append(_SQL_SELECT_MDRACTION_WHERE);
412
413 if (uuid == null) {
414 query.append(_FINDER_COLUMN_UUID_UUID_1);
415 }
416 else {
417 if (uuid.equals(StringPool.BLANK)) {
418 query.append(_FINDER_COLUMN_UUID_UUID_3);
419 }
420 else {
421 query.append(_FINDER_COLUMN_UUID_UUID_2);
422 }
423 }
424
425 if (orderByComparator != null) {
426 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
427
428 if (orderByConditionFields.length > 0) {
429 query.append(WHERE_AND);
430 }
431
432 for (int i = 0; i < orderByConditionFields.length; i++) {
433 query.append(_ORDER_BY_ENTITY_ALIAS);
434 query.append(orderByConditionFields[i]);
435
436 if ((i + 1) < orderByConditionFields.length) {
437 if (orderByComparator.isAscending() ^ previous) {
438 query.append(WHERE_GREATER_THAN_HAS_NEXT);
439 }
440 else {
441 query.append(WHERE_LESSER_THAN_HAS_NEXT);
442 }
443 }
444 else {
445 if (orderByComparator.isAscending() ^ previous) {
446 query.append(WHERE_GREATER_THAN);
447 }
448 else {
449 query.append(WHERE_LESSER_THAN);
450 }
451 }
452 }
453
454 query.append(ORDER_BY_CLAUSE);
455
456 String[] orderByFields = orderByComparator.getOrderByFields();
457
458 for (int i = 0; i < orderByFields.length; i++) {
459 query.append(_ORDER_BY_ENTITY_ALIAS);
460 query.append(orderByFields[i]);
461
462 if ((i + 1) < orderByFields.length) {
463 if (orderByComparator.isAscending() ^ previous) {
464 query.append(ORDER_BY_ASC_HAS_NEXT);
465 }
466 else {
467 query.append(ORDER_BY_DESC_HAS_NEXT);
468 }
469 }
470 else {
471 if (orderByComparator.isAscending() ^ previous) {
472 query.append(ORDER_BY_ASC);
473 }
474 else {
475 query.append(ORDER_BY_DESC);
476 }
477 }
478 }
479 }
480 else {
481 query.append(MDRActionModelImpl.ORDER_BY_JPQL);
482 }
483
484 String sql = query.toString();
485
486 Query q = session.createQuery(sql);
487
488 q.setFirstResult(0);
489 q.setMaxResults(2);
490
491 QueryPos qPos = QueryPos.getInstance(q);
492
493 if (uuid != null) {
494 qPos.add(uuid);
495 }
496
497 if (orderByComparator != null) {
498 Object[] values = orderByComparator.getOrderByConditionValues(mdrAction);
499
500 for (Object value : values) {
501 qPos.add(value);
502 }
503 }
504
505 List<MDRAction> list = q.list();
506
507 if (list.size() == 2) {
508 return list.get(1);
509 }
510 else {
511 return null;
512 }
513 }
514
515
521 public void removeByUuid(String uuid) throws SystemException {
522 for (MDRAction mdrAction : findByUuid(uuid, QueryUtil.ALL_POS,
523 QueryUtil.ALL_POS, null)) {
524 remove(mdrAction);
525 }
526 }
527
528
535 public int countByUuid(String uuid) throws SystemException {
536 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
537
538 Object[] finderArgs = new Object[] { uuid };
539
540 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
541 this);
542
543 if (count == null) {
544 StringBundler query = new StringBundler(2);
545
546 query.append(_SQL_COUNT_MDRACTION_WHERE);
547
548 if (uuid == null) {
549 query.append(_FINDER_COLUMN_UUID_UUID_1);
550 }
551 else {
552 if (uuid.equals(StringPool.BLANK)) {
553 query.append(_FINDER_COLUMN_UUID_UUID_3);
554 }
555 else {
556 query.append(_FINDER_COLUMN_UUID_UUID_2);
557 }
558 }
559
560 String sql = query.toString();
561
562 Session session = null;
563
564 try {
565 session = openSession();
566
567 Query q = session.createQuery(sql);
568
569 QueryPos qPos = QueryPos.getInstance(q);
570
571 if (uuid != null) {
572 qPos.add(uuid);
573 }
574
575 count = (Long)q.uniqueResult();
576
577 FinderCacheUtil.putResult(finderPath, finderArgs, count);
578 }
579 catch (Exception e) {
580 FinderCacheUtil.removeResult(finderPath, finderArgs);
581
582 throw processException(e);
583 }
584 finally {
585 closeSession(session);
586 }
587 }
588
589 return count.intValue();
590 }
591
592 private static final String _FINDER_COLUMN_UUID_UUID_1 = "mdrAction.uuid IS NULL";
593 private static final String _FINDER_COLUMN_UUID_UUID_2 = "mdrAction.uuid = ?";
594 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(mdrAction.uuid IS NULL OR mdrAction.uuid = ?)";
595 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
596 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
597 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
598 new String[] { String.class.getName(), Long.class.getName() },
599 MDRActionModelImpl.UUID_COLUMN_BITMASK |
600 MDRActionModelImpl.GROUPID_COLUMN_BITMASK);
601 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
602 MDRActionModelImpl.FINDER_CACHE_ENABLED, Long.class,
603 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
604 new String[] { String.class.getName(), Long.class.getName() });
605
606
615 public MDRAction findByUUID_G(String uuid, long groupId)
616 throws NoSuchActionException, SystemException {
617 MDRAction mdrAction = fetchByUUID_G(uuid, groupId);
618
619 if (mdrAction == null) {
620 StringBundler msg = new StringBundler(6);
621
622 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
623
624 msg.append("uuid=");
625 msg.append(uuid);
626
627 msg.append(", groupId=");
628 msg.append(groupId);
629
630 msg.append(StringPool.CLOSE_CURLY_BRACE);
631
632 if (_log.isWarnEnabled()) {
633 _log.warn(msg.toString());
634 }
635
636 throw new NoSuchActionException(msg.toString());
637 }
638
639 return mdrAction;
640 }
641
642
650 public MDRAction fetchByUUID_G(String uuid, long groupId)
651 throws SystemException {
652 return fetchByUUID_G(uuid, groupId, true);
653 }
654
655
664 public MDRAction fetchByUUID_G(String uuid, long groupId,
665 boolean retrieveFromCache) throws SystemException {
666 Object[] finderArgs = new Object[] { uuid, groupId };
667
668 Object result = null;
669
670 if (retrieveFromCache) {
671 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
672 finderArgs, this);
673 }
674
675 if (result instanceof MDRAction) {
676 MDRAction mdrAction = (MDRAction)result;
677
678 if (!Validator.equals(uuid, mdrAction.getUuid()) ||
679 (groupId != mdrAction.getGroupId())) {
680 result = null;
681 }
682 }
683
684 if (result == null) {
685 StringBundler query = new StringBundler(4);
686
687 query.append(_SQL_SELECT_MDRACTION_WHERE);
688
689 if (uuid == null) {
690 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
691 }
692 else {
693 if (uuid.equals(StringPool.BLANK)) {
694 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
695 }
696 else {
697 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
698 }
699 }
700
701 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
702
703 String sql = query.toString();
704
705 Session session = null;
706
707 try {
708 session = openSession();
709
710 Query q = session.createQuery(sql);
711
712 QueryPos qPos = QueryPos.getInstance(q);
713
714 if (uuid != null) {
715 qPos.add(uuid);
716 }
717
718 qPos.add(groupId);
719
720 List<MDRAction> list = q.list();
721
722 if (list.isEmpty()) {
723 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
724 finderArgs, list);
725 }
726 else {
727 MDRAction mdrAction = list.get(0);
728
729 result = mdrAction;
730
731 cacheResult(mdrAction);
732
733 if ((mdrAction.getUuid() == null) ||
734 !mdrAction.getUuid().equals(uuid) ||
735 (mdrAction.getGroupId() != groupId)) {
736 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
737 finderArgs, mdrAction);
738 }
739 }
740 }
741 catch (Exception e) {
742 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
743 finderArgs);
744
745 throw processException(e);
746 }
747 finally {
748 closeSession(session);
749 }
750 }
751
752 if (result instanceof List<?>) {
753 return null;
754 }
755 else {
756 return (MDRAction)result;
757 }
758 }
759
760
768 public MDRAction removeByUUID_G(String uuid, long groupId)
769 throws NoSuchActionException, SystemException {
770 MDRAction mdrAction = findByUUID_G(uuid, groupId);
771
772 return remove(mdrAction);
773 }
774
775
783 public int countByUUID_G(String uuid, long groupId)
784 throws SystemException {
785 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
786
787 Object[] finderArgs = new Object[] { uuid, groupId };
788
789 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
790 this);
791
792 if (count == null) {
793 StringBundler query = new StringBundler(3);
794
795 query.append(_SQL_COUNT_MDRACTION_WHERE);
796
797 if (uuid == null) {
798 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
799 }
800 else {
801 if (uuid.equals(StringPool.BLANK)) {
802 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
803 }
804 else {
805 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
806 }
807 }
808
809 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
810
811 String sql = query.toString();
812
813 Session session = null;
814
815 try {
816 session = openSession();
817
818 Query q = session.createQuery(sql);
819
820 QueryPos qPos = QueryPos.getInstance(q);
821
822 if (uuid != null) {
823 qPos.add(uuid);
824 }
825
826 qPos.add(groupId);
827
828 count = (Long)q.uniqueResult();
829
830 FinderCacheUtil.putResult(finderPath, finderArgs, count);
831 }
832 catch (Exception e) {
833 FinderCacheUtil.removeResult(finderPath, finderArgs);
834
835 throw processException(e);
836 }
837 finally {
838 closeSession(session);
839 }
840 }
841
842 return count.intValue();
843 }
844
845 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "mdrAction.uuid IS NULL AND ";
846 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "mdrAction.uuid = ? AND ";
847 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(mdrAction.uuid IS NULL OR mdrAction.uuid = ?) AND ";
848 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "mdrAction.groupId = ?";
849 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
850 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
851 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
852 new String[] {
853 String.class.getName(), Long.class.getName(),
854
855 Integer.class.getName(), Integer.class.getName(),
856 OrderByComparator.class.getName()
857 });
858 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
859 new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
860 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
861 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
862 new String[] { String.class.getName(), Long.class.getName() },
863 MDRActionModelImpl.UUID_COLUMN_BITMASK |
864 MDRActionModelImpl.COMPANYID_COLUMN_BITMASK);
865 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
866 MDRActionModelImpl.FINDER_CACHE_ENABLED, Long.class,
867 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
868 new String[] { String.class.getName(), Long.class.getName() });
869
870
878 public List<MDRAction> findByUuid_C(String uuid, long companyId)
879 throws SystemException {
880 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
881 QueryUtil.ALL_POS, null);
882 }
883
884
898 public List<MDRAction> findByUuid_C(String uuid, long companyId, int start,
899 int end) throws SystemException {
900 return findByUuid_C(uuid, companyId, start, end, null);
901 }
902
903
918 public List<MDRAction> findByUuid_C(String uuid, long companyId, int start,
919 int end, OrderByComparator orderByComparator) throws SystemException {
920 boolean pagination = true;
921 FinderPath finderPath = null;
922 Object[] finderArgs = null;
923
924 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
925 (orderByComparator == null)) {
926 pagination = false;
927 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
928 finderArgs = new Object[] { uuid, companyId };
929 }
930 else {
931 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
932 finderArgs = new Object[] {
933 uuid, companyId,
934
935 start, end, orderByComparator
936 };
937 }
938
939 List<MDRAction> list = (List<MDRAction>)FinderCacheUtil.getResult(finderPath,
940 finderArgs, this);
941
942 if ((list != null) && !list.isEmpty()) {
943 for (MDRAction mdrAction : list) {
944 if (!Validator.equals(uuid, mdrAction.getUuid()) ||
945 (companyId != mdrAction.getCompanyId())) {
946 list = null;
947
948 break;
949 }
950 }
951 }
952
953 if (list == null) {
954 StringBundler query = null;
955
956 if (orderByComparator != null) {
957 query = new StringBundler(4 +
958 (orderByComparator.getOrderByFields().length * 3));
959 }
960 else {
961 query = new StringBundler(4);
962 }
963
964 query.append(_SQL_SELECT_MDRACTION_WHERE);
965
966 if (uuid == null) {
967 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
968 }
969 else {
970 if (uuid.equals(StringPool.BLANK)) {
971 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
972 }
973 else {
974 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
975 }
976 }
977
978 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
979
980 if (orderByComparator != null) {
981 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
982 orderByComparator);
983 }
984 else
985 if (pagination) {
986 query.append(MDRActionModelImpl.ORDER_BY_JPQL);
987 }
988
989 String sql = query.toString();
990
991 Session session = null;
992
993 try {
994 session = openSession();
995
996 Query q = session.createQuery(sql);
997
998 QueryPos qPos = QueryPos.getInstance(q);
999
1000 if (uuid != null) {
1001 qPos.add(uuid);
1002 }
1003
1004 qPos.add(companyId);
1005
1006 if (!pagination) {
1007 list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
1008 start, end, false);
1009
1010 Collections.sort(list);
1011
1012 list = new UnmodifiableList<MDRAction>(list);
1013 }
1014 else {
1015 list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
1016 start, end);
1017 }
1018
1019 cacheResult(list);
1020
1021 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1022 }
1023 catch (Exception e) {
1024 FinderCacheUtil.removeResult(finderPath, finderArgs);
1025
1026 throw processException(e);
1027 }
1028 finally {
1029 closeSession(session);
1030 }
1031 }
1032
1033 return list;
1034 }
1035
1036
1046 public MDRAction findByUuid_C_First(String uuid, long companyId,
1047 OrderByComparator orderByComparator)
1048 throws NoSuchActionException, SystemException {
1049 MDRAction mdrAction = fetchByUuid_C_First(uuid, companyId,
1050 orderByComparator);
1051
1052 if (mdrAction != null) {
1053 return mdrAction;
1054 }
1055
1056 StringBundler msg = new StringBundler(6);
1057
1058 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1059
1060 msg.append("uuid=");
1061 msg.append(uuid);
1062
1063 msg.append(", companyId=");
1064 msg.append(companyId);
1065
1066 msg.append(StringPool.CLOSE_CURLY_BRACE);
1067
1068 throw new NoSuchActionException(msg.toString());
1069 }
1070
1071
1080 public MDRAction fetchByUuid_C_First(String uuid, long companyId,
1081 OrderByComparator orderByComparator) throws SystemException {
1082 List<MDRAction> list = findByUuid_C(uuid, companyId, 0, 1,
1083 orderByComparator);
1084
1085 if (!list.isEmpty()) {
1086 return list.get(0);
1087 }
1088
1089 return null;
1090 }
1091
1092
1102 public MDRAction findByUuid_C_Last(String uuid, long companyId,
1103 OrderByComparator orderByComparator)
1104 throws NoSuchActionException, SystemException {
1105 MDRAction mdrAction = fetchByUuid_C_Last(uuid, companyId,
1106 orderByComparator);
1107
1108 if (mdrAction != null) {
1109 return mdrAction;
1110 }
1111
1112 StringBundler msg = new StringBundler(6);
1113
1114 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1115
1116 msg.append("uuid=");
1117 msg.append(uuid);
1118
1119 msg.append(", companyId=");
1120 msg.append(companyId);
1121
1122 msg.append(StringPool.CLOSE_CURLY_BRACE);
1123
1124 throw new NoSuchActionException(msg.toString());
1125 }
1126
1127
1136 public MDRAction fetchByUuid_C_Last(String uuid, long companyId,
1137 OrderByComparator orderByComparator) throws SystemException {
1138 int count = countByUuid_C(uuid, companyId);
1139
1140 List<MDRAction> list = findByUuid_C(uuid, companyId, count - 1, count,
1141 orderByComparator);
1142
1143 if (!list.isEmpty()) {
1144 return list.get(0);
1145 }
1146
1147 return null;
1148 }
1149
1150
1161 public MDRAction[] findByUuid_C_PrevAndNext(long actionId, String uuid,
1162 long companyId, OrderByComparator orderByComparator)
1163 throws NoSuchActionException, SystemException {
1164 MDRAction mdrAction = findByPrimaryKey(actionId);
1165
1166 Session session = null;
1167
1168 try {
1169 session = openSession();
1170
1171 MDRAction[] array = new MDRActionImpl[3];
1172
1173 array[0] = getByUuid_C_PrevAndNext(session, mdrAction, uuid,
1174 companyId, orderByComparator, true);
1175
1176 array[1] = mdrAction;
1177
1178 array[2] = getByUuid_C_PrevAndNext(session, mdrAction, uuid,
1179 companyId, orderByComparator, false);
1180
1181 return array;
1182 }
1183 catch (Exception e) {
1184 throw processException(e);
1185 }
1186 finally {
1187 closeSession(session);
1188 }
1189 }
1190
1191 protected MDRAction getByUuid_C_PrevAndNext(Session session,
1192 MDRAction mdrAction, String uuid, long companyId,
1193 OrderByComparator orderByComparator, boolean previous) {
1194 StringBundler query = null;
1195
1196 if (orderByComparator != null) {
1197 query = new StringBundler(6 +
1198 (orderByComparator.getOrderByFields().length * 6));
1199 }
1200 else {
1201 query = new StringBundler(3);
1202 }
1203
1204 query.append(_SQL_SELECT_MDRACTION_WHERE);
1205
1206 if (uuid == null) {
1207 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1208 }
1209 else {
1210 if (uuid.equals(StringPool.BLANK)) {
1211 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1212 }
1213 else {
1214 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1215 }
1216 }
1217
1218 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1219
1220 if (orderByComparator != null) {
1221 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1222
1223 if (orderByConditionFields.length > 0) {
1224 query.append(WHERE_AND);
1225 }
1226
1227 for (int i = 0; i < orderByConditionFields.length; i++) {
1228 query.append(_ORDER_BY_ENTITY_ALIAS);
1229 query.append(orderByConditionFields[i]);
1230
1231 if ((i + 1) < orderByConditionFields.length) {
1232 if (orderByComparator.isAscending() ^ previous) {
1233 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1234 }
1235 else {
1236 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1237 }
1238 }
1239 else {
1240 if (orderByComparator.isAscending() ^ previous) {
1241 query.append(WHERE_GREATER_THAN);
1242 }
1243 else {
1244 query.append(WHERE_LESSER_THAN);
1245 }
1246 }
1247 }
1248
1249 query.append(ORDER_BY_CLAUSE);
1250
1251 String[] orderByFields = orderByComparator.getOrderByFields();
1252
1253 for (int i = 0; i < orderByFields.length; i++) {
1254 query.append(_ORDER_BY_ENTITY_ALIAS);
1255 query.append(orderByFields[i]);
1256
1257 if ((i + 1) < orderByFields.length) {
1258 if (orderByComparator.isAscending() ^ previous) {
1259 query.append(ORDER_BY_ASC_HAS_NEXT);
1260 }
1261 else {
1262 query.append(ORDER_BY_DESC_HAS_NEXT);
1263 }
1264 }
1265 else {
1266 if (orderByComparator.isAscending() ^ previous) {
1267 query.append(ORDER_BY_ASC);
1268 }
1269 else {
1270 query.append(ORDER_BY_DESC);
1271 }
1272 }
1273 }
1274 }
1275 else {
1276 query.append(MDRActionModelImpl.ORDER_BY_JPQL);
1277 }
1278
1279 String sql = query.toString();
1280
1281 Query q = session.createQuery(sql);
1282
1283 q.setFirstResult(0);
1284 q.setMaxResults(2);
1285
1286 QueryPos qPos = QueryPos.getInstance(q);
1287
1288 if (uuid != null) {
1289 qPos.add(uuid);
1290 }
1291
1292 qPos.add(companyId);
1293
1294 if (orderByComparator != null) {
1295 Object[] values = orderByComparator.getOrderByConditionValues(mdrAction);
1296
1297 for (Object value : values) {
1298 qPos.add(value);
1299 }
1300 }
1301
1302 List<MDRAction> list = q.list();
1303
1304 if (list.size() == 2) {
1305 return list.get(1);
1306 }
1307 else {
1308 return null;
1309 }
1310 }
1311
1312
1319 public void removeByUuid_C(String uuid, long companyId)
1320 throws SystemException {
1321 for (MDRAction mdrAction : findByUuid_C(uuid, companyId,
1322 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1323 remove(mdrAction);
1324 }
1325 }
1326
1327
1335 public int countByUuid_C(String uuid, long companyId)
1336 throws SystemException {
1337 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1338
1339 Object[] finderArgs = new Object[] { uuid, companyId };
1340
1341 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1342 this);
1343
1344 if (count == null) {
1345 StringBundler query = new StringBundler(3);
1346
1347 query.append(_SQL_COUNT_MDRACTION_WHERE);
1348
1349 if (uuid == null) {
1350 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1351 }
1352 else {
1353 if (uuid.equals(StringPool.BLANK)) {
1354 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1355 }
1356 else {
1357 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1358 }
1359 }
1360
1361 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1362
1363 String sql = query.toString();
1364
1365 Session session = null;
1366
1367 try {
1368 session = openSession();
1369
1370 Query q = session.createQuery(sql);
1371
1372 QueryPos qPos = QueryPos.getInstance(q);
1373
1374 if (uuid != null) {
1375 qPos.add(uuid);
1376 }
1377
1378 qPos.add(companyId);
1379
1380 count = (Long)q.uniqueResult();
1381
1382 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1383 }
1384 catch (Exception e) {
1385 FinderCacheUtil.removeResult(finderPath, finderArgs);
1386
1387 throw processException(e);
1388 }
1389 finally {
1390 closeSession(session);
1391 }
1392 }
1393
1394 return count.intValue();
1395 }
1396
1397 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "mdrAction.uuid IS NULL AND ";
1398 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "mdrAction.uuid = ? AND ";
1399 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(mdrAction.uuid IS NULL OR mdrAction.uuid = ?) AND ";
1400 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "mdrAction.companyId = ?";
1401 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RULEGROUPINSTANCEID =
1402 new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
1403 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
1404 FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1405 "findByRuleGroupInstanceId",
1406 new String[] {
1407 Long.class.getName(),
1408
1409 Integer.class.getName(), Integer.class.getName(),
1410 OrderByComparator.class.getName()
1411 });
1412 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID =
1413 new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
1414 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
1415 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1416 "findByRuleGroupInstanceId", new String[] { Long.class.getName() },
1417 MDRActionModelImpl.RULEGROUPINSTANCEID_COLUMN_BITMASK);
1418 public static final FinderPath FINDER_PATH_COUNT_BY_RULEGROUPINSTANCEID = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
1419 MDRActionModelImpl.FINDER_CACHE_ENABLED, Long.class,
1420 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1421 "countByRuleGroupInstanceId", new String[] { Long.class.getName() });
1422
1423
1430 public List<MDRAction> findByRuleGroupInstanceId(long ruleGroupInstanceId)
1431 throws SystemException {
1432 return findByRuleGroupInstanceId(ruleGroupInstanceId,
1433 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1434 }
1435
1436
1449 public List<MDRAction> findByRuleGroupInstanceId(long ruleGroupInstanceId,
1450 int start, int end) throws SystemException {
1451 return findByRuleGroupInstanceId(ruleGroupInstanceId, start, end, null);
1452 }
1453
1454
1468 public List<MDRAction> findByRuleGroupInstanceId(long ruleGroupInstanceId,
1469 int start, int end, OrderByComparator orderByComparator)
1470 throws SystemException {
1471 boolean pagination = true;
1472 FinderPath finderPath = null;
1473 Object[] finderArgs = null;
1474
1475 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1476 (orderByComparator == null)) {
1477 pagination = false;
1478 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID;
1479 finderArgs = new Object[] { ruleGroupInstanceId };
1480 }
1481 else {
1482 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RULEGROUPINSTANCEID;
1483 finderArgs = new Object[] {
1484 ruleGroupInstanceId,
1485
1486 start, end, orderByComparator
1487 };
1488 }
1489
1490 List<MDRAction> list = (List<MDRAction>)FinderCacheUtil.getResult(finderPath,
1491 finderArgs, this);
1492
1493 if ((list != null) && !list.isEmpty()) {
1494 for (MDRAction mdrAction : list) {
1495 if ((ruleGroupInstanceId != mdrAction.getRuleGroupInstanceId())) {
1496 list = null;
1497
1498 break;
1499 }
1500 }
1501 }
1502
1503 if (list == null) {
1504 StringBundler query = null;
1505
1506 if (orderByComparator != null) {
1507 query = new StringBundler(3 +
1508 (orderByComparator.getOrderByFields().length * 3));
1509 }
1510 else {
1511 query = new StringBundler(3);
1512 }
1513
1514 query.append(_SQL_SELECT_MDRACTION_WHERE);
1515
1516 query.append(_FINDER_COLUMN_RULEGROUPINSTANCEID_RULEGROUPINSTANCEID_2);
1517
1518 if (orderByComparator != null) {
1519 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1520 orderByComparator);
1521 }
1522 else
1523 if (pagination) {
1524 query.append(MDRActionModelImpl.ORDER_BY_JPQL);
1525 }
1526
1527 String sql = query.toString();
1528
1529 Session session = null;
1530
1531 try {
1532 session = openSession();
1533
1534 Query q = session.createQuery(sql);
1535
1536 QueryPos qPos = QueryPos.getInstance(q);
1537
1538 qPos.add(ruleGroupInstanceId);
1539
1540 if (!pagination) {
1541 list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
1542 start, end, false);
1543
1544 Collections.sort(list);
1545
1546 list = new UnmodifiableList<MDRAction>(list);
1547 }
1548 else {
1549 list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
1550 start, end);
1551 }
1552
1553 cacheResult(list);
1554
1555 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1556 }
1557 catch (Exception e) {
1558 FinderCacheUtil.removeResult(finderPath, finderArgs);
1559
1560 throw processException(e);
1561 }
1562 finally {
1563 closeSession(session);
1564 }
1565 }
1566
1567 return list;
1568 }
1569
1570
1579 public MDRAction findByRuleGroupInstanceId_First(long ruleGroupInstanceId,
1580 OrderByComparator orderByComparator)
1581 throws NoSuchActionException, SystemException {
1582 MDRAction mdrAction = fetchByRuleGroupInstanceId_First(ruleGroupInstanceId,
1583 orderByComparator);
1584
1585 if (mdrAction != null) {
1586 return mdrAction;
1587 }
1588
1589 StringBundler msg = new StringBundler(4);
1590
1591 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1592
1593 msg.append("ruleGroupInstanceId=");
1594 msg.append(ruleGroupInstanceId);
1595
1596 msg.append(StringPool.CLOSE_CURLY_BRACE);
1597
1598 throw new NoSuchActionException(msg.toString());
1599 }
1600
1601
1609 public MDRAction fetchByRuleGroupInstanceId_First(
1610 long ruleGroupInstanceId, OrderByComparator orderByComparator)
1611 throws SystemException {
1612 List<MDRAction> list = findByRuleGroupInstanceId(ruleGroupInstanceId,
1613 0, 1, orderByComparator);
1614
1615 if (!list.isEmpty()) {
1616 return list.get(0);
1617 }
1618
1619 return null;
1620 }
1621
1622
1631 public MDRAction findByRuleGroupInstanceId_Last(long ruleGroupInstanceId,
1632 OrderByComparator orderByComparator)
1633 throws NoSuchActionException, SystemException {
1634 MDRAction mdrAction = fetchByRuleGroupInstanceId_Last(ruleGroupInstanceId,
1635 orderByComparator);
1636
1637 if (mdrAction != null) {
1638 return mdrAction;
1639 }
1640
1641 StringBundler msg = new StringBundler(4);
1642
1643 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1644
1645 msg.append("ruleGroupInstanceId=");
1646 msg.append(ruleGroupInstanceId);
1647
1648 msg.append(StringPool.CLOSE_CURLY_BRACE);
1649
1650 throw new NoSuchActionException(msg.toString());
1651 }
1652
1653
1661 public MDRAction fetchByRuleGroupInstanceId_Last(long ruleGroupInstanceId,
1662 OrderByComparator orderByComparator) throws SystemException {
1663 int count = countByRuleGroupInstanceId(ruleGroupInstanceId);
1664
1665 List<MDRAction> list = findByRuleGroupInstanceId(ruleGroupInstanceId,
1666 count - 1, count, orderByComparator);
1667
1668 if (!list.isEmpty()) {
1669 return list.get(0);
1670 }
1671
1672 return null;
1673 }
1674
1675
1685 public MDRAction[] findByRuleGroupInstanceId_PrevAndNext(long actionId,
1686 long ruleGroupInstanceId, OrderByComparator orderByComparator)
1687 throws NoSuchActionException, SystemException {
1688 MDRAction mdrAction = findByPrimaryKey(actionId);
1689
1690 Session session = null;
1691
1692 try {
1693 session = openSession();
1694
1695 MDRAction[] array = new MDRActionImpl[3];
1696
1697 array[0] = getByRuleGroupInstanceId_PrevAndNext(session, mdrAction,
1698 ruleGroupInstanceId, orderByComparator, true);
1699
1700 array[1] = mdrAction;
1701
1702 array[2] = getByRuleGroupInstanceId_PrevAndNext(session, mdrAction,
1703 ruleGroupInstanceId, orderByComparator, false);
1704
1705 return array;
1706 }
1707 catch (Exception e) {
1708 throw processException(e);
1709 }
1710 finally {
1711 closeSession(session);
1712 }
1713 }
1714
1715 protected MDRAction getByRuleGroupInstanceId_PrevAndNext(Session session,
1716 MDRAction mdrAction, long ruleGroupInstanceId,
1717 OrderByComparator orderByComparator, boolean previous) {
1718 StringBundler query = null;
1719
1720 if (orderByComparator != null) {
1721 query = new StringBundler(6 +
1722 (orderByComparator.getOrderByFields().length * 6));
1723 }
1724 else {
1725 query = new StringBundler(3);
1726 }
1727
1728 query.append(_SQL_SELECT_MDRACTION_WHERE);
1729
1730 query.append(_FINDER_COLUMN_RULEGROUPINSTANCEID_RULEGROUPINSTANCEID_2);
1731
1732 if (orderByComparator != null) {
1733 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1734
1735 if (orderByConditionFields.length > 0) {
1736 query.append(WHERE_AND);
1737 }
1738
1739 for (int i = 0; i < orderByConditionFields.length; i++) {
1740 query.append(_ORDER_BY_ENTITY_ALIAS);
1741 query.append(orderByConditionFields[i]);
1742
1743 if ((i + 1) < orderByConditionFields.length) {
1744 if (orderByComparator.isAscending() ^ previous) {
1745 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1746 }
1747 else {
1748 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1749 }
1750 }
1751 else {
1752 if (orderByComparator.isAscending() ^ previous) {
1753 query.append(WHERE_GREATER_THAN);
1754 }
1755 else {
1756 query.append(WHERE_LESSER_THAN);
1757 }
1758 }
1759 }
1760
1761 query.append(ORDER_BY_CLAUSE);
1762
1763 String[] orderByFields = orderByComparator.getOrderByFields();
1764
1765 for (int i = 0; i < orderByFields.length; i++) {
1766 query.append(_ORDER_BY_ENTITY_ALIAS);
1767 query.append(orderByFields[i]);
1768
1769 if ((i + 1) < orderByFields.length) {
1770 if (orderByComparator.isAscending() ^ previous) {
1771 query.append(ORDER_BY_ASC_HAS_NEXT);
1772 }
1773 else {
1774 query.append(ORDER_BY_DESC_HAS_NEXT);
1775 }
1776 }
1777 else {
1778 if (orderByComparator.isAscending() ^ previous) {
1779 query.append(ORDER_BY_ASC);
1780 }
1781 else {
1782 query.append(ORDER_BY_DESC);
1783 }
1784 }
1785 }
1786 }
1787 else {
1788 query.append(MDRActionModelImpl.ORDER_BY_JPQL);
1789 }
1790
1791 String sql = query.toString();
1792
1793 Query q = session.createQuery(sql);
1794
1795 q.setFirstResult(0);
1796 q.setMaxResults(2);
1797
1798 QueryPos qPos = QueryPos.getInstance(q);
1799
1800 qPos.add(ruleGroupInstanceId);
1801
1802 if (orderByComparator != null) {
1803 Object[] values = orderByComparator.getOrderByConditionValues(mdrAction);
1804
1805 for (Object value : values) {
1806 qPos.add(value);
1807 }
1808 }
1809
1810 List<MDRAction> list = q.list();
1811
1812 if (list.size() == 2) {
1813 return list.get(1);
1814 }
1815 else {
1816 return null;
1817 }
1818 }
1819
1820
1826 public void removeByRuleGroupInstanceId(long ruleGroupInstanceId)
1827 throws SystemException {
1828 for (MDRAction mdrAction : findByRuleGroupInstanceId(
1829 ruleGroupInstanceId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1830 remove(mdrAction);
1831 }
1832 }
1833
1834
1841 public int countByRuleGroupInstanceId(long ruleGroupInstanceId)
1842 throws SystemException {
1843 FinderPath finderPath = FINDER_PATH_COUNT_BY_RULEGROUPINSTANCEID;
1844
1845 Object[] finderArgs = new Object[] { ruleGroupInstanceId };
1846
1847 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1848 this);
1849
1850 if (count == null) {
1851 StringBundler query = new StringBundler(2);
1852
1853 query.append(_SQL_COUNT_MDRACTION_WHERE);
1854
1855 query.append(_FINDER_COLUMN_RULEGROUPINSTANCEID_RULEGROUPINSTANCEID_2);
1856
1857 String sql = query.toString();
1858
1859 Session session = null;
1860
1861 try {
1862 session = openSession();
1863
1864 Query q = session.createQuery(sql);
1865
1866 QueryPos qPos = QueryPos.getInstance(q);
1867
1868 qPos.add(ruleGroupInstanceId);
1869
1870 count = (Long)q.uniqueResult();
1871
1872 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1873 }
1874 catch (Exception e) {
1875 FinderCacheUtil.removeResult(finderPath, finderArgs);
1876
1877 throw processException(e);
1878 }
1879 finally {
1880 closeSession(session);
1881 }
1882 }
1883
1884 return count.intValue();
1885 }
1886
1887 private static final String _FINDER_COLUMN_RULEGROUPINSTANCEID_RULEGROUPINSTANCEID_2 =
1888 "mdrAction.ruleGroupInstanceId = ?";
1889
1890
1895 public void cacheResult(MDRAction mdrAction) {
1896 EntityCacheUtil.putResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
1897 MDRActionImpl.class, mdrAction.getPrimaryKey(), mdrAction);
1898
1899 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1900 new Object[] {
1901 mdrAction.getUuid(), Long.valueOf(mdrAction.getGroupId())
1902 }, mdrAction);
1903
1904 mdrAction.resetOriginalValues();
1905 }
1906
1907
1912 public void cacheResult(List<MDRAction> mdrActions) {
1913 for (MDRAction mdrAction : mdrActions) {
1914 if (EntityCacheUtil.getResult(
1915 MDRActionModelImpl.ENTITY_CACHE_ENABLED,
1916 MDRActionImpl.class, mdrAction.getPrimaryKey()) == null) {
1917 cacheResult(mdrAction);
1918 }
1919 else {
1920 mdrAction.resetOriginalValues();
1921 }
1922 }
1923 }
1924
1925
1932 @Override
1933 public void clearCache() {
1934 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
1935 CacheRegistryUtil.clear(MDRActionImpl.class.getName());
1936 }
1937
1938 EntityCacheUtil.clearCache(MDRActionImpl.class.getName());
1939
1940 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
1941 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1942 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1943 }
1944
1945
1952 @Override
1953 public void clearCache(MDRAction mdrAction) {
1954 EntityCacheUtil.removeResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
1955 MDRActionImpl.class, mdrAction.getPrimaryKey());
1956
1957 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1958 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1959
1960 clearUniqueFindersCache(mdrAction);
1961 }
1962
1963 @Override
1964 public void clearCache(List<MDRAction> mdrActions) {
1965 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1966 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1967
1968 for (MDRAction mdrAction : mdrActions) {
1969 EntityCacheUtil.removeResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
1970 MDRActionImpl.class, mdrAction.getPrimaryKey());
1971
1972 clearUniqueFindersCache(mdrAction);
1973 }
1974 }
1975
1976 protected void cacheUniqueFindersCache(MDRAction mdrAction) {
1977 if (mdrAction.isNew()) {
1978 Object[] args = new Object[] {
1979 mdrAction.getUuid(), Long.valueOf(mdrAction.getGroupId())
1980 };
1981
1982 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
1983 Long.valueOf(1));
1984 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
1985 mdrAction);
1986 }
1987 else {
1988 MDRActionModelImpl mdrActionModelImpl = (MDRActionModelImpl)mdrAction;
1989
1990 if ((mdrActionModelImpl.getColumnBitmask() &
1991 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
1992 Object[] args = new Object[] {
1993 mdrAction.getUuid(),
1994 Long.valueOf(mdrAction.getGroupId())
1995 };
1996
1997 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
1998 Long.valueOf(1));
1999 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
2000 mdrAction);
2001 }
2002 }
2003 }
2004
2005 protected void clearUniqueFindersCache(MDRAction mdrAction) {
2006 MDRActionModelImpl mdrActionModelImpl = (MDRActionModelImpl)mdrAction;
2007
2008 Object[] args = new Object[] {
2009 mdrAction.getUuid(), Long.valueOf(mdrAction.getGroupId())
2010 };
2011
2012 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
2013 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
2014
2015 if ((mdrActionModelImpl.getColumnBitmask() &
2016 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
2017 args = new Object[] {
2018 mdrActionModelImpl.getOriginalUuid(),
2019 Long.valueOf(mdrActionModelImpl.getOriginalGroupId())
2020 };
2021
2022 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
2023 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
2024 }
2025 }
2026
2027
2033 public MDRAction create(long actionId) {
2034 MDRAction mdrAction = new MDRActionImpl();
2035
2036 mdrAction.setNew(true);
2037 mdrAction.setPrimaryKey(actionId);
2038
2039 String uuid = PortalUUIDUtil.generate();
2040
2041 mdrAction.setUuid(uuid);
2042
2043 return mdrAction;
2044 }
2045
2046
2054 public MDRAction remove(long actionId)
2055 throws NoSuchActionException, SystemException {
2056 return remove(Long.valueOf(actionId));
2057 }
2058
2059
2067 @Override
2068 public MDRAction remove(Serializable primaryKey)
2069 throws NoSuchActionException, SystemException {
2070 Session session = null;
2071
2072 try {
2073 session = openSession();
2074
2075 MDRAction mdrAction = (MDRAction)session.get(MDRActionImpl.class,
2076 primaryKey);
2077
2078 if (mdrAction == null) {
2079 if (_log.isWarnEnabled()) {
2080 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2081 }
2082
2083 throw new NoSuchActionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2084 primaryKey);
2085 }
2086
2087 return remove(mdrAction);
2088 }
2089 catch (NoSuchActionException nsee) {
2090 throw nsee;
2091 }
2092 catch (Exception e) {
2093 throw processException(e);
2094 }
2095 finally {
2096 closeSession(session);
2097 }
2098 }
2099
2100 @Override
2101 protected MDRAction removeImpl(MDRAction mdrAction)
2102 throws SystemException {
2103 mdrAction = toUnwrappedModel(mdrAction);
2104
2105 Session session = null;
2106
2107 try {
2108 session = openSession();
2109
2110 if (!session.contains(mdrAction)) {
2111 mdrAction = (MDRAction)session.get(MDRActionImpl.class,
2112 mdrAction.getPrimaryKeyObj());
2113 }
2114
2115 if (mdrAction != null) {
2116 session.delete(mdrAction);
2117 }
2118 }
2119 catch (Exception e) {
2120 throw processException(e);
2121 }
2122 finally {
2123 closeSession(session);
2124 }
2125
2126 if (mdrAction != null) {
2127 clearCache(mdrAction);
2128 }
2129
2130 return mdrAction;
2131 }
2132
2133 @Override
2134 public MDRAction updateImpl(
2135 com.liferay.portlet.mobiledevicerules.model.MDRAction mdrAction)
2136 throws SystemException {
2137 mdrAction = toUnwrappedModel(mdrAction);
2138
2139 boolean isNew = mdrAction.isNew();
2140
2141 MDRActionModelImpl mdrActionModelImpl = (MDRActionModelImpl)mdrAction;
2142
2143 if (Validator.isNull(mdrAction.getUuid())) {
2144 String uuid = PortalUUIDUtil.generate();
2145
2146 mdrAction.setUuid(uuid);
2147 }
2148
2149 Session session = null;
2150
2151 try {
2152 session = openSession();
2153
2154 if (mdrAction.isNew()) {
2155 session.save(mdrAction);
2156
2157 mdrAction.setNew(false);
2158 }
2159 else {
2160 session.merge(mdrAction);
2161 }
2162 }
2163 catch (Exception e) {
2164 throw processException(e);
2165 }
2166 finally {
2167 closeSession(session);
2168 }
2169
2170 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2171
2172 if (isNew || !MDRActionModelImpl.COLUMN_BITMASK_ENABLED) {
2173 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2174 }
2175
2176 else {
2177 if ((mdrActionModelImpl.getColumnBitmask() &
2178 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
2179 Object[] args = new Object[] {
2180 mdrActionModelImpl.getOriginalUuid()
2181 };
2182
2183 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
2184 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
2185 args);
2186
2187 args = new Object[] { mdrActionModelImpl.getUuid() };
2188
2189 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
2190 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
2191 args);
2192 }
2193
2194 if ((mdrActionModelImpl.getColumnBitmask() &
2195 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
2196 Object[] args = new Object[] {
2197 mdrActionModelImpl.getOriginalUuid(),
2198 Long.valueOf(mdrActionModelImpl.getOriginalCompanyId())
2199 };
2200
2201 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
2202 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
2203 args);
2204
2205 args = new Object[] {
2206 mdrActionModelImpl.getUuid(),
2207 Long.valueOf(mdrActionModelImpl.getCompanyId())
2208 };
2209
2210 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
2211 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
2212 args);
2213 }
2214
2215 if ((mdrActionModelImpl.getColumnBitmask() &
2216 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID.getColumnBitmask()) != 0) {
2217 Object[] args = new Object[] {
2218 Long.valueOf(mdrActionModelImpl.getOriginalRuleGroupInstanceId())
2219 };
2220
2221 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RULEGROUPINSTANCEID,
2222 args);
2223 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID,
2224 args);
2225
2226 args = new Object[] {
2227 Long.valueOf(mdrActionModelImpl.getRuleGroupInstanceId())
2228 };
2229
2230 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RULEGROUPINSTANCEID,
2231 args);
2232 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID,
2233 args);
2234 }
2235 }
2236
2237 EntityCacheUtil.putResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
2238 MDRActionImpl.class, mdrAction.getPrimaryKey(), mdrAction);
2239
2240 clearUniqueFindersCache(mdrAction);
2241 cacheUniqueFindersCache(mdrAction);
2242
2243 return mdrAction;
2244 }
2245
2246 protected MDRAction toUnwrappedModel(MDRAction mdrAction) {
2247 if (mdrAction instanceof MDRActionImpl) {
2248 return mdrAction;
2249 }
2250
2251 MDRActionImpl mdrActionImpl = new MDRActionImpl();
2252
2253 mdrActionImpl.setNew(mdrAction.isNew());
2254 mdrActionImpl.setPrimaryKey(mdrAction.getPrimaryKey());
2255
2256 mdrActionImpl.setUuid(mdrAction.getUuid());
2257 mdrActionImpl.setActionId(mdrAction.getActionId());
2258 mdrActionImpl.setGroupId(mdrAction.getGroupId());
2259 mdrActionImpl.setCompanyId(mdrAction.getCompanyId());
2260 mdrActionImpl.setUserId(mdrAction.getUserId());
2261 mdrActionImpl.setUserName(mdrAction.getUserName());
2262 mdrActionImpl.setCreateDate(mdrAction.getCreateDate());
2263 mdrActionImpl.setModifiedDate(mdrAction.getModifiedDate());
2264 mdrActionImpl.setClassNameId(mdrAction.getClassNameId());
2265 mdrActionImpl.setClassPK(mdrAction.getClassPK());
2266 mdrActionImpl.setRuleGroupInstanceId(mdrAction.getRuleGroupInstanceId());
2267 mdrActionImpl.setName(mdrAction.getName());
2268 mdrActionImpl.setDescription(mdrAction.getDescription());
2269 mdrActionImpl.setType(mdrAction.getType());
2270 mdrActionImpl.setTypeSettings(mdrAction.getTypeSettings());
2271
2272 return mdrActionImpl;
2273 }
2274
2275
2283 @Override
2284 public MDRAction findByPrimaryKey(Serializable primaryKey)
2285 throws NoSuchModelException, SystemException {
2286 return findByPrimaryKey(((Long)primaryKey).longValue());
2287 }
2288
2289
2297 public MDRAction findByPrimaryKey(long actionId)
2298 throws NoSuchActionException, SystemException {
2299 MDRAction mdrAction = fetchByPrimaryKey(actionId);
2300
2301 if (mdrAction == null) {
2302 if (_log.isWarnEnabled()) {
2303 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + actionId);
2304 }
2305
2306 throw new NoSuchActionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2307 actionId);
2308 }
2309
2310 return mdrAction;
2311 }
2312
2313
2320 @Override
2321 public MDRAction fetchByPrimaryKey(Serializable primaryKey)
2322 throws SystemException {
2323 return fetchByPrimaryKey(((Long)primaryKey).longValue());
2324 }
2325
2326
2333 public MDRAction fetchByPrimaryKey(long actionId) throws SystemException {
2334 MDRAction mdrAction = (MDRAction)EntityCacheUtil.getResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
2335 MDRActionImpl.class, actionId);
2336
2337 if (mdrAction == _nullMDRAction) {
2338 return null;
2339 }
2340
2341 if (mdrAction == null) {
2342 Session session = null;
2343
2344 try {
2345 session = openSession();
2346
2347 mdrAction = (MDRAction)session.get(MDRActionImpl.class,
2348 Long.valueOf(actionId));
2349
2350 if (mdrAction != null) {
2351 cacheResult(mdrAction);
2352 }
2353 else {
2354 EntityCacheUtil.putResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
2355 MDRActionImpl.class, actionId, _nullMDRAction);
2356 }
2357 }
2358 catch (Exception e) {
2359 EntityCacheUtil.removeResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
2360 MDRActionImpl.class, actionId);
2361
2362 throw processException(e);
2363 }
2364 finally {
2365 closeSession(session);
2366 }
2367 }
2368
2369 return mdrAction;
2370 }
2371
2372
2378 public List<MDRAction> findAll() throws SystemException {
2379 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2380 }
2381
2382
2394 public List<MDRAction> findAll(int start, int end)
2395 throws SystemException {
2396 return findAll(start, end, null);
2397 }
2398
2399
2412 public List<MDRAction> findAll(int start, int end,
2413 OrderByComparator orderByComparator) throws SystemException {
2414 boolean pagination = true;
2415 FinderPath finderPath = null;
2416 Object[] finderArgs = null;
2417
2418 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2419 (orderByComparator == null)) {
2420 pagination = false;
2421 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2422 finderArgs = FINDER_ARGS_EMPTY;
2423 }
2424 else {
2425 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2426 finderArgs = new Object[] { start, end, orderByComparator };
2427 }
2428
2429 List<MDRAction> list = (List<MDRAction>)FinderCacheUtil.getResult(finderPath,
2430 finderArgs, this);
2431
2432 if (list == null) {
2433 StringBundler query = null;
2434 String sql = null;
2435
2436 if (orderByComparator != null) {
2437 query = new StringBundler(2 +
2438 (orderByComparator.getOrderByFields().length * 3));
2439
2440 query.append(_SQL_SELECT_MDRACTION);
2441
2442 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2443 orderByComparator);
2444
2445 sql = query.toString();
2446 }
2447 else {
2448 sql = _SQL_SELECT_MDRACTION;
2449
2450 if (pagination) {
2451 sql = sql.concat(MDRActionModelImpl.ORDER_BY_JPQL);
2452 }
2453 }
2454
2455 Session session = null;
2456
2457 try {
2458 session = openSession();
2459
2460 Query q = session.createQuery(sql);
2461
2462 if (!pagination) {
2463 list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
2464 start, end, false);
2465
2466 Collections.sort(list);
2467
2468 list = new UnmodifiableList<MDRAction>(list);
2469 }
2470 else {
2471 list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
2472 start, end);
2473 }
2474
2475 cacheResult(list);
2476
2477 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2478 }
2479 catch (Exception e) {
2480 FinderCacheUtil.removeResult(finderPath, finderArgs);
2481
2482 throw processException(e);
2483 }
2484 finally {
2485 closeSession(session);
2486 }
2487 }
2488
2489 return list;
2490 }
2491
2492
2497 public void removeAll() throws SystemException {
2498 for (MDRAction mdrAction : findAll()) {
2499 remove(mdrAction);
2500 }
2501 }
2502
2503
2509 public int countAll() throws SystemException {
2510 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2511 FINDER_ARGS_EMPTY, this);
2512
2513 if (count == null) {
2514 Session session = null;
2515
2516 try {
2517 session = openSession();
2518
2519 Query q = session.createQuery(_SQL_COUNT_MDRACTION);
2520
2521 count = (Long)q.uniqueResult();
2522
2523 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2524 FINDER_ARGS_EMPTY, count);
2525 }
2526 catch (Exception e) {
2527 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
2528 FINDER_ARGS_EMPTY);
2529
2530 throw processException(e);
2531 }
2532 finally {
2533 closeSession(session);
2534 }
2535 }
2536
2537 return count.intValue();
2538 }
2539
2540
2543 public void afterPropertiesSet() {
2544 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2545 com.liferay.portal.util.PropsUtil.get(
2546 "value.object.listener.com.liferay.portlet.mobiledevicerules.model.MDRAction")));
2547
2548 if (listenerClassNames.length > 0) {
2549 try {
2550 List<ModelListener<MDRAction>> listenersList = new ArrayList<ModelListener<MDRAction>>();
2551
2552 for (String listenerClassName : listenerClassNames) {
2553 listenersList.add((ModelListener<MDRAction>)InstanceFactory.newInstance(
2554 listenerClassName));
2555 }
2556
2557 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2558 }
2559 catch (Exception e) {
2560 _log.error(e);
2561 }
2562 }
2563 }
2564
2565 public void destroy() {
2566 EntityCacheUtil.removeCache(MDRActionImpl.class.getName());
2567 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2568 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2569 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2570 }
2571
2572 private static final String _SQL_SELECT_MDRACTION = "SELECT mdrAction FROM MDRAction mdrAction";
2573 private static final String _SQL_SELECT_MDRACTION_WHERE = "SELECT mdrAction FROM MDRAction mdrAction WHERE ";
2574 private static final String _SQL_COUNT_MDRACTION = "SELECT COUNT(mdrAction) FROM MDRAction mdrAction";
2575 private static final String _SQL_COUNT_MDRACTION_WHERE = "SELECT COUNT(mdrAction) FROM MDRAction mdrAction WHERE ";
2576 private static final String _ORDER_BY_ENTITY_ALIAS = "mdrAction.";
2577 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MDRAction exists with the primary key ";
2578 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MDRAction exists with the key {";
2579 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2580 private static Log _log = LogFactoryUtil.getLog(MDRActionPersistenceImpl.class);
2581 private static MDRAction _nullMDRAction = new MDRActionImpl() {
2582 @Override
2583 public Object clone() {
2584 return this;
2585 }
2586
2587 @Override
2588 public CacheModel<MDRAction> toCacheModel() {
2589 return _nullMDRActionCacheModel;
2590 }
2591 };
2592
2593 private static CacheModel<MDRAction> _nullMDRActionCacheModel = new CacheModel<MDRAction>() {
2594 public MDRAction toEntityModel() {
2595 return _nullMDRAction;
2596 }
2597 };
2598 }