001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.NoSuchPasswordTrackerException;
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023 import com.liferay.portal.kernel.dao.orm.FinderPath;
024 import com.liferay.portal.kernel.dao.orm.Query;
025 import com.liferay.portal.kernel.dao.orm.QueryPos;
026 import com.liferay.portal.kernel.dao.orm.QueryUtil;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.model.CacheModel;
038 import com.liferay.portal.model.ModelListener;
039 import com.liferay.portal.model.PasswordTracker;
040 import com.liferay.portal.model.impl.PasswordTrackerImpl;
041 import com.liferay.portal.model.impl.PasswordTrackerModelImpl;
042 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043
044 import java.io.Serializable;
045
046 import java.util.ArrayList;
047 import java.util.Collections;
048 import java.util.List;
049
050
062 public class PasswordTrackerPersistenceImpl extends BasePersistenceImpl<PasswordTracker>
063 implements PasswordTrackerPersistence {
064
069 public static final String FINDER_CLASS_NAME_ENTITY = PasswordTrackerImpl.class.getName();
070 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
071 ".List1";
072 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
073 ".List2";
074 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
075 PasswordTrackerModelImpl.FINDER_CACHE_ENABLED,
076 PasswordTrackerImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
077 "findByUserId",
078 new String[] {
079 Long.class.getName(),
080
081 "java.lang.Integer", "java.lang.Integer",
082 "com.liferay.portal.kernel.util.OrderByComparator"
083 });
084 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
085 new FinderPath(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
086 PasswordTrackerModelImpl.FINDER_CACHE_ENABLED,
087 PasswordTrackerImpl.class,
088 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
089 new String[] { Long.class.getName() },
090 PasswordTrackerModelImpl.USERID_COLUMN_BITMASK);
091 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
092 PasswordTrackerModelImpl.FINDER_CACHE_ENABLED, Long.class,
093 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
094 new String[] { Long.class.getName() });
095 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
096 PasswordTrackerModelImpl.FINDER_CACHE_ENABLED,
097 PasswordTrackerImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
098 "findAll", new String[0]);
099 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
100 PasswordTrackerModelImpl.FINDER_CACHE_ENABLED,
101 PasswordTrackerImpl.class,
102 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
103 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
104 PasswordTrackerModelImpl.FINDER_CACHE_ENABLED, Long.class,
105 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
106
107
112 public void cacheResult(PasswordTracker passwordTracker) {
113 EntityCacheUtil.putResult(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
114 PasswordTrackerImpl.class, passwordTracker.getPrimaryKey(),
115 passwordTracker);
116
117 passwordTracker.resetOriginalValues();
118 }
119
120
125 public void cacheResult(List<PasswordTracker> passwordTrackers) {
126 for (PasswordTracker passwordTracker : passwordTrackers) {
127 if (EntityCacheUtil.getResult(
128 PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
129 PasswordTrackerImpl.class,
130 passwordTracker.getPrimaryKey()) == null) {
131 cacheResult(passwordTracker);
132 }
133 else {
134 passwordTracker.resetOriginalValues();
135 }
136 }
137 }
138
139
146 @Override
147 public void clearCache() {
148 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
149 CacheRegistryUtil.clear(PasswordTrackerImpl.class.getName());
150 }
151
152 EntityCacheUtil.clearCache(PasswordTrackerImpl.class.getName());
153
154 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
155 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
156 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
157 }
158
159
166 @Override
167 public void clearCache(PasswordTracker passwordTracker) {
168 EntityCacheUtil.removeResult(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
169 PasswordTrackerImpl.class, passwordTracker.getPrimaryKey());
170
171 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
172 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
173 }
174
175 @Override
176 public void clearCache(List<PasswordTracker> passwordTrackers) {
177 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
178 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
179
180 for (PasswordTracker passwordTracker : passwordTrackers) {
181 EntityCacheUtil.removeResult(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
182 PasswordTrackerImpl.class, passwordTracker.getPrimaryKey());
183 }
184 }
185
186
192 public PasswordTracker create(long passwordTrackerId) {
193 PasswordTracker passwordTracker = new PasswordTrackerImpl();
194
195 passwordTracker.setNew(true);
196 passwordTracker.setPrimaryKey(passwordTrackerId);
197
198 return passwordTracker;
199 }
200
201
209 public PasswordTracker remove(long passwordTrackerId)
210 throws NoSuchPasswordTrackerException, SystemException {
211 return remove(Long.valueOf(passwordTrackerId));
212 }
213
214
222 @Override
223 public PasswordTracker remove(Serializable primaryKey)
224 throws NoSuchPasswordTrackerException, SystemException {
225 Session session = null;
226
227 try {
228 session = openSession();
229
230 PasswordTracker passwordTracker = (PasswordTracker)session.get(PasswordTrackerImpl.class,
231 primaryKey);
232
233 if (passwordTracker == null) {
234 if (_log.isWarnEnabled()) {
235 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
236 }
237
238 throw new NoSuchPasswordTrackerException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
239 primaryKey);
240 }
241
242 return remove(passwordTracker);
243 }
244 catch (NoSuchPasswordTrackerException nsee) {
245 throw nsee;
246 }
247 catch (Exception e) {
248 throw processException(e);
249 }
250 finally {
251 closeSession(session);
252 }
253 }
254
255 @Override
256 protected PasswordTracker removeImpl(PasswordTracker passwordTracker)
257 throws SystemException {
258 passwordTracker = toUnwrappedModel(passwordTracker);
259
260 Session session = null;
261
262 try {
263 session = openSession();
264
265 if (passwordTracker.isCachedModel()) {
266 passwordTracker = (PasswordTracker)session.get(PasswordTrackerImpl.class,
267 passwordTracker.getPrimaryKeyObj());
268 }
269
270 session.delete(passwordTracker);
271 }
272 catch (Exception e) {
273 throw processException(e);
274 }
275 finally {
276 closeSession(session);
277 }
278
279 clearCache(passwordTracker);
280
281 return passwordTracker;
282 }
283
284 @Override
285 public PasswordTracker updateImpl(
286 com.liferay.portal.model.PasswordTracker passwordTracker)
287 throws SystemException {
288 passwordTracker = toUnwrappedModel(passwordTracker);
289
290 boolean isNew = passwordTracker.isNew();
291
292 PasswordTrackerModelImpl passwordTrackerModelImpl = (PasswordTrackerModelImpl)passwordTracker;
293
294 Session session = null;
295
296 try {
297 session = openSession();
298
299 if (passwordTracker.isNew()) {
300 session.save(passwordTracker);
301
302 passwordTracker.setNew(false);
303 }
304 else {
305 session.merge(passwordTracker);
306 }
307 }
308 catch (Exception e) {
309 throw processException(e);
310 }
311 finally {
312 closeSession(session);
313 }
314
315 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
316
317 if (isNew || !PasswordTrackerModelImpl.COLUMN_BITMASK_ENABLED) {
318 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
319 }
320
321 else {
322 if ((passwordTrackerModelImpl.getColumnBitmask() &
323 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
324 Object[] args = new Object[] {
325 Long.valueOf(passwordTrackerModelImpl.getOriginalUserId())
326 };
327
328 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
329 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
330 args);
331
332 args = new Object[] {
333 Long.valueOf(passwordTrackerModelImpl.getUserId())
334 };
335
336 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
337 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
338 args);
339 }
340 }
341
342 EntityCacheUtil.putResult(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
343 PasswordTrackerImpl.class, passwordTracker.getPrimaryKey(),
344 passwordTracker);
345
346 return passwordTracker;
347 }
348
349 protected PasswordTracker toUnwrappedModel(PasswordTracker passwordTracker) {
350 if (passwordTracker instanceof PasswordTrackerImpl) {
351 return passwordTracker;
352 }
353
354 PasswordTrackerImpl passwordTrackerImpl = new PasswordTrackerImpl();
355
356 passwordTrackerImpl.setNew(passwordTracker.isNew());
357 passwordTrackerImpl.setPrimaryKey(passwordTracker.getPrimaryKey());
358
359 passwordTrackerImpl.setPasswordTrackerId(passwordTracker.getPasswordTrackerId());
360 passwordTrackerImpl.setUserId(passwordTracker.getUserId());
361 passwordTrackerImpl.setCreateDate(passwordTracker.getCreateDate());
362 passwordTrackerImpl.setPassword(passwordTracker.getPassword());
363
364 return passwordTrackerImpl;
365 }
366
367
375 @Override
376 public PasswordTracker findByPrimaryKey(Serializable primaryKey)
377 throws NoSuchModelException, SystemException {
378 return findByPrimaryKey(((Long)primaryKey).longValue());
379 }
380
381
389 public PasswordTracker findByPrimaryKey(long passwordTrackerId)
390 throws NoSuchPasswordTrackerException, SystemException {
391 PasswordTracker passwordTracker = fetchByPrimaryKey(passwordTrackerId);
392
393 if (passwordTracker == null) {
394 if (_log.isWarnEnabled()) {
395 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + passwordTrackerId);
396 }
397
398 throw new NoSuchPasswordTrackerException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
399 passwordTrackerId);
400 }
401
402 return passwordTracker;
403 }
404
405
412 @Override
413 public PasswordTracker fetchByPrimaryKey(Serializable primaryKey)
414 throws SystemException {
415 return fetchByPrimaryKey(((Long)primaryKey).longValue());
416 }
417
418
425 public PasswordTracker fetchByPrimaryKey(long passwordTrackerId)
426 throws SystemException {
427 PasswordTracker passwordTracker = (PasswordTracker)EntityCacheUtil.getResult(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
428 PasswordTrackerImpl.class, passwordTrackerId);
429
430 if (passwordTracker == _nullPasswordTracker) {
431 return null;
432 }
433
434 if (passwordTracker == null) {
435 Session session = null;
436
437 boolean hasException = false;
438
439 try {
440 session = openSession();
441
442 passwordTracker = (PasswordTracker)session.get(PasswordTrackerImpl.class,
443 Long.valueOf(passwordTrackerId));
444 }
445 catch (Exception e) {
446 hasException = true;
447
448 throw processException(e);
449 }
450 finally {
451 if (passwordTracker != null) {
452 cacheResult(passwordTracker);
453 }
454 else if (!hasException) {
455 EntityCacheUtil.putResult(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
456 PasswordTrackerImpl.class, passwordTrackerId,
457 _nullPasswordTracker);
458 }
459
460 closeSession(session);
461 }
462 }
463
464 return passwordTracker;
465 }
466
467
474 public List<PasswordTracker> findByUserId(long userId)
475 throws SystemException {
476 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
477 }
478
479
492 public List<PasswordTracker> findByUserId(long userId, int start, int end)
493 throws SystemException {
494 return findByUserId(userId, start, end, null);
495 }
496
497
511 public List<PasswordTracker> findByUserId(long userId, int start, int end,
512 OrderByComparator orderByComparator) throws SystemException {
513 FinderPath finderPath = null;
514 Object[] finderArgs = null;
515
516 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
517 (orderByComparator == null)) {
518 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
519 finderArgs = new Object[] { userId };
520 }
521 else {
522 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
523 finderArgs = new Object[] { userId, start, end, orderByComparator };
524 }
525
526 List<PasswordTracker> list = (List<PasswordTracker>)FinderCacheUtil.getResult(finderPath,
527 finderArgs, this);
528
529 if ((list != null) && !list.isEmpty()) {
530 for (PasswordTracker passwordTracker : list) {
531 if ((userId != passwordTracker.getUserId())) {
532 list = null;
533
534 break;
535 }
536 }
537 }
538
539 if (list == null) {
540 StringBundler query = null;
541
542 if (orderByComparator != null) {
543 query = new StringBundler(3 +
544 (orderByComparator.getOrderByFields().length * 3));
545 }
546 else {
547 query = new StringBundler(3);
548 }
549
550 query.append(_SQL_SELECT_PASSWORDTRACKER_WHERE);
551
552 query.append(_FINDER_COLUMN_USERID_USERID_2);
553
554 if (orderByComparator != null) {
555 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
556 orderByComparator);
557 }
558
559 else {
560 query.append(PasswordTrackerModelImpl.ORDER_BY_JPQL);
561 }
562
563 String sql = query.toString();
564
565 Session session = null;
566
567 try {
568 session = openSession();
569
570 Query q = session.createQuery(sql);
571
572 QueryPos qPos = QueryPos.getInstance(q);
573
574 qPos.add(userId);
575
576 list = (List<PasswordTracker>)QueryUtil.list(q, getDialect(),
577 start, end);
578 }
579 catch (Exception e) {
580 throw processException(e);
581 }
582 finally {
583 if (list == null) {
584 FinderCacheUtil.removeResult(finderPath, finderArgs);
585 }
586 else {
587 cacheResult(list);
588
589 FinderCacheUtil.putResult(finderPath, finderArgs, list);
590 }
591
592 closeSession(session);
593 }
594 }
595
596 return list;
597 }
598
599
608 public PasswordTracker findByUserId_First(long userId,
609 OrderByComparator orderByComparator)
610 throws NoSuchPasswordTrackerException, SystemException {
611 PasswordTracker passwordTracker = fetchByUserId_First(userId,
612 orderByComparator);
613
614 if (passwordTracker != null) {
615 return passwordTracker;
616 }
617
618 StringBundler msg = new StringBundler(4);
619
620 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
621
622 msg.append("userId=");
623 msg.append(userId);
624
625 msg.append(StringPool.CLOSE_CURLY_BRACE);
626
627 throw new NoSuchPasswordTrackerException(msg.toString());
628 }
629
630
638 public PasswordTracker fetchByUserId_First(long userId,
639 OrderByComparator orderByComparator) throws SystemException {
640 List<PasswordTracker> list = findByUserId(userId, 0, 1,
641 orderByComparator);
642
643 if (!list.isEmpty()) {
644 return list.get(0);
645 }
646
647 return null;
648 }
649
650
659 public PasswordTracker findByUserId_Last(long userId,
660 OrderByComparator orderByComparator)
661 throws NoSuchPasswordTrackerException, SystemException {
662 PasswordTracker passwordTracker = fetchByUserId_Last(userId,
663 orderByComparator);
664
665 if (passwordTracker != null) {
666 return passwordTracker;
667 }
668
669 StringBundler msg = new StringBundler(4);
670
671 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
672
673 msg.append("userId=");
674 msg.append(userId);
675
676 msg.append(StringPool.CLOSE_CURLY_BRACE);
677
678 throw new NoSuchPasswordTrackerException(msg.toString());
679 }
680
681
689 public PasswordTracker fetchByUserId_Last(long userId,
690 OrderByComparator orderByComparator) throws SystemException {
691 int count = countByUserId(userId);
692
693 List<PasswordTracker> list = findByUserId(userId, count - 1, count,
694 orderByComparator);
695
696 if (!list.isEmpty()) {
697 return list.get(0);
698 }
699
700 return null;
701 }
702
703
713 public PasswordTracker[] findByUserId_PrevAndNext(long passwordTrackerId,
714 long userId, OrderByComparator orderByComparator)
715 throws NoSuchPasswordTrackerException, SystemException {
716 PasswordTracker passwordTracker = findByPrimaryKey(passwordTrackerId);
717
718 Session session = null;
719
720 try {
721 session = openSession();
722
723 PasswordTracker[] array = new PasswordTrackerImpl[3];
724
725 array[0] = getByUserId_PrevAndNext(session, passwordTracker,
726 userId, orderByComparator, true);
727
728 array[1] = passwordTracker;
729
730 array[2] = getByUserId_PrevAndNext(session, passwordTracker,
731 userId, orderByComparator, false);
732
733 return array;
734 }
735 catch (Exception e) {
736 throw processException(e);
737 }
738 finally {
739 closeSession(session);
740 }
741 }
742
743 protected PasswordTracker getByUserId_PrevAndNext(Session session,
744 PasswordTracker passwordTracker, long userId,
745 OrderByComparator orderByComparator, boolean previous) {
746 StringBundler query = null;
747
748 if (orderByComparator != null) {
749 query = new StringBundler(6 +
750 (orderByComparator.getOrderByFields().length * 6));
751 }
752 else {
753 query = new StringBundler(3);
754 }
755
756 query.append(_SQL_SELECT_PASSWORDTRACKER_WHERE);
757
758 query.append(_FINDER_COLUMN_USERID_USERID_2);
759
760 if (orderByComparator != null) {
761 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
762
763 if (orderByConditionFields.length > 0) {
764 query.append(WHERE_AND);
765 }
766
767 for (int i = 0; i < orderByConditionFields.length; i++) {
768 query.append(_ORDER_BY_ENTITY_ALIAS);
769 query.append(orderByConditionFields[i]);
770
771 if ((i + 1) < orderByConditionFields.length) {
772 if (orderByComparator.isAscending() ^ previous) {
773 query.append(WHERE_GREATER_THAN_HAS_NEXT);
774 }
775 else {
776 query.append(WHERE_LESSER_THAN_HAS_NEXT);
777 }
778 }
779 else {
780 if (orderByComparator.isAscending() ^ previous) {
781 query.append(WHERE_GREATER_THAN);
782 }
783 else {
784 query.append(WHERE_LESSER_THAN);
785 }
786 }
787 }
788
789 query.append(ORDER_BY_CLAUSE);
790
791 String[] orderByFields = orderByComparator.getOrderByFields();
792
793 for (int i = 0; i < orderByFields.length; i++) {
794 query.append(_ORDER_BY_ENTITY_ALIAS);
795 query.append(orderByFields[i]);
796
797 if ((i + 1) < orderByFields.length) {
798 if (orderByComparator.isAscending() ^ previous) {
799 query.append(ORDER_BY_ASC_HAS_NEXT);
800 }
801 else {
802 query.append(ORDER_BY_DESC_HAS_NEXT);
803 }
804 }
805 else {
806 if (orderByComparator.isAscending() ^ previous) {
807 query.append(ORDER_BY_ASC);
808 }
809 else {
810 query.append(ORDER_BY_DESC);
811 }
812 }
813 }
814 }
815
816 else {
817 query.append(PasswordTrackerModelImpl.ORDER_BY_JPQL);
818 }
819
820 String sql = query.toString();
821
822 Query q = session.createQuery(sql);
823
824 q.setFirstResult(0);
825 q.setMaxResults(2);
826
827 QueryPos qPos = QueryPos.getInstance(q);
828
829 qPos.add(userId);
830
831 if (orderByComparator != null) {
832 Object[] values = orderByComparator.getOrderByConditionValues(passwordTracker);
833
834 for (Object value : values) {
835 qPos.add(value);
836 }
837 }
838
839 List<PasswordTracker> list = q.list();
840
841 if (list.size() == 2) {
842 return list.get(1);
843 }
844 else {
845 return null;
846 }
847 }
848
849
855 public List<PasswordTracker> findAll() throws SystemException {
856 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
857 }
858
859
871 public List<PasswordTracker> findAll(int start, int end)
872 throws SystemException {
873 return findAll(start, end, null);
874 }
875
876
889 public List<PasswordTracker> findAll(int start, int end,
890 OrderByComparator orderByComparator) throws SystemException {
891 FinderPath finderPath = null;
892 Object[] finderArgs = new Object[] { start, end, orderByComparator };
893
894 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
895 (orderByComparator == null)) {
896 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
897 finderArgs = FINDER_ARGS_EMPTY;
898 }
899 else {
900 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
901 finderArgs = new Object[] { start, end, orderByComparator };
902 }
903
904 List<PasswordTracker> list = (List<PasswordTracker>)FinderCacheUtil.getResult(finderPath,
905 finderArgs, this);
906
907 if (list == null) {
908 StringBundler query = null;
909 String sql = null;
910
911 if (orderByComparator != null) {
912 query = new StringBundler(2 +
913 (orderByComparator.getOrderByFields().length * 3));
914
915 query.append(_SQL_SELECT_PASSWORDTRACKER);
916
917 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
918 orderByComparator);
919
920 sql = query.toString();
921 }
922 else {
923 sql = _SQL_SELECT_PASSWORDTRACKER.concat(PasswordTrackerModelImpl.ORDER_BY_JPQL);
924 }
925
926 Session session = null;
927
928 try {
929 session = openSession();
930
931 Query q = session.createQuery(sql);
932
933 if (orderByComparator == null) {
934 list = (List<PasswordTracker>)QueryUtil.list(q,
935 getDialect(), start, end, false);
936
937 Collections.sort(list);
938 }
939 else {
940 list = (List<PasswordTracker>)QueryUtil.list(q,
941 getDialect(), start, end);
942 }
943 }
944 catch (Exception e) {
945 throw processException(e);
946 }
947 finally {
948 if (list == null) {
949 FinderCacheUtil.removeResult(finderPath, finderArgs);
950 }
951 else {
952 cacheResult(list);
953
954 FinderCacheUtil.putResult(finderPath, finderArgs, list);
955 }
956
957 closeSession(session);
958 }
959 }
960
961 return list;
962 }
963
964
970 public void removeByUserId(long userId) throws SystemException {
971 for (PasswordTracker passwordTracker : findByUserId(userId)) {
972 remove(passwordTracker);
973 }
974 }
975
976
981 public void removeAll() throws SystemException {
982 for (PasswordTracker passwordTracker : findAll()) {
983 remove(passwordTracker);
984 }
985 }
986
987
994 public int countByUserId(long userId) throws SystemException {
995 Object[] finderArgs = new Object[] { userId };
996
997 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
998 finderArgs, this);
999
1000 if (count == null) {
1001 StringBundler query = new StringBundler(2);
1002
1003 query.append(_SQL_COUNT_PASSWORDTRACKER_WHERE);
1004
1005 query.append(_FINDER_COLUMN_USERID_USERID_2);
1006
1007 String sql = query.toString();
1008
1009 Session session = null;
1010
1011 try {
1012 session = openSession();
1013
1014 Query q = session.createQuery(sql);
1015
1016 QueryPos qPos = QueryPos.getInstance(q);
1017
1018 qPos.add(userId);
1019
1020 count = (Long)q.uniqueResult();
1021 }
1022 catch (Exception e) {
1023 throw processException(e);
1024 }
1025 finally {
1026 if (count == null) {
1027 count = Long.valueOf(0);
1028 }
1029
1030 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
1031 finderArgs, count);
1032
1033 closeSession(session);
1034 }
1035 }
1036
1037 return count.intValue();
1038 }
1039
1040
1046 public int countAll() throws SystemException {
1047 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1048 FINDER_ARGS_EMPTY, this);
1049
1050 if (count == null) {
1051 Session session = null;
1052
1053 try {
1054 session = openSession();
1055
1056 Query q = session.createQuery(_SQL_COUNT_PASSWORDTRACKER);
1057
1058 count = (Long)q.uniqueResult();
1059 }
1060 catch (Exception e) {
1061 throw processException(e);
1062 }
1063 finally {
1064 if (count == null) {
1065 count = Long.valueOf(0);
1066 }
1067
1068 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1069 FINDER_ARGS_EMPTY, count);
1070
1071 closeSession(session);
1072 }
1073 }
1074
1075 return count.intValue();
1076 }
1077
1078
1081 public void afterPropertiesSet() {
1082 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1083 com.liferay.portal.util.PropsUtil.get(
1084 "value.object.listener.com.liferay.portal.model.PasswordTracker")));
1085
1086 if (listenerClassNames.length > 0) {
1087 try {
1088 List<ModelListener<PasswordTracker>> listenersList = new ArrayList<ModelListener<PasswordTracker>>();
1089
1090 for (String listenerClassName : listenerClassNames) {
1091 listenersList.add((ModelListener<PasswordTracker>)InstanceFactory.newInstance(
1092 listenerClassName));
1093 }
1094
1095 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1096 }
1097 catch (Exception e) {
1098 _log.error(e);
1099 }
1100 }
1101 }
1102
1103 public void destroy() {
1104 EntityCacheUtil.removeCache(PasswordTrackerImpl.class.getName());
1105 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1106 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1107 }
1108
1109 @BeanReference(type = AccountPersistence.class)
1110 protected AccountPersistence accountPersistence;
1111 @BeanReference(type = AddressPersistence.class)
1112 protected AddressPersistence addressPersistence;
1113 @BeanReference(type = BrowserTrackerPersistence.class)
1114 protected BrowserTrackerPersistence browserTrackerPersistence;
1115 @BeanReference(type = ClassNamePersistence.class)
1116 protected ClassNamePersistence classNamePersistence;
1117 @BeanReference(type = ClusterGroupPersistence.class)
1118 protected ClusterGroupPersistence clusterGroupPersistence;
1119 @BeanReference(type = CompanyPersistence.class)
1120 protected CompanyPersistence companyPersistence;
1121 @BeanReference(type = ContactPersistence.class)
1122 protected ContactPersistence contactPersistence;
1123 @BeanReference(type = CountryPersistence.class)
1124 protected CountryPersistence countryPersistence;
1125 @BeanReference(type = EmailAddressPersistence.class)
1126 protected EmailAddressPersistence emailAddressPersistence;
1127 @BeanReference(type = GroupPersistence.class)
1128 protected GroupPersistence groupPersistence;
1129 @BeanReference(type = ImagePersistence.class)
1130 protected ImagePersistence imagePersistence;
1131 @BeanReference(type = LayoutPersistence.class)
1132 protected LayoutPersistence layoutPersistence;
1133 @BeanReference(type = LayoutBranchPersistence.class)
1134 protected LayoutBranchPersistence layoutBranchPersistence;
1135 @BeanReference(type = LayoutPrototypePersistence.class)
1136 protected LayoutPrototypePersistence layoutPrototypePersistence;
1137 @BeanReference(type = LayoutRevisionPersistence.class)
1138 protected LayoutRevisionPersistence layoutRevisionPersistence;
1139 @BeanReference(type = LayoutSetPersistence.class)
1140 protected LayoutSetPersistence layoutSetPersistence;
1141 @BeanReference(type = LayoutSetBranchPersistence.class)
1142 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
1143 @BeanReference(type = LayoutSetPrototypePersistence.class)
1144 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1145 @BeanReference(type = ListTypePersistence.class)
1146 protected ListTypePersistence listTypePersistence;
1147 @BeanReference(type = LockPersistence.class)
1148 protected LockPersistence lockPersistence;
1149 @BeanReference(type = MembershipRequestPersistence.class)
1150 protected MembershipRequestPersistence membershipRequestPersistence;
1151 @BeanReference(type = OrganizationPersistence.class)
1152 protected OrganizationPersistence organizationPersistence;
1153 @BeanReference(type = OrgGroupRolePersistence.class)
1154 protected OrgGroupRolePersistence orgGroupRolePersistence;
1155 @BeanReference(type = OrgLaborPersistence.class)
1156 protected OrgLaborPersistence orgLaborPersistence;
1157 @BeanReference(type = PasswordPolicyPersistence.class)
1158 protected PasswordPolicyPersistence passwordPolicyPersistence;
1159 @BeanReference(type = PasswordPolicyRelPersistence.class)
1160 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1161 @BeanReference(type = PasswordTrackerPersistence.class)
1162 protected PasswordTrackerPersistence passwordTrackerPersistence;
1163 @BeanReference(type = PhonePersistence.class)
1164 protected PhonePersistence phonePersistence;
1165 @BeanReference(type = PluginSettingPersistence.class)
1166 protected PluginSettingPersistence pluginSettingPersistence;
1167 @BeanReference(type = PortalPreferencesPersistence.class)
1168 protected PortalPreferencesPersistence portalPreferencesPersistence;
1169 @BeanReference(type = PortletPersistence.class)
1170 protected PortletPersistence portletPersistence;
1171 @BeanReference(type = PortletItemPersistence.class)
1172 protected PortletItemPersistence portletItemPersistence;
1173 @BeanReference(type = PortletPreferencesPersistence.class)
1174 protected PortletPreferencesPersistence portletPreferencesPersistence;
1175 @BeanReference(type = RegionPersistence.class)
1176 protected RegionPersistence regionPersistence;
1177 @BeanReference(type = ReleasePersistence.class)
1178 protected ReleasePersistence releasePersistence;
1179 @BeanReference(type = RepositoryPersistence.class)
1180 protected RepositoryPersistence repositoryPersistence;
1181 @BeanReference(type = RepositoryEntryPersistence.class)
1182 protected RepositoryEntryPersistence repositoryEntryPersistence;
1183 @BeanReference(type = ResourceActionPersistence.class)
1184 protected ResourceActionPersistence resourceActionPersistence;
1185 @BeanReference(type = ResourceBlockPersistence.class)
1186 protected ResourceBlockPersistence resourceBlockPersistence;
1187 @BeanReference(type = ResourceBlockPermissionPersistence.class)
1188 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
1189 @BeanReference(type = ResourcePermissionPersistence.class)
1190 protected ResourcePermissionPersistence resourcePermissionPersistence;
1191 @BeanReference(type = ResourceTypePermissionPersistence.class)
1192 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
1193 @BeanReference(type = RolePersistence.class)
1194 protected RolePersistence rolePersistence;
1195 @BeanReference(type = ServiceComponentPersistence.class)
1196 protected ServiceComponentPersistence serviceComponentPersistence;
1197 @BeanReference(type = ShardPersistence.class)
1198 protected ShardPersistence shardPersistence;
1199 @BeanReference(type = SubscriptionPersistence.class)
1200 protected SubscriptionPersistence subscriptionPersistence;
1201 @BeanReference(type = TeamPersistence.class)
1202 protected TeamPersistence teamPersistence;
1203 @BeanReference(type = TicketPersistence.class)
1204 protected TicketPersistence ticketPersistence;
1205 @BeanReference(type = UserPersistence.class)
1206 protected UserPersistence userPersistence;
1207 @BeanReference(type = UserGroupPersistence.class)
1208 protected UserGroupPersistence userGroupPersistence;
1209 @BeanReference(type = UserGroupGroupRolePersistence.class)
1210 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1211 @BeanReference(type = UserGroupRolePersistence.class)
1212 protected UserGroupRolePersistence userGroupRolePersistence;
1213 @BeanReference(type = UserIdMapperPersistence.class)
1214 protected UserIdMapperPersistence userIdMapperPersistence;
1215 @BeanReference(type = UserNotificationEventPersistence.class)
1216 protected UserNotificationEventPersistence userNotificationEventPersistence;
1217 @BeanReference(type = UserTrackerPersistence.class)
1218 protected UserTrackerPersistence userTrackerPersistence;
1219 @BeanReference(type = UserTrackerPathPersistence.class)
1220 protected UserTrackerPathPersistence userTrackerPathPersistence;
1221 @BeanReference(type = VirtualHostPersistence.class)
1222 protected VirtualHostPersistence virtualHostPersistence;
1223 @BeanReference(type = WebDAVPropsPersistence.class)
1224 protected WebDAVPropsPersistence webDAVPropsPersistence;
1225 @BeanReference(type = WebsitePersistence.class)
1226 protected WebsitePersistence websitePersistence;
1227 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1228 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1229 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1230 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1231 private static final String _SQL_SELECT_PASSWORDTRACKER = "SELECT passwordTracker FROM PasswordTracker passwordTracker";
1232 private static final String _SQL_SELECT_PASSWORDTRACKER_WHERE = "SELECT passwordTracker FROM PasswordTracker passwordTracker WHERE ";
1233 private static final String _SQL_COUNT_PASSWORDTRACKER = "SELECT COUNT(passwordTracker) FROM PasswordTracker passwordTracker";
1234 private static final String _SQL_COUNT_PASSWORDTRACKER_WHERE = "SELECT COUNT(passwordTracker) FROM PasswordTracker passwordTracker WHERE ";
1235 private static final String _FINDER_COLUMN_USERID_USERID_2 = "passwordTracker.userId = ?";
1236 private static final String _ORDER_BY_ENTITY_ALIAS = "passwordTracker.";
1237 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No PasswordTracker exists with the primary key ";
1238 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No PasswordTracker exists with the key {";
1239 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1240 private static Log _log = LogFactoryUtil.getLog(PasswordTrackerPersistenceImpl.class);
1241 private static PasswordTracker _nullPasswordTracker = new PasswordTrackerImpl() {
1242 @Override
1243 public Object clone() {
1244 return this;
1245 }
1246
1247 @Override
1248 public CacheModel<PasswordTracker> toCacheModel() {
1249 return _nullPasswordTrackerCacheModel;
1250 }
1251 };
1252
1253 private static CacheModel<PasswordTracker> _nullPasswordTrackerCacheModel = new CacheModel<PasswordTracker>() {
1254 public PasswordTracker toEntityModel() {
1255 return _nullPasswordTracker;
1256 }
1257 };
1258 }