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