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 @Override
113 public List<UserIdMapper> findByUserId(long userId)
114 throws SystemException {
115 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
116 }
117
118
131 @Override
132 public List<UserIdMapper> findByUserId(long userId, int start, int end)
133 throws SystemException {
134 return findByUserId(userId, start, end, null);
135 }
136
137
151 @Override
152 public List<UserIdMapper> findByUserId(long userId, int start, int end,
153 OrderByComparator orderByComparator) throws SystemException {
154 boolean pagination = true;
155 FinderPath finderPath = null;
156 Object[] finderArgs = null;
157
158 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
159 (orderByComparator == null)) {
160 pagination = false;
161 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
162 finderArgs = new Object[] { userId };
163 }
164 else {
165 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
166 finderArgs = new Object[] { userId, start, end, orderByComparator };
167 }
168
169 List<UserIdMapper> list = (List<UserIdMapper>)FinderCacheUtil.getResult(finderPath,
170 finderArgs, this);
171
172 if ((list != null) && !list.isEmpty()) {
173 for (UserIdMapper userIdMapper : list) {
174 if ((userId != userIdMapper.getUserId())) {
175 list = null;
176
177 break;
178 }
179 }
180 }
181
182 if (list == null) {
183 StringBundler query = null;
184
185 if (orderByComparator != null) {
186 query = new StringBundler(3 +
187 (orderByComparator.getOrderByFields().length * 3));
188 }
189 else {
190 query = new StringBundler(3);
191 }
192
193 query.append(_SQL_SELECT_USERIDMAPPER_WHERE);
194
195 query.append(_FINDER_COLUMN_USERID_USERID_2);
196
197 if (orderByComparator != null) {
198 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
199 orderByComparator);
200 }
201 else
202 if (pagination) {
203 query.append(UserIdMapperModelImpl.ORDER_BY_JPQL);
204 }
205
206 String sql = query.toString();
207
208 Session session = null;
209
210 try {
211 session = openSession();
212
213 Query q = session.createQuery(sql);
214
215 QueryPos qPos = QueryPos.getInstance(q);
216
217 qPos.add(userId);
218
219 if (!pagination) {
220 list = (List<UserIdMapper>)QueryUtil.list(q, getDialect(),
221 start, end, false);
222
223 Collections.sort(list);
224
225 list = new UnmodifiableList<UserIdMapper>(list);
226 }
227 else {
228 list = (List<UserIdMapper>)QueryUtil.list(q, getDialect(),
229 start, end);
230 }
231
232 cacheResult(list);
233
234 FinderCacheUtil.putResult(finderPath, finderArgs, list);
235 }
236 catch (Exception e) {
237 FinderCacheUtil.removeResult(finderPath, finderArgs);
238
239 throw processException(e);
240 }
241 finally {
242 closeSession(session);
243 }
244 }
245
246 return list;
247 }
248
249
258 @Override
259 public UserIdMapper findByUserId_First(long userId,
260 OrderByComparator orderByComparator)
261 throws NoSuchUserIdMapperException, SystemException {
262 UserIdMapper userIdMapper = fetchByUserId_First(userId,
263 orderByComparator);
264
265 if (userIdMapper != null) {
266 return userIdMapper;
267 }
268
269 StringBundler msg = new StringBundler(4);
270
271 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
272
273 msg.append("userId=");
274 msg.append(userId);
275
276 msg.append(StringPool.CLOSE_CURLY_BRACE);
277
278 throw new NoSuchUserIdMapperException(msg.toString());
279 }
280
281
289 @Override
290 public UserIdMapper fetchByUserId_First(long userId,
291 OrderByComparator orderByComparator) throws SystemException {
292 List<UserIdMapper> list = findByUserId(userId, 0, 1, orderByComparator);
293
294 if (!list.isEmpty()) {
295 return list.get(0);
296 }
297
298 return null;
299 }
300
301
310 @Override
311 public UserIdMapper findByUserId_Last(long userId,
312 OrderByComparator orderByComparator)
313 throws NoSuchUserIdMapperException, SystemException {
314 UserIdMapper userIdMapper = fetchByUserId_Last(userId, orderByComparator);
315
316 if (userIdMapper != null) {
317 return userIdMapper;
318 }
319
320 StringBundler msg = new StringBundler(4);
321
322 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
323
324 msg.append("userId=");
325 msg.append(userId);
326
327 msg.append(StringPool.CLOSE_CURLY_BRACE);
328
329 throw new NoSuchUserIdMapperException(msg.toString());
330 }
331
332
340 @Override
341 public UserIdMapper fetchByUserId_Last(long userId,
342 OrderByComparator orderByComparator) throws SystemException {
343 int count = countByUserId(userId);
344
345 if (count == 0) {
346 return null;
347 }
348
349 List<UserIdMapper> list = findByUserId(userId, count - 1, count,
350 orderByComparator);
351
352 if (!list.isEmpty()) {
353 return list.get(0);
354 }
355
356 return null;
357 }
358
359
369 @Override
370 public UserIdMapper[] findByUserId_PrevAndNext(long userIdMapperId,
371 long userId, OrderByComparator orderByComparator)
372 throws NoSuchUserIdMapperException, SystemException {
373 UserIdMapper userIdMapper = findByPrimaryKey(userIdMapperId);
374
375 Session session = null;
376
377 try {
378 session = openSession();
379
380 UserIdMapper[] array = new UserIdMapperImpl[3];
381
382 array[0] = getByUserId_PrevAndNext(session, userIdMapper, userId,
383 orderByComparator, true);
384
385 array[1] = userIdMapper;
386
387 array[2] = getByUserId_PrevAndNext(session, userIdMapper, userId,
388 orderByComparator, false);
389
390 return array;
391 }
392 catch (Exception e) {
393 throw processException(e);
394 }
395 finally {
396 closeSession(session);
397 }
398 }
399
400 protected UserIdMapper getByUserId_PrevAndNext(Session session,
401 UserIdMapper userIdMapper, long userId,
402 OrderByComparator orderByComparator, boolean previous) {
403 StringBundler query = null;
404
405 if (orderByComparator != null) {
406 query = new StringBundler(6 +
407 (orderByComparator.getOrderByFields().length * 6));
408 }
409 else {
410 query = new StringBundler(3);
411 }
412
413 query.append(_SQL_SELECT_USERIDMAPPER_WHERE);
414
415 query.append(_FINDER_COLUMN_USERID_USERID_2);
416
417 if (orderByComparator != null) {
418 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
419
420 if (orderByConditionFields.length > 0) {
421 query.append(WHERE_AND);
422 }
423
424 for (int i = 0; i < orderByConditionFields.length; i++) {
425 query.append(_ORDER_BY_ENTITY_ALIAS);
426 query.append(orderByConditionFields[i]);
427
428 if ((i + 1) < orderByConditionFields.length) {
429 if (orderByComparator.isAscending() ^ previous) {
430 query.append(WHERE_GREATER_THAN_HAS_NEXT);
431 }
432 else {
433 query.append(WHERE_LESSER_THAN_HAS_NEXT);
434 }
435 }
436 else {
437 if (orderByComparator.isAscending() ^ previous) {
438 query.append(WHERE_GREATER_THAN);
439 }
440 else {
441 query.append(WHERE_LESSER_THAN);
442 }
443 }
444 }
445
446 query.append(ORDER_BY_CLAUSE);
447
448 String[] orderByFields = orderByComparator.getOrderByFields();
449
450 for (int i = 0; i < orderByFields.length; i++) {
451 query.append(_ORDER_BY_ENTITY_ALIAS);
452 query.append(orderByFields[i]);
453
454 if ((i + 1) < orderByFields.length) {
455 if (orderByComparator.isAscending() ^ previous) {
456 query.append(ORDER_BY_ASC_HAS_NEXT);
457 }
458 else {
459 query.append(ORDER_BY_DESC_HAS_NEXT);
460 }
461 }
462 else {
463 if (orderByComparator.isAscending() ^ previous) {
464 query.append(ORDER_BY_ASC);
465 }
466 else {
467 query.append(ORDER_BY_DESC);
468 }
469 }
470 }
471 }
472 else {
473 query.append(UserIdMapperModelImpl.ORDER_BY_JPQL);
474 }
475
476 String sql = query.toString();
477
478 Query q = session.createQuery(sql);
479
480 q.setFirstResult(0);
481 q.setMaxResults(2);
482
483 QueryPos qPos = QueryPos.getInstance(q);
484
485 qPos.add(userId);
486
487 if (orderByComparator != null) {
488 Object[] values = orderByComparator.getOrderByConditionValues(userIdMapper);
489
490 for (Object value : values) {
491 qPos.add(value);
492 }
493 }
494
495 List<UserIdMapper> list = q.list();
496
497 if (list.size() == 2) {
498 return list.get(1);
499 }
500 else {
501 return null;
502 }
503 }
504
505
511 @Override
512 public void removeByUserId(long userId) throws SystemException {
513 for (UserIdMapper userIdMapper : findByUserId(userId,
514 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
515 remove(userIdMapper);
516 }
517 }
518
519
526 @Override
527 public int countByUserId(long userId) throws SystemException {
528 FinderPath finderPath = FINDER_PATH_COUNT_BY_USERID;
529
530 Object[] finderArgs = new Object[] { userId };
531
532 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
533 this);
534
535 if (count == null) {
536 StringBundler query = new StringBundler(2);
537
538 query.append(_SQL_COUNT_USERIDMAPPER_WHERE);
539
540 query.append(_FINDER_COLUMN_USERID_USERID_2);
541
542 String sql = query.toString();
543
544 Session session = null;
545
546 try {
547 session = openSession();
548
549 Query q = session.createQuery(sql);
550
551 QueryPos qPos = QueryPos.getInstance(q);
552
553 qPos.add(userId);
554
555 count = (Long)q.uniqueResult();
556
557 FinderCacheUtil.putResult(finderPath, finderArgs, count);
558 }
559 catch (Exception e) {
560 FinderCacheUtil.removeResult(finderPath, finderArgs);
561
562 throw processException(e);
563 }
564 finally {
565 closeSession(session);
566 }
567 }
568
569 return count.intValue();
570 }
571
572 private static final String _FINDER_COLUMN_USERID_USERID_2 = "userIdMapper.userId = ?";
573 public static final FinderPath FINDER_PATH_FETCH_BY_U_T = new FinderPath(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
574 UserIdMapperModelImpl.FINDER_CACHE_ENABLED, UserIdMapperImpl.class,
575 FINDER_CLASS_NAME_ENTITY, "fetchByU_T",
576 new String[] { Long.class.getName(), String.class.getName() },
577 UserIdMapperModelImpl.USERID_COLUMN_BITMASK |
578 UserIdMapperModelImpl.TYPE_COLUMN_BITMASK);
579 public static final FinderPath FINDER_PATH_COUNT_BY_U_T = new FinderPath(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
580 UserIdMapperModelImpl.FINDER_CACHE_ENABLED, Long.class,
581 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_T",
582 new String[] { Long.class.getName(), String.class.getName() });
583
584
593 @Override
594 public UserIdMapper findByU_T(long userId, String type)
595 throws NoSuchUserIdMapperException, SystemException {
596 UserIdMapper userIdMapper = fetchByU_T(userId, type);
597
598 if (userIdMapper == null) {
599 StringBundler msg = new StringBundler(6);
600
601 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
602
603 msg.append("userId=");
604 msg.append(userId);
605
606 msg.append(", type=");
607 msg.append(type);
608
609 msg.append(StringPool.CLOSE_CURLY_BRACE);
610
611 if (_log.isWarnEnabled()) {
612 _log.warn(msg.toString());
613 }
614
615 throw new NoSuchUserIdMapperException(msg.toString());
616 }
617
618 return userIdMapper;
619 }
620
621
629 @Override
630 public UserIdMapper fetchByU_T(long userId, String type)
631 throws SystemException {
632 return fetchByU_T(userId, type, true);
633 }
634
635
644 @Override
645 public UserIdMapper fetchByU_T(long userId, String type,
646 boolean retrieveFromCache) throws SystemException {
647 Object[] finderArgs = new Object[] { userId, type };
648
649 Object result = null;
650
651 if (retrieveFromCache) {
652 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_U_T,
653 finderArgs, this);
654 }
655
656 if (result instanceof UserIdMapper) {
657 UserIdMapper userIdMapper = (UserIdMapper)result;
658
659 if ((userId != userIdMapper.getUserId()) ||
660 !Validator.equals(type, userIdMapper.getType())) {
661 result = null;
662 }
663 }
664
665 if (result == null) {
666 StringBundler query = new StringBundler(4);
667
668 query.append(_SQL_SELECT_USERIDMAPPER_WHERE);
669
670 query.append(_FINDER_COLUMN_U_T_USERID_2);
671
672 boolean bindType = false;
673
674 if (type == null) {
675 query.append(_FINDER_COLUMN_U_T_TYPE_1);
676 }
677 else if (type.equals(StringPool.BLANK)) {
678 query.append(_FINDER_COLUMN_U_T_TYPE_3);
679 }
680 else {
681 bindType = true;
682
683 query.append(_FINDER_COLUMN_U_T_TYPE_2);
684 }
685
686 String sql = query.toString();
687
688 Session session = null;
689
690 try {
691 session = openSession();
692
693 Query q = session.createQuery(sql);
694
695 QueryPos qPos = QueryPos.getInstance(q);
696
697 qPos.add(userId);
698
699 if (bindType) {
700 qPos.add(type);
701 }
702
703 List<UserIdMapper> list = q.list();
704
705 if (list.isEmpty()) {
706 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_T,
707 finderArgs, list);
708 }
709 else {
710 UserIdMapper userIdMapper = list.get(0);
711
712 result = userIdMapper;
713
714 cacheResult(userIdMapper);
715
716 if ((userIdMapper.getUserId() != userId) ||
717 (userIdMapper.getType() == null) ||
718 !userIdMapper.getType().equals(type)) {
719 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_T,
720 finderArgs, userIdMapper);
721 }
722 }
723 }
724 catch (Exception e) {
725 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_T,
726 finderArgs);
727
728 throw processException(e);
729 }
730 finally {
731 closeSession(session);
732 }
733 }
734
735 if (result instanceof List<?>) {
736 return null;
737 }
738 else {
739 return (UserIdMapper)result;
740 }
741 }
742
743
751 @Override
752 public UserIdMapper removeByU_T(long userId, String type)
753 throws NoSuchUserIdMapperException, SystemException {
754 UserIdMapper userIdMapper = findByU_T(userId, type);
755
756 return remove(userIdMapper);
757 }
758
759
767 @Override
768 public int countByU_T(long userId, String type) throws SystemException {
769 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_T;
770
771 Object[] finderArgs = new Object[] { userId, type };
772
773 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
774 this);
775
776 if (count == null) {
777 StringBundler query = new StringBundler(3);
778
779 query.append(_SQL_COUNT_USERIDMAPPER_WHERE);
780
781 query.append(_FINDER_COLUMN_U_T_USERID_2);
782
783 boolean bindType = false;
784
785 if (type == null) {
786 query.append(_FINDER_COLUMN_U_T_TYPE_1);
787 }
788 else if (type.equals(StringPool.BLANK)) {
789 query.append(_FINDER_COLUMN_U_T_TYPE_3);
790 }
791 else {
792 bindType = true;
793
794 query.append(_FINDER_COLUMN_U_T_TYPE_2);
795 }
796
797 String sql = query.toString();
798
799 Session session = null;
800
801 try {
802 session = openSession();
803
804 Query q = session.createQuery(sql);
805
806 QueryPos qPos = QueryPos.getInstance(q);
807
808 qPos.add(userId);
809
810 if (bindType) {
811 qPos.add(type);
812 }
813
814 count = (Long)q.uniqueResult();
815
816 FinderCacheUtil.putResult(finderPath, finderArgs, count);
817 }
818 catch (Exception e) {
819 FinderCacheUtil.removeResult(finderPath, finderArgs);
820
821 throw processException(e);
822 }
823 finally {
824 closeSession(session);
825 }
826 }
827
828 return count.intValue();
829 }
830
831 private static final String _FINDER_COLUMN_U_T_USERID_2 = "userIdMapper.userId = ? AND ";
832 private static final String _FINDER_COLUMN_U_T_TYPE_1 = "userIdMapper.type IS NULL";
833 private static final String _FINDER_COLUMN_U_T_TYPE_2 = "userIdMapper.type = ?";
834 private static final String _FINDER_COLUMN_U_T_TYPE_3 = "(userIdMapper.type IS NULL OR userIdMapper.type = '')";
835 public static final FinderPath FINDER_PATH_FETCH_BY_T_E = new FinderPath(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
836 UserIdMapperModelImpl.FINDER_CACHE_ENABLED, UserIdMapperImpl.class,
837 FINDER_CLASS_NAME_ENTITY, "fetchByT_E",
838 new String[] { String.class.getName(), String.class.getName() },
839 UserIdMapperModelImpl.TYPE_COLUMN_BITMASK |
840 UserIdMapperModelImpl.EXTERNALUSERID_COLUMN_BITMASK);
841 public static final FinderPath FINDER_PATH_COUNT_BY_T_E = new FinderPath(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
842 UserIdMapperModelImpl.FINDER_CACHE_ENABLED, Long.class,
843 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByT_E",
844 new String[] { String.class.getName(), String.class.getName() });
845
846
855 @Override
856 public UserIdMapper findByT_E(String type, String externalUserId)
857 throws NoSuchUserIdMapperException, SystemException {
858 UserIdMapper userIdMapper = fetchByT_E(type, externalUserId);
859
860 if (userIdMapper == null) {
861 StringBundler msg = new StringBundler(6);
862
863 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
864
865 msg.append("type=");
866 msg.append(type);
867
868 msg.append(", externalUserId=");
869 msg.append(externalUserId);
870
871 msg.append(StringPool.CLOSE_CURLY_BRACE);
872
873 if (_log.isWarnEnabled()) {
874 _log.warn(msg.toString());
875 }
876
877 throw new NoSuchUserIdMapperException(msg.toString());
878 }
879
880 return userIdMapper;
881 }
882
883
891 @Override
892 public UserIdMapper fetchByT_E(String type, String externalUserId)
893 throws SystemException {
894 return fetchByT_E(type, externalUserId, true);
895 }
896
897
906 @Override
907 public UserIdMapper fetchByT_E(String type, String externalUserId,
908 boolean retrieveFromCache) throws SystemException {
909 Object[] finderArgs = new Object[] { type, externalUserId };
910
911 Object result = null;
912
913 if (retrieveFromCache) {
914 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_T_E,
915 finderArgs, this);
916 }
917
918 if (result instanceof UserIdMapper) {
919 UserIdMapper userIdMapper = (UserIdMapper)result;
920
921 if (!Validator.equals(type, userIdMapper.getType()) ||
922 !Validator.equals(externalUserId,
923 userIdMapper.getExternalUserId())) {
924 result = null;
925 }
926 }
927
928 if (result == null) {
929 StringBundler query = new StringBundler(4);
930
931 query.append(_SQL_SELECT_USERIDMAPPER_WHERE);
932
933 boolean bindType = false;
934
935 if (type == null) {
936 query.append(_FINDER_COLUMN_T_E_TYPE_1);
937 }
938 else if (type.equals(StringPool.BLANK)) {
939 query.append(_FINDER_COLUMN_T_E_TYPE_3);
940 }
941 else {
942 bindType = true;
943
944 query.append(_FINDER_COLUMN_T_E_TYPE_2);
945 }
946
947 boolean bindExternalUserId = false;
948
949 if (externalUserId == null) {
950 query.append(_FINDER_COLUMN_T_E_EXTERNALUSERID_1);
951 }
952 else if (externalUserId.equals(StringPool.BLANK)) {
953 query.append(_FINDER_COLUMN_T_E_EXTERNALUSERID_3);
954 }
955 else {
956 bindExternalUserId = true;
957
958 query.append(_FINDER_COLUMN_T_E_EXTERNALUSERID_2);
959 }
960
961 String sql = query.toString();
962
963 Session session = null;
964
965 try {
966 session = openSession();
967
968 Query q = session.createQuery(sql);
969
970 QueryPos qPos = QueryPos.getInstance(q);
971
972 if (bindType) {
973 qPos.add(type);
974 }
975
976 if (bindExternalUserId) {
977 qPos.add(externalUserId);
978 }
979
980 List<UserIdMapper> list = q.list();
981
982 if (list.isEmpty()) {
983 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_T_E,
984 finderArgs, list);
985 }
986 else {
987 UserIdMapper userIdMapper = list.get(0);
988
989 result = userIdMapper;
990
991 cacheResult(userIdMapper);
992
993 if ((userIdMapper.getType() == null) ||
994 !userIdMapper.getType().equals(type) ||
995 (userIdMapper.getExternalUserId() == null) ||
996 !userIdMapper.getExternalUserId()
997 .equals(externalUserId)) {
998 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_T_E,
999 finderArgs, userIdMapper);
1000 }
1001 }
1002 }
1003 catch (Exception e) {
1004 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_T_E,
1005 finderArgs);
1006
1007 throw processException(e);
1008 }
1009 finally {
1010 closeSession(session);
1011 }
1012 }
1013
1014 if (result instanceof List<?>) {
1015 return null;
1016 }
1017 else {
1018 return (UserIdMapper)result;
1019 }
1020 }
1021
1022
1030 @Override
1031 public UserIdMapper removeByT_E(String type, String externalUserId)
1032 throws NoSuchUserIdMapperException, SystemException {
1033 UserIdMapper userIdMapper = findByT_E(type, externalUserId);
1034
1035 return remove(userIdMapper);
1036 }
1037
1038
1046 @Override
1047 public int countByT_E(String type, String externalUserId)
1048 throws SystemException {
1049 FinderPath finderPath = FINDER_PATH_COUNT_BY_T_E;
1050
1051 Object[] finderArgs = new Object[] { type, externalUserId };
1052
1053 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1054 this);
1055
1056 if (count == null) {
1057 StringBundler query = new StringBundler(3);
1058
1059 query.append(_SQL_COUNT_USERIDMAPPER_WHERE);
1060
1061 boolean bindType = false;
1062
1063 if (type == null) {
1064 query.append(_FINDER_COLUMN_T_E_TYPE_1);
1065 }
1066 else if (type.equals(StringPool.BLANK)) {
1067 query.append(_FINDER_COLUMN_T_E_TYPE_3);
1068 }
1069 else {
1070 bindType = true;
1071
1072 query.append(_FINDER_COLUMN_T_E_TYPE_2);
1073 }
1074
1075 boolean bindExternalUserId = false;
1076
1077 if (externalUserId == null) {
1078 query.append(_FINDER_COLUMN_T_E_EXTERNALUSERID_1);
1079 }
1080 else if (externalUserId.equals(StringPool.BLANK)) {
1081 query.append(_FINDER_COLUMN_T_E_EXTERNALUSERID_3);
1082 }
1083 else {
1084 bindExternalUserId = true;
1085
1086 query.append(_FINDER_COLUMN_T_E_EXTERNALUSERID_2);
1087 }
1088
1089 String sql = query.toString();
1090
1091 Session session = null;
1092
1093 try {
1094 session = openSession();
1095
1096 Query q = session.createQuery(sql);
1097
1098 QueryPos qPos = QueryPos.getInstance(q);
1099
1100 if (bindType) {
1101 qPos.add(type);
1102 }
1103
1104 if (bindExternalUserId) {
1105 qPos.add(externalUserId);
1106 }
1107
1108 count = (Long)q.uniqueResult();
1109
1110 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1111 }
1112 catch (Exception e) {
1113 FinderCacheUtil.removeResult(finderPath, finderArgs);
1114
1115 throw processException(e);
1116 }
1117 finally {
1118 closeSession(session);
1119 }
1120 }
1121
1122 return count.intValue();
1123 }
1124
1125 private static final String _FINDER_COLUMN_T_E_TYPE_1 = "userIdMapper.type IS NULL AND ";
1126 private static final String _FINDER_COLUMN_T_E_TYPE_2 = "userIdMapper.type = ? AND ";
1127 private static final String _FINDER_COLUMN_T_E_TYPE_3 = "(userIdMapper.type IS NULL OR userIdMapper.type = '') AND ";
1128 private static final String _FINDER_COLUMN_T_E_EXTERNALUSERID_1 = "userIdMapper.externalUserId IS NULL";
1129 private static final String _FINDER_COLUMN_T_E_EXTERNALUSERID_2 = "userIdMapper.externalUserId = ?";
1130 private static final String _FINDER_COLUMN_T_E_EXTERNALUSERID_3 = "(userIdMapper.externalUserId IS NULL OR userIdMapper.externalUserId = '')";
1131
1132
1137 @Override
1138 public void cacheResult(UserIdMapper userIdMapper) {
1139 EntityCacheUtil.putResult(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
1140 UserIdMapperImpl.class, userIdMapper.getPrimaryKey(), userIdMapper);
1141
1142 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_T,
1143 new Object[] { userIdMapper.getUserId(), userIdMapper.getType() },
1144 userIdMapper);
1145
1146 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_T_E,
1147 new Object[] {
1148 userIdMapper.getType(), userIdMapper.getExternalUserId()
1149 }, userIdMapper);
1150
1151 userIdMapper.resetOriginalValues();
1152 }
1153
1154
1159 @Override
1160 public void cacheResult(List<UserIdMapper> userIdMappers) {
1161 for (UserIdMapper userIdMapper : userIdMappers) {
1162 if (EntityCacheUtil.getResult(
1163 UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
1164 UserIdMapperImpl.class, userIdMapper.getPrimaryKey()) == null) {
1165 cacheResult(userIdMapper);
1166 }
1167 else {
1168 userIdMapper.resetOriginalValues();
1169 }
1170 }
1171 }
1172
1173
1180 @Override
1181 public void clearCache() {
1182 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
1183 CacheRegistryUtil.clear(UserIdMapperImpl.class.getName());
1184 }
1185
1186 EntityCacheUtil.clearCache(UserIdMapperImpl.class.getName());
1187
1188 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
1189 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1190 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1191 }
1192
1193
1200 @Override
1201 public void clearCache(UserIdMapper userIdMapper) {
1202 EntityCacheUtil.removeResult(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
1203 UserIdMapperImpl.class, userIdMapper.getPrimaryKey());
1204
1205 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1206 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1207
1208 clearUniqueFindersCache(userIdMapper);
1209 }
1210
1211 @Override
1212 public void clearCache(List<UserIdMapper> userIdMappers) {
1213 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1214 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1215
1216 for (UserIdMapper userIdMapper : userIdMappers) {
1217 EntityCacheUtil.removeResult(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
1218 UserIdMapperImpl.class, userIdMapper.getPrimaryKey());
1219
1220 clearUniqueFindersCache(userIdMapper);
1221 }
1222 }
1223
1224 protected void cacheUniqueFindersCache(UserIdMapper userIdMapper) {
1225 if (userIdMapper.isNew()) {
1226 Object[] args = new Object[] {
1227 userIdMapper.getUserId(), userIdMapper.getType()
1228 };
1229
1230 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_T, args,
1231 Long.valueOf(1));
1232 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_T, args,
1233 userIdMapper);
1234
1235 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 else {
1245 UserIdMapperModelImpl userIdMapperModelImpl = (UserIdMapperModelImpl)userIdMapper;
1246
1247 if ((userIdMapperModelImpl.getColumnBitmask() &
1248 FINDER_PATH_FETCH_BY_U_T.getColumnBitmask()) != 0) {
1249 Object[] args = new Object[] {
1250 userIdMapper.getUserId(), userIdMapper.getType()
1251 };
1252
1253 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_T, args,
1254 Long.valueOf(1));
1255 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_T, args,
1256 userIdMapper);
1257 }
1258
1259 if ((userIdMapperModelImpl.getColumnBitmask() &
1260 FINDER_PATH_FETCH_BY_T_E.getColumnBitmask()) != 0) {
1261 Object[] args = new Object[] {
1262 userIdMapper.getType(), userIdMapper.getExternalUserId()
1263 };
1264
1265 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_E, args,
1266 Long.valueOf(1));
1267 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_T_E, args,
1268 userIdMapper);
1269 }
1270 }
1271 }
1272
1273 protected void clearUniqueFindersCache(UserIdMapper userIdMapper) {
1274 UserIdMapperModelImpl userIdMapperModelImpl = (UserIdMapperModelImpl)userIdMapper;
1275
1276 Object[] args = new Object[] {
1277 userIdMapper.getUserId(), userIdMapper.getType()
1278 };
1279
1280 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_T, args);
1281 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_T, args);
1282
1283 if ((userIdMapperModelImpl.getColumnBitmask() &
1284 FINDER_PATH_FETCH_BY_U_T.getColumnBitmask()) != 0) {
1285 args = new Object[] {
1286 userIdMapperModelImpl.getOriginalUserId(),
1287 userIdMapperModelImpl.getOriginalType()
1288 };
1289
1290 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_T, args);
1291 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_T, args);
1292 }
1293
1294 args = new Object[] {
1295 userIdMapper.getType(), userIdMapper.getExternalUserId()
1296 };
1297
1298 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_E, args);
1299 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_T_E, args);
1300
1301 if ((userIdMapperModelImpl.getColumnBitmask() &
1302 FINDER_PATH_FETCH_BY_T_E.getColumnBitmask()) != 0) {
1303 args = new Object[] {
1304 userIdMapperModelImpl.getOriginalType(),
1305 userIdMapperModelImpl.getOriginalExternalUserId()
1306 };
1307
1308 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_E, args);
1309 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_T_E, args);
1310 }
1311 }
1312
1313
1319 @Override
1320 public UserIdMapper create(long userIdMapperId) {
1321 UserIdMapper userIdMapper = new UserIdMapperImpl();
1322
1323 userIdMapper.setNew(true);
1324 userIdMapper.setPrimaryKey(userIdMapperId);
1325
1326 return userIdMapper;
1327 }
1328
1329
1337 @Override
1338 public UserIdMapper remove(long userIdMapperId)
1339 throws NoSuchUserIdMapperException, SystemException {
1340 return remove((Serializable)userIdMapperId);
1341 }
1342
1343
1351 @Override
1352 public UserIdMapper remove(Serializable primaryKey)
1353 throws NoSuchUserIdMapperException, SystemException {
1354 Session session = null;
1355
1356 try {
1357 session = openSession();
1358
1359 UserIdMapper userIdMapper = (UserIdMapper)session.get(UserIdMapperImpl.class,
1360 primaryKey);
1361
1362 if (userIdMapper == null) {
1363 if (_log.isWarnEnabled()) {
1364 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
1365 }
1366
1367 throw new NoSuchUserIdMapperException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1368 primaryKey);
1369 }
1370
1371 return remove(userIdMapper);
1372 }
1373 catch (NoSuchUserIdMapperException nsee) {
1374 throw nsee;
1375 }
1376 catch (Exception e) {
1377 throw processException(e);
1378 }
1379 finally {
1380 closeSession(session);
1381 }
1382 }
1383
1384 @Override
1385 protected UserIdMapper removeImpl(UserIdMapper userIdMapper)
1386 throws SystemException {
1387 userIdMapper = toUnwrappedModel(userIdMapper);
1388
1389 Session session = null;
1390
1391 try {
1392 session = openSession();
1393
1394 if (!session.contains(userIdMapper)) {
1395 userIdMapper = (UserIdMapper)session.get(UserIdMapperImpl.class,
1396 userIdMapper.getPrimaryKeyObj());
1397 }
1398
1399 if (userIdMapper != null) {
1400 session.delete(userIdMapper);
1401 }
1402 }
1403 catch (Exception e) {
1404 throw processException(e);
1405 }
1406 finally {
1407 closeSession(session);
1408 }
1409
1410 if (userIdMapper != null) {
1411 clearCache(userIdMapper);
1412 }
1413
1414 return userIdMapper;
1415 }
1416
1417 @Override
1418 public UserIdMapper updateImpl(
1419 com.liferay.portal.model.UserIdMapper userIdMapper)
1420 throws SystemException {
1421 userIdMapper = toUnwrappedModel(userIdMapper);
1422
1423 boolean isNew = userIdMapper.isNew();
1424
1425 UserIdMapperModelImpl userIdMapperModelImpl = (UserIdMapperModelImpl)userIdMapper;
1426
1427 Session session = null;
1428
1429 try {
1430 session = openSession();
1431
1432 if (userIdMapper.isNew()) {
1433 session.save(userIdMapper);
1434
1435 userIdMapper.setNew(false);
1436 }
1437 else {
1438 session.merge(userIdMapper);
1439 }
1440 }
1441 catch (Exception e) {
1442 throw processException(e);
1443 }
1444 finally {
1445 closeSession(session);
1446 }
1447
1448 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1449
1450 if (isNew || !UserIdMapperModelImpl.COLUMN_BITMASK_ENABLED) {
1451 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1452 }
1453
1454 else {
1455 if ((userIdMapperModelImpl.getColumnBitmask() &
1456 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
1457 Object[] args = new Object[] {
1458 userIdMapperModelImpl.getOriginalUserId()
1459 };
1460
1461 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
1462 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
1463 args);
1464
1465 args = new Object[] { userIdMapperModelImpl.getUserId() };
1466
1467 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
1468 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
1469 args);
1470 }
1471 }
1472
1473 EntityCacheUtil.putResult(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
1474 UserIdMapperImpl.class, userIdMapper.getPrimaryKey(), userIdMapper);
1475
1476 clearUniqueFindersCache(userIdMapper);
1477 cacheUniqueFindersCache(userIdMapper);
1478
1479 return userIdMapper;
1480 }
1481
1482 protected UserIdMapper toUnwrappedModel(UserIdMapper userIdMapper) {
1483 if (userIdMapper instanceof UserIdMapperImpl) {
1484 return userIdMapper;
1485 }
1486
1487 UserIdMapperImpl userIdMapperImpl = new UserIdMapperImpl();
1488
1489 userIdMapperImpl.setNew(userIdMapper.isNew());
1490 userIdMapperImpl.setPrimaryKey(userIdMapper.getPrimaryKey());
1491
1492 userIdMapperImpl.setUserIdMapperId(userIdMapper.getUserIdMapperId());
1493 userIdMapperImpl.setUserId(userIdMapper.getUserId());
1494 userIdMapperImpl.setType(userIdMapper.getType());
1495 userIdMapperImpl.setDescription(userIdMapper.getDescription());
1496 userIdMapperImpl.setExternalUserId(userIdMapper.getExternalUserId());
1497
1498 return userIdMapperImpl;
1499 }
1500
1501
1509 @Override
1510 public UserIdMapper findByPrimaryKey(Serializable primaryKey)
1511 throws NoSuchUserIdMapperException, SystemException {
1512 UserIdMapper userIdMapper = fetchByPrimaryKey(primaryKey);
1513
1514 if (userIdMapper == null) {
1515 if (_log.isWarnEnabled()) {
1516 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
1517 }
1518
1519 throw new NoSuchUserIdMapperException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1520 primaryKey);
1521 }
1522
1523 return userIdMapper;
1524 }
1525
1526
1534 @Override
1535 public UserIdMapper findByPrimaryKey(long userIdMapperId)
1536 throws NoSuchUserIdMapperException, SystemException {
1537 return findByPrimaryKey((Serializable)userIdMapperId);
1538 }
1539
1540
1547 @Override
1548 public UserIdMapper fetchByPrimaryKey(Serializable primaryKey)
1549 throws SystemException {
1550 UserIdMapper userIdMapper = (UserIdMapper)EntityCacheUtil.getResult(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
1551 UserIdMapperImpl.class, primaryKey);
1552
1553 if (userIdMapper == _nullUserIdMapper) {
1554 return null;
1555 }
1556
1557 if (userIdMapper == null) {
1558 Session session = null;
1559
1560 try {
1561 session = openSession();
1562
1563 userIdMapper = (UserIdMapper)session.get(UserIdMapperImpl.class,
1564 primaryKey);
1565
1566 if (userIdMapper != null) {
1567 cacheResult(userIdMapper);
1568 }
1569 else {
1570 EntityCacheUtil.putResult(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
1571 UserIdMapperImpl.class, primaryKey, _nullUserIdMapper);
1572 }
1573 }
1574 catch (Exception e) {
1575 EntityCacheUtil.removeResult(UserIdMapperModelImpl.ENTITY_CACHE_ENABLED,
1576 UserIdMapperImpl.class, primaryKey);
1577
1578 throw processException(e);
1579 }
1580 finally {
1581 closeSession(session);
1582 }
1583 }
1584
1585 return userIdMapper;
1586 }
1587
1588
1595 @Override
1596 public UserIdMapper fetchByPrimaryKey(long userIdMapperId)
1597 throws SystemException {
1598 return fetchByPrimaryKey((Serializable)userIdMapperId);
1599 }
1600
1601
1607 @Override
1608 public List<UserIdMapper> findAll() throws SystemException {
1609 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1610 }
1611
1612
1624 @Override
1625 public List<UserIdMapper> findAll(int start, int end)
1626 throws SystemException {
1627 return findAll(start, end, null);
1628 }
1629
1630
1643 @Override
1644 public List<UserIdMapper> findAll(int start, int end,
1645 OrderByComparator orderByComparator) throws SystemException {
1646 boolean pagination = true;
1647 FinderPath finderPath = null;
1648 Object[] finderArgs = null;
1649
1650 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1651 (orderByComparator == null)) {
1652 pagination = false;
1653 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1654 finderArgs = FINDER_ARGS_EMPTY;
1655 }
1656 else {
1657 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1658 finderArgs = new Object[] { start, end, orderByComparator };
1659 }
1660
1661 List<UserIdMapper> list = (List<UserIdMapper>)FinderCacheUtil.getResult(finderPath,
1662 finderArgs, this);
1663
1664 if (list == null) {
1665 StringBundler query = null;
1666 String sql = null;
1667
1668 if (orderByComparator != null) {
1669 query = new StringBundler(2 +
1670 (orderByComparator.getOrderByFields().length * 3));
1671
1672 query.append(_SQL_SELECT_USERIDMAPPER);
1673
1674 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1675 orderByComparator);
1676
1677 sql = query.toString();
1678 }
1679 else {
1680 sql = _SQL_SELECT_USERIDMAPPER;
1681
1682 if (pagination) {
1683 sql = sql.concat(UserIdMapperModelImpl.ORDER_BY_JPQL);
1684 }
1685 }
1686
1687 Session session = null;
1688
1689 try {
1690 session = openSession();
1691
1692 Query q = session.createQuery(sql);
1693
1694 if (!pagination) {
1695 list = (List<UserIdMapper>)QueryUtil.list(q, getDialect(),
1696 start, end, false);
1697
1698 Collections.sort(list);
1699
1700 list = new UnmodifiableList<UserIdMapper>(list);
1701 }
1702 else {
1703 list = (List<UserIdMapper>)QueryUtil.list(q, getDialect(),
1704 start, end);
1705 }
1706
1707 cacheResult(list);
1708
1709 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1710 }
1711 catch (Exception e) {
1712 FinderCacheUtil.removeResult(finderPath, finderArgs);
1713
1714 throw processException(e);
1715 }
1716 finally {
1717 closeSession(session);
1718 }
1719 }
1720
1721 return list;
1722 }
1723
1724
1729 @Override
1730 public void removeAll() throws SystemException {
1731 for (UserIdMapper userIdMapper : findAll()) {
1732 remove(userIdMapper);
1733 }
1734 }
1735
1736
1742 @Override
1743 public int countAll() throws SystemException {
1744 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1745 FINDER_ARGS_EMPTY, this);
1746
1747 if (count == null) {
1748 Session session = null;
1749
1750 try {
1751 session = openSession();
1752
1753 Query q = session.createQuery(_SQL_COUNT_USERIDMAPPER);
1754
1755 count = (Long)q.uniqueResult();
1756
1757 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1758 FINDER_ARGS_EMPTY, count);
1759 }
1760 catch (Exception e) {
1761 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
1762 FINDER_ARGS_EMPTY);
1763
1764 throw processException(e);
1765 }
1766 finally {
1767 closeSession(session);
1768 }
1769 }
1770
1771 return count.intValue();
1772 }
1773
1774 @Override
1775 protected Set<String> getBadColumnNames() {
1776 return _badColumnNames;
1777 }
1778
1779
1782 public void afterPropertiesSet() {
1783 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1784 com.liferay.portal.util.PropsUtil.get(
1785 "value.object.listener.com.liferay.portal.model.UserIdMapper")));
1786
1787 if (listenerClassNames.length > 0) {
1788 try {
1789 List<ModelListener<UserIdMapper>> listenersList = new ArrayList<ModelListener<UserIdMapper>>();
1790
1791 for (String listenerClassName : listenerClassNames) {
1792 listenersList.add((ModelListener<UserIdMapper>)InstanceFactory.newInstance(
1793 getClassLoader(), listenerClassName));
1794 }
1795
1796 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1797 }
1798 catch (Exception e) {
1799 _log.error(e);
1800 }
1801 }
1802 }
1803
1804 public void destroy() {
1805 EntityCacheUtil.removeCache(UserIdMapperImpl.class.getName());
1806 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1807 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1808 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1809 }
1810
1811 private static final String _SQL_SELECT_USERIDMAPPER = "SELECT userIdMapper FROM UserIdMapper userIdMapper";
1812 private static final String _SQL_SELECT_USERIDMAPPER_WHERE = "SELECT userIdMapper FROM UserIdMapper userIdMapper WHERE ";
1813 private static final String _SQL_COUNT_USERIDMAPPER = "SELECT COUNT(userIdMapper) FROM UserIdMapper userIdMapper";
1814 private static final String _SQL_COUNT_USERIDMAPPER_WHERE = "SELECT COUNT(userIdMapper) FROM UserIdMapper userIdMapper WHERE ";
1815 private static final String _ORDER_BY_ENTITY_ALIAS = "userIdMapper.";
1816 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserIdMapper exists with the primary key ";
1817 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserIdMapper exists with the key {";
1818 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1819 private static Log _log = LogFactoryUtil.getLog(UserIdMapperPersistenceImpl.class);
1820 private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
1821 "type"
1822 });
1823 private static UserIdMapper _nullUserIdMapper = new UserIdMapperImpl() {
1824 @Override
1825 public Object clone() {
1826 return this;
1827 }
1828
1829 @Override
1830 public CacheModel<UserIdMapper> toCacheModel() {
1831 return _nullUserIdMapperCacheModel;
1832 }
1833 };
1834
1835 private static CacheModel<UserIdMapper> _nullUserIdMapperCacheModel = new CacheModel<UserIdMapper>() {
1836 @Override
1837 public UserIdMapper toEntityModel() {
1838 return _nullUserIdMapper;
1839 }
1840 };
1841 }