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 BatchSessionUtil.delete(session, passwordTracker);
266 }
267 catch (Exception e) {
268 throw processException(e);
269 }
270 finally {
271 closeSession(session);
272 }
273
274 clearCache(passwordTracker);
275
276 return passwordTracker;
277 }
278
279 @Override
280 public PasswordTracker updateImpl(
281 com.liferay.portal.model.PasswordTracker passwordTracker, boolean merge)
282 throws SystemException {
283 passwordTracker = toUnwrappedModel(passwordTracker);
284
285 boolean isNew = passwordTracker.isNew();
286
287 PasswordTrackerModelImpl passwordTrackerModelImpl = (PasswordTrackerModelImpl)passwordTracker;
288
289 Session session = null;
290
291 try {
292 session = openSession();
293
294 BatchSessionUtil.update(session, passwordTracker, merge);
295
296 passwordTracker.setNew(false);
297 }
298 catch (Exception e) {
299 throw processException(e);
300 }
301 finally {
302 closeSession(session);
303 }
304
305 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
306
307 if (isNew || !PasswordTrackerModelImpl.COLUMN_BITMASK_ENABLED) {
308 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
309 }
310
311 else {
312 if ((passwordTrackerModelImpl.getColumnBitmask() &
313 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
314 Object[] args = new Object[] {
315 Long.valueOf(passwordTrackerModelImpl.getOriginalUserId())
316 };
317
318 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
319 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
320 args);
321
322 args = new Object[] {
323 Long.valueOf(passwordTrackerModelImpl.getUserId())
324 };
325
326 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
327 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
328 args);
329 }
330 }
331
332 EntityCacheUtil.putResult(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
333 PasswordTrackerImpl.class, passwordTracker.getPrimaryKey(),
334 passwordTracker);
335
336 return passwordTracker;
337 }
338
339 protected PasswordTracker toUnwrappedModel(PasswordTracker passwordTracker) {
340 if (passwordTracker instanceof PasswordTrackerImpl) {
341 return passwordTracker;
342 }
343
344 PasswordTrackerImpl passwordTrackerImpl = new PasswordTrackerImpl();
345
346 passwordTrackerImpl.setNew(passwordTracker.isNew());
347 passwordTrackerImpl.setPrimaryKey(passwordTracker.getPrimaryKey());
348
349 passwordTrackerImpl.setPasswordTrackerId(passwordTracker.getPasswordTrackerId());
350 passwordTrackerImpl.setUserId(passwordTracker.getUserId());
351 passwordTrackerImpl.setCreateDate(passwordTracker.getCreateDate());
352 passwordTrackerImpl.setPassword(passwordTracker.getPassword());
353
354 return passwordTrackerImpl;
355 }
356
357
365 @Override
366 public PasswordTracker findByPrimaryKey(Serializable primaryKey)
367 throws NoSuchModelException, SystemException {
368 return findByPrimaryKey(((Long)primaryKey).longValue());
369 }
370
371
379 public PasswordTracker findByPrimaryKey(long passwordTrackerId)
380 throws NoSuchPasswordTrackerException, SystemException {
381 PasswordTracker passwordTracker = fetchByPrimaryKey(passwordTrackerId);
382
383 if (passwordTracker == null) {
384 if (_log.isWarnEnabled()) {
385 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + passwordTrackerId);
386 }
387
388 throw new NoSuchPasswordTrackerException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
389 passwordTrackerId);
390 }
391
392 return passwordTracker;
393 }
394
395
402 @Override
403 public PasswordTracker fetchByPrimaryKey(Serializable primaryKey)
404 throws SystemException {
405 return fetchByPrimaryKey(((Long)primaryKey).longValue());
406 }
407
408
415 public PasswordTracker fetchByPrimaryKey(long passwordTrackerId)
416 throws SystemException {
417 PasswordTracker passwordTracker = (PasswordTracker)EntityCacheUtil.getResult(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
418 PasswordTrackerImpl.class, passwordTrackerId);
419
420 if (passwordTracker == _nullPasswordTracker) {
421 return null;
422 }
423
424 if (passwordTracker == null) {
425 Session session = null;
426
427 boolean hasException = false;
428
429 try {
430 session = openSession();
431
432 passwordTracker = (PasswordTracker)session.get(PasswordTrackerImpl.class,
433 Long.valueOf(passwordTrackerId));
434 }
435 catch (Exception e) {
436 hasException = true;
437
438 throw processException(e);
439 }
440 finally {
441 if (passwordTracker != null) {
442 cacheResult(passwordTracker);
443 }
444 else if (!hasException) {
445 EntityCacheUtil.putResult(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
446 PasswordTrackerImpl.class, passwordTrackerId,
447 _nullPasswordTracker);
448 }
449
450 closeSession(session);
451 }
452 }
453
454 return passwordTracker;
455 }
456
457
464 public List<PasswordTracker> findByUserId(long userId)
465 throws SystemException {
466 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
467 }
468
469
482 public List<PasswordTracker> findByUserId(long userId, int start, int end)
483 throws SystemException {
484 return findByUserId(userId, start, end, null);
485 }
486
487
501 public List<PasswordTracker> findByUserId(long userId, int start, int end,
502 OrderByComparator orderByComparator) throws SystemException {
503 FinderPath finderPath = null;
504 Object[] finderArgs = null;
505
506 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
507 (orderByComparator == null)) {
508 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
509 finderArgs = new Object[] { userId };
510 }
511 else {
512 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
513 finderArgs = new Object[] { userId, start, end, orderByComparator };
514 }
515
516 List<PasswordTracker> list = (List<PasswordTracker>)FinderCacheUtil.getResult(finderPath,
517 finderArgs, this);
518
519 if ((list != null) && !list.isEmpty()) {
520 for (PasswordTracker passwordTracker : list) {
521 if ((userId != passwordTracker.getUserId())) {
522 list = null;
523
524 break;
525 }
526 }
527 }
528
529 if (list == null) {
530 StringBundler query = null;
531
532 if (orderByComparator != null) {
533 query = new StringBundler(3 +
534 (orderByComparator.getOrderByFields().length * 3));
535 }
536 else {
537 query = new StringBundler(3);
538 }
539
540 query.append(_SQL_SELECT_PASSWORDTRACKER_WHERE);
541
542 query.append(_FINDER_COLUMN_USERID_USERID_2);
543
544 if (orderByComparator != null) {
545 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
546 orderByComparator);
547 }
548
549 else {
550 query.append(PasswordTrackerModelImpl.ORDER_BY_JPQL);
551 }
552
553 String sql = query.toString();
554
555 Session session = null;
556
557 try {
558 session = openSession();
559
560 Query q = session.createQuery(sql);
561
562 QueryPos qPos = QueryPos.getInstance(q);
563
564 qPos.add(userId);
565
566 list = (List<PasswordTracker>)QueryUtil.list(q, getDialect(),
567 start, end);
568 }
569 catch (Exception e) {
570 throw processException(e);
571 }
572 finally {
573 if (list == null) {
574 FinderCacheUtil.removeResult(finderPath, finderArgs);
575 }
576 else {
577 cacheResult(list);
578
579 FinderCacheUtil.putResult(finderPath, finderArgs, list);
580 }
581
582 closeSession(session);
583 }
584 }
585
586 return list;
587 }
588
589
598 public PasswordTracker findByUserId_First(long userId,
599 OrderByComparator orderByComparator)
600 throws NoSuchPasswordTrackerException, SystemException {
601 PasswordTracker passwordTracker = fetchByUserId_First(userId,
602 orderByComparator);
603
604 if (passwordTracker != null) {
605 return passwordTracker;
606 }
607
608 StringBundler msg = new StringBundler(4);
609
610 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
611
612 msg.append("userId=");
613 msg.append(userId);
614
615 msg.append(StringPool.CLOSE_CURLY_BRACE);
616
617 throw new NoSuchPasswordTrackerException(msg.toString());
618 }
619
620
628 public PasswordTracker fetchByUserId_First(long userId,
629 OrderByComparator orderByComparator) throws SystemException {
630 List<PasswordTracker> list = findByUserId(userId, 0, 1,
631 orderByComparator);
632
633 if (!list.isEmpty()) {
634 return list.get(0);
635 }
636
637 return null;
638 }
639
640
649 public PasswordTracker findByUserId_Last(long userId,
650 OrderByComparator orderByComparator)
651 throws NoSuchPasswordTrackerException, SystemException {
652 PasswordTracker passwordTracker = fetchByUserId_Last(userId,
653 orderByComparator);
654
655 if (passwordTracker != null) {
656 return passwordTracker;
657 }
658
659 StringBundler msg = new StringBundler(4);
660
661 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
662
663 msg.append("userId=");
664 msg.append(userId);
665
666 msg.append(StringPool.CLOSE_CURLY_BRACE);
667
668 throw new NoSuchPasswordTrackerException(msg.toString());
669 }
670
671
679 public PasswordTracker fetchByUserId_Last(long userId,
680 OrderByComparator orderByComparator) throws SystemException {
681 int count = countByUserId(userId);
682
683 List<PasswordTracker> list = findByUserId(userId, count - 1, count,
684 orderByComparator);
685
686 if (!list.isEmpty()) {
687 return list.get(0);
688 }
689
690 return null;
691 }
692
693
703 public PasswordTracker[] findByUserId_PrevAndNext(long passwordTrackerId,
704 long userId, OrderByComparator orderByComparator)
705 throws NoSuchPasswordTrackerException, SystemException {
706 PasswordTracker passwordTracker = findByPrimaryKey(passwordTrackerId);
707
708 Session session = null;
709
710 try {
711 session = openSession();
712
713 PasswordTracker[] array = new PasswordTrackerImpl[3];
714
715 array[0] = getByUserId_PrevAndNext(session, passwordTracker,
716 userId, orderByComparator, true);
717
718 array[1] = passwordTracker;
719
720 array[2] = getByUserId_PrevAndNext(session, passwordTracker,
721 userId, orderByComparator, false);
722
723 return array;
724 }
725 catch (Exception e) {
726 throw processException(e);
727 }
728 finally {
729 closeSession(session);
730 }
731 }
732
733 protected PasswordTracker getByUserId_PrevAndNext(Session session,
734 PasswordTracker passwordTracker, long userId,
735 OrderByComparator orderByComparator, boolean previous) {
736 StringBundler query = null;
737
738 if (orderByComparator != null) {
739 query = new StringBundler(6 +
740 (orderByComparator.getOrderByFields().length * 6));
741 }
742 else {
743 query = new StringBundler(3);
744 }
745
746 query.append(_SQL_SELECT_PASSWORDTRACKER_WHERE);
747
748 query.append(_FINDER_COLUMN_USERID_USERID_2);
749
750 if (orderByComparator != null) {
751 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
752
753 if (orderByConditionFields.length > 0) {
754 query.append(WHERE_AND);
755 }
756
757 for (int i = 0; i < orderByConditionFields.length; i++) {
758 query.append(_ORDER_BY_ENTITY_ALIAS);
759 query.append(orderByConditionFields[i]);
760
761 if ((i + 1) < orderByConditionFields.length) {
762 if (orderByComparator.isAscending() ^ previous) {
763 query.append(WHERE_GREATER_THAN_HAS_NEXT);
764 }
765 else {
766 query.append(WHERE_LESSER_THAN_HAS_NEXT);
767 }
768 }
769 else {
770 if (orderByComparator.isAscending() ^ previous) {
771 query.append(WHERE_GREATER_THAN);
772 }
773 else {
774 query.append(WHERE_LESSER_THAN);
775 }
776 }
777 }
778
779 query.append(ORDER_BY_CLAUSE);
780
781 String[] orderByFields = orderByComparator.getOrderByFields();
782
783 for (int i = 0; i < orderByFields.length; i++) {
784 query.append(_ORDER_BY_ENTITY_ALIAS);
785 query.append(orderByFields[i]);
786
787 if ((i + 1) < orderByFields.length) {
788 if (orderByComparator.isAscending() ^ previous) {
789 query.append(ORDER_BY_ASC_HAS_NEXT);
790 }
791 else {
792 query.append(ORDER_BY_DESC_HAS_NEXT);
793 }
794 }
795 else {
796 if (orderByComparator.isAscending() ^ previous) {
797 query.append(ORDER_BY_ASC);
798 }
799 else {
800 query.append(ORDER_BY_DESC);
801 }
802 }
803 }
804 }
805
806 else {
807 query.append(PasswordTrackerModelImpl.ORDER_BY_JPQL);
808 }
809
810 String sql = query.toString();
811
812 Query q = session.createQuery(sql);
813
814 q.setFirstResult(0);
815 q.setMaxResults(2);
816
817 QueryPos qPos = QueryPos.getInstance(q);
818
819 qPos.add(userId);
820
821 if (orderByComparator != null) {
822 Object[] values = orderByComparator.getOrderByConditionValues(passwordTracker);
823
824 for (Object value : values) {
825 qPos.add(value);
826 }
827 }
828
829 List<PasswordTracker> list = q.list();
830
831 if (list.size() == 2) {
832 return list.get(1);
833 }
834 else {
835 return null;
836 }
837 }
838
839
845 public List<PasswordTracker> findAll() throws SystemException {
846 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
847 }
848
849
861 public List<PasswordTracker> findAll(int start, int end)
862 throws SystemException {
863 return findAll(start, end, null);
864 }
865
866
879 public List<PasswordTracker> findAll(int start, int end,
880 OrderByComparator orderByComparator) throws SystemException {
881 FinderPath finderPath = null;
882 Object[] finderArgs = new Object[] { start, end, orderByComparator };
883
884 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
885 (orderByComparator == null)) {
886 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
887 finderArgs = FINDER_ARGS_EMPTY;
888 }
889 else {
890 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
891 finderArgs = new Object[] { start, end, orderByComparator };
892 }
893
894 List<PasswordTracker> list = (List<PasswordTracker>)FinderCacheUtil.getResult(finderPath,
895 finderArgs, this);
896
897 if (list == null) {
898 StringBundler query = null;
899 String sql = null;
900
901 if (orderByComparator != null) {
902 query = new StringBundler(2 +
903 (orderByComparator.getOrderByFields().length * 3));
904
905 query.append(_SQL_SELECT_PASSWORDTRACKER);
906
907 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
908 orderByComparator);
909
910 sql = query.toString();
911 }
912 else {
913 sql = _SQL_SELECT_PASSWORDTRACKER.concat(PasswordTrackerModelImpl.ORDER_BY_JPQL);
914 }
915
916 Session session = null;
917
918 try {
919 session = openSession();
920
921 Query q = session.createQuery(sql);
922
923 if (orderByComparator == null) {
924 list = (List<PasswordTracker>)QueryUtil.list(q,
925 getDialect(), start, end, false);
926
927 Collections.sort(list);
928 }
929 else {
930 list = (List<PasswordTracker>)QueryUtil.list(q,
931 getDialect(), start, end);
932 }
933 }
934 catch (Exception e) {
935 throw processException(e);
936 }
937 finally {
938 if (list == null) {
939 FinderCacheUtil.removeResult(finderPath, finderArgs);
940 }
941 else {
942 cacheResult(list);
943
944 FinderCacheUtil.putResult(finderPath, finderArgs, list);
945 }
946
947 closeSession(session);
948 }
949 }
950
951 return list;
952 }
953
954
960 public void removeByUserId(long userId) throws SystemException {
961 for (PasswordTracker passwordTracker : findByUserId(userId)) {
962 remove(passwordTracker);
963 }
964 }
965
966
971 public void removeAll() throws SystemException {
972 for (PasswordTracker passwordTracker : findAll()) {
973 remove(passwordTracker);
974 }
975 }
976
977
984 public int countByUserId(long userId) throws SystemException {
985 Object[] finderArgs = new Object[] { userId };
986
987 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
988 finderArgs, this);
989
990 if (count == null) {
991 StringBundler query = new StringBundler(2);
992
993 query.append(_SQL_COUNT_PASSWORDTRACKER_WHERE);
994
995 query.append(_FINDER_COLUMN_USERID_USERID_2);
996
997 String sql = query.toString();
998
999 Session session = null;
1000
1001 try {
1002 session = openSession();
1003
1004 Query q = session.createQuery(sql);
1005
1006 QueryPos qPos = QueryPos.getInstance(q);
1007
1008 qPos.add(userId);
1009
1010 count = (Long)q.uniqueResult();
1011 }
1012 catch (Exception e) {
1013 throw processException(e);
1014 }
1015 finally {
1016 if (count == null) {
1017 count = Long.valueOf(0);
1018 }
1019
1020 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
1021 finderArgs, count);
1022
1023 closeSession(session);
1024 }
1025 }
1026
1027 return count.intValue();
1028 }
1029
1030
1036 public int countAll() throws SystemException {
1037 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1038 FINDER_ARGS_EMPTY, this);
1039
1040 if (count == null) {
1041 Session session = null;
1042
1043 try {
1044 session = openSession();
1045
1046 Query q = session.createQuery(_SQL_COUNT_PASSWORDTRACKER);
1047
1048 count = (Long)q.uniqueResult();
1049 }
1050 catch (Exception e) {
1051 throw processException(e);
1052 }
1053 finally {
1054 if (count == null) {
1055 count = Long.valueOf(0);
1056 }
1057
1058 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1059 FINDER_ARGS_EMPTY, count);
1060
1061 closeSession(session);
1062 }
1063 }
1064
1065 return count.intValue();
1066 }
1067
1068
1071 public void afterPropertiesSet() {
1072 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1073 com.liferay.portal.util.PropsUtil.get(
1074 "value.object.listener.com.liferay.portal.model.PasswordTracker")));
1075
1076 if (listenerClassNames.length > 0) {
1077 try {
1078 List<ModelListener<PasswordTracker>> listenersList = new ArrayList<ModelListener<PasswordTracker>>();
1079
1080 for (String listenerClassName : listenerClassNames) {
1081 Class<?> clazz = getClass();
1082
1083 listenersList.add((ModelListener<PasswordTracker>)InstanceFactory.newInstance(
1084 clazz.getClassLoader(), listenerClassName));
1085 }
1086
1087 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1088 }
1089 catch (Exception e) {
1090 _log.error(e);
1091 }
1092 }
1093 }
1094
1095 public void destroy() {
1096 EntityCacheUtil.removeCache(PasswordTrackerImpl.class.getName());
1097 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1098 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1099 }
1100
1101 @BeanReference(type = AccountPersistence.class)
1102 protected AccountPersistence accountPersistence;
1103 @BeanReference(type = AddressPersistence.class)
1104 protected AddressPersistence addressPersistence;
1105 @BeanReference(type = BrowserTrackerPersistence.class)
1106 protected BrowserTrackerPersistence browserTrackerPersistence;
1107 @BeanReference(type = ClassNamePersistence.class)
1108 protected ClassNamePersistence classNamePersistence;
1109 @BeanReference(type = ClusterGroupPersistence.class)
1110 protected ClusterGroupPersistence clusterGroupPersistence;
1111 @BeanReference(type = CompanyPersistence.class)
1112 protected CompanyPersistence companyPersistence;
1113 @BeanReference(type = ContactPersistence.class)
1114 protected ContactPersistence contactPersistence;
1115 @BeanReference(type = CountryPersistence.class)
1116 protected CountryPersistence countryPersistence;
1117 @BeanReference(type = EmailAddressPersistence.class)
1118 protected EmailAddressPersistence emailAddressPersistence;
1119 @BeanReference(type = GroupPersistence.class)
1120 protected GroupPersistence groupPersistence;
1121 @BeanReference(type = ImagePersistence.class)
1122 protected ImagePersistence imagePersistence;
1123 @BeanReference(type = LayoutPersistence.class)
1124 protected LayoutPersistence layoutPersistence;
1125 @BeanReference(type = LayoutBranchPersistence.class)
1126 protected LayoutBranchPersistence layoutBranchPersistence;
1127 @BeanReference(type = LayoutPrototypePersistence.class)
1128 protected LayoutPrototypePersistence layoutPrototypePersistence;
1129 @BeanReference(type = LayoutRevisionPersistence.class)
1130 protected LayoutRevisionPersistence layoutRevisionPersistence;
1131 @BeanReference(type = LayoutSetPersistence.class)
1132 protected LayoutSetPersistence layoutSetPersistence;
1133 @BeanReference(type = LayoutSetBranchPersistence.class)
1134 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
1135 @BeanReference(type = LayoutSetPrototypePersistence.class)
1136 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1137 @BeanReference(type = ListTypePersistence.class)
1138 protected ListTypePersistence listTypePersistence;
1139 @BeanReference(type = LockPersistence.class)
1140 protected LockPersistence lockPersistence;
1141 @BeanReference(type = MembershipRequestPersistence.class)
1142 protected MembershipRequestPersistence membershipRequestPersistence;
1143 @BeanReference(type = OrganizationPersistence.class)
1144 protected OrganizationPersistence organizationPersistence;
1145 @BeanReference(type = OrgGroupPermissionPersistence.class)
1146 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1147 @BeanReference(type = OrgGroupRolePersistence.class)
1148 protected OrgGroupRolePersistence orgGroupRolePersistence;
1149 @BeanReference(type = OrgLaborPersistence.class)
1150 protected OrgLaborPersistence orgLaborPersistence;
1151 @BeanReference(type = PasswordPolicyPersistence.class)
1152 protected PasswordPolicyPersistence passwordPolicyPersistence;
1153 @BeanReference(type = PasswordPolicyRelPersistence.class)
1154 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1155 @BeanReference(type = PasswordTrackerPersistence.class)
1156 protected PasswordTrackerPersistence passwordTrackerPersistence;
1157 @BeanReference(type = PermissionPersistence.class)
1158 protected PermissionPersistence permissionPersistence;
1159 @BeanReference(type = PhonePersistence.class)
1160 protected PhonePersistence phonePersistence;
1161 @BeanReference(type = PluginSettingPersistence.class)
1162 protected PluginSettingPersistence pluginSettingPersistence;
1163 @BeanReference(type = PortalPreferencesPersistence.class)
1164 protected PortalPreferencesPersistence portalPreferencesPersistence;
1165 @BeanReference(type = PortletPersistence.class)
1166 protected PortletPersistence portletPersistence;
1167 @BeanReference(type = PortletItemPersistence.class)
1168 protected PortletItemPersistence portletItemPersistence;
1169 @BeanReference(type = PortletPreferencesPersistence.class)
1170 protected PortletPreferencesPersistence portletPreferencesPersistence;
1171 @BeanReference(type = RegionPersistence.class)
1172 protected RegionPersistence regionPersistence;
1173 @BeanReference(type = ReleasePersistence.class)
1174 protected ReleasePersistence releasePersistence;
1175 @BeanReference(type = RepositoryPersistence.class)
1176 protected RepositoryPersistence repositoryPersistence;
1177 @BeanReference(type = RepositoryEntryPersistence.class)
1178 protected RepositoryEntryPersistence repositoryEntryPersistence;
1179 @BeanReference(type = ResourcePersistence.class)
1180 protected ResourcePersistence resourcePersistence;
1181 @BeanReference(type = ResourceActionPersistence.class)
1182 protected ResourceActionPersistence resourceActionPersistence;
1183 @BeanReference(type = ResourceBlockPersistence.class)
1184 protected ResourceBlockPersistence resourceBlockPersistence;
1185 @BeanReference(type = ResourceBlockPermissionPersistence.class)
1186 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
1187 @BeanReference(type = ResourceCodePersistence.class)
1188 protected ResourceCodePersistence resourceCodePersistence;
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 }