001
014
015 package com.liferay.portal.service.persistence.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.exception.NoSuchUserIdMapperException;
020 import com.liferay.portal.kernel.bean.BeanReference;
021 import com.liferay.portal.kernel.dao.orm.EntityCache;
022 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
023 import com.liferay.portal.kernel.dao.orm.FinderCache;
024 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
025 import com.liferay.portal.kernel.dao.orm.FinderPath;
026 import com.liferay.portal.kernel.dao.orm.Query;
027 import com.liferay.portal.kernel.dao.orm.QueryPos;
028 import com.liferay.portal.kernel.dao.orm.QueryUtil;
029 import com.liferay.portal.kernel.dao.orm.Session;
030 import com.liferay.portal.kernel.log.Log;
031 import com.liferay.portal.kernel.log.LogFactoryUtil;
032 import com.liferay.portal.kernel.util.OrderByComparator;
033 import com.liferay.portal.kernel.util.SetUtil;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.Validator;
037 import com.liferay.portal.model.CacheModel;
038 import com.liferay.portal.model.MVCCModel;
039 import com.liferay.portal.model.UserIdMapper;
040 import com.liferay.portal.model.impl.UserIdMapperImpl;
041 import com.liferay.portal.model.impl.UserIdMapperModelImpl;
042 import com.liferay.portal.service.persistence.CompanyProvider;
043 import com.liferay.portal.service.persistence.CompanyProviderWrapper;
044 import com.liferay.portal.service.persistence.UserIdMapperPersistence;
045
046 import java.io.Serializable;
047
048 import java.util.Collections;
049 import java.util.HashMap;
050 import java.util.HashSet;
051 import java.util.Iterator;
052 import java.util.List;
053 import java.util.Map;
054 import java.util.Set;
055
056
068 @ProviderType
069 public class UserIdMapperPersistenceImpl extends BasePersistenceImpl<UserIdMapper>
070 implements UserIdMapperPersistence {
071
076 public static final String FINDER_CLASS_NAME_ENTITY = UserIdMapperImpl.class.getName();
077 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
078 ".List1";
079 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
080 ".List2";
081 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
082 UserIdMapperModelImpl.FINDER_CACHE_ENABLED, UserIdMapperImpl.class,
083 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
084 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
085 UserIdMapperModelImpl.FINDER_CACHE_ENABLED, UserIdMapperImpl.class,
086 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
087 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
088 UserIdMapperModelImpl.FINDER_CACHE_ENABLED, Long.class,
089 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
090 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
091 UserIdMapperModelImpl.FINDER_CACHE_ENABLED, UserIdMapperImpl.class,
092 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
093 new String[] {
094 Long.class.getName(),
095
096 Integer.class.getName(), Integer.class.getName(),
097 OrderByComparator.class.getName()
098 });
099 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
100 new FinderPath(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
101 UserIdMapperModelImpl.FINDER_CACHE_ENABLED, UserIdMapperImpl.class,
102 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
103 new String[] { Long.class.getName() },
104 UserIdMapperModelImpl.USERID_COLUMN_BITMASK);
105 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
106 UserIdMapperModelImpl.FINDER_CACHE_ENABLED, Long.class,
107 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
108 new String[] { Long.class.getName() });
109
110
116 @Override
117 public List<UserIdMapper> findByUserId(long userId) {
118 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
119 }
120
121
133 @Override
134 public List<UserIdMapper> findByUserId(long userId, int start, int end) {
135 return findByUserId(userId, start, end, null);
136 }
137
138
151 @Override
152 public List<UserIdMapper> findByUserId(long userId, int start, int end,
153 OrderByComparator<UserIdMapper> orderByComparator) {
154 return findByUserId(userId, start, end, orderByComparator, true);
155 }
156
157
171 @Override
172 public List<UserIdMapper> findByUserId(long userId, int start, int end,
173 OrderByComparator<UserIdMapper> orderByComparator,
174 boolean retrieveFromCache) {
175 boolean pagination = true;
176 FinderPath finderPath = null;
177 Object[] finderArgs = null;
178
179 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
180 (orderByComparator == null)) {
181 pagination = false;
182 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
183 finderArgs = new Object[] { userId };
184 }
185 else {
186 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
187 finderArgs = new Object[] { userId, start, end, orderByComparator };
188 }
189
190 List<UserIdMapper> list = null;
191
192 if (retrieveFromCache) {
193 list = (List<UserIdMapper>)finderCache.getResult(finderPath,
194 finderArgs, this);
195
196 if ((list != null) && !list.isEmpty()) {
197 for (UserIdMapper userIdMapper : list) {
198 if ((userId != userIdMapper.getUserId())) {
199 list = null;
200
201 break;
202 }
203 }
204 }
205 }
206
207 if (list == null) {
208 StringBundler query = null;
209
210 if (orderByComparator != null) {
211 query = new StringBundler(3 +
212 (orderByComparator.getOrderByFields().length * 2));
213 }
214 else {
215 query = new StringBundler(3);
216 }
217
218 query.append(_SQL_SELECT_USERIDMAPPER_WHERE);
219
220 query.append(_FINDER_COLUMN_USERID_USERID_2);
221
222 if (orderByComparator != null) {
223 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
224 orderByComparator);
225 }
226 else
227 if (pagination) {
228 query.append(UserIdMapperModelImpl.ORDER_BY_JPQL);
229 }
230
231 String sql = query.toString();
232
233 Session session = null;
234
235 try {
236 session = openSession();
237
238 Query q = session.createQuery(sql);
239
240 QueryPos qPos = QueryPos.getInstance(q);
241
242 qPos.add(userId);
243
244 if (!pagination) {
245 list = (List<UserIdMapper>)QueryUtil.list(q, getDialect(),
246 start, end, false);
247
248 Collections.sort(list);
249
250 list = Collections.unmodifiableList(list);
251 }
252 else {
253 list = (List<UserIdMapper>)QueryUtil.list(q, getDialect(),
254 start, end);
255 }
256
257 cacheResult(list);
258
259 finderCache.putResult(finderPath, finderArgs, list);
260 }
261 catch (Exception e) {
262 finderCache.removeResult(finderPath, finderArgs);
263
264 throw processException(e);
265 }
266 finally {
267 closeSession(session);
268 }
269 }
270
271 return list;
272 }
273
274
282 @Override
283 public UserIdMapper findByUserId_First(long userId,
284 OrderByComparator<UserIdMapper> orderByComparator)
285 throws NoSuchUserIdMapperException {
286 UserIdMapper userIdMapper = fetchByUserId_First(userId,
287 orderByComparator);
288
289 if (userIdMapper != null) {
290 return userIdMapper;
291 }
292
293 StringBundler msg = new StringBundler(4);
294
295 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
296
297 msg.append("userId=");
298 msg.append(userId);
299
300 msg.append(StringPool.CLOSE_CURLY_BRACE);
301
302 throw new NoSuchUserIdMapperException(msg.toString());
303 }
304
305
312 @Override
313 public UserIdMapper fetchByUserId_First(long userId,
314 OrderByComparator<UserIdMapper> orderByComparator) {
315 List<UserIdMapper> list = findByUserId(userId, 0, 1, orderByComparator);
316
317 if (!list.isEmpty()) {
318 return list.get(0);
319 }
320
321 return null;
322 }
323
324
332 @Override
333 public UserIdMapper findByUserId_Last(long userId,
334 OrderByComparator<UserIdMapper> orderByComparator)
335 throws NoSuchUserIdMapperException {
336 UserIdMapper userIdMapper = fetchByUserId_Last(userId, orderByComparator);
337
338 if (userIdMapper != null) {
339 return userIdMapper;
340 }
341
342 StringBundler msg = new StringBundler(4);
343
344 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
345
346 msg.append("userId=");
347 msg.append(userId);
348
349 msg.append(StringPool.CLOSE_CURLY_BRACE);
350
351 throw new NoSuchUserIdMapperException(msg.toString());
352 }
353
354
361 @Override
362 public UserIdMapper fetchByUserId_Last(long userId,
363 OrderByComparator<UserIdMapper> orderByComparator) {
364 int count = countByUserId(userId);
365
366 if (count == 0) {
367 return null;
368 }
369
370 List<UserIdMapper> list = findByUserId(userId, count - 1, count,
371 orderByComparator);
372
373 if (!list.isEmpty()) {
374 return list.get(0);
375 }
376
377 return null;
378 }
379
380
389 @Override
390 public UserIdMapper[] findByUserId_PrevAndNext(long userIdMapperId,
391 long userId, OrderByComparator<UserIdMapper> orderByComparator)
392 throws NoSuchUserIdMapperException {
393 UserIdMapper userIdMapper = findByPrimaryKey(userIdMapperId);
394
395 Session session = null;
396
397 try {
398 session = openSession();
399
400 UserIdMapper[] array = new UserIdMapperImpl[3];
401
402 array[0] = getByUserId_PrevAndNext(session, userIdMapper, userId,
403 orderByComparator, true);
404
405 array[1] = userIdMapper;
406
407 array[2] = getByUserId_PrevAndNext(session, userIdMapper, userId,
408 orderByComparator, false);
409
410 return array;
411 }
412 catch (Exception e) {
413 throw processException(e);
414 }
415 finally {
416 closeSession(session);
417 }
418 }
419
420 protected UserIdMapper getByUserId_PrevAndNext(Session session,
421 UserIdMapper userIdMapper, long userId,
422 OrderByComparator<UserIdMapper> orderByComparator, boolean previous) {
423 StringBundler query = null;
424
425 if (orderByComparator != null) {
426 query = new StringBundler(4 +
427 (orderByComparator.getOrderByConditionFields().length * 3) +
428 (orderByComparator.getOrderByFields().length * 3));
429 }
430 else {
431 query = new StringBundler(3);
432 }
433
434 query.append(_SQL_SELECT_USERIDMAPPER_WHERE);
435
436 query.append(_FINDER_COLUMN_USERID_USERID_2);
437
438 if (orderByComparator != null) {
439 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
440
441 if (orderByConditionFields.length > 0) {
442 query.append(WHERE_AND);
443 }
444
445 for (int i = 0; i < orderByConditionFields.length; i++) {
446 query.append(_ORDER_BY_ENTITY_ALIAS);
447 query.append(orderByConditionFields[i]);
448
449 if ((i + 1) < orderByConditionFields.length) {
450 if (orderByComparator.isAscending() ^ previous) {
451 query.append(WHERE_GREATER_THAN_HAS_NEXT);
452 }
453 else {
454 query.append(WHERE_LESSER_THAN_HAS_NEXT);
455 }
456 }
457 else {
458 if (orderByComparator.isAscending() ^ previous) {
459 query.append(WHERE_GREATER_THAN);
460 }
461 else {
462 query.append(WHERE_LESSER_THAN);
463 }
464 }
465 }
466
467 query.append(ORDER_BY_CLAUSE);
468
469 String[] orderByFields = orderByComparator.getOrderByFields();
470
471 for (int i = 0; i < orderByFields.length; i++) {
472 query.append(_ORDER_BY_ENTITY_ALIAS);
473 query.append(orderByFields[i]);
474
475 if ((i + 1) < orderByFields.length) {
476 if (orderByComparator.isAscending() ^ previous) {
477 query.append(ORDER_BY_ASC_HAS_NEXT);
478 }
479 else {
480 query.append(ORDER_BY_DESC_HAS_NEXT);
481 }
482 }
483 else {
484 if (orderByComparator.isAscending() ^ previous) {
485 query.append(ORDER_BY_ASC);
486 }
487 else {
488 query.append(ORDER_BY_DESC);
489 }
490 }
491 }
492 }
493 else {
494 query.append(UserIdMapperModelImpl.ORDER_BY_JPQL);
495 }
496
497 String sql = query.toString();
498
499 Query q = session.createQuery(sql);
500
501 q.setFirstResult(0);
502 q.setMaxResults(2);
503
504 QueryPos qPos = QueryPos.getInstance(q);
505
506 qPos.add(userId);
507
508 if (orderByComparator != null) {
509 Object[] values = orderByComparator.getOrderByConditionValues(userIdMapper);
510
511 for (Object value : values) {
512 qPos.add(value);
513 }
514 }
515
516 List<UserIdMapper> list = q.list();
517
518 if (list.size() == 2) {
519 return list.get(1);
520 }
521 else {
522 return null;
523 }
524 }
525
526
531 @Override
532 public void removeByUserId(long userId) {
533 for (UserIdMapper userIdMapper : findByUserId(userId,
534 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
535 remove(userIdMapper);
536 }
537 }
538
539
545 @Override
546 public int countByUserId(long userId) {
547 FinderPath finderPath = FINDER_PATH_COUNT_BY_USERID;
548
549 Object[] finderArgs = new Object[] { userId };
550
551 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
552
553 if (count == null) {
554 StringBundler query = new StringBundler(2);
555
556 query.append(_SQL_COUNT_USERIDMAPPER_WHERE);
557
558 query.append(_FINDER_COLUMN_USERID_USERID_2);
559
560 String sql = query.toString();
561
562 Session session = null;
563
564 try {
565 session = openSession();
566
567 Query q = session.createQuery(sql);
568
569 QueryPos qPos = QueryPos.getInstance(q);
570
571 qPos.add(userId);
572
573 count = (Long)q.uniqueResult();
574
575 finderCache.putResult(finderPath, finderArgs, count);
576 }
577 catch (Exception e) {
578 finderCache.removeResult(finderPath, finderArgs);
579
580 throw processException(e);
581 }
582 finally {
583 closeSession(session);
584 }
585 }
586
587 return count.intValue();
588 }
589
590 private static final String _FINDER_COLUMN_USERID_USERID_2 = "userIdMapper.userId = ?";
591 public static final FinderPath FINDER_PATH_FETCH_BY_U_T = new FinderPath(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
592 UserIdMapperModelImpl.FINDER_CACHE_ENABLED, UserIdMapperImpl.class,
593 FINDER_CLASS_NAME_ENTITY, "fetchByU_T",
594 new String[] { Long.class.getName(), String.class.getName() },
595 UserIdMapperModelImpl.USERID_COLUMN_BITMASK |
596 UserIdMapperModelImpl.TYPE_COLUMN_BITMASK);
597 public static final FinderPath FINDER_PATH_COUNT_BY_U_T = new FinderPath(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
598 UserIdMapperModelImpl.FINDER_CACHE_ENABLED, Long.class,
599 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_T",
600 new String[] { Long.class.getName(), String.class.getName() });
601
602
610 @Override
611 public UserIdMapper findByU_T(long userId, String type)
612 throws NoSuchUserIdMapperException {
613 UserIdMapper userIdMapper = fetchByU_T(userId, type);
614
615 if (userIdMapper == null) {
616 StringBundler msg = new StringBundler(6);
617
618 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
619
620 msg.append("userId=");
621 msg.append(userId);
622
623 msg.append(", type=");
624 msg.append(type);
625
626 msg.append(StringPool.CLOSE_CURLY_BRACE);
627
628 if (_log.isWarnEnabled()) {
629 _log.warn(msg.toString());
630 }
631
632 throw new NoSuchUserIdMapperException(msg.toString());
633 }
634
635 return userIdMapper;
636 }
637
638
645 @Override
646 public UserIdMapper fetchByU_T(long userId, String type) {
647 return fetchByU_T(userId, type, true);
648 }
649
650
658 @Override
659 public UserIdMapper fetchByU_T(long userId, String type,
660 boolean retrieveFromCache) {
661 Object[] finderArgs = new Object[] { userId, type };
662
663 Object result = null;
664
665 if (retrieveFromCache) {
666 result = finderCache.getResult(FINDER_PATH_FETCH_BY_U_T,
667 finderArgs, this);
668 }
669
670 if (result instanceof UserIdMapper) {
671 UserIdMapper userIdMapper = (UserIdMapper)result;
672
673 if ((userId != userIdMapper.getUserId()) ||
674 !Validator.equals(type, userIdMapper.getType())) {
675 result = null;
676 }
677 }
678
679 if (result == null) {
680 StringBundler query = new StringBundler(4);
681
682 query.append(_SQL_SELECT_USERIDMAPPER_WHERE);
683
684 query.append(_FINDER_COLUMN_U_T_USERID_2);
685
686 boolean bindType = false;
687
688 if (type == null) {
689 query.append(_FINDER_COLUMN_U_T_TYPE_1);
690 }
691 else if (type.equals(StringPool.BLANK)) {
692 query.append(_FINDER_COLUMN_U_T_TYPE_3);
693 }
694 else {
695 bindType = true;
696
697 query.append(_FINDER_COLUMN_U_T_TYPE_2);
698 }
699
700 String sql = query.toString();
701
702 Session session = null;
703
704 try {
705 session = openSession();
706
707 Query q = session.createQuery(sql);
708
709 QueryPos qPos = QueryPos.getInstance(q);
710
711 qPos.add(userId);
712
713 if (bindType) {
714 qPos.add(type);
715 }
716
717 List<UserIdMapper> list = q.list();
718
719 if (list.isEmpty()) {
720 finderCache.putResult(FINDER_PATH_FETCH_BY_U_T, finderArgs,
721 list);
722 }
723 else {
724 UserIdMapper userIdMapper = list.get(0);
725
726 result = userIdMapper;
727
728 cacheResult(userIdMapper);
729
730 if ((userIdMapper.getUserId() != userId) ||
731 (userIdMapper.getType() == null) ||
732 !userIdMapper.getType().equals(type)) {
733 finderCache.putResult(FINDER_PATH_FETCH_BY_U_T,
734 finderArgs, userIdMapper);
735 }
736 }
737 }
738 catch (Exception e) {
739 finderCache.removeResult(FINDER_PATH_FETCH_BY_U_T, finderArgs);
740
741 throw processException(e);
742 }
743 finally {
744 closeSession(session);
745 }
746 }
747
748 if (result instanceof List<?>) {
749 return null;
750 }
751 else {
752 return (UserIdMapper)result;
753 }
754 }
755
756
763 @Override
764 public UserIdMapper removeByU_T(long userId, String type)
765 throws NoSuchUserIdMapperException {
766 UserIdMapper userIdMapper = findByU_T(userId, type);
767
768 return remove(userIdMapper);
769 }
770
771
778 @Override
779 public int countByU_T(long userId, String type) {
780 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_T;
781
782 Object[] finderArgs = new Object[] { userId, type };
783
784 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
785
786 if (count == null) {
787 StringBundler query = new StringBundler(3);
788
789 query.append(_SQL_COUNT_USERIDMAPPER_WHERE);
790
791 query.append(_FINDER_COLUMN_U_T_USERID_2);
792
793 boolean bindType = false;
794
795 if (type == null) {
796 query.append(_FINDER_COLUMN_U_T_TYPE_1);
797 }
798 else if (type.equals(StringPool.BLANK)) {
799 query.append(_FINDER_COLUMN_U_T_TYPE_3);
800 }
801 else {
802 bindType = true;
803
804 query.append(_FINDER_COLUMN_U_T_TYPE_2);
805 }
806
807 String sql = query.toString();
808
809 Session session = null;
810
811 try {
812 session = openSession();
813
814 Query q = session.createQuery(sql);
815
816 QueryPos qPos = QueryPos.getInstance(q);
817
818 qPos.add(userId);
819
820 if (bindType) {
821 qPos.add(type);
822 }
823
824 count = (Long)q.uniqueResult();
825
826 finderCache.putResult(finderPath, finderArgs, count);
827 }
828 catch (Exception e) {
829 finderCache.removeResult(finderPath, finderArgs);
830
831 throw processException(e);
832 }
833 finally {
834 closeSession(session);
835 }
836 }
837
838 return count.intValue();
839 }
840
841 private static final String _FINDER_COLUMN_U_T_USERID_2 = "userIdMapper.userId = ? AND ";
842 private static final String _FINDER_COLUMN_U_T_TYPE_1 = "userIdMapper.type IS NULL";
843 private static final String _FINDER_COLUMN_U_T_TYPE_2 = "userIdMapper.type = ?";
844 private static final String _FINDER_COLUMN_U_T_TYPE_3 = "(userIdMapper.type IS NULL OR userIdMapper.type = '')";
845 public static final FinderPath FINDER_PATH_FETCH_BY_T_E = new FinderPath(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
846 UserIdMapperModelImpl.FINDER_CACHE_ENABLED, UserIdMapperImpl.class,
847 FINDER_CLASS_NAME_ENTITY, "fetchByT_E",
848 new String[] { String.class.getName(), String.class.getName() },
849 UserIdMapperModelImpl.TYPE_COLUMN_BITMASK |
850 UserIdMapperModelImpl.EXTERNALUSERID_COLUMN_BITMASK);
851 public static final FinderPath FINDER_PATH_COUNT_BY_T_E = new FinderPath(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
852 UserIdMapperModelImpl.FINDER_CACHE_ENABLED, Long.class,
853 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByT_E",
854 new String[] { String.class.getName(), String.class.getName() });
855
856
864 @Override
865 public UserIdMapper findByT_E(String type, String externalUserId)
866 throws NoSuchUserIdMapperException {
867 UserIdMapper userIdMapper = fetchByT_E(type, externalUserId);
868
869 if (userIdMapper == null) {
870 StringBundler msg = new StringBundler(6);
871
872 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
873
874 msg.append("type=");
875 msg.append(type);
876
877 msg.append(", externalUserId=");
878 msg.append(externalUserId);
879
880 msg.append(StringPool.CLOSE_CURLY_BRACE);
881
882 if (_log.isWarnEnabled()) {
883 _log.warn(msg.toString());
884 }
885
886 throw new NoSuchUserIdMapperException(msg.toString());
887 }
888
889 return userIdMapper;
890 }
891
892
899 @Override
900 public UserIdMapper fetchByT_E(String type, String externalUserId) {
901 return fetchByT_E(type, externalUserId, true);
902 }
903
904
912 @Override
913 public UserIdMapper fetchByT_E(String type, String externalUserId,
914 boolean retrieveFromCache) {
915 Object[] finderArgs = new Object[] { type, externalUserId };
916
917 Object result = null;
918
919 if (retrieveFromCache) {
920 result = finderCache.getResult(FINDER_PATH_FETCH_BY_T_E,
921 finderArgs, this);
922 }
923
924 if (result instanceof UserIdMapper) {
925 UserIdMapper userIdMapper = (UserIdMapper)result;
926
927 if (!Validator.equals(type, userIdMapper.getType()) ||
928 !Validator.equals(externalUserId,
929 userIdMapper.getExternalUserId())) {
930 result = null;
931 }
932 }
933
934 if (result == null) {
935 StringBundler query = new StringBundler(4);
936
937 query.append(_SQL_SELECT_USERIDMAPPER_WHERE);
938
939 boolean bindType = false;
940
941 if (type == null) {
942 query.append(_FINDER_COLUMN_T_E_TYPE_1);
943 }
944 else if (type.equals(StringPool.BLANK)) {
945 query.append(_FINDER_COLUMN_T_E_TYPE_3);
946 }
947 else {
948 bindType = true;
949
950 query.append(_FINDER_COLUMN_T_E_TYPE_2);
951 }
952
953 boolean bindExternalUserId = false;
954
955 if (externalUserId == null) {
956 query.append(_FINDER_COLUMN_T_E_EXTERNALUSERID_1);
957 }
958 else if (externalUserId.equals(StringPool.BLANK)) {
959 query.append(_FINDER_COLUMN_T_E_EXTERNALUSERID_3);
960 }
961 else {
962 bindExternalUserId = true;
963
964 query.append(_FINDER_COLUMN_T_E_EXTERNALUSERID_2);
965 }
966
967 String sql = query.toString();
968
969 Session session = null;
970
971 try {
972 session = openSession();
973
974 Query q = session.createQuery(sql);
975
976 QueryPos qPos = QueryPos.getInstance(q);
977
978 if (bindType) {
979 qPos.add(type);
980 }
981
982 if (bindExternalUserId) {
983 qPos.add(externalUserId);
984 }
985
986 List<UserIdMapper> list = q.list();
987
988 if (list.isEmpty()) {
989 finderCache.putResult(FINDER_PATH_FETCH_BY_T_E, finderArgs,
990 list);
991 }
992 else {
993 UserIdMapper userIdMapper = list.get(0);
994
995 result = userIdMapper;
996
997 cacheResult(userIdMapper);
998
999 if ((userIdMapper.getType() == null) ||
1000 !userIdMapper.getType().equals(type) ||
1001 (userIdMapper.getExternalUserId() == null) ||
1002 !userIdMapper.getExternalUserId()
1003 .equals(externalUserId)) {
1004 finderCache.putResult(FINDER_PATH_FETCH_BY_T_E,
1005 finderArgs, userIdMapper);
1006 }
1007 }
1008 }
1009 catch (Exception e) {
1010 finderCache.removeResult(FINDER_PATH_FETCH_BY_T_E, finderArgs);
1011
1012 throw processException(e);
1013 }
1014 finally {
1015 closeSession(session);
1016 }
1017 }
1018
1019 if (result instanceof List<?>) {
1020 return null;
1021 }
1022 else {
1023 return (UserIdMapper)result;
1024 }
1025 }
1026
1027
1034 @Override
1035 public UserIdMapper removeByT_E(String type, String externalUserId)
1036 throws NoSuchUserIdMapperException {
1037 UserIdMapper userIdMapper = findByT_E(type, externalUserId);
1038
1039 return remove(userIdMapper);
1040 }
1041
1042
1049 @Override
1050 public int countByT_E(String type, String externalUserId) {
1051 FinderPath finderPath = FINDER_PATH_COUNT_BY_T_E;
1052
1053 Object[] finderArgs = new Object[] { type, externalUserId };
1054
1055 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1056
1057 if (count == null) {
1058 StringBundler query = new StringBundler(3);
1059
1060 query.append(_SQL_COUNT_USERIDMAPPER_WHERE);
1061
1062 boolean bindType = false;
1063
1064 if (type == null) {
1065 query.append(_FINDER_COLUMN_T_E_TYPE_1);
1066 }
1067 else if (type.equals(StringPool.BLANK)) {
1068 query.append(_FINDER_COLUMN_T_E_TYPE_3);
1069 }
1070 else {
1071 bindType = true;
1072
1073 query.append(_FINDER_COLUMN_T_E_TYPE_2);
1074 }
1075
1076 boolean bindExternalUserId = false;
1077
1078 if (externalUserId == null) {
1079 query.append(_FINDER_COLUMN_T_E_EXTERNALUSERID_1);
1080 }
1081 else if (externalUserId.equals(StringPool.BLANK)) {
1082 query.append(_FINDER_COLUMN_T_E_EXTERNALUSERID_3);
1083 }
1084 else {
1085 bindExternalUserId = true;
1086
1087 query.append(_FINDER_COLUMN_T_E_EXTERNALUSERID_2);
1088 }
1089
1090 String sql = query.toString();
1091
1092 Session session = null;
1093
1094 try {
1095 session = openSession();
1096
1097 Query q = session.createQuery(sql);
1098
1099 QueryPos qPos = QueryPos.getInstance(q);
1100
1101 if (bindType) {
1102 qPos.add(type);
1103 }
1104
1105 if (bindExternalUserId) {
1106 qPos.add(externalUserId);
1107 }
1108
1109 count = (Long)q.uniqueResult();
1110
1111 finderCache.putResult(finderPath, finderArgs, count);
1112 }
1113 catch (Exception e) {
1114 finderCache.removeResult(finderPath, finderArgs);
1115
1116 throw processException(e);
1117 }
1118 finally {
1119 closeSession(session);
1120 }
1121 }
1122
1123 return count.intValue();
1124 }
1125
1126 private static final String _FINDER_COLUMN_T_E_TYPE_1 = "userIdMapper.type IS NULL AND ";
1127 private static final String _FINDER_COLUMN_T_E_TYPE_2 = "userIdMapper.type = ? AND ";
1128 private static final String _FINDER_COLUMN_T_E_TYPE_3 = "(userIdMapper.type IS NULL OR userIdMapper.type = '') AND ";
1129 private static final String _FINDER_COLUMN_T_E_EXTERNALUSERID_1 = "userIdMapper.externalUserId IS NULL";
1130 private static final String _FINDER_COLUMN_T_E_EXTERNALUSERID_2 = "userIdMapper.externalUserId = ?";
1131 private static final String _FINDER_COLUMN_T_E_EXTERNALUSERID_3 = "(userIdMapper.externalUserId IS NULL OR userIdMapper.externalUserId = '')";
1132
1133 public UserIdMapperPersistenceImpl() {
1134 setModelClass(UserIdMapper.class);
1135 }
1136
1137
1142 @Override
1143 public void cacheResult(UserIdMapper userIdMapper) {
1144 entityCache.putResult(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
1145 UserIdMapperImpl.class, userIdMapper.getPrimaryKey(), userIdMapper);
1146
1147 finderCache.putResult(FINDER_PATH_FETCH_BY_U_T,
1148 new Object[] { userIdMapper.getUserId(), userIdMapper.getType() },
1149 userIdMapper);
1150
1151 finderCache.putResult(FINDER_PATH_FETCH_BY_T_E,
1152 new Object[] {
1153 userIdMapper.getType(), userIdMapper.getExternalUserId()
1154 }, userIdMapper);
1155
1156 userIdMapper.resetOriginalValues();
1157 }
1158
1159
1164 @Override
1165 public void cacheResult(List<UserIdMapper> userIdMappers) {
1166 for (UserIdMapper userIdMapper : userIdMappers) {
1167 if (entityCache.getResult(
1168 UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
1169 UserIdMapperImpl.class, userIdMapper.getPrimaryKey()) == null) {
1170 cacheResult(userIdMapper);
1171 }
1172 else {
1173 userIdMapper.resetOriginalValues();
1174 }
1175 }
1176 }
1177
1178
1185 @Override
1186 public void clearCache() {
1187 entityCache.clearCache(UserIdMapperImpl.class);
1188
1189 finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
1190 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1191 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1192 }
1193
1194
1201 @Override
1202 public void clearCache(UserIdMapper userIdMapper) {
1203 entityCache.removeResult(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
1204 UserIdMapperImpl.class, userIdMapper.getPrimaryKey());
1205
1206 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1207 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1208
1209 clearUniqueFindersCache((UserIdMapperModelImpl)userIdMapper);
1210 }
1211
1212 @Override
1213 public void clearCache(List<UserIdMapper> userIdMappers) {
1214 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1215 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1216
1217 for (UserIdMapper userIdMapper : userIdMappers) {
1218 entityCache.removeResult(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
1219 UserIdMapperImpl.class, userIdMapper.getPrimaryKey());
1220
1221 clearUniqueFindersCache((UserIdMapperModelImpl)userIdMapper);
1222 }
1223 }
1224
1225 protected void cacheUniqueFindersCache(
1226 UserIdMapperModelImpl userIdMapperModelImpl, boolean isNew) {
1227 if (isNew) {
1228 Object[] args = new Object[] {
1229 userIdMapperModelImpl.getUserId(),
1230 userIdMapperModelImpl.getType()
1231 };
1232
1233 finderCache.putResult(FINDER_PATH_COUNT_BY_U_T, args,
1234 Long.valueOf(1));
1235 finderCache.putResult(FINDER_PATH_FETCH_BY_U_T, args,
1236 userIdMapperModelImpl);
1237
1238 args = new Object[] {
1239 userIdMapperModelImpl.getType(),
1240 userIdMapperModelImpl.getExternalUserId()
1241 };
1242
1243 finderCache.putResult(FINDER_PATH_COUNT_BY_T_E, args,
1244 Long.valueOf(1));
1245 finderCache.putResult(FINDER_PATH_FETCH_BY_T_E, args,
1246 userIdMapperModelImpl);
1247 }
1248 else {
1249 if ((userIdMapperModelImpl.getColumnBitmask() &
1250 FINDER_PATH_FETCH_BY_U_T.getColumnBitmask()) != 0) {
1251 Object[] args = new Object[] {
1252 userIdMapperModelImpl.getUserId(),
1253 userIdMapperModelImpl.getType()
1254 };
1255
1256 finderCache.putResult(FINDER_PATH_COUNT_BY_U_T, args,
1257 Long.valueOf(1));
1258 finderCache.putResult(FINDER_PATH_FETCH_BY_U_T, args,
1259 userIdMapperModelImpl);
1260 }
1261
1262 if ((userIdMapperModelImpl.getColumnBitmask() &
1263 FINDER_PATH_FETCH_BY_T_E.getColumnBitmask()) != 0) {
1264 Object[] args = new Object[] {
1265 userIdMapperModelImpl.getType(),
1266 userIdMapperModelImpl.getExternalUserId()
1267 };
1268
1269 finderCache.putResult(FINDER_PATH_COUNT_BY_T_E, args,
1270 Long.valueOf(1));
1271 finderCache.putResult(FINDER_PATH_FETCH_BY_T_E, args,
1272 userIdMapperModelImpl);
1273 }
1274 }
1275 }
1276
1277 protected void clearUniqueFindersCache(
1278 UserIdMapperModelImpl userIdMapperModelImpl) {
1279 Object[] args = new Object[] {
1280 userIdMapperModelImpl.getUserId(),
1281 userIdMapperModelImpl.getType()
1282 };
1283
1284 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_T, args);
1285 finderCache.removeResult(FINDER_PATH_FETCH_BY_U_T, args);
1286
1287 if ((userIdMapperModelImpl.getColumnBitmask() &
1288 FINDER_PATH_FETCH_BY_U_T.getColumnBitmask()) != 0) {
1289 args = new Object[] {
1290 userIdMapperModelImpl.getOriginalUserId(),
1291 userIdMapperModelImpl.getOriginalType()
1292 };
1293
1294 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_T, args);
1295 finderCache.removeResult(FINDER_PATH_FETCH_BY_U_T, args);
1296 }
1297
1298 args = new Object[] {
1299 userIdMapperModelImpl.getType(),
1300 userIdMapperModelImpl.getExternalUserId()
1301 };
1302
1303 finderCache.removeResult(FINDER_PATH_COUNT_BY_T_E, args);
1304 finderCache.removeResult(FINDER_PATH_FETCH_BY_T_E, args);
1305
1306 if ((userIdMapperModelImpl.getColumnBitmask() &
1307 FINDER_PATH_FETCH_BY_T_E.getColumnBitmask()) != 0) {
1308 args = new Object[] {
1309 userIdMapperModelImpl.getOriginalType(),
1310 userIdMapperModelImpl.getOriginalExternalUserId()
1311 };
1312
1313 finderCache.removeResult(FINDER_PATH_COUNT_BY_T_E, args);
1314 finderCache.removeResult(FINDER_PATH_FETCH_BY_T_E, args);
1315 }
1316 }
1317
1318
1324 @Override
1325 public UserIdMapper create(long userIdMapperId) {
1326 UserIdMapper userIdMapper = new UserIdMapperImpl();
1327
1328 userIdMapper.setNew(true);
1329 userIdMapper.setPrimaryKey(userIdMapperId);
1330
1331 userIdMapper.setCompanyId(companyProvider.getCompanyId());
1332
1333 return userIdMapper;
1334 }
1335
1336
1343 @Override
1344 public UserIdMapper remove(long userIdMapperId)
1345 throws NoSuchUserIdMapperException {
1346 return remove((Serializable)userIdMapperId);
1347 }
1348
1349
1356 @Override
1357 public UserIdMapper remove(Serializable primaryKey)
1358 throws NoSuchUserIdMapperException {
1359 Session session = null;
1360
1361 try {
1362 session = openSession();
1363
1364 UserIdMapper userIdMapper = (UserIdMapper)session.get(UserIdMapperImpl.class,
1365 primaryKey);
1366
1367 if (userIdMapper == null) {
1368 if (_log.isWarnEnabled()) {
1369 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
1370 }
1371
1372 throw new NoSuchUserIdMapperException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1373 primaryKey);
1374 }
1375
1376 return remove(userIdMapper);
1377 }
1378 catch (NoSuchUserIdMapperException nsee) {
1379 throw nsee;
1380 }
1381 catch (Exception e) {
1382 throw processException(e);
1383 }
1384 finally {
1385 closeSession(session);
1386 }
1387 }
1388
1389 @Override
1390 protected UserIdMapper removeImpl(UserIdMapper userIdMapper) {
1391 userIdMapper = toUnwrappedModel(userIdMapper);
1392
1393 Session session = null;
1394
1395 try {
1396 session = openSession();
1397
1398 if (!session.contains(userIdMapper)) {
1399 userIdMapper = (UserIdMapper)session.get(UserIdMapperImpl.class,
1400 userIdMapper.getPrimaryKeyObj());
1401 }
1402
1403 if (userIdMapper != null) {
1404 session.delete(userIdMapper);
1405 }
1406 }
1407 catch (Exception e) {
1408 throw processException(e);
1409 }
1410 finally {
1411 closeSession(session);
1412 }
1413
1414 if (userIdMapper != null) {
1415 clearCache(userIdMapper);
1416 }
1417
1418 return userIdMapper;
1419 }
1420
1421 @Override
1422 public UserIdMapper updateImpl(UserIdMapper userIdMapper) {
1423 userIdMapper = toUnwrappedModel(userIdMapper);
1424
1425 boolean isNew = userIdMapper.isNew();
1426
1427 UserIdMapperModelImpl userIdMapperModelImpl = (UserIdMapperModelImpl)userIdMapper;
1428
1429 Session session = null;
1430
1431 try {
1432 session = openSession();
1433
1434 if (userIdMapper.isNew()) {
1435 session.save(userIdMapper);
1436
1437 userIdMapper.setNew(false);
1438 }
1439 else {
1440 userIdMapper = (UserIdMapper)session.merge(userIdMapper);
1441 }
1442 }
1443 catch (Exception e) {
1444 throw processException(e);
1445 }
1446 finally {
1447 closeSession(session);
1448 }
1449
1450 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1451
1452 if (isNew || !UserIdMapperModelImpl.COLUMN_BITMASK_ENABLED) {
1453 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1454 }
1455
1456 else {
1457 if ((userIdMapperModelImpl.getColumnBitmask() &
1458 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
1459 Object[] args = new Object[] {
1460 userIdMapperModelImpl.getOriginalUserId()
1461 };
1462
1463 finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
1464 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
1465 args);
1466
1467 args = new Object[] { userIdMapperModelImpl.getUserId() };
1468
1469 finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
1470 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
1471 args);
1472 }
1473 }
1474
1475 entityCache.putResult(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
1476 UserIdMapperImpl.class, userIdMapper.getPrimaryKey(), userIdMapper,
1477 false);
1478
1479 clearUniqueFindersCache(userIdMapperModelImpl);
1480 cacheUniqueFindersCache(userIdMapperModelImpl, isNew);
1481
1482 userIdMapper.resetOriginalValues();
1483
1484 return userIdMapper;
1485 }
1486
1487 protected UserIdMapper toUnwrappedModel(UserIdMapper userIdMapper) {
1488 if (userIdMapper instanceof UserIdMapperImpl) {
1489 return userIdMapper;
1490 }
1491
1492 UserIdMapperImpl userIdMapperImpl = new UserIdMapperImpl();
1493
1494 userIdMapperImpl.setNew(userIdMapper.isNew());
1495 userIdMapperImpl.setPrimaryKey(userIdMapper.getPrimaryKey());
1496
1497 userIdMapperImpl.setMvccVersion(userIdMapper.getMvccVersion());
1498 userIdMapperImpl.setUserIdMapperId(userIdMapper.getUserIdMapperId());
1499 userIdMapperImpl.setCompanyId(userIdMapper.getCompanyId());
1500 userIdMapperImpl.setUserId(userIdMapper.getUserId());
1501 userIdMapperImpl.setType(userIdMapper.getType());
1502 userIdMapperImpl.setDescription(userIdMapper.getDescription());
1503 userIdMapperImpl.setExternalUserId(userIdMapper.getExternalUserId());
1504
1505 return userIdMapperImpl;
1506 }
1507
1508
1515 @Override
1516 public UserIdMapper findByPrimaryKey(Serializable primaryKey)
1517 throws NoSuchUserIdMapperException {
1518 UserIdMapper userIdMapper = fetchByPrimaryKey(primaryKey);
1519
1520 if (userIdMapper == null) {
1521 if (_log.isWarnEnabled()) {
1522 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
1523 }
1524
1525 throw new NoSuchUserIdMapperException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1526 primaryKey);
1527 }
1528
1529 return userIdMapper;
1530 }
1531
1532
1539 @Override
1540 public UserIdMapper findByPrimaryKey(long userIdMapperId)
1541 throws NoSuchUserIdMapperException {
1542 return findByPrimaryKey((Serializable)userIdMapperId);
1543 }
1544
1545
1551 @Override
1552 public UserIdMapper fetchByPrimaryKey(Serializable primaryKey) {
1553 UserIdMapper userIdMapper = (UserIdMapper)entityCache.getResult(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
1554 UserIdMapperImpl.class, primaryKey);
1555
1556 if (userIdMapper == _nullUserIdMapper) {
1557 return null;
1558 }
1559
1560 if (userIdMapper == null) {
1561 Session session = null;
1562
1563 try {
1564 session = openSession();
1565
1566 userIdMapper = (UserIdMapper)session.get(UserIdMapperImpl.class,
1567 primaryKey);
1568
1569 if (userIdMapper != null) {
1570 cacheResult(userIdMapper);
1571 }
1572 else {
1573 entityCache.putResult(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
1574 UserIdMapperImpl.class, primaryKey, _nullUserIdMapper);
1575 }
1576 }
1577 catch (Exception e) {
1578 entityCache.removeResult(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
1579 UserIdMapperImpl.class, primaryKey);
1580
1581 throw processException(e);
1582 }
1583 finally {
1584 closeSession(session);
1585 }
1586 }
1587
1588 return userIdMapper;
1589 }
1590
1591
1597 @Override
1598 public UserIdMapper fetchByPrimaryKey(long userIdMapperId) {
1599 return fetchByPrimaryKey((Serializable)userIdMapperId);
1600 }
1601
1602 @Override
1603 public Map<Serializable, UserIdMapper> fetchByPrimaryKeys(
1604 Set<Serializable> primaryKeys) {
1605 if (primaryKeys.isEmpty()) {
1606 return Collections.emptyMap();
1607 }
1608
1609 Map<Serializable, UserIdMapper> map = new HashMap<Serializable, UserIdMapper>();
1610
1611 if (primaryKeys.size() == 1) {
1612 Iterator<Serializable> iterator = primaryKeys.iterator();
1613
1614 Serializable primaryKey = iterator.next();
1615
1616 UserIdMapper userIdMapper = fetchByPrimaryKey(primaryKey);
1617
1618 if (userIdMapper != null) {
1619 map.put(primaryKey, userIdMapper);
1620 }
1621
1622 return map;
1623 }
1624
1625 Set<Serializable> uncachedPrimaryKeys = null;
1626
1627 for (Serializable primaryKey : primaryKeys) {
1628 UserIdMapper userIdMapper = (UserIdMapper)entityCache.getResult(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
1629 UserIdMapperImpl.class, primaryKey);
1630
1631 if (userIdMapper == null) {
1632 if (uncachedPrimaryKeys == null) {
1633 uncachedPrimaryKeys = new HashSet<Serializable>();
1634 }
1635
1636 uncachedPrimaryKeys.add(primaryKey);
1637 }
1638 else {
1639 map.put(primaryKey, userIdMapper);
1640 }
1641 }
1642
1643 if (uncachedPrimaryKeys == null) {
1644 return map;
1645 }
1646
1647 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
1648 1);
1649
1650 query.append(_SQL_SELECT_USERIDMAPPER_WHERE_PKS_IN);
1651
1652 for (Serializable primaryKey : uncachedPrimaryKeys) {
1653 query.append(String.valueOf(primaryKey));
1654
1655 query.append(StringPool.COMMA);
1656 }
1657
1658 query.setIndex(query.index() - 1);
1659
1660 query.append(StringPool.CLOSE_PARENTHESIS);
1661
1662 String sql = query.toString();
1663
1664 Session session = null;
1665
1666 try {
1667 session = openSession();
1668
1669 Query q = session.createQuery(sql);
1670
1671 for (UserIdMapper userIdMapper : (List<UserIdMapper>)q.list()) {
1672 map.put(userIdMapper.getPrimaryKeyObj(), userIdMapper);
1673
1674 cacheResult(userIdMapper);
1675
1676 uncachedPrimaryKeys.remove(userIdMapper.getPrimaryKeyObj());
1677 }
1678
1679 for (Serializable primaryKey : uncachedPrimaryKeys) {
1680 entityCache.putResult(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
1681 UserIdMapperImpl.class, primaryKey, _nullUserIdMapper);
1682 }
1683 }
1684 catch (Exception e) {
1685 throw processException(e);
1686 }
1687 finally {
1688 closeSession(session);
1689 }
1690
1691 return map;
1692 }
1693
1694
1699 @Override
1700 public List<UserIdMapper> findAll() {
1701 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1702 }
1703
1704
1715 @Override
1716 public List<UserIdMapper> findAll(int start, int end) {
1717 return findAll(start, end, null);
1718 }
1719
1720
1732 @Override
1733 public List<UserIdMapper> findAll(int start, int end,
1734 OrderByComparator<UserIdMapper> orderByComparator) {
1735 return findAll(start, end, orderByComparator, true);
1736 }
1737
1738
1751 @Override
1752 public List<UserIdMapper> findAll(int start, int end,
1753 OrderByComparator<UserIdMapper> orderByComparator,
1754 boolean retrieveFromCache) {
1755 boolean pagination = true;
1756 FinderPath finderPath = null;
1757 Object[] finderArgs = null;
1758
1759 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1760 (orderByComparator == null)) {
1761 pagination = false;
1762 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1763 finderArgs = FINDER_ARGS_EMPTY;
1764 }
1765 else {
1766 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1767 finderArgs = new Object[] { start, end, orderByComparator };
1768 }
1769
1770 List<UserIdMapper> list = null;
1771
1772 if (retrieveFromCache) {
1773 list = (List<UserIdMapper>)finderCache.getResult(finderPath,
1774 finderArgs, this);
1775 }
1776
1777 if (list == null) {
1778 StringBundler query = null;
1779 String sql = null;
1780
1781 if (orderByComparator != null) {
1782 query = new StringBundler(2 +
1783 (orderByComparator.getOrderByFields().length * 2));
1784
1785 query.append(_SQL_SELECT_USERIDMAPPER);
1786
1787 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1788 orderByComparator);
1789
1790 sql = query.toString();
1791 }
1792 else {
1793 sql = _SQL_SELECT_USERIDMAPPER;
1794
1795 if (pagination) {
1796 sql = sql.concat(UserIdMapperModelImpl.ORDER_BY_JPQL);
1797 }
1798 }
1799
1800 Session session = null;
1801
1802 try {
1803 session = openSession();
1804
1805 Query q = session.createQuery(sql);
1806
1807 if (!pagination) {
1808 list = (List<UserIdMapper>)QueryUtil.list(q, getDialect(),
1809 start, end, false);
1810
1811 Collections.sort(list);
1812
1813 list = Collections.unmodifiableList(list);
1814 }
1815 else {
1816 list = (List<UserIdMapper>)QueryUtil.list(q, getDialect(),
1817 start, end);
1818 }
1819
1820 cacheResult(list);
1821
1822 finderCache.putResult(finderPath, finderArgs, list);
1823 }
1824 catch (Exception e) {
1825 finderCache.removeResult(finderPath, finderArgs);
1826
1827 throw processException(e);
1828 }
1829 finally {
1830 closeSession(session);
1831 }
1832 }
1833
1834 return list;
1835 }
1836
1837
1841 @Override
1842 public void removeAll() {
1843 for (UserIdMapper userIdMapper : findAll()) {
1844 remove(userIdMapper);
1845 }
1846 }
1847
1848
1853 @Override
1854 public int countAll() {
1855 Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
1856 FINDER_ARGS_EMPTY, this);
1857
1858 if (count == null) {
1859 Session session = null;
1860
1861 try {
1862 session = openSession();
1863
1864 Query q = session.createQuery(_SQL_COUNT_USERIDMAPPER);
1865
1866 count = (Long)q.uniqueResult();
1867
1868 finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
1869 count);
1870 }
1871 catch (Exception e) {
1872 finderCache.removeResult(FINDER_PATH_COUNT_ALL,
1873 FINDER_ARGS_EMPTY);
1874
1875 throw processException(e);
1876 }
1877 finally {
1878 closeSession(session);
1879 }
1880 }
1881
1882 return count.intValue();
1883 }
1884
1885 @Override
1886 public Set<String> getBadColumnNames() {
1887 return _badColumnNames;
1888 }
1889
1890 @Override
1891 protected Map<String, Integer> getTableColumnsMap() {
1892 return UserIdMapperModelImpl.TABLE_COLUMNS_MAP;
1893 }
1894
1895
1898 public void afterPropertiesSet() {
1899 }
1900
1901 public void destroy() {
1902 entityCache.removeCache(UserIdMapperImpl.class.getName());
1903 finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
1904 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1905 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1906 }
1907
1908 @BeanReference(type = CompanyProviderWrapper.class)
1909 protected CompanyProvider companyProvider;
1910 protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
1911 protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
1912 private static final String _SQL_SELECT_USERIDMAPPER = "SELECT userIdMapper FROM UserIdMapper userIdMapper";
1913 private static final String _SQL_SELECT_USERIDMAPPER_WHERE_PKS_IN = "SELECT userIdMapper FROM UserIdMapper userIdMapper WHERE userIdMapperId IN (";
1914 private static final String _SQL_SELECT_USERIDMAPPER_WHERE = "SELECT userIdMapper FROM UserIdMapper userIdMapper WHERE ";
1915 private static final String _SQL_COUNT_USERIDMAPPER = "SELECT COUNT(userIdMapper) FROM UserIdMapper userIdMapper";
1916 private static final String _SQL_COUNT_USERIDMAPPER_WHERE = "SELECT COUNT(userIdMapper) FROM UserIdMapper userIdMapper WHERE ";
1917 private static final String _ORDER_BY_ENTITY_ALIAS = "userIdMapper.";
1918 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserIdMapper exists with the primary key ";
1919 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserIdMapper exists with the key {";
1920 private static final Log _log = LogFactoryUtil.getLog(UserIdMapperPersistenceImpl.class);
1921 private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
1922 "type"
1923 });
1924 private static final UserIdMapper _nullUserIdMapper = new UserIdMapperImpl() {
1925 @Override
1926 public Object clone() {
1927 return this;
1928 }
1929
1930 @Override
1931 public CacheModel<UserIdMapper> toCacheModel() {
1932 return _nullUserIdMapperCacheModel;
1933 }
1934 };
1935
1936 private static final CacheModel<UserIdMapper> _nullUserIdMapperCacheModel = new NullCacheModel();
1937
1938 private static class NullCacheModel implements CacheModel<UserIdMapper>,
1939 MVCCModel {
1940 @Override
1941 public long getMvccVersion() {
1942 return -1;
1943 }
1944
1945 @Override
1946 public void setMvccVersion(long mvccVersion) {
1947 }
1948
1949 @Override
1950 public UserIdMapper toEntityModel() {
1951 return _nullUserIdMapper;
1952 }
1953 }
1954 }