001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.NoSuchUserIdMapperException;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.Session;
027 import com.liferay.portal.kernel.exception.SystemException;
028 import com.liferay.portal.kernel.log.Log;
029 import com.liferay.portal.kernel.log.LogFactoryUtil;
030 import com.liferay.portal.kernel.util.GetterUtil;
031 import com.liferay.portal.kernel.util.InstanceFactory;
032 import com.liferay.portal.kernel.util.OrderByComparator;
033 import com.liferay.portal.kernel.util.StringBundler;
034 import com.liferay.portal.kernel.util.StringPool;
035 import com.liferay.portal.kernel.util.StringUtil;
036 import com.liferay.portal.kernel.util.UnmodifiableList;
037 import com.liferay.portal.kernel.util.Validator;
038 import com.liferay.portal.model.CacheModel;
039 import com.liferay.portal.model.ModelListener;
040 import com.liferay.portal.model.UserIdMapper;
041 import com.liferay.portal.model.impl.UserIdMapperImpl;
042 import com.liferay.portal.model.impl.UserIdMapperModelImpl;
043 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
044
045 import java.io.Serializable;
046
047 import java.util.ArrayList;
048 import java.util.Collections;
049 import java.util.List;
050
051
063 public class UserIdMapperPersistenceImpl extends BasePersistenceImpl<UserIdMapper>
064 implements UserIdMapperPersistence {
065
070 public static final String FINDER_CLASS_NAME_ENTITY = UserIdMapperImpl.class.getName();
071 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
072 ".List1";
073 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074 ".List2";
075 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
076 UserIdMapperModelImpl.FINDER_CACHE_ENABLED, UserIdMapperImpl.class,
077 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
078 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
079 UserIdMapperModelImpl.FINDER_CACHE_ENABLED, UserIdMapperImpl.class,
080 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
081 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
082 UserIdMapperModelImpl.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_USERID = new FinderPath(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
085 UserIdMapperModelImpl.FINDER_CACHE_ENABLED, UserIdMapperImpl.class,
086 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
087 new String[] {
088 Long.class.getName(),
089
090 Integer.class.getName(), Integer.class.getName(),
091 OrderByComparator.class.getName()
092 });
093 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
094 new FinderPath(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
095 UserIdMapperModelImpl.FINDER_CACHE_ENABLED, UserIdMapperImpl.class,
096 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
097 new String[] { Long.class.getName() },
098 UserIdMapperModelImpl.USERID_COLUMN_BITMASK);
099 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
100 UserIdMapperModelImpl.FINDER_CACHE_ENABLED, Long.class,
101 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
102 new String[] { Long.class.getName() });
103
104
111 public List<UserIdMapper> findByUserId(long userId)
112 throws SystemException {
113 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
114 }
115
116
129 public List<UserIdMapper> findByUserId(long userId, int start, int end)
130 throws SystemException {
131 return findByUserId(userId, start, end, null);
132 }
133
134
148 public List<UserIdMapper> findByUserId(long userId, int start, int end,
149 OrderByComparator orderByComparator) throws SystemException {
150 boolean pagination = true;
151 FinderPath finderPath = null;
152 Object[] finderArgs = null;
153
154 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
155 (orderByComparator == null)) {
156 pagination = false;
157 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
158 finderArgs = new Object[] { userId };
159 }
160 else {
161 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
162 finderArgs = new Object[] { userId, start, end, orderByComparator };
163 }
164
165 List<UserIdMapper> list = (List<UserIdMapper>)FinderCacheUtil.getResult(finderPath,
166 finderArgs, this);
167
168 if ((list != null) && !list.isEmpty()) {
169 for (UserIdMapper userIdMapper : list) {
170 if ((userId != userIdMapper.getUserId())) {
171 list = null;
172
173 break;
174 }
175 }
176 }
177
178 if (list == null) {
179 StringBundler query = null;
180
181 if (orderByComparator != null) {
182 query = new StringBundler(3 +
183 (orderByComparator.getOrderByFields().length * 3));
184 }
185 else {
186 query = new StringBundler(3);
187 }
188
189 query.append(_SQL_SELECT_USERIDMAPPER_WHERE);
190
191 query.append(_FINDER_COLUMN_USERID_USERID_2);
192
193 if (orderByComparator != null) {
194 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
195 orderByComparator);
196 }
197 else
198 if (pagination) {
199 query.append(UserIdMapperModelImpl.ORDER_BY_JPQL);
200 }
201
202 String sql = query.toString();
203
204 Session session = null;
205
206 try {
207 session = openSession();
208
209 Query q = session.createQuery(sql);
210
211 QueryPos qPos = QueryPos.getInstance(q);
212
213 qPos.add(userId);
214
215 if (!pagination) {
216 list = (List<UserIdMapper>)QueryUtil.list(q, getDialect(),
217 start, end, false);
218
219 Collections.sort(list);
220
221 list = new UnmodifiableList<UserIdMapper>(list);
222 }
223 else {
224 list = (List<UserIdMapper>)QueryUtil.list(q, getDialect(),
225 start, end);
226 }
227
228 cacheResult(list);
229
230 FinderCacheUtil.putResult(finderPath, finderArgs, list);
231 }
232 catch (Exception e) {
233 FinderCacheUtil.removeResult(finderPath, finderArgs);
234
235 throw processException(e);
236 }
237 finally {
238 closeSession(session);
239 }
240 }
241
242 return list;
243 }
244
245
254 public UserIdMapper findByUserId_First(long userId,
255 OrderByComparator orderByComparator)
256 throws NoSuchUserIdMapperException, SystemException {
257 UserIdMapper userIdMapper = fetchByUserId_First(userId,
258 orderByComparator);
259
260 if (userIdMapper != null) {
261 return userIdMapper;
262 }
263
264 StringBundler msg = new StringBundler(4);
265
266 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
267
268 msg.append("userId=");
269 msg.append(userId);
270
271 msg.append(StringPool.CLOSE_CURLY_BRACE);
272
273 throw new NoSuchUserIdMapperException(msg.toString());
274 }
275
276
284 public UserIdMapper fetchByUserId_First(long userId,
285 OrderByComparator orderByComparator) throws SystemException {
286 List<UserIdMapper> list = findByUserId(userId, 0, 1, orderByComparator);
287
288 if (!list.isEmpty()) {
289 return list.get(0);
290 }
291
292 return null;
293 }
294
295
304 public UserIdMapper findByUserId_Last(long userId,
305 OrderByComparator orderByComparator)
306 throws NoSuchUserIdMapperException, SystemException {
307 UserIdMapper userIdMapper = fetchByUserId_Last(userId, orderByComparator);
308
309 if (userIdMapper != null) {
310 return userIdMapper;
311 }
312
313 StringBundler msg = new StringBundler(4);
314
315 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
316
317 msg.append("userId=");
318 msg.append(userId);
319
320 msg.append(StringPool.CLOSE_CURLY_BRACE);
321
322 throw new NoSuchUserIdMapperException(msg.toString());
323 }
324
325
333 public UserIdMapper fetchByUserId_Last(long userId,
334 OrderByComparator orderByComparator) throws SystemException {
335 int count = countByUserId(userId);
336
337 List<UserIdMapper> list = findByUserId(userId, count - 1, count,
338 orderByComparator);
339
340 if (!list.isEmpty()) {
341 return list.get(0);
342 }
343
344 return null;
345 }
346
347
357 public UserIdMapper[] findByUserId_PrevAndNext(long userIdMapperId,
358 long userId, OrderByComparator orderByComparator)
359 throws NoSuchUserIdMapperException, SystemException {
360 UserIdMapper userIdMapper = findByPrimaryKey(userIdMapperId);
361
362 Session session = null;
363
364 try {
365 session = openSession();
366
367 UserIdMapper[] array = new UserIdMapperImpl[3];
368
369 array[0] = getByUserId_PrevAndNext(session, userIdMapper, userId,
370 orderByComparator, true);
371
372 array[1] = userIdMapper;
373
374 array[2] = getByUserId_PrevAndNext(session, userIdMapper, userId,
375 orderByComparator, false);
376
377 return array;
378 }
379 catch (Exception e) {
380 throw processException(e);
381 }
382 finally {
383 closeSession(session);
384 }
385 }
386
387 protected UserIdMapper getByUserId_PrevAndNext(Session session,
388 UserIdMapper userIdMapper, long userId,
389 OrderByComparator orderByComparator, boolean previous) {
390 StringBundler query = null;
391
392 if (orderByComparator != null) {
393 query = new StringBundler(6 +
394 (orderByComparator.getOrderByFields().length * 6));
395 }
396 else {
397 query = new StringBundler(3);
398 }
399
400 query.append(_SQL_SELECT_USERIDMAPPER_WHERE);
401
402 query.append(_FINDER_COLUMN_USERID_USERID_2);
403
404 if (orderByComparator != null) {
405 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
406
407 if (orderByConditionFields.length > 0) {
408 query.append(WHERE_AND);
409 }
410
411 for (int i = 0; i < orderByConditionFields.length; i++) {
412 query.append(_ORDER_BY_ENTITY_ALIAS);
413 query.append(orderByConditionFields[i]);
414
415 if ((i + 1) < orderByConditionFields.length) {
416 if (orderByComparator.isAscending() ^ previous) {
417 query.append(WHERE_GREATER_THAN_HAS_NEXT);
418 }
419 else {
420 query.append(WHERE_LESSER_THAN_HAS_NEXT);
421 }
422 }
423 else {
424 if (orderByComparator.isAscending() ^ previous) {
425 query.append(WHERE_GREATER_THAN);
426 }
427 else {
428 query.append(WHERE_LESSER_THAN);
429 }
430 }
431 }
432
433 query.append(ORDER_BY_CLAUSE);
434
435 String[] orderByFields = orderByComparator.getOrderByFields();
436
437 for (int i = 0; i < orderByFields.length; i++) {
438 query.append(_ORDER_BY_ENTITY_ALIAS);
439 query.append(orderByFields[i]);
440
441 if ((i + 1) < orderByFields.length) {
442 if (orderByComparator.isAscending() ^ previous) {
443 query.append(ORDER_BY_ASC_HAS_NEXT);
444 }
445 else {
446 query.append(ORDER_BY_DESC_HAS_NEXT);
447 }
448 }
449 else {
450 if (orderByComparator.isAscending() ^ previous) {
451 query.append(ORDER_BY_ASC);
452 }
453 else {
454 query.append(ORDER_BY_DESC);
455 }
456 }
457 }
458 }
459 else {
460 query.append(UserIdMapperModelImpl.ORDER_BY_JPQL);
461 }
462
463 String sql = query.toString();
464
465 Query q = session.createQuery(sql);
466
467 q.setFirstResult(0);
468 q.setMaxResults(2);
469
470 QueryPos qPos = QueryPos.getInstance(q);
471
472 qPos.add(userId);
473
474 if (orderByComparator != null) {
475 Object[] values = orderByComparator.getOrderByConditionValues(userIdMapper);
476
477 for (Object value : values) {
478 qPos.add(value);
479 }
480 }
481
482 List<UserIdMapper> list = q.list();
483
484 if (list.size() == 2) {
485 return list.get(1);
486 }
487 else {
488 return null;
489 }
490 }
491
492
498 public void removeByUserId(long userId) throws SystemException {
499 for (UserIdMapper userIdMapper : findByUserId(userId,
500 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
501 remove(userIdMapper);
502 }
503 }
504
505
512 public int countByUserId(long userId) throws SystemException {
513 FinderPath finderPath = FINDER_PATH_COUNT_BY_USERID;
514
515 Object[] finderArgs = new Object[] { userId };
516
517 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
518 this);
519
520 if (count == null) {
521 StringBundler query = new StringBundler(2);
522
523 query.append(_SQL_COUNT_USERIDMAPPER_WHERE);
524
525 query.append(_FINDER_COLUMN_USERID_USERID_2);
526
527 String sql = query.toString();
528
529 Session session = null;
530
531 try {
532 session = openSession();
533
534 Query q = session.createQuery(sql);
535
536 QueryPos qPos = QueryPos.getInstance(q);
537
538 qPos.add(userId);
539
540 count = (Long)q.uniqueResult();
541
542 FinderCacheUtil.putResult(finderPath, finderArgs, count);
543 }
544 catch (Exception e) {
545 FinderCacheUtil.removeResult(finderPath, finderArgs);
546
547 throw processException(e);
548 }
549 finally {
550 closeSession(session);
551 }
552 }
553
554 return count.intValue();
555 }
556
557 private static final String _FINDER_COLUMN_USERID_USERID_2 = "userIdMapper.userId = ?";
558 public static final FinderPath FINDER_PATH_FETCH_BY_U_T = new FinderPath(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
559 UserIdMapperModelImpl.FINDER_CACHE_ENABLED, UserIdMapperImpl.class,
560 FINDER_CLASS_NAME_ENTITY, "fetchByU_T",
561 new String[] { Long.class.getName(), String.class.getName() },
562 UserIdMapperModelImpl.USERID_COLUMN_BITMASK |
563 UserIdMapperModelImpl.TYPE_COLUMN_BITMASK);
564 public static final FinderPath FINDER_PATH_COUNT_BY_U_T = new FinderPath(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
565 UserIdMapperModelImpl.FINDER_CACHE_ENABLED, Long.class,
566 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_T",
567 new String[] { Long.class.getName(), String.class.getName() });
568
569
578 public UserIdMapper findByU_T(long userId, String type)
579 throws NoSuchUserIdMapperException, SystemException {
580 UserIdMapper userIdMapper = fetchByU_T(userId, type);
581
582 if (userIdMapper == null) {
583 StringBundler msg = new StringBundler(6);
584
585 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
586
587 msg.append("userId=");
588 msg.append(userId);
589
590 msg.append(", type=");
591 msg.append(type);
592
593 msg.append(StringPool.CLOSE_CURLY_BRACE);
594
595 if (_log.isWarnEnabled()) {
596 _log.warn(msg.toString());
597 }
598
599 throw new NoSuchUserIdMapperException(msg.toString());
600 }
601
602 return userIdMapper;
603 }
604
605
613 public UserIdMapper fetchByU_T(long userId, String type)
614 throws SystemException {
615 return fetchByU_T(userId, type, true);
616 }
617
618
627 public UserIdMapper fetchByU_T(long userId, String type,
628 boolean retrieveFromCache) throws SystemException {
629 Object[] finderArgs = new Object[] { userId, type };
630
631 Object result = null;
632
633 if (retrieveFromCache) {
634 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_U_T,
635 finderArgs, this);
636 }
637
638 if (result instanceof UserIdMapper) {
639 UserIdMapper userIdMapper = (UserIdMapper)result;
640
641 if ((userId != userIdMapper.getUserId()) ||
642 !Validator.equals(type, userIdMapper.getType())) {
643 result = null;
644 }
645 }
646
647 if (result == null) {
648 StringBundler query = new StringBundler(4);
649
650 query.append(_SQL_SELECT_USERIDMAPPER_WHERE);
651
652 query.append(_FINDER_COLUMN_U_T_USERID_2);
653
654 if (type == null) {
655 query.append(_FINDER_COLUMN_U_T_TYPE_1);
656 }
657 else {
658 if (type.equals(StringPool.BLANK)) {
659 query.append(_FINDER_COLUMN_U_T_TYPE_3);
660 }
661 else {
662 query.append(_FINDER_COLUMN_U_T_TYPE_2);
663 }
664 }
665
666 String sql = query.toString();
667
668 Session session = null;
669
670 try {
671 session = openSession();
672
673 Query q = session.createQuery(sql);
674
675 QueryPos qPos = QueryPos.getInstance(q);
676
677 qPos.add(userId);
678
679 if (type != null) {
680 qPos.add(type);
681 }
682
683 List<UserIdMapper> list = q.list();
684
685 if (list.isEmpty()) {
686 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_T,
687 finderArgs, list);
688 }
689 else {
690 UserIdMapper userIdMapper = list.get(0);
691
692 result = userIdMapper;
693
694 cacheResult(userIdMapper);
695
696 if ((userIdMapper.getUserId() != userId) ||
697 (userIdMapper.getType() == null) ||
698 !userIdMapper.getType().equals(type)) {
699 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_T,
700 finderArgs, userIdMapper);
701 }
702 }
703 }
704 catch (Exception e) {
705 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_T,
706 finderArgs);
707
708 throw processException(e);
709 }
710 finally {
711 closeSession(session);
712 }
713 }
714
715 if (result instanceof List<?>) {
716 return null;
717 }
718 else {
719 return (UserIdMapper)result;
720 }
721 }
722
723
731 public UserIdMapper removeByU_T(long userId, String type)
732 throws NoSuchUserIdMapperException, SystemException {
733 UserIdMapper userIdMapper = findByU_T(userId, type);
734
735 return remove(userIdMapper);
736 }
737
738
746 public int countByU_T(long userId, String type) throws SystemException {
747 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_T;
748
749 Object[] finderArgs = new Object[] { userId, type };
750
751 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
752 this);
753
754 if (count == null) {
755 StringBundler query = new StringBundler(3);
756
757 query.append(_SQL_COUNT_USERIDMAPPER_WHERE);
758
759 query.append(_FINDER_COLUMN_U_T_USERID_2);
760
761 if (type == null) {
762 query.append(_FINDER_COLUMN_U_T_TYPE_1);
763 }
764 else {
765 if (type.equals(StringPool.BLANK)) {
766 query.append(_FINDER_COLUMN_U_T_TYPE_3);
767 }
768 else {
769 query.append(_FINDER_COLUMN_U_T_TYPE_2);
770 }
771 }
772
773 String sql = query.toString();
774
775 Session session = null;
776
777 try {
778 session = openSession();
779
780 Query q = session.createQuery(sql);
781
782 QueryPos qPos = QueryPos.getInstance(q);
783
784 qPos.add(userId);
785
786 if (type != null) {
787 qPos.add(type);
788 }
789
790 count = (Long)q.uniqueResult();
791
792 FinderCacheUtil.putResult(finderPath, finderArgs, count);
793 }
794 catch (Exception e) {
795 FinderCacheUtil.removeResult(finderPath, finderArgs);
796
797 throw processException(e);
798 }
799 finally {
800 closeSession(session);
801 }
802 }
803
804 return count.intValue();
805 }
806
807 private static final String _FINDER_COLUMN_U_T_USERID_2 = "userIdMapper.userId = ? AND ";
808 private static final String _FINDER_COLUMN_U_T_TYPE_1 = "userIdMapper.type IS NULL";
809 private static final String _FINDER_COLUMN_U_T_TYPE_2 = "userIdMapper.type = ?";
810 private static final String _FINDER_COLUMN_U_T_TYPE_3 = "(userIdMapper.type IS NULL OR userIdMapper.type = ?)";
811 public static final FinderPath FINDER_PATH_FETCH_BY_T_E = new FinderPath(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
812 UserIdMapperModelImpl.FINDER_CACHE_ENABLED, UserIdMapperImpl.class,
813 FINDER_CLASS_NAME_ENTITY, "fetchByT_E",
814 new String[] { String.class.getName(), String.class.getName() },
815 UserIdMapperModelImpl.TYPE_COLUMN_BITMASK |
816 UserIdMapperModelImpl.EXTERNALUSERID_COLUMN_BITMASK);
817 public static final FinderPath FINDER_PATH_COUNT_BY_T_E = new FinderPath(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
818 UserIdMapperModelImpl.FINDER_CACHE_ENABLED, Long.class,
819 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByT_E",
820 new String[] { String.class.getName(), String.class.getName() });
821
822
831 public UserIdMapper findByT_E(String type, String externalUserId)
832 throws NoSuchUserIdMapperException, SystemException {
833 UserIdMapper userIdMapper = fetchByT_E(type, externalUserId);
834
835 if (userIdMapper == null) {
836 StringBundler msg = new StringBundler(6);
837
838 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
839
840 msg.append("type=");
841 msg.append(type);
842
843 msg.append(", externalUserId=");
844 msg.append(externalUserId);
845
846 msg.append(StringPool.CLOSE_CURLY_BRACE);
847
848 if (_log.isWarnEnabled()) {
849 _log.warn(msg.toString());
850 }
851
852 throw new NoSuchUserIdMapperException(msg.toString());
853 }
854
855 return userIdMapper;
856 }
857
858
866 public UserIdMapper fetchByT_E(String type, String externalUserId)
867 throws SystemException {
868 return fetchByT_E(type, externalUserId, true);
869 }
870
871
880 public UserIdMapper fetchByT_E(String type, String externalUserId,
881 boolean retrieveFromCache) throws SystemException {
882 Object[] finderArgs = new Object[] { type, externalUserId };
883
884 Object result = null;
885
886 if (retrieveFromCache) {
887 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_T_E,
888 finderArgs, this);
889 }
890
891 if (result instanceof UserIdMapper) {
892 UserIdMapper userIdMapper = (UserIdMapper)result;
893
894 if (!Validator.equals(type, userIdMapper.getType()) ||
895 !Validator.equals(externalUserId,
896 userIdMapper.getExternalUserId())) {
897 result = null;
898 }
899 }
900
901 if (result == null) {
902 StringBundler query = new StringBundler(4);
903
904 query.append(_SQL_SELECT_USERIDMAPPER_WHERE);
905
906 if (type == null) {
907 query.append(_FINDER_COLUMN_T_E_TYPE_1);
908 }
909 else {
910 if (type.equals(StringPool.BLANK)) {
911 query.append(_FINDER_COLUMN_T_E_TYPE_3);
912 }
913 else {
914 query.append(_FINDER_COLUMN_T_E_TYPE_2);
915 }
916 }
917
918 if (externalUserId == null) {
919 query.append(_FINDER_COLUMN_T_E_EXTERNALUSERID_1);
920 }
921 else {
922 if (externalUserId.equals(StringPool.BLANK)) {
923 query.append(_FINDER_COLUMN_T_E_EXTERNALUSERID_3);
924 }
925 else {
926 query.append(_FINDER_COLUMN_T_E_EXTERNALUSERID_2);
927 }
928 }
929
930 String sql = query.toString();
931
932 Session session = null;
933
934 try {
935 session = openSession();
936
937 Query q = session.createQuery(sql);
938
939 QueryPos qPos = QueryPos.getInstance(q);
940
941 if (type != null) {
942 qPos.add(type);
943 }
944
945 if (externalUserId != null) {
946 qPos.add(externalUserId);
947 }
948
949 List<UserIdMapper> list = q.list();
950
951 if (list.isEmpty()) {
952 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_T_E,
953 finderArgs, list);
954 }
955 else {
956 UserIdMapper userIdMapper = list.get(0);
957
958 result = userIdMapper;
959
960 cacheResult(userIdMapper);
961
962 if ((userIdMapper.getType() == null) ||
963 !userIdMapper.getType().equals(type) ||
964 (userIdMapper.getExternalUserId() == null) ||
965 !userIdMapper.getExternalUserId()
966 .equals(externalUserId)) {
967 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_T_E,
968 finderArgs, userIdMapper);
969 }
970 }
971 }
972 catch (Exception e) {
973 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_T_E,
974 finderArgs);
975
976 throw processException(e);
977 }
978 finally {
979 closeSession(session);
980 }
981 }
982
983 if (result instanceof List<?>) {
984 return null;
985 }
986 else {
987 return (UserIdMapper)result;
988 }
989 }
990
991
999 public UserIdMapper removeByT_E(String type, String externalUserId)
1000 throws NoSuchUserIdMapperException, SystemException {
1001 UserIdMapper userIdMapper = findByT_E(type, externalUserId);
1002
1003 return remove(userIdMapper);
1004 }
1005
1006
1014 public int countByT_E(String type, String externalUserId)
1015 throws SystemException {
1016 FinderPath finderPath = FINDER_PATH_COUNT_BY_T_E;
1017
1018 Object[] finderArgs = new Object[] { type, externalUserId };
1019
1020 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1021 this);
1022
1023 if (count == null) {
1024 StringBundler query = new StringBundler(3);
1025
1026 query.append(_SQL_COUNT_USERIDMAPPER_WHERE);
1027
1028 if (type == null) {
1029 query.append(_FINDER_COLUMN_T_E_TYPE_1);
1030 }
1031 else {
1032 if (type.equals(StringPool.BLANK)) {
1033 query.append(_FINDER_COLUMN_T_E_TYPE_3);
1034 }
1035 else {
1036 query.append(_FINDER_COLUMN_T_E_TYPE_2);
1037 }
1038 }
1039
1040 if (externalUserId == null) {
1041 query.append(_FINDER_COLUMN_T_E_EXTERNALUSERID_1);
1042 }
1043 else {
1044 if (externalUserId.equals(StringPool.BLANK)) {
1045 query.append(_FINDER_COLUMN_T_E_EXTERNALUSERID_3);
1046 }
1047 else {
1048 query.append(_FINDER_COLUMN_T_E_EXTERNALUSERID_2);
1049 }
1050 }
1051
1052 String sql = query.toString();
1053
1054 Session session = null;
1055
1056 try {
1057 session = openSession();
1058
1059 Query q = session.createQuery(sql);
1060
1061 QueryPos qPos = QueryPos.getInstance(q);
1062
1063 if (type != null) {
1064 qPos.add(type);
1065 }
1066
1067 if (externalUserId != null) {
1068 qPos.add(externalUserId);
1069 }
1070
1071 count = (Long)q.uniqueResult();
1072
1073 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1074 }
1075 catch (Exception e) {
1076 FinderCacheUtil.removeResult(finderPath, finderArgs);
1077
1078 throw processException(e);
1079 }
1080 finally {
1081 closeSession(session);
1082 }
1083 }
1084
1085 return count.intValue();
1086 }
1087
1088 private static final String _FINDER_COLUMN_T_E_TYPE_1 = "userIdMapper.type IS NULL AND ";
1089 private static final String _FINDER_COLUMN_T_E_TYPE_2 = "userIdMapper.type = ? AND ";
1090 private static final String _FINDER_COLUMN_T_E_TYPE_3 = "(userIdMapper.type IS NULL OR userIdMapper.type = ?) AND ";
1091 private static final String _FINDER_COLUMN_T_E_EXTERNALUSERID_1 = "userIdMapper.externalUserId IS NULL";
1092 private static final String _FINDER_COLUMN_T_E_EXTERNALUSERID_2 = "userIdMapper.externalUserId = ?";
1093 private static final String _FINDER_COLUMN_T_E_EXTERNALUSERID_3 = "(userIdMapper.externalUserId IS NULL OR userIdMapper.externalUserId = ?)";
1094
1095
1100 public void cacheResult(UserIdMapper userIdMapper) {
1101 EntityCacheUtil.putResult(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
1102 UserIdMapperImpl.class, userIdMapper.getPrimaryKey(), userIdMapper);
1103
1104 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_T,
1105 new Object[] {
1106 Long.valueOf(userIdMapper.getUserId()),
1107
1108 userIdMapper.getType()
1109 }, userIdMapper);
1110
1111 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_T_E,
1112 new Object[] {
1113 userIdMapper.getType(),
1114
1115 userIdMapper.getExternalUserId()
1116 }, userIdMapper);
1117
1118 userIdMapper.resetOriginalValues();
1119 }
1120
1121
1126 public void cacheResult(List<UserIdMapper> userIdMappers) {
1127 for (UserIdMapper userIdMapper : userIdMappers) {
1128 if (EntityCacheUtil.getResult(
1129 UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
1130 UserIdMapperImpl.class, userIdMapper.getPrimaryKey()) == null) {
1131 cacheResult(userIdMapper);
1132 }
1133 else {
1134 userIdMapper.resetOriginalValues();
1135 }
1136 }
1137 }
1138
1139
1146 @Override
1147 public void clearCache() {
1148 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
1149 CacheRegistryUtil.clear(UserIdMapperImpl.class.getName());
1150 }
1151
1152 EntityCacheUtil.clearCache(UserIdMapperImpl.class.getName());
1153
1154 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
1155 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1156 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1157 }
1158
1159
1166 @Override
1167 public void clearCache(UserIdMapper userIdMapper) {
1168 EntityCacheUtil.removeResult(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
1169 UserIdMapperImpl.class, userIdMapper.getPrimaryKey());
1170
1171 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1172 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1173
1174 clearUniqueFindersCache(userIdMapper);
1175 }
1176
1177 @Override
1178 public void clearCache(List<UserIdMapper> userIdMappers) {
1179 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1180 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1181
1182 for (UserIdMapper userIdMapper : userIdMappers) {
1183 EntityCacheUtil.removeResult(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
1184 UserIdMapperImpl.class, userIdMapper.getPrimaryKey());
1185
1186 clearUniqueFindersCache(userIdMapper);
1187 }
1188 }
1189
1190 protected void cacheUniqueFindersCache(UserIdMapper userIdMapper) {
1191 if (userIdMapper.isNew()) {
1192 Object[] args = new Object[] {
1193 Long.valueOf(userIdMapper.getUserId()),
1194
1195 userIdMapper.getType()
1196 };
1197
1198 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_T, args,
1199 Long.valueOf(1));
1200 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_T, args,
1201 userIdMapper);
1202
1203 args = new Object[] {
1204 userIdMapper.getType(),
1205
1206 userIdMapper.getExternalUserId()
1207 };
1208
1209 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_E, args,
1210 Long.valueOf(1));
1211 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_T_E, args,
1212 userIdMapper);
1213 }
1214 else {
1215 UserIdMapperModelImpl userIdMapperModelImpl = (UserIdMapperModelImpl)userIdMapper;
1216
1217 if ((userIdMapperModelImpl.getColumnBitmask() &
1218 FINDER_PATH_FETCH_BY_U_T.getColumnBitmask()) != 0) {
1219 Object[] args = new Object[] {
1220 Long.valueOf(userIdMapper.getUserId()),
1221
1222 userIdMapper.getType()
1223 };
1224
1225 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_T, args,
1226 Long.valueOf(1));
1227 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_T, args,
1228 userIdMapper);
1229 }
1230
1231 if ((userIdMapperModelImpl.getColumnBitmask() &
1232 FINDER_PATH_FETCH_BY_T_E.getColumnBitmask()) != 0) {
1233 Object[] args = new Object[] {
1234 userIdMapper.getType(),
1235
1236 userIdMapper.getExternalUserId()
1237 };
1238
1239 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_E, args,
1240 Long.valueOf(1));
1241 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_T_E, args,
1242 userIdMapper);
1243 }
1244 }
1245 }
1246
1247 protected void clearUniqueFindersCache(UserIdMapper userIdMapper) {
1248 UserIdMapperModelImpl userIdMapperModelImpl = (UserIdMapperModelImpl)userIdMapper;
1249
1250 Object[] args = new Object[] {
1251 Long.valueOf(userIdMapper.getUserId()),
1252
1253 userIdMapper.getType()
1254 };
1255
1256 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_T, args);
1257 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_T, args);
1258
1259 if ((userIdMapperModelImpl.getColumnBitmask() &
1260 FINDER_PATH_FETCH_BY_U_T.getColumnBitmask()) != 0) {
1261 args = new Object[] {
1262 Long.valueOf(userIdMapperModelImpl.getOriginalUserId()),
1263
1264 userIdMapperModelImpl.getOriginalType()
1265 };
1266
1267 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_T, args);
1268 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_T, args);
1269 }
1270
1271 args = new Object[] {
1272 userIdMapper.getType(),
1273
1274 userIdMapper.getExternalUserId()
1275 };
1276
1277 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_E, args);
1278 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_T_E, args);
1279
1280 if ((userIdMapperModelImpl.getColumnBitmask() &
1281 FINDER_PATH_FETCH_BY_T_E.getColumnBitmask()) != 0) {
1282 args = new Object[] {
1283 userIdMapperModelImpl.getOriginalType(),
1284
1285 userIdMapperModelImpl.getOriginalExternalUserId()
1286 };
1287
1288 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_E, args);
1289 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_T_E, args);
1290 }
1291 }
1292
1293
1299 public UserIdMapper create(long userIdMapperId) {
1300 UserIdMapper userIdMapper = new UserIdMapperImpl();
1301
1302 userIdMapper.setNew(true);
1303 userIdMapper.setPrimaryKey(userIdMapperId);
1304
1305 return userIdMapper;
1306 }
1307
1308
1316 public UserIdMapper remove(long userIdMapperId)
1317 throws NoSuchUserIdMapperException, SystemException {
1318 return remove(Long.valueOf(userIdMapperId));
1319 }
1320
1321
1329 @Override
1330 public UserIdMapper remove(Serializable primaryKey)
1331 throws NoSuchUserIdMapperException, SystemException {
1332 Session session = null;
1333
1334 try {
1335 session = openSession();
1336
1337 UserIdMapper userIdMapper = (UserIdMapper)session.get(UserIdMapperImpl.class,
1338 primaryKey);
1339
1340 if (userIdMapper == null) {
1341 if (_log.isWarnEnabled()) {
1342 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
1343 }
1344
1345 throw new NoSuchUserIdMapperException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1346 primaryKey);
1347 }
1348
1349 return remove(userIdMapper);
1350 }
1351 catch (NoSuchUserIdMapperException nsee) {
1352 throw nsee;
1353 }
1354 catch (Exception e) {
1355 throw processException(e);
1356 }
1357 finally {
1358 closeSession(session);
1359 }
1360 }
1361
1362 @Override
1363 protected UserIdMapper removeImpl(UserIdMapper userIdMapper)
1364 throws SystemException {
1365 userIdMapper = toUnwrappedModel(userIdMapper);
1366
1367 Session session = null;
1368
1369 try {
1370 session = openSession();
1371
1372 if (!session.contains(userIdMapper)) {
1373 userIdMapper = (UserIdMapper)session.get(UserIdMapperImpl.class,
1374 userIdMapper.getPrimaryKeyObj());
1375 }
1376
1377 if (userIdMapper != null) {
1378 session.delete(userIdMapper);
1379 }
1380 }
1381 catch (Exception e) {
1382 throw processException(e);
1383 }
1384 finally {
1385 closeSession(session);
1386 }
1387
1388 if (userIdMapper != null) {
1389 clearCache(userIdMapper);
1390 }
1391
1392 return userIdMapper;
1393 }
1394
1395 @Override
1396 public UserIdMapper updateImpl(
1397 com.liferay.portal.model.UserIdMapper userIdMapper)
1398 throws SystemException {
1399 userIdMapper = toUnwrappedModel(userIdMapper);
1400
1401 boolean isNew = userIdMapper.isNew();
1402
1403 UserIdMapperModelImpl userIdMapperModelImpl = (UserIdMapperModelImpl)userIdMapper;
1404
1405 Session session = null;
1406
1407 try {
1408 session = openSession();
1409
1410 if (userIdMapper.isNew()) {
1411 session.save(userIdMapper);
1412
1413 userIdMapper.setNew(false);
1414 }
1415 else {
1416 session.merge(userIdMapper);
1417 }
1418 }
1419 catch (Exception e) {
1420 throw processException(e);
1421 }
1422 finally {
1423 closeSession(session);
1424 }
1425
1426 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1427
1428 if (isNew || !UserIdMapperModelImpl.COLUMN_BITMASK_ENABLED) {
1429 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1430 }
1431
1432 else {
1433 if ((userIdMapperModelImpl.getColumnBitmask() &
1434 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
1435 Object[] args = new Object[] {
1436 Long.valueOf(userIdMapperModelImpl.getOriginalUserId())
1437 };
1438
1439 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
1440 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
1441 args);
1442
1443 args = new Object[] {
1444 Long.valueOf(userIdMapperModelImpl.getUserId())
1445 };
1446
1447 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
1448 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
1449 args);
1450 }
1451 }
1452
1453 EntityCacheUtil.putResult(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
1454 UserIdMapperImpl.class, userIdMapper.getPrimaryKey(), userIdMapper);
1455
1456 clearUniqueFindersCache(userIdMapper);
1457 cacheUniqueFindersCache(userIdMapper);
1458
1459 return userIdMapper;
1460 }
1461
1462 protected UserIdMapper toUnwrappedModel(UserIdMapper userIdMapper) {
1463 if (userIdMapper instanceof UserIdMapperImpl) {
1464 return userIdMapper;
1465 }
1466
1467 UserIdMapperImpl userIdMapperImpl = new UserIdMapperImpl();
1468
1469 userIdMapperImpl.setNew(userIdMapper.isNew());
1470 userIdMapperImpl.setPrimaryKey(userIdMapper.getPrimaryKey());
1471
1472 userIdMapperImpl.setUserIdMapperId(userIdMapper.getUserIdMapperId());
1473 userIdMapperImpl.setUserId(userIdMapper.getUserId());
1474 userIdMapperImpl.setType(userIdMapper.getType());
1475 userIdMapperImpl.setDescription(userIdMapper.getDescription());
1476 userIdMapperImpl.setExternalUserId(userIdMapper.getExternalUserId());
1477
1478 return userIdMapperImpl;
1479 }
1480
1481
1489 @Override
1490 public UserIdMapper findByPrimaryKey(Serializable primaryKey)
1491 throws NoSuchModelException, SystemException {
1492 return findByPrimaryKey(((Long)primaryKey).longValue());
1493 }
1494
1495
1503 public UserIdMapper findByPrimaryKey(long userIdMapperId)
1504 throws NoSuchUserIdMapperException, SystemException {
1505 UserIdMapper userIdMapper = fetchByPrimaryKey(userIdMapperId);
1506
1507 if (userIdMapper == null) {
1508 if (_log.isWarnEnabled()) {
1509 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + userIdMapperId);
1510 }
1511
1512 throw new NoSuchUserIdMapperException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1513 userIdMapperId);
1514 }
1515
1516 return userIdMapper;
1517 }
1518
1519
1526 @Override
1527 public UserIdMapper fetchByPrimaryKey(Serializable primaryKey)
1528 throws SystemException {
1529 return fetchByPrimaryKey(((Long)primaryKey).longValue());
1530 }
1531
1532
1539 public UserIdMapper fetchByPrimaryKey(long userIdMapperId)
1540 throws SystemException {
1541 UserIdMapper userIdMapper = (UserIdMapper)EntityCacheUtil.getResult(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
1542 UserIdMapperImpl.class, userIdMapperId);
1543
1544 if (userIdMapper == _nullUserIdMapper) {
1545 return null;
1546 }
1547
1548 if (userIdMapper == null) {
1549 Session session = null;
1550
1551 try {
1552 session = openSession();
1553
1554 userIdMapper = (UserIdMapper)session.get(UserIdMapperImpl.class,
1555 Long.valueOf(userIdMapperId));
1556
1557 if (userIdMapper != null) {
1558 cacheResult(userIdMapper);
1559 }
1560 else {
1561 EntityCacheUtil.putResult(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
1562 UserIdMapperImpl.class, userIdMapperId,
1563 _nullUserIdMapper);
1564 }
1565 }
1566 catch (Exception e) {
1567 EntityCacheUtil.removeResult(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
1568 UserIdMapperImpl.class, userIdMapperId);
1569
1570 throw processException(e);
1571 }
1572 finally {
1573 closeSession(session);
1574 }
1575 }
1576
1577 return userIdMapper;
1578 }
1579
1580
1586 public List<UserIdMapper> findAll() throws SystemException {
1587 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1588 }
1589
1590
1602 public List<UserIdMapper> findAll(int start, int end)
1603 throws SystemException {
1604 return findAll(start, end, null);
1605 }
1606
1607
1620 public List<UserIdMapper> findAll(int start, int end,
1621 OrderByComparator orderByComparator) throws SystemException {
1622 boolean pagination = true;
1623 FinderPath finderPath = null;
1624 Object[] finderArgs = null;
1625
1626 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1627 (orderByComparator == null)) {
1628 pagination = false;
1629 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1630 finderArgs = FINDER_ARGS_EMPTY;
1631 }
1632 else {
1633 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1634 finderArgs = new Object[] { start, end, orderByComparator };
1635 }
1636
1637 List<UserIdMapper> list = (List<UserIdMapper>)FinderCacheUtil.getResult(finderPath,
1638 finderArgs, this);
1639
1640 if (list == null) {
1641 StringBundler query = null;
1642 String sql = null;
1643
1644 if (orderByComparator != null) {
1645 query = new StringBundler(2 +
1646 (orderByComparator.getOrderByFields().length * 3));
1647
1648 query.append(_SQL_SELECT_USERIDMAPPER);
1649
1650 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1651 orderByComparator);
1652
1653 sql = query.toString();
1654 }
1655 else {
1656 sql = _SQL_SELECT_USERIDMAPPER;
1657
1658 if (pagination) {
1659 sql = sql.concat(UserIdMapperModelImpl.ORDER_BY_JPQL);
1660 }
1661 }
1662
1663 Session session = null;
1664
1665 try {
1666 session = openSession();
1667
1668 Query q = session.createQuery(sql);
1669
1670 if (!pagination) {
1671 list = (List<UserIdMapper>)QueryUtil.list(q, getDialect(),
1672 start, end, false);
1673
1674 Collections.sort(list);
1675
1676 list = new UnmodifiableList<UserIdMapper>(list);
1677 }
1678 else {
1679 list = (List<UserIdMapper>)QueryUtil.list(q, getDialect(),
1680 start, end);
1681 }
1682
1683 cacheResult(list);
1684
1685 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1686 }
1687 catch (Exception e) {
1688 FinderCacheUtil.removeResult(finderPath, finderArgs);
1689
1690 throw processException(e);
1691 }
1692 finally {
1693 closeSession(session);
1694 }
1695 }
1696
1697 return list;
1698 }
1699
1700
1705 public void removeAll() throws SystemException {
1706 for (UserIdMapper userIdMapper : findAll()) {
1707 remove(userIdMapper);
1708 }
1709 }
1710
1711
1717 public int countAll() throws SystemException {
1718 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1719 FINDER_ARGS_EMPTY, this);
1720
1721 if (count == null) {
1722 Session session = null;
1723
1724 try {
1725 session = openSession();
1726
1727 Query q = session.createQuery(_SQL_COUNT_USERIDMAPPER);
1728
1729 count = (Long)q.uniqueResult();
1730
1731 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1732 FINDER_ARGS_EMPTY, count);
1733 }
1734 catch (Exception e) {
1735 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
1736 FINDER_ARGS_EMPTY);
1737
1738 throw processException(e);
1739 }
1740 finally {
1741 closeSession(session);
1742 }
1743 }
1744
1745 return count.intValue();
1746 }
1747
1748
1751 public void afterPropertiesSet() {
1752 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1753 com.liferay.portal.util.PropsUtil.get(
1754 "value.object.listener.com.liferay.portal.model.UserIdMapper")));
1755
1756 if (listenerClassNames.length > 0) {
1757 try {
1758 List<ModelListener<UserIdMapper>> listenersList = new ArrayList<ModelListener<UserIdMapper>>();
1759
1760 for (String listenerClassName : listenerClassNames) {
1761 listenersList.add((ModelListener<UserIdMapper>)InstanceFactory.newInstance(
1762 listenerClassName));
1763 }
1764
1765 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1766 }
1767 catch (Exception e) {
1768 _log.error(e);
1769 }
1770 }
1771 }
1772
1773 public void destroy() {
1774 EntityCacheUtil.removeCache(UserIdMapperImpl.class.getName());
1775 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1776 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1777 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1778 }
1779
1780 private static final String _SQL_SELECT_USERIDMAPPER = "SELECT userIdMapper FROM UserIdMapper userIdMapper";
1781 private static final String _SQL_SELECT_USERIDMAPPER_WHERE = "SELECT userIdMapper FROM UserIdMapper userIdMapper WHERE ";
1782 private static final String _SQL_COUNT_USERIDMAPPER = "SELECT COUNT(userIdMapper) FROM UserIdMapper userIdMapper";
1783 private static final String _SQL_COUNT_USERIDMAPPER_WHERE = "SELECT COUNT(userIdMapper) FROM UserIdMapper userIdMapper WHERE ";
1784 private static final String _ORDER_BY_ENTITY_ALIAS = "userIdMapper.";
1785 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserIdMapper exists with the primary key ";
1786 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserIdMapper exists with the key {";
1787 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1788 private static Log _log = LogFactoryUtil.getLog(UserIdMapperPersistenceImpl.class);
1789 private static UserIdMapper _nullUserIdMapper = new UserIdMapperImpl() {
1790 @Override
1791 public Object clone() {
1792 return this;
1793 }
1794
1795 @Override
1796 public CacheModel<UserIdMapper> toCacheModel() {
1797 return _nullUserIdMapperCacheModel;
1798 }
1799 };
1800
1801 private static CacheModel<UserIdMapper> _nullUserIdMapperCacheModel = new CacheModel<UserIdMapper>() {
1802 public UserIdMapper toEntityModel() {
1803 return _nullUserIdMapper;
1804 }
1805 };
1806 }