001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchPasswordPolicyRelException;
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.model.CacheModel;
037 import com.liferay.portal.model.ModelListener;
038 import com.liferay.portal.model.PasswordPolicyRel;
039 import com.liferay.portal.model.impl.PasswordPolicyRelImpl;
040 import com.liferay.portal.model.impl.PasswordPolicyRelModelImpl;
041 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042
043 import java.io.Serializable;
044
045 import java.util.ArrayList;
046 import java.util.Collections;
047 import java.util.List;
048
049
061 public class PasswordPolicyRelPersistenceImpl extends BasePersistenceImpl<PasswordPolicyRel>
062 implements PasswordPolicyRelPersistence {
063
068 public static final String FINDER_CLASS_NAME_ENTITY = PasswordPolicyRelImpl.class.getName();
069 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
070 ".List1";
071 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
072 ".List2";
073 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
074 PasswordPolicyRelModelImpl.FINDER_CACHE_ENABLED,
075 PasswordPolicyRelImpl.class,
076 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
077 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
078 PasswordPolicyRelModelImpl.FINDER_CACHE_ENABLED,
079 PasswordPolicyRelImpl.class,
080 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
081 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
082 PasswordPolicyRelModelImpl.FINDER_CACHE_ENABLED, Long.class,
083 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
084 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_PASSWORDPOLICYID =
085 new FinderPath(PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
086 PasswordPolicyRelModelImpl.FINDER_CACHE_ENABLED,
087 PasswordPolicyRelImpl.class,
088 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByPasswordPolicyId",
089 new String[] {
090 Long.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_PASSWORDPOLICYID =
096 new FinderPath(PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
097 PasswordPolicyRelModelImpl.FINDER_CACHE_ENABLED,
098 PasswordPolicyRelImpl.class,
099 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
100 "findByPasswordPolicyId", new String[] { Long.class.getName() },
101 PasswordPolicyRelModelImpl.PASSWORDPOLICYID_COLUMN_BITMASK);
102 public static final FinderPath FINDER_PATH_COUNT_BY_PASSWORDPOLICYID = new FinderPath(PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
103 PasswordPolicyRelModelImpl.FINDER_CACHE_ENABLED, Long.class,
104 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
105 "countByPasswordPolicyId", new String[] { Long.class.getName() });
106
107
114 @Override
115 public List<PasswordPolicyRel> findByPasswordPolicyId(long passwordPolicyId)
116 throws SystemException {
117 return findByPasswordPolicyId(passwordPolicyId, QueryUtil.ALL_POS,
118 QueryUtil.ALL_POS, null);
119 }
120
121
134 @Override
135 public List<PasswordPolicyRel> findByPasswordPolicyId(
136 long passwordPolicyId, int start, int end) throws SystemException {
137 return findByPasswordPolicyId(passwordPolicyId, start, end, null);
138 }
139
140
154 @Override
155 public List<PasswordPolicyRel> findByPasswordPolicyId(
156 long passwordPolicyId, int start, int end,
157 OrderByComparator orderByComparator) throws SystemException {
158 boolean pagination = true;
159 FinderPath finderPath = null;
160 Object[] finderArgs = null;
161
162 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
163 (orderByComparator == null)) {
164 pagination = false;
165 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PASSWORDPOLICYID;
166 finderArgs = new Object[] { passwordPolicyId };
167 }
168 else {
169 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PASSWORDPOLICYID;
170 finderArgs = new Object[] {
171 passwordPolicyId,
172
173 start, end, orderByComparator
174 };
175 }
176
177 List<PasswordPolicyRel> list = (List<PasswordPolicyRel>)FinderCacheUtil.getResult(finderPath,
178 finderArgs, this);
179
180 if ((list != null) && !list.isEmpty()) {
181 for (PasswordPolicyRel passwordPolicyRel : list) {
182 if ((passwordPolicyId != passwordPolicyRel.getPasswordPolicyId())) {
183 list = null;
184
185 break;
186 }
187 }
188 }
189
190 if (list == null) {
191 StringBundler query = null;
192
193 if (orderByComparator != null) {
194 query = new StringBundler(3 +
195 (orderByComparator.getOrderByFields().length * 3));
196 }
197 else {
198 query = new StringBundler(3);
199 }
200
201 query.append(_SQL_SELECT_PASSWORDPOLICYREL_WHERE);
202
203 query.append(_FINDER_COLUMN_PASSWORDPOLICYID_PASSWORDPOLICYID_2);
204
205 if (orderByComparator != null) {
206 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
207 orderByComparator);
208 }
209 else
210 if (pagination) {
211 query.append(PasswordPolicyRelModelImpl.ORDER_BY_JPQL);
212 }
213
214 String sql = query.toString();
215
216 Session session = null;
217
218 try {
219 session = openSession();
220
221 Query q = session.createQuery(sql);
222
223 QueryPos qPos = QueryPos.getInstance(q);
224
225 qPos.add(passwordPolicyId);
226
227 if (!pagination) {
228 list = (List<PasswordPolicyRel>)QueryUtil.list(q,
229 getDialect(), start, end, false);
230
231 Collections.sort(list);
232
233 list = new UnmodifiableList<PasswordPolicyRel>(list);
234 }
235 else {
236 list = (List<PasswordPolicyRel>)QueryUtil.list(q,
237 getDialect(), 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 @Override
267 public PasswordPolicyRel findByPasswordPolicyId_First(
268 long passwordPolicyId, OrderByComparator orderByComparator)
269 throws NoSuchPasswordPolicyRelException, SystemException {
270 PasswordPolicyRel passwordPolicyRel = fetchByPasswordPolicyId_First(passwordPolicyId,
271 orderByComparator);
272
273 if (passwordPolicyRel != null) {
274 return passwordPolicyRel;
275 }
276
277 StringBundler msg = new StringBundler(4);
278
279 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
280
281 msg.append("passwordPolicyId=");
282 msg.append(passwordPolicyId);
283
284 msg.append(StringPool.CLOSE_CURLY_BRACE);
285
286 throw new NoSuchPasswordPolicyRelException(msg.toString());
287 }
288
289
297 @Override
298 public PasswordPolicyRel fetchByPasswordPolicyId_First(
299 long passwordPolicyId, OrderByComparator orderByComparator)
300 throws SystemException {
301 List<PasswordPolicyRel> list = findByPasswordPolicyId(passwordPolicyId,
302 0, 1, orderByComparator);
303
304 if (!list.isEmpty()) {
305 return list.get(0);
306 }
307
308 return null;
309 }
310
311
320 @Override
321 public PasswordPolicyRel findByPasswordPolicyId_Last(
322 long passwordPolicyId, OrderByComparator orderByComparator)
323 throws NoSuchPasswordPolicyRelException, SystemException {
324 PasswordPolicyRel passwordPolicyRel = fetchByPasswordPolicyId_Last(passwordPolicyId,
325 orderByComparator);
326
327 if (passwordPolicyRel != null) {
328 return passwordPolicyRel;
329 }
330
331 StringBundler msg = new StringBundler(4);
332
333 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
334
335 msg.append("passwordPolicyId=");
336 msg.append(passwordPolicyId);
337
338 msg.append(StringPool.CLOSE_CURLY_BRACE);
339
340 throw new NoSuchPasswordPolicyRelException(msg.toString());
341 }
342
343
351 @Override
352 public PasswordPolicyRel fetchByPasswordPolicyId_Last(
353 long passwordPolicyId, OrderByComparator orderByComparator)
354 throws SystemException {
355 int count = countByPasswordPolicyId(passwordPolicyId);
356
357 if (count == 0) {
358 return null;
359 }
360
361 List<PasswordPolicyRel> list = findByPasswordPolicyId(passwordPolicyId,
362 count - 1, count, orderByComparator);
363
364 if (!list.isEmpty()) {
365 return list.get(0);
366 }
367
368 return null;
369 }
370
371
381 @Override
382 public PasswordPolicyRel[] findByPasswordPolicyId_PrevAndNext(
383 long passwordPolicyRelId, long passwordPolicyId,
384 OrderByComparator orderByComparator)
385 throws NoSuchPasswordPolicyRelException, SystemException {
386 PasswordPolicyRel passwordPolicyRel = findByPrimaryKey(passwordPolicyRelId);
387
388 Session session = null;
389
390 try {
391 session = openSession();
392
393 PasswordPolicyRel[] array = new PasswordPolicyRelImpl[3];
394
395 array[0] = getByPasswordPolicyId_PrevAndNext(session,
396 passwordPolicyRel, passwordPolicyId, orderByComparator, true);
397
398 array[1] = passwordPolicyRel;
399
400 array[2] = getByPasswordPolicyId_PrevAndNext(session,
401 passwordPolicyRel, passwordPolicyId, orderByComparator,
402 false);
403
404 return array;
405 }
406 catch (Exception e) {
407 throw processException(e);
408 }
409 finally {
410 closeSession(session);
411 }
412 }
413
414 protected PasswordPolicyRel getByPasswordPolicyId_PrevAndNext(
415 Session session, PasswordPolicyRel passwordPolicyRel,
416 long passwordPolicyId, OrderByComparator orderByComparator,
417 boolean previous) {
418 StringBundler query = null;
419
420 if (orderByComparator != null) {
421 query = new StringBundler(6 +
422 (orderByComparator.getOrderByFields().length * 6));
423 }
424 else {
425 query = new StringBundler(3);
426 }
427
428 query.append(_SQL_SELECT_PASSWORDPOLICYREL_WHERE);
429
430 query.append(_FINDER_COLUMN_PASSWORDPOLICYID_PASSWORDPOLICYID_2);
431
432 if (orderByComparator != null) {
433 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
434
435 if (orderByConditionFields.length > 0) {
436 query.append(WHERE_AND);
437 }
438
439 for (int i = 0; i < orderByConditionFields.length; i++) {
440 query.append(_ORDER_BY_ENTITY_ALIAS);
441 query.append(orderByConditionFields[i]);
442
443 if ((i + 1) < orderByConditionFields.length) {
444 if (orderByComparator.isAscending() ^ previous) {
445 query.append(WHERE_GREATER_THAN_HAS_NEXT);
446 }
447 else {
448 query.append(WHERE_LESSER_THAN_HAS_NEXT);
449 }
450 }
451 else {
452 if (orderByComparator.isAscending() ^ previous) {
453 query.append(WHERE_GREATER_THAN);
454 }
455 else {
456 query.append(WHERE_LESSER_THAN);
457 }
458 }
459 }
460
461 query.append(ORDER_BY_CLAUSE);
462
463 String[] orderByFields = orderByComparator.getOrderByFields();
464
465 for (int i = 0; i < orderByFields.length; i++) {
466 query.append(_ORDER_BY_ENTITY_ALIAS);
467 query.append(orderByFields[i]);
468
469 if ((i + 1) < orderByFields.length) {
470 if (orderByComparator.isAscending() ^ previous) {
471 query.append(ORDER_BY_ASC_HAS_NEXT);
472 }
473 else {
474 query.append(ORDER_BY_DESC_HAS_NEXT);
475 }
476 }
477 else {
478 if (orderByComparator.isAscending() ^ previous) {
479 query.append(ORDER_BY_ASC);
480 }
481 else {
482 query.append(ORDER_BY_DESC);
483 }
484 }
485 }
486 }
487 else {
488 query.append(PasswordPolicyRelModelImpl.ORDER_BY_JPQL);
489 }
490
491 String sql = query.toString();
492
493 Query q = session.createQuery(sql);
494
495 q.setFirstResult(0);
496 q.setMaxResults(2);
497
498 QueryPos qPos = QueryPos.getInstance(q);
499
500 qPos.add(passwordPolicyId);
501
502 if (orderByComparator != null) {
503 Object[] values = orderByComparator.getOrderByConditionValues(passwordPolicyRel);
504
505 for (Object value : values) {
506 qPos.add(value);
507 }
508 }
509
510 List<PasswordPolicyRel> list = q.list();
511
512 if (list.size() == 2) {
513 return list.get(1);
514 }
515 else {
516 return null;
517 }
518 }
519
520
526 @Override
527 public void removeByPasswordPolicyId(long passwordPolicyId)
528 throws SystemException {
529 for (PasswordPolicyRel passwordPolicyRel : findByPasswordPolicyId(
530 passwordPolicyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
531 remove(passwordPolicyRel);
532 }
533 }
534
535
542 @Override
543 public int countByPasswordPolicyId(long passwordPolicyId)
544 throws SystemException {
545 FinderPath finderPath = FINDER_PATH_COUNT_BY_PASSWORDPOLICYID;
546
547 Object[] finderArgs = new Object[] { passwordPolicyId };
548
549 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
550 this);
551
552 if (count == null) {
553 StringBundler query = new StringBundler(2);
554
555 query.append(_SQL_COUNT_PASSWORDPOLICYREL_WHERE);
556
557 query.append(_FINDER_COLUMN_PASSWORDPOLICYID_PASSWORDPOLICYID_2);
558
559 String sql = query.toString();
560
561 Session session = null;
562
563 try {
564 session = openSession();
565
566 Query q = session.createQuery(sql);
567
568 QueryPos qPos = QueryPos.getInstance(q);
569
570 qPos.add(passwordPolicyId);
571
572 count = (Long)q.uniqueResult();
573
574 FinderCacheUtil.putResult(finderPath, finderArgs, count);
575 }
576 catch (Exception e) {
577 FinderCacheUtil.removeResult(finderPath, finderArgs);
578
579 throw processException(e);
580 }
581 finally {
582 closeSession(session);
583 }
584 }
585
586 return count.intValue();
587 }
588
589 private static final String _FINDER_COLUMN_PASSWORDPOLICYID_PASSWORDPOLICYID_2 =
590 "passwordPolicyRel.passwordPolicyId = ?";
591 public static final FinderPath FINDER_PATH_FETCH_BY_C_C = new FinderPath(PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
592 PasswordPolicyRelModelImpl.FINDER_CACHE_ENABLED,
593 PasswordPolicyRelImpl.class, FINDER_CLASS_NAME_ENTITY,
594 "fetchByC_C",
595 new String[] { Long.class.getName(), Long.class.getName() },
596 PasswordPolicyRelModelImpl.CLASSNAMEID_COLUMN_BITMASK |
597 PasswordPolicyRelModelImpl.CLASSPK_COLUMN_BITMASK);
598 public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
599 PasswordPolicyRelModelImpl.FINDER_CACHE_ENABLED, Long.class,
600 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
601 new String[] { Long.class.getName(), Long.class.getName() });
602
603
612 @Override
613 public PasswordPolicyRel findByC_C(long classNameId, long classPK)
614 throws NoSuchPasswordPolicyRelException, SystemException {
615 PasswordPolicyRel passwordPolicyRel = fetchByC_C(classNameId, classPK);
616
617 if (passwordPolicyRel == null) {
618 StringBundler msg = new StringBundler(6);
619
620 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
621
622 msg.append("classNameId=");
623 msg.append(classNameId);
624
625 msg.append(", classPK=");
626 msg.append(classPK);
627
628 msg.append(StringPool.CLOSE_CURLY_BRACE);
629
630 if (_log.isWarnEnabled()) {
631 _log.warn(msg.toString());
632 }
633
634 throw new NoSuchPasswordPolicyRelException(msg.toString());
635 }
636
637 return passwordPolicyRel;
638 }
639
640
648 @Override
649 public PasswordPolicyRel fetchByC_C(long classNameId, long classPK)
650 throws SystemException {
651 return fetchByC_C(classNameId, classPK, true);
652 }
653
654
663 @Override
664 public PasswordPolicyRel fetchByC_C(long classNameId, long classPK,
665 boolean retrieveFromCache) throws SystemException {
666 Object[] finderArgs = new Object[] { classNameId, classPK };
667
668 Object result = null;
669
670 if (retrieveFromCache) {
671 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C,
672 finderArgs, this);
673 }
674
675 if (result instanceof PasswordPolicyRel) {
676 PasswordPolicyRel passwordPolicyRel = (PasswordPolicyRel)result;
677
678 if ((classNameId != passwordPolicyRel.getClassNameId()) ||
679 (classPK != passwordPolicyRel.getClassPK())) {
680 result = null;
681 }
682 }
683
684 if (result == null) {
685 StringBundler query = new StringBundler(4);
686
687 query.append(_SQL_SELECT_PASSWORDPOLICYREL_WHERE);
688
689 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
690
691 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
692
693 String sql = query.toString();
694
695 Session session = null;
696
697 try {
698 session = openSession();
699
700 Query q = session.createQuery(sql);
701
702 QueryPos qPos = QueryPos.getInstance(q);
703
704 qPos.add(classNameId);
705
706 qPos.add(classPK);
707
708 List<PasswordPolicyRel> list = q.list();
709
710 if (list.isEmpty()) {
711 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
712 finderArgs, list);
713 }
714 else {
715 PasswordPolicyRel passwordPolicyRel = list.get(0);
716
717 result = passwordPolicyRel;
718
719 cacheResult(passwordPolicyRel);
720
721 if ((passwordPolicyRel.getClassNameId() != classNameId) ||
722 (passwordPolicyRel.getClassPK() != classPK)) {
723 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
724 finderArgs, passwordPolicyRel);
725 }
726 }
727 }
728 catch (Exception e) {
729 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
730 finderArgs);
731
732 throw processException(e);
733 }
734 finally {
735 closeSession(session);
736 }
737 }
738
739 if (result instanceof List<?>) {
740 return null;
741 }
742 else {
743 return (PasswordPolicyRel)result;
744 }
745 }
746
747
755 @Override
756 public PasswordPolicyRel removeByC_C(long classNameId, long classPK)
757 throws NoSuchPasswordPolicyRelException, SystemException {
758 PasswordPolicyRel passwordPolicyRel = findByC_C(classNameId, classPK);
759
760 return remove(passwordPolicyRel);
761 }
762
763
771 @Override
772 public int countByC_C(long classNameId, long classPK)
773 throws SystemException {
774 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C;
775
776 Object[] finderArgs = new Object[] { classNameId, classPK };
777
778 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
779 this);
780
781 if (count == null) {
782 StringBundler query = new StringBundler(3);
783
784 query.append(_SQL_COUNT_PASSWORDPOLICYREL_WHERE);
785
786 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
787
788 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
789
790 String sql = query.toString();
791
792 Session session = null;
793
794 try {
795 session = openSession();
796
797 Query q = session.createQuery(sql);
798
799 QueryPos qPos = QueryPos.getInstance(q);
800
801 qPos.add(classNameId);
802
803 qPos.add(classPK);
804
805 count = (Long)q.uniqueResult();
806
807 FinderCacheUtil.putResult(finderPath, finderArgs, count);
808 }
809 catch (Exception e) {
810 FinderCacheUtil.removeResult(finderPath, finderArgs);
811
812 throw processException(e);
813 }
814 finally {
815 closeSession(session);
816 }
817 }
818
819 return count.intValue();
820 }
821
822 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "passwordPolicyRel.classNameId = ? AND ";
823 private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "passwordPolicyRel.classPK = ?";
824
825 public PasswordPolicyRelPersistenceImpl() {
826 setModelClass(PasswordPolicyRel.class);
827 }
828
829
834 @Override
835 public void cacheResult(PasswordPolicyRel passwordPolicyRel) {
836 EntityCacheUtil.putResult(PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
837 PasswordPolicyRelImpl.class, passwordPolicyRel.getPrimaryKey(),
838 passwordPolicyRel);
839
840 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
841 new Object[] {
842 passwordPolicyRel.getClassNameId(),
843 passwordPolicyRel.getClassPK()
844 }, passwordPolicyRel);
845
846 passwordPolicyRel.resetOriginalValues();
847 }
848
849
854 @Override
855 public void cacheResult(List<PasswordPolicyRel> passwordPolicyRels) {
856 for (PasswordPolicyRel passwordPolicyRel : passwordPolicyRels) {
857 if (EntityCacheUtil.getResult(
858 PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
859 PasswordPolicyRelImpl.class,
860 passwordPolicyRel.getPrimaryKey()) == null) {
861 cacheResult(passwordPolicyRel);
862 }
863 else {
864 passwordPolicyRel.resetOriginalValues();
865 }
866 }
867 }
868
869
876 @Override
877 public void clearCache() {
878 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
879 CacheRegistryUtil.clear(PasswordPolicyRelImpl.class.getName());
880 }
881
882 EntityCacheUtil.clearCache(PasswordPolicyRelImpl.class.getName());
883
884 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
885 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
886 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
887 }
888
889
896 @Override
897 public void clearCache(PasswordPolicyRel passwordPolicyRel) {
898 EntityCacheUtil.removeResult(PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
899 PasswordPolicyRelImpl.class, passwordPolicyRel.getPrimaryKey());
900
901 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
902 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
903
904 clearUniqueFindersCache(passwordPolicyRel);
905 }
906
907 @Override
908 public void clearCache(List<PasswordPolicyRel> passwordPolicyRels) {
909 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
910 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
911
912 for (PasswordPolicyRel passwordPolicyRel : passwordPolicyRels) {
913 EntityCacheUtil.removeResult(PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
914 PasswordPolicyRelImpl.class, passwordPolicyRel.getPrimaryKey());
915
916 clearUniqueFindersCache(passwordPolicyRel);
917 }
918 }
919
920 protected void cacheUniqueFindersCache(PasswordPolicyRel passwordPolicyRel) {
921 if (passwordPolicyRel.isNew()) {
922 Object[] args = new Object[] {
923 passwordPolicyRel.getClassNameId(),
924 passwordPolicyRel.getClassPK()
925 };
926
927 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, args,
928 Long.valueOf(1));
929 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C, args,
930 passwordPolicyRel);
931 }
932 else {
933 PasswordPolicyRelModelImpl passwordPolicyRelModelImpl = (PasswordPolicyRelModelImpl)passwordPolicyRel;
934
935 if ((passwordPolicyRelModelImpl.getColumnBitmask() &
936 FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
937 Object[] args = new Object[] {
938 passwordPolicyRel.getClassNameId(),
939 passwordPolicyRel.getClassPK()
940 };
941
942 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, args,
943 Long.valueOf(1));
944 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C, args,
945 passwordPolicyRel);
946 }
947 }
948 }
949
950 protected void clearUniqueFindersCache(PasswordPolicyRel passwordPolicyRel) {
951 PasswordPolicyRelModelImpl passwordPolicyRelModelImpl = (PasswordPolicyRelModelImpl)passwordPolicyRel;
952
953 Object[] args = new Object[] {
954 passwordPolicyRel.getClassNameId(),
955 passwordPolicyRel.getClassPK()
956 };
957
958 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
959 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
960
961 if ((passwordPolicyRelModelImpl.getColumnBitmask() &
962 FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
963 args = new Object[] {
964 passwordPolicyRelModelImpl.getOriginalClassNameId(),
965 passwordPolicyRelModelImpl.getOriginalClassPK()
966 };
967
968 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
969 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
970 }
971 }
972
973
979 @Override
980 public PasswordPolicyRel create(long passwordPolicyRelId) {
981 PasswordPolicyRel passwordPolicyRel = new PasswordPolicyRelImpl();
982
983 passwordPolicyRel.setNew(true);
984 passwordPolicyRel.setPrimaryKey(passwordPolicyRelId);
985
986 return passwordPolicyRel;
987 }
988
989
997 @Override
998 public PasswordPolicyRel remove(long passwordPolicyRelId)
999 throws NoSuchPasswordPolicyRelException, SystemException {
1000 return remove((Serializable)passwordPolicyRelId);
1001 }
1002
1003
1011 @Override
1012 public PasswordPolicyRel remove(Serializable primaryKey)
1013 throws NoSuchPasswordPolicyRelException, SystemException {
1014 Session session = null;
1015
1016 try {
1017 session = openSession();
1018
1019 PasswordPolicyRel passwordPolicyRel = (PasswordPolicyRel)session.get(PasswordPolicyRelImpl.class,
1020 primaryKey);
1021
1022 if (passwordPolicyRel == null) {
1023 if (_log.isWarnEnabled()) {
1024 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
1025 }
1026
1027 throw new NoSuchPasswordPolicyRelException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1028 primaryKey);
1029 }
1030
1031 return remove(passwordPolicyRel);
1032 }
1033 catch (NoSuchPasswordPolicyRelException nsee) {
1034 throw nsee;
1035 }
1036 catch (Exception e) {
1037 throw processException(e);
1038 }
1039 finally {
1040 closeSession(session);
1041 }
1042 }
1043
1044 @Override
1045 protected PasswordPolicyRel removeImpl(PasswordPolicyRel passwordPolicyRel)
1046 throws SystemException {
1047 passwordPolicyRel = toUnwrappedModel(passwordPolicyRel);
1048
1049 Session session = null;
1050
1051 try {
1052 session = openSession();
1053
1054 if (!session.contains(passwordPolicyRel)) {
1055 passwordPolicyRel = (PasswordPolicyRel)session.get(PasswordPolicyRelImpl.class,
1056 passwordPolicyRel.getPrimaryKeyObj());
1057 }
1058
1059 if (passwordPolicyRel != null) {
1060 session.delete(passwordPolicyRel);
1061 }
1062 }
1063 catch (Exception e) {
1064 throw processException(e);
1065 }
1066 finally {
1067 closeSession(session);
1068 }
1069
1070 if (passwordPolicyRel != null) {
1071 clearCache(passwordPolicyRel);
1072 }
1073
1074 return passwordPolicyRel;
1075 }
1076
1077 @Override
1078 public PasswordPolicyRel updateImpl(
1079 com.liferay.portal.model.PasswordPolicyRel passwordPolicyRel)
1080 throws SystemException {
1081 passwordPolicyRel = toUnwrappedModel(passwordPolicyRel);
1082
1083 boolean isNew = passwordPolicyRel.isNew();
1084
1085 PasswordPolicyRelModelImpl passwordPolicyRelModelImpl = (PasswordPolicyRelModelImpl)passwordPolicyRel;
1086
1087 Session session = null;
1088
1089 try {
1090 session = openSession();
1091
1092 if (passwordPolicyRel.isNew()) {
1093 session.save(passwordPolicyRel);
1094
1095 passwordPolicyRel.setNew(false);
1096 }
1097 else {
1098 session.merge(passwordPolicyRel);
1099 }
1100 }
1101 catch (Exception e) {
1102 throw processException(e);
1103 }
1104 finally {
1105 closeSession(session);
1106 }
1107
1108 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1109
1110 if (isNew || !PasswordPolicyRelModelImpl.COLUMN_BITMASK_ENABLED) {
1111 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1112 }
1113
1114 else {
1115 if ((passwordPolicyRelModelImpl.getColumnBitmask() &
1116 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PASSWORDPOLICYID.getColumnBitmask()) != 0) {
1117 Object[] args = new Object[] {
1118 passwordPolicyRelModelImpl.getOriginalPasswordPolicyId()
1119 };
1120
1121 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PASSWORDPOLICYID,
1122 args);
1123 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PASSWORDPOLICYID,
1124 args);
1125
1126 args = new Object[] {
1127 passwordPolicyRelModelImpl.getPasswordPolicyId()
1128 };
1129
1130 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PASSWORDPOLICYID,
1131 args);
1132 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PASSWORDPOLICYID,
1133 args);
1134 }
1135 }
1136
1137 EntityCacheUtil.putResult(PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
1138 PasswordPolicyRelImpl.class, passwordPolicyRel.getPrimaryKey(),
1139 passwordPolicyRel);
1140
1141 clearUniqueFindersCache(passwordPolicyRel);
1142 cacheUniqueFindersCache(passwordPolicyRel);
1143
1144 return passwordPolicyRel;
1145 }
1146
1147 protected PasswordPolicyRel toUnwrappedModel(
1148 PasswordPolicyRel passwordPolicyRel) {
1149 if (passwordPolicyRel instanceof PasswordPolicyRelImpl) {
1150 return passwordPolicyRel;
1151 }
1152
1153 PasswordPolicyRelImpl passwordPolicyRelImpl = new PasswordPolicyRelImpl();
1154
1155 passwordPolicyRelImpl.setNew(passwordPolicyRel.isNew());
1156 passwordPolicyRelImpl.setPrimaryKey(passwordPolicyRel.getPrimaryKey());
1157
1158 passwordPolicyRelImpl.setPasswordPolicyRelId(passwordPolicyRel.getPasswordPolicyRelId());
1159 passwordPolicyRelImpl.setPasswordPolicyId(passwordPolicyRel.getPasswordPolicyId());
1160 passwordPolicyRelImpl.setClassNameId(passwordPolicyRel.getClassNameId());
1161 passwordPolicyRelImpl.setClassPK(passwordPolicyRel.getClassPK());
1162
1163 return passwordPolicyRelImpl;
1164 }
1165
1166
1174 @Override
1175 public PasswordPolicyRel findByPrimaryKey(Serializable primaryKey)
1176 throws NoSuchPasswordPolicyRelException, SystemException {
1177 PasswordPolicyRel passwordPolicyRel = fetchByPrimaryKey(primaryKey);
1178
1179 if (passwordPolicyRel == null) {
1180 if (_log.isWarnEnabled()) {
1181 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
1182 }
1183
1184 throw new NoSuchPasswordPolicyRelException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1185 primaryKey);
1186 }
1187
1188 return passwordPolicyRel;
1189 }
1190
1191
1199 @Override
1200 public PasswordPolicyRel findByPrimaryKey(long passwordPolicyRelId)
1201 throws NoSuchPasswordPolicyRelException, SystemException {
1202 return findByPrimaryKey((Serializable)passwordPolicyRelId);
1203 }
1204
1205
1212 @Override
1213 public PasswordPolicyRel fetchByPrimaryKey(Serializable primaryKey)
1214 throws SystemException {
1215 PasswordPolicyRel passwordPolicyRel = (PasswordPolicyRel)EntityCacheUtil.getResult(PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
1216 PasswordPolicyRelImpl.class, primaryKey);
1217
1218 if (passwordPolicyRel == _nullPasswordPolicyRel) {
1219 return null;
1220 }
1221
1222 if (passwordPolicyRel == null) {
1223 Session session = null;
1224
1225 try {
1226 session = openSession();
1227
1228 passwordPolicyRel = (PasswordPolicyRel)session.get(PasswordPolicyRelImpl.class,
1229 primaryKey);
1230
1231 if (passwordPolicyRel != null) {
1232 cacheResult(passwordPolicyRel);
1233 }
1234 else {
1235 EntityCacheUtil.putResult(PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
1236 PasswordPolicyRelImpl.class, primaryKey,
1237 _nullPasswordPolicyRel);
1238 }
1239 }
1240 catch (Exception e) {
1241 EntityCacheUtil.removeResult(PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
1242 PasswordPolicyRelImpl.class, primaryKey);
1243
1244 throw processException(e);
1245 }
1246 finally {
1247 closeSession(session);
1248 }
1249 }
1250
1251 return passwordPolicyRel;
1252 }
1253
1254
1261 @Override
1262 public PasswordPolicyRel fetchByPrimaryKey(long passwordPolicyRelId)
1263 throws SystemException {
1264 return fetchByPrimaryKey((Serializable)passwordPolicyRelId);
1265 }
1266
1267
1273 @Override
1274 public List<PasswordPolicyRel> findAll() throws SystemException {
1275 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1276 }
1277
1278
1290 @Override
1291 public List<PasswordPolicyRel> findAll(int start, int end)
1292 throws SystemException {
1293 return findAll(start, end, null);
1294 }
1295
1296
1309 @Override
1310 public List<PasswordPolicyRel> findAll(int start, int end,
1311 OrderByComparator orderByComparator) throws SystemException {
1312 boolean pagination = true;
1313 FinderPath finderPath = null;
1314 Object[] finderArgs = null;
1315
1316 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1317 (orderByComparator == null)) {
1318 pagination = false;
1319 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1320 finderArgs = FINDER_ARGS_EMPTY;
1321 }
1322 else {
1323 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1324 finderArgs = new Object[] { start, end, orderByComparator };
1325 }
1326
1327 List<PasswordPolicyRel> list = (List<PasswordPolicyRel>)FinderCacheUtil.getResult(finderPath,
1328 finderArgs, this);
1329
1330 if (list == null) {
1331 StringBundler query = null;
1332 String sql = null;
1333
1334 if (orderByComparator != null) {
1335 query = new StringBundler(2 +
1336 (orderByComparator.getOrderByFields().length * 3));
1337
1338 query.append(_SQL_SELECT_PASSWORDPOLICYREL);
1339
1340 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1341 orderByComparator);
1342
1343 sql = query.toString();
1344 }
1345 else {
1346 sql = _SQL_SELECT_PASSWORDPOLICYREL;
1347
1348 if (pagination) {
1349 sql = sql.concat(PasswordPolicyRelModelImpl.ORDER_BY_JPQL);
1350 }
1351 }
1352
1353 Session session = null;
1354
1355 try {
1356 session = openSession();
1357
1358 Query q = session.createQuery(sql);
1359
1360 if (!pagination) {
1361 list = (List<PasswordPolicyRel>)QueryUtil.list(q,
1362 getDialect(), start, end, false);
1363
1364 Collections.sort(list);
1365
1366 list = new UnmodifiableList<PasswordPolicyRel>(list);
1367 }
1368 else {
1369 list = (List<PasswordPolicyRel>)QueryUtil.list(q,
1370 getDialect(), start, end);
1371 }
1372
1373 cacheResult(list);
1374
1375 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1376 }
1377 catch (Exception e) {
1378 FinderCacheUtil.removeResult(finderPath, finderArgs);
1379
1380 throw processException(e);
1381 }
1382 finally {
1383 closeSession(session);
1384 }
1385 }
1386
1387 return list;
1388 }
1389
1390
1395 @Override
1396 public void removeAll() throws SystemException {
1397 for (PasswordPolicyRel passwordPolicyRel : findAll()) {
1398 remove(passwordPolicyRel);
1399 }
1400 }
1401
1402
1408 @Override
1409 public int countAll() throws SystemException {
1410 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1411 FINDER_ARGS_EMPTY, this);
1412
1413 if (count == null) {
1414 Session session = null;
1415
1416 try {
1417 session = openSession();
1418
1419 Query q = session.createQuery(_SQL_COUNT_PASSWORDPOLICYREL);
1420
1421 count = (Long)q.uniqueResult();
1422
1423 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1424 FINDER_ARGS_EMPTY, count);
1425 }
1426 catch (Exception e) {
1427 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
1428 FINDER_ARGS_EMPTY);
1429
1430 throw processException(e);
1431 }
1432 finally {
1433 closeSession(session);
1434 }
1435 }
1436
1437 return count.intValue();
1438 }
1439
1440
1443 public void afterPropertiesSet() {
1444 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1445 com.liferay.portal.util.PropsUtil.get(
1446 "value.object.listener.com.liferay.portal.model.PasswordPolicyRel")));
1447
1448 if (listenerClassNames.length > 0) {
1449 try {
1450 List<ModelListener<PasswordPolicyRel>> listenersList = new ArrayList<ModelListener<PasswordPolicyRel>>();
1451
1452 for (String listenerClassName : listenerClassNames) {
1453 listenersList.add((ModelListener<PasswordPolicyRel>)InstanceFactory.newInstance(
1454 getClassLoader(), listenerClassName));
1455 }
1456
1457 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1458 }
1459 catch (Exception e) {
1460 _log.error(e);
1461 }
1462 }
1463 }
1464
1465 public void destroy() {
1466 EntityCacheUtil.removeCache(PasswordPolicyRelImpl.class.getName());
1467 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1468 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1469 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1470 }
1471
1472 private static final String _SQL_SELECT_PASSWORDPOLICYREL = "SELECT passwordPolicyRel FROM PasswordPolicyRel passwordPolicyRel";
1473 private static final String _SQL_SELECT_PASSWORDPOLICYREL_WHERE = "SELECT passwordPolicyRel FROM PasswordPolicyRel passwordPolicyRel WHERE ";
1474 private static final String _SQL_COUNT_PASSWORDPOLICYREL = "SELECT COUNT(passwordPolicyRel) FROM PasswordPolicyRel passwordPolicyRel";
1475 private static final String _SQL_COUNT_PASSWORDPOLICYREL_WHERE = "SELECT COUNT(passwordPolicyRel) FROM PasswordPolicyRel passwordPolicyRel WHERE ";
1476 private static final String _ORDER_BY_ENTITY_ALIAS = "passwordPolicyRel.";
1477 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No PasswordPolicyRel exists with the primary key ";
1478 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No PasswordPolicyRel exists with the key {";
1479 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1480 private static Log _log = LogFactoryUtil.getLog(PasswordPolicyRelPersistenceImpl.class);
1481 private static PasswordPolicyRel _nullPasswordPolicyRel = new PasswordPolicyRelImpl() {
1482 @Override
1483 public Object clone() {
1484 return this;
1485 }
1486
1487 @Override
1488 public CacheModel<PasswordPolicyRel> toCacheModel() {
1489 return _nullPasswordPolicyRelCacheModel;
1490 }
1491 };
1492
1493 private static CacheModel<PasswordPolicyRel> _nullPasswordPolicyRelCacheModel =
1494 new CacheModel<PasswordPolicyRel>() {
1495 @Override
1496 public PasswordPolicyRel toEntityModel() {
1497 return _nullPasswordPolicyRel;
1498 }
1499 };
1500 }