001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.NoSuchUserException;
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
022 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
023 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
024 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
025 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
026 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
027 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
028 import com.liferay.portal.kernel.dao.orm.FinderPath;
029 import com.liferay.portal.kernel.dao.orm.Query;
030 import com.liferay.portal.kernel.dao.orm.QueryPos;
031 import com.liferay.portal.kernel.dao.orm.QueryUtil;
032 import com.liferay.portal.kernel.dao.orm.SQLQuery;
033 import com.liferay.portal.kernel.dao.orm.Session;
034 import com.liferay.portal.kernel.exception.SystemException;
035 import com.liferay.portal.kernel.log.Log;
036 import com.liferay.portal.kernel.log.LogFactoryUtil;
037 import com.liferay.portal.kernel.util.CalendarUtil;
038 import com.liferay.portal.kernel.util.GetterUtil;
039 import com.liferay.portal.kernel.util.InstanceFactory;
040 import com.liferay.portal.kernel.util.OrderByComparator;
041 import com.liferay.portal.kernel.util.SetUtil;
042 import com.liferay.portal.kernel.util.StringBundler;
043 import com.liferay.portal.kernel.util.StringPool;
044 import com.liferay.portal.kernel.util.StringUtil;
045 import com.liferay.portal.kernel.util.UnmodifiableList;
046 import com.liferay.portal.kernel.util.Validator;
047 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
048 import com.liferay.portal.model.CacheModel;
049 import com.liferay.portal.model.ModelListener;
050 import com.liferay.portal.model.User;
051 import com.liferay.portal.model.impl.UserImpl;
052 import com.liferay.portal.model.impl.UserModelImpl;
053 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
054
055 import java.io.Serializable;
056
057 import java.util.ArrayList;
058 import java.util.Collections;
059 import java.util.Date;
060 import java.util.List;
061 import java.util.Set;
062
063
075 public class UserPersistenceImpl extends BasePersistenceImpl<User>
076 implements UserPersistence {
077
082 public static final String FINDER_CLASS_NAME_ENTITY = UserImpl.class.getName();
083 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
084 ".List1";
085 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
086 ".List2";
087 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
088 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
089 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
090 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
091 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
092 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
093 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
094 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
095 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
096 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
097 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
098 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
099 new String[] {
100 String.class.getName(),
101
102 Integer.class.getName(), Integer.class.getName(),
103 OrderByComparator.class.getName()
104 });
105 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
106 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
107 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
108 new String[] { String.class.getName() },
109 UserModelImpl.UUID_COLUMN_BITMASK);
110 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
111 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
112 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
113 new String[] { String.class.getName() });
114
115
122 public List<User> findByUuid(String uuid) throws SystemException {
123 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
124 }
125
126
139 public List<User> findByUuid(String uuid, int start, int end)
140 throws SystemException {
141 return findByUuid(uuid, start, end, null);
142 }
143
144
158 public List<User> findByUuid(String uuid, int start, int end,
159 OrderByComparator orderByComparator) throws SystemException {
160 boolean pagination = true;
161 FinderPath finderPath = null;
162 Object[] finderArgs = null;
163
164 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
165 (orderByComparator == null)) {
166 pagination = false;
167 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
168 finderArgs = new Object[] { uuid };
169 }
170 else {
171 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
172 finderArgs = new Object[] { uuid, start, end, orderByComparator };
173 }
174
175 List<User> list = (List<User>)FinderCacheUtil.getResult(finderPath,
176 finderArgs, this);
177
178 if ((list != null) && !list.isEmpty()) {
179 for (User user : list) {
180 if (!Validator.equals(uuid, user.getUuid())) {
181 list = null;
182
183 break;
184 }
185 }
186 }
187
188 if (list == null) {
189 StringBundler query = null;
190
191 if (orderByComparator != null) {
192 query = new StringBundler(3 +
193 (orderByComparator.getOrderByFields().length * 3));
194 }
195 else {
196 query = new StringBundler(3);
197 }
198
199 query.append(_SQL_SELECT_USER_WHERE);
200
201 if (uuid == null) {
202 query.append(_FINDER_COLUMN_UUID_UUID_1);
203 }
204 else {
205 if (uuid.equals(StringPool.BLANK)) {
206 query.append(_FINDER_COLUMN_UUID_UUID_3);
207 }
208 else {
209 query.append(_FINDER_COLUMN_UUID_UUID_2);
210 }
211 }
212
213 if (orderByComparator != null) {
214 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
215 orderByComparator);
216 }
217 else
218 if (pagination) {
219 query.append(UserModelImpl.ORDER_BY_JPQL);
220 }
221
222 String sql = query.toString();
223
224 Session session = null;
225
226 try {
227 session = openSession();
228
229 Query q = session.createQuery(sql);
230
231 QueryPos qPos = QueryPos.getInstance(q);
232
233 if (uuid != null) {
234 qPos.add(uuid);
235 }
236
237 if (!pagination) {
238 list = (List<User>)QueryUtil.list(q, getDialect(), start,
239 end, false);
240
241 Collections.sort(list);
242
243 list = new UnmodifiableList<User>(list);
244 }
245 else {
246 list = (List<User>)QueryUtil.list(q, getDialect(), start,
247 end);
248 }
249
250 cacheResult(list);
251
252 FinderCacheUtil.putResult(finderPath, finderArgs, list);
253 }
254 catch (Exception e) {
255 FinderCacheUtil.removeResult(finderPath, finderArgs);
256
257 throw processException(e);
258 }
259 finally {
260 closeSession(session);
261 }
262 }
263
264 return list;
265 }
266
267
276 public User findByUuid_First(String uuid,
277 OrderByComparator orderByComparator)
278 throws NoSuchUserException, SystemException {
279 User user = fetchByUuid_First(uuid, orderByComparator);
280
281 if (user != null) {
282 return user;
283 }
284
285 StringBundler msg = new StringBundler(4);
286
287 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
288
289 msg.append("uuid=");
290 msg.append(uuid);
291
292 msg.append(StringPool.CLOSE_CURLY_BRACE);
293
294 throw new NoSuchUserException(msg.toString());
295 }
296
297
305 public User fetchByUuid_First(String uuid,
306 OrderByComparator orderByComparator) throws SystemException {
307 List<User> list = findByUuid(uuid, 0, 1, orderByComparator);
308
309 if (!list.isEmpty()) {
310 return list.get(0);
311 }
312
313 return null;
314 }
315
316
325 public User findByUuid_Last(String uuid, OrderByComparator orderByComparator)
326 throws NoSuchUserException, SystemException {
327 User user = fetchByUuid_Last(uuid, orderByComparator);
328
329 if (user != null) {
330 return user;
331 }
332
333 StringBundler msg = new StringBundler(4);
334
335 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
336
337 msg.append("uuid=");
338 msg.append(uuid);
339
340 msg.append(StringPool.CLOSE_CURLY_BRACE);
341
342 throw new NoSuchUserException(msg.toString());
343 }
344
345
353 public User fetchByUuid_Last(String uuid,
354 OrderByComparator orderByComparator) throws SystemException {
355 int count = countByUuid(uuid);
356
357 List<User> list = findByUuid(uuid, count - 1, count, orderByComparator);
358
359 if (!list.isEmpty()) {
360 return list.get(0);
361 }
362
363 return null;
364 }
365
366
376 public User[] findByUuid_PrevAndNext(long userId, String uuid,
377 OrderByComparator orderByComparator)
378 throws NoSuchUserException, SystemException {
379 User user = findByPrimaryKey(userId);
380
381 Session session = null;
382
383 try {
384 session = openSession();
385
386 User[] array = new UserImpl[3];
387
388 array[0] = getByUuid_PrevAndNext(session, user, uuid,
389 orderByComparator, true);
390
391 array[1] = user;
392
393 array[2] = getByUuid_PrevAndNext(session, user, uuid,
394 orderByComparator, false);
395
396 return array;
397 }
398 catch (Exception e) {
399 throw processException(e);
400 }
401 finally {
402 closeSession(session);
403 }
404 }
405
406 protected User getByUuid_PrevAndNext(Session session, User user,
407 String uuid, OrderByComparator orderByComparator, boolean previous) {
408 StringBundler query = null;
409
410 if (orderByComparator != null) {
411 query = new StringBundler(6 +
412 (orderByComparator.getOrderByFields().length * 6));
413 }
414 else {
415 query = new StringBundler(3);
416 }
417
418 query.append(_SQL_SELECT_USER_WHERE);
419
420 if (uuid == null) {
421 query.append(_FINDER_COLUMN_UUID_UUID_1);
422 }
423 else {
424 if (uuid.equals(StringPool.BLANK)) {
425 query.append(_FINDER_COLUMN_UUID_UUID_3);
426 }
427 else {
428 query.append(_FINDER_COLUMN_UUID_UUID_2);
429 }
430 }
431
432 if (orderByComparator != null) {
433 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
434
435 if (orderByConditionFields.length > 0) {
436 query.append(WHERE_AND);
437 }
438
439 for (int i = 0; i < orderByConditionFields.length; i++) {
440 query.append(_ORDER_BY_ENTITY_ALIAS);
441 query.append(orderByConditionFields[i]);
442
443 if ((i + 1) < orderByConditionFields.length) {
444 if (orderByComparator.isAscending() ^ previous) {
445 query.append(WHERE_GREATER_THAN_HAS_NEXT);
446 }
447 else {
448 query.append(WHERE_LESSER_THAN_HAS_NEXT);
449 }
450 }
451 else {
452 if (orderByComparator.isAscending() ^ previous) {
453 query.append(WHERE_GREATER_THAN);
454 }
455 else {
456 query.append(WHERE_LESSER_THAN);
457 }
458 }
459 }
460
461 query.append(ORDER_BY_CLAUSE);
462
463 String[] orderByFields = orderByComparator.getOrderByFields();
464
465 for (int i = 0; i < orderByFields.length; i++) {
466 query.append(_ORDER_BY_ENTITY_ALIAS);
467 query.append(orderByFields[i]);
468
469 if ((i + 1) < orderByFields.length) {
470 if (orderByComparator.isAscending() ^ previous) {
471 query.append(ORDER_BY_ASC_HAS_NEXT);
472 }
473 else {
474 query.append(ORDER_BY_DESC_HAS_NEXT);
475 }
476 }
477 else {
478 if (orderByComparator.isAscending() ^ previous) {
479 query.append(ORDER_BY_ASC);
480 }
481 else {
482 query.append(ORDER_BY_DESC);
483 }
484 }
485 }
486 }
487 else {
488 query.append(UserModelImpl.ORDER_BY_JPQL);
489 }
490
491 String sql = query.toString();
492
493 Query q = session.createQuery(sql);
494
495 q.setFirstResult(0);
496 q.setMaxResults(2);
497
498 QueryPos qPos = QueryPos.getInstance(q);
499
500 if (uuid != null) {
501 qPos.add(uuid);
502 }
503
504 if (orderByComparator != null) {
505 Object[] values = orderByComparator.getOrderByConditionValues(user);
506
507 for (Object value : values) {
508 qPos.add(value);
509 }
510 }
511
512 List<User> list = q.list();
513
514 if (list.size() == 2) {
515 return list.get(1);
516 }
517 else {
518 return null;
519 }
520 }
521
522
528 public void removeByUuid(String uuid) throws SystemException {
529 for (User user : findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
530 null)) {
531 remove(user);
532 }
533 }
534
535
542 public int countByUuid(String uuid) throws SystemException {
543 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
544
545 Object[] finderArgs = new Object[] { uuid };
546
547 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
548 this);
549
550 if (count == null) {
551 StringBundler query = new StringBundler(2);
552
553 query.append(_SQL_COUNT_USER_WHERE);
554
555 if (uuid == null) {
556 query.append(_FINDER_COLUMN_UUID_UUID_1);
557 }
558 else {
559 if (uuid.equals(StringPool.BLANK)) {
560 query.append(_FINDER_COLUMN_UUID_UUID_3);
561 }
562 else {
563 query.append(_FINDER_COLUMN_UUID_UUID_2);
564 }
565 }
566
567 String sql = query.toString();
568
569 Session session = null;
570
571 try {
572 session = openSession();
573
574 Query q = session.createQuery(sql);
575
576 QueryPos qPos = QueryPos.getInstance(q);
577
578 if (uuid != null) {
579 qPos.add(uuid);
580 }
581
582 count = (Long)q.uniqueResult();
583
584 FinderCacheUtil.putResult(finderPath, finderArgs, count);
585 }
586 catch (Exception e) {
587 FinderCacheUtil.removeResult(finderPath, finderArgs);
588
589 throw processException(e);
590 }
591 finally {
592 closeSession(session);
593 }
594 }
595
596 return count.intValue();
597 }
598
599 private static final String _FINDER_COLUMN_UUID_UUID_1 = "user.uuid IS NULL";
600 private static final String _FINDER_COLUMN_UUID_UUID_2 = "user.uuid = ?";
601 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(user.uuid IS NULL OR user.uuid = ?)";
602 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
603 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
604 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
605 new String[] {
606 String.class.getName(), Long.class.getName(),
607
608 Integer.class.getName(), Integer.class.getName(),
609 OrderByComparator.class.getName()
610 });
611 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
612 new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
613 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
614 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
615 new String[] { String.class.getName(), Long.class.getName() },
616 UserModelImpl.UUID_COLUMN_BITMASK |
617 UserModelImpl.COMPANYID_COLUMN_BITMASK);
618 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
619 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
620 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
621 new String[] { String.class.getName(), Long.class.getName() });
622
623
631 public List<User> findByUuid_C(String uuid, long companyId)
632 throws SystemException {
633 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
634 QueryUtil.ALL_POS, null);
635 }
636
637
651 public List<User> findByUuid_C(String uuid, long companyId, int start,
652 int end) throws SystemException {
653 return findByUuid_C(uuid, companyId, start, end, null);
654 }
655
656
671 public List<User> findByUuid_C(String uuid, long companyId, int start,
672 int end, OrderByComparator orderByComparator) throws SystemException {
673 boolean pagination = true;
674 FinderPath finderPath = null;
675 Object[] finderArgs = null;
676
677 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
678 (orderByComparator == null)) {
679 pagination = false;
680 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
681 finderArgs = new Object[] { uuid, companyId };
682 }
683 else {
684 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
685 finderArgs = new Object[] {
686 uuid, companyId,
687
688 start, end, orderByComparator
689 };
690 }
691
692 List<User> list = (List<User>)FinderCacheUtil.getResult(finderPath,
693 finderArgs, this);
694
695 if ((list != null) && !list.isEmpty()) {
696 for (User user : list) {
697 if (!Validator.equals(uuid, user.getUuid()) ||
698 (companyId != user.getCompanyId())) {
699 list = null;
700
701 break;
702 }
703 }
704 }
705
706 if (list == null) {
707 StringBundler query = null;
708
709 if (orderByComparator != null) {
710 query = new StringBundler(4 +
711 (orderByComparator.getOrderByFields().length * 3));
712 }
713 else {
714 query = new StringBundler(4);
715 }
716
717 query.append(_SQL_SELECT_USER_WHERE);
718
719 if (uuid == null) {
720 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
721 }
722 else {
723 if (uuid.equals(StringPool.BLANK)) {
724 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
725 }
726 else {
727 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
728 }
729 }
730
731 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
732
733 if (orderByComparator != null) {
734 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
735 orderByComparator);
736 }
737 else
738 if (pagination) {
739 query.append(UserModelImpl.ORDER_BY_JPQL);
740 }
741
742 String sql = query.toString();
743
744 Session session = null;
745
746 try {
747 session = openSession();
748
749 Query q = session.createQuery(sql);
750
751 QueryPos qPos = QueryPos.getInstance(q);
752
753 if (uuid != null) {
754 qPos.add(uuid);
755 }
756
757 qPos.add(companyId);
758
759 if (!pagination) {
760 list = (List<User>)QueryUtil.list(q, getDialect(), start,
761 end, false);
762
763 Collections.sort(list);
764
765 list = new UnmodifiableList<User>(list);
766 }
767 else {
768 list = (List<User>)QueryUtil.list(q, getDialect(), start,
769 end);
770 }
771
772 cacheResult(list);
773
774 FinderCacheUtil.putResult(finderPath, finderArgs, list);
775 }
776 catch (Exception e) {
777 FinderCacheUtil.removeResult(finderPath, finderArgs);
778
779 throw processException(e);
780 }
781 finally {
782 closeSession(session);
783 }
784 }
785
786 return list;
787 }
788
789
799 public User findByUuid_C_First(String uuid, long companyId,
800 OrderByComparator orderByComparator)
801 throws NoSuchUserException, SystemException {
802 User user = fetchByUuid_C_First(uuid, companyId, orderByComparator);
803
804 if (user != null) {
805 return user;
806 }
807
808 StringBundler msg = new StringBundler(6);
809
810 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
811
812 msg.append("uuid=");
813 msg.append(uuid);
814
815 msg.append(", companyId=");
816 msg.append(companyId);
817
818 msg.append(StringPool.CLOSE_CURLY_BRACE);
819
820 throw new NoSuchUserException(msg.toString());
821 }
822
823
832 public User fetchByUuid_C_First(String uuid, long companyId,
833 OrderByComparator orderByComparator) throws SystemException {
834 List<User> list = findByUuid_C(uuid, companyId, 0, 1, orderByComparator);
835
836 if (!list.isEmpty()) {
837 return list.get(0);
838 }
839
840 return null;
841 }
842
843
853 public User findByUuid_C_Last(String uuid, long companyId,
854 OrderByComparator orderByComparator)
855 throws NoSuchUserException, SystemException {
856 User user = fetchByUuid_C_Last(uuid, companyId, orderByComparator);
857
858 if (user != null) {
859 return user;
860 }
861
862 StringBundler msg = new StringBundler(6);
863
864 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
865
866 msg.append("uuid=");
867 msg.append(uuid);
868
869 msg.append(", companyId=");
870 msg.append(companyId);
871
872 msg.append(StringPool.CLOSE_CURLY_BRACE);
873
874 throw new NoSuchUserException(msg.toString());
875 }
876
877
886 public User fetchByUuid_C_Last(String uuid, long companyId,
887 OrderByComparator orderByComparator) throws SystemException {
888 int count = countByUuid_C(uuid, companyId);
889
890 List<User> list = findByUuid_C(uuid, companyId, count - 1, count,
891 orderByComparator);
892
893 if (!list.isEmpty()) {
894 return list.get(0);
895 }
896
897 return null;
898 }
899
900
911 public User[] findByUuid_C_PrevAndNext(long userId, String uuid,
912 long companyId, OrderByComparator orderByComparator)
913 throws NoSuchUserException, SystemException {
914 User user = findByPrimaryKey(userId);
915
916 Session session = null;
917
918 try {
919 session = openSession();
920
921 User[] array = new UserImpl[3];
922
923 array[0] = getByUuid_C_PrevAndNext(session, user, uuid, companyId,
924 orderByComparator, true);
925
926 array[1] = user;
927
928 array[2] = getByUuid_C_PrevAndNext(session, user, uuid, companyId,
929 orderByComparator, false);
930
931 return array;
932 }
933 catch (Exception e) {
934 throw processException(e);
935 }
936 finally {
937 closeSession(session);
938 }
939 }
940
941 protected User getByUuid_C_PrevAndNext(Session session, User user,
942 String uuid, long companyId, OrderByComparator orderByComparator,
943 boolean previous) {
944 StringBundler query = null;
945
946 if (orderByComparator != null) {
947 query = new StringBundler(6 +
948 (orderByComparator.getOrderByFields().length * 6));
949 }
950 else {
951 query = new StringBundler(3);
952 }
953
954 query.append(_SQL_SELECT_USER_WHERE);
955
956 if (uuid == null) {
957 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
958 }
959 else {
960 if (uuid.equals(StringPool.BLANK)) {
961 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
962 }
963 else {
964 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
965 }
966 }
967
968 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
969
970 if (orderByComparator != null) {
971 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
972
973 if (orderByConditionFields.length > 0) {
974 query.append(WHERE_AND);
975 }
976
977 for (int i = 0; i < orderByConditionFields.length; i++) {
978 query.append(_ORDER_BY_ENTITY_ALIAS);
979 query.append(orderByConditionFields[i]);
980
981 if ((i + 1) < orderByConditionFields.length) {
982 if (orderByComparator.isAscending() ^ previous) {
983 query.append(WHERE_GREATER_THAN_HAS_NEXT);
984 }
985 else {
986 query.append(WHERE_LESSER_THAN_HAS_NEXT);
987 }
988 }
989 else {
990 if (orderByComparator.isAscending() ^ previous) {
991 query.append(WHERE_GREATER_THAN);
992 }
993 else {
994 query.append(WHERE_LESSER_THAN);
995 }
996 }
997 }
998
999 query.append(ORDER_BY_CLAUSE);
1000
1001 String[] orderByFields = orderByComparator.getOrderByFields();
1002
1003 for (int i = 0; i < orderByFields.length; i++) {
1004 query.append(_ORDER_BY_ENTITY_ALIAS);
1005 query.append(orderByFields[i]);
1006
1007 if ((i + 1) < orderByFields.length) {
1008 if (orderByComparator.isAscending() ^ previous) {
1009 query.append(ORDER_BY_ASC_HAS_NEXT);
1010 }
1011 else {
1012 query.append(ORDER_BY_DESC_HAS_NEXT);
1013 }
1014 }
1015 else {
1016 if (orderByComparator.isAscending() ^ previous) {
1017 query.append(ORDER_BY_ASC);
1018 }
1019 else {
1020 query.append(ORDER_BY_DESC);
1021 }
1022 }
1023 }
1024 }
1025 else {
1026 query.append(UserModelImpl.ORDER_BY_JPQL);
1027 }
1028
1029 String sql = query.toString();
1030
1031 Query q = session.createQuery(sql);
1032
1033 q.setFirstResult(0);
1034 q.setMaxResults(2);
1035
1036 QueryPos qPos = QueryPos.getInstance(q);
1037
1038 if (uuid != null) {
1039 qPos.add(uuid);
1040 }
1041
1042 qPos.add(companyId);
1043
1044 if (orderByComparator != null) {
1045 Object[] values = orderByComparator.getOrderByConditionValues(user);
1046
1047 for (Object value : values) {
1048 qPos.add(value);
1049 }
1050 }
1051
1052 List<User> list = q.list();
1053
1054 if (list.size() == 2) {
1055 return list.get(1);
1056 }
1057 else {
1058 return null;
1059 }
1060 }
1061
1062
1069 public void removeByUuid_C(String uuid, long companyId)
1070 throws SystemException {
1071 for (User user : findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1072 QueryUtil.ALL_POS, null)) {
1073 remove(user);
1074 }
1075 }
1076
1077
1085 public int countByUuid_C(String uuid, long companyId)
1086 throws SystemException {
1087 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1088
1089 Object[] finderArgs = new Object[] { uuid, companyId };
1090
1091 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1092 this);
1093
1094 if (count == null) {
1095 StringBundler query = new StringBundler(3);
1096
1097 query.append(_SQL_COUNT_USER_WHERE);
1098
1099 if (uuid == null) {
1100 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1101 }
1102 else {
1103 if (uuid.equals(StringPool.BLANK)) {
1104 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1105 }
1106 else {
1107 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1108 }
1109 }
1110
1111 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1112
1113 String sql = query.toString();
1114
1115 Session session = null;
1116
1117 try {
1118 session = openSession();
1119
1120 Query q = session.createQuery(sql);
1121
1122 QueryPos qPos = QueryPos.getInstance(q);
1123
1124 if (uuid != null) {
1125 qPos.add(uuid);
1126 }
1127
1128 qPos.add(companyId);
1129
1130 count = (Long)q.uniqueResult();
1131
1132 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1133 }
1134 catch (Exception e) {
1135 FinderCacheUtil.removeResult(finderPath, finderArgs);
1136
1137 throw processException(e);
1138 }
1139 finally {
1140 closeSession(session);
1141 }
1142 }
1143
1144 return count.intValue();
1145 }
1146
1147 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "user.uuid IS NULL AND ";
1148 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "user.uuid = ? AND ";
1149 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(user.uuid IS NULL OR user.uuid = ?) AND ";
1150 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "user.companyId = ?";
1151 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
1152 new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
1153 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
1154 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
1155 new String[] {
1156 Long.class.getName(),
1157
1158 Integer.class.getName(), Integer.class.getName(),
1159 OrderByComparator.class.getName()
1160 });
1161 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
1162 new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
1163 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
1164 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
1165 new String[] { Long.class.getName() },
1166 UserModelImpl.COMPANYID_COLUMN_BITMASK);
1167 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
1168 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
1169 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
1170 new String[] { Long.class.getName() });
1171
1172
1179 public List<User> findByCompanyId(long companyId) throws SystemException {
1180 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1181 null);
1182 }
1183
1184
1197 public List<User> findByCompanyId(long companyId, int start, int end)
1198 throws SystemException {
1199 return findByCompanyId(companyId, start, end, null);
1200 }
1201
1202
1216 public List<User> findByCompanyId(long companyId, int start, int end,
1217 OrderByComparator orderByComparator) throws SystemException {
1218 boolean pagination = true;
1219 FinderPath finderPath = null;
1220 Object[] finderArgs = null;
1221
1222 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1223 (orderByComparator == null)) {
1224 pagination = false;
1225 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
1226 finderArgs = new Object[] { companyId };
1227 }
1228 else {
1229 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
1230 finderArgs = new Object[] { companyId, start, end, orderByComparator };
1231 }
1232
1233 List<User> list = (List<User>)FinderCacheUtil.getResult(finderPath,
1234 finderArgs, this);
1235
1236 if ((list != null) && !list.isEmpty()) {
1237 for (User user : list) {
1238 if ((companyId != user.getCompanyId())) {
1239 list = null;
1240
1241 break;
1242 }
1243 }
1244 }
1245
1246 if (list == null) {
1247 StringBundler query = null;
1248
1249 if (orderByComparator != null) {
1250 query = new StringBundler(3 +
1251 (orderByComparator.getOrderByFields().length * 3));
1252 }
1253 else {
1254 query = new StringBundler(3);
1255 }
1256
1257 query.append(_SQL_SELECT_USER_WHERE);
1258
1259 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1260
1261 if (orderByComparator != null) {
1262 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1263 orderByComparator);
1264 }
1265 else
1266 if (pagination) {
1267 query.append(UserModelImpl.ORDER_BY_JPQL);
1268 }
1269
1270 String sql = query.toString();
1271
1272 Session session = null;
1273
1274 try {
1275 session = openSession();
1276
1277 Query q = session.createQuery(sql);
1278
1279 QueryPos qPos = QueryPos.getInstance(q);
1280
1281 qPos.add(companyId);
1282
1283 if (!pagination) {
1284 list = (List<User>)QueryUtil.list(q, getDialect(), start,
1285 end, false);
1286
1287 Collections.sort(list);
1288
1289 list = new UnmodifiableList<User>(list);
1290 }
1291 else {
1292 list = (List<User>)QueryUtil.list(q, getDialect(), start,
1293 end);
1294 }
1295
1296 cacheResult(list);
1297
1298 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1299 }
1300 catch (Exception e) {
1301 FinderCacheUtil.removeResult(finderPath, finderArgs);
1302
1303 throw processException(e);
1304 }
1305 finally {
1306 closeSession(session);
1307 }
1308 }
1309
1310 return list;
1311 }
1312
1313
1322 public User findByCompanyId_First(long companyId,
1323 OrderByComparator orderByComparator)
1324 throws NoSuchUserException, SystemException {
1325 User user = fetchByCompanyId_First(companyId, orderByComparator);
1326
1327 if (user != null) {
1328 return user;
1329 }
1330
1331 StringBundler msg = new StringBundler(4);
1332
1333 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1334
1335 msg.append("companyId=");
1336 msg.append(companyId);
1337
1338 msg.append(StringPool.CLOSE_CURLY_BRACE);
1339
1340 throw new NoSuchUserException(msg.toString());
1341 }
1342
1343
1351 public User fetchByCompanyId_First(long companyId,
1352 OrderByComparator orderByComparator) throws SystemException {
1353 List<User> list = findByCompanyId(companyId, 0, 1, orderByComparator);
1354
1355 if (!list.isEmpty()) {
1356 return list.get(0);
1357 }
1358
1359 return null;
1360 }
1361
1362
1371 public User findByCompanyId_Last(long companyId,
1372 OrderByComparator orderByComparator)
1373 throws NoSuchUserException, SystemException {
1374 User user = fetchByCompanyId_Last(companyId, orderByComparator);
1375
1376 if (user != null) {
1377 return user;
1378 }
1379
1380 StringBundler msg = new StringBundler(4);
1381
1382 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1383
1384 msg.append("companyId=");
1385 msg.append(companyId);
1386
1387 msg.append(StringPool.CLOSE_CURLY_BRACE);
1388
1389 throw new NoSuchUserException(msg.toString());
1390 }
1391
1392
1400 public User fetchByCompanyId_Last(long companyId,
1401 OrderByComparator orderByComparator) throws SystemException {
1402 int count = countByCompanyId(companyId);
1403
1404 List<User> list = findByCompanyId(companyId, count - 1, count,
1405 orderByComparator);
1406
1407 if (!list.isEmpty()) {
1408 return list.get(0);
1409 }
1410
1411 return null;
1412 }
1413
1414
1424 public User[] findByCompanyId_PrevAndNext(long userId, long companyId,
1425 OrderByComparator orderByComparator)
1426 throws NoSuchUserException, SystemException {
1427 User user = findByPrimaryKey(userId);
1428
1429 Session session = null;
1430
1431 try {
1432 session = openSession();
1433
1434 User[] array = new UserImpl[3];
1435
1436 array[0] = getByCompanyId_PrevAndNext(session, user, companyId,
1437 orderByComparator, true);
1438
1439 array[1] = user;
1440
1441 array[2] = getByCompanyId_PrevAndNext(session, user, companyId,
1442 orderByComparator, false);
1443
1444 return array;
1445 }
1446 catch (Exception e) {
1447 throw processException(e);
1448 }
1449 finally {
1450 closeSession(session);
1451 }
1452 }
1453
1454 protected User getByCompanyId_PrevAndNext(Session session, User user,
1455 long companyId, OrderByComparator orderByComparator, boolean previous) {
1456 StringBundler query = null;
1457
1458 if (orderByComparator != null) {
1459 query = new StringBundler(6 +
1460 (orderByComparator.getOrderByFields().length * 6));
1461 }
1462 else {
1463 query = new StringBundler(3);
1464 }
1465
1466 query.append(_SQL_SELECT_USER_WHERE);
1467
1468 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1469
1470 if (orderByComparator != null) {
1471 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1472
1473 if (orderByConditionFields.length > 0) {
1474 query.append(WHERE_AND);
1475 }
1476
1477 for (int i = 0; i < orderByConditionFields.length; i++) {
1478 query.append(_ORDER_BY_ENTITY_ALIAS);
1479 query.append(orderByConditionFields[i]);
1480
1481 if ((i + 1) < orderByConditionFields.length) {
1482 if (orderByComparator.isAscending() ^ previous) {
1483 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1484 }
1485 else {
1486 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1487 }
1488 }
1489 else {
1490 if (orderByComparator.isAscending() ^ previous) {
1491 query.append(WHERE_GREATER_THAN);
1492 }
1493 else {
1494 query.append(WHERE_LESSER_THAN);
1495 }
1496 }
1497 }
1498
1499 query.append(ORDER_BY_CLAUSE);
1500
1501 String[] orderByFields = orderByComparator.getOrderByFields();
1502
1503 for (int i = 0; i < orderByFields.length; i++) {
1504 query.append(_ORDER_BY_ENTITY_ALIAS);
1505 query.append(orderByFields[i]);
1506
1507 if ((i + 1) < orderByFields.length) {
1508 if (orderByComparator.isAscending() ^ previous) {
1509 query.append(ORDER_BY_ASC_HAS_NEXT);
1510 }
1511 else {
1512 query.append(ORDER_BY_DESC_HAS_NEXT);
1513 }
1514 }
1515 else {
1516 if (orderByComparator.isAscending() ^ previous) {
1517 query.append(ORDER_BY_ASC);
1518 }
1519 else {
1520 query.append(ORDER_BY_DESC);
1521 }
1522 }
1523 }
1524 }
1525 else {
1526 query.append(UserModelImpl.ORDER_BY_JPQL);
1527 }
1528
1529 String sql = query.toString();
1530
1531 Query q = session.createQuery(sql);
1532
1533 q.setFirstResult(0);
1534 q.setMaxResults(2);
1535
1536 QueryPos qPos = QueryPos.getInstance(q);
1537
1538 qPos.add(companyId);
1539
1540 if (orderByComparator != null) {
1541 Object[] values = orderByComparator.getOrderByConditionValues(user);
1542
1543 for (Object value : values) {
1544 qPos.add(value);
1545 }
1546 }
1547
1548 List<User> list = q.list();
1549
1550 if (list.size() == 2) {
1551 return list.get(1);
1552 }
1553 else {
1554 return null;
1555 }
1556 }
1557
1558
1564 public void removeByCompanyId(long companyId) throws SystemException {
1565 for (User user : findByCompanyId(companyId, QueryUtil.ALL_POS,
1566 QueryUtil.ALL_POS, null)) {
1567 remove(user);
1568 }
1569 }
1570
1571
1578 public int countByCompanyId(long companyId) throws SystemException {
1579 FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
1580
1581 Object[] finderArgs = new Object[] { companyId };
1582
1583 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1584 this);
1585
1586 if (count == null) {
1587 StringBundler query = new StringBundler(2);
1588
1589 query.append(_SQL_COUNT_USER_WHERE);
1590
1591 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1592
1593 String sql = query.toString();
1594
1595 Session session = null;
1596
1597 try {
1598 session = openSession();
1599
1600 Query q = session.createQuery(sql);
1601
1602 QueryPos qPos = QueryPos.getInstance(q);
1603
1604 qPos.add(companyId);
1605
1606 count = (Long)q.uniqueResult();
1607
1608 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1609 }
1610 catch (Exception e) {
1611 FinderCacheUtil.removeResult(finderPath, finderArgs);
1612
1613 throw processException(e);
1614 }
1615 finally {
1616 closeSession(session);
1617 }
1618 }
1619
1620 return count.intValue();
1621 }
1622
1623 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "user.companyId = ?";
1624 public static final FinderPath FINDER_PATH_FETCH_BY_CONTACTID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
1625 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
1626 FINDER_CLASS_NAME_ENTITY, "fetchByContactId",
1627 new String[] { Long.class.getName() },
1628 UserModelImpl.CONTACTID_COLUMN_BITMASK);
1629 public static final FinderPath FINDER_PATH_COUNT_BY_CONTACTID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
1630 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
1631 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByContactId",
1632 new String[] { Long.class.getName() });
1633
1634
1642 public User findByContactId(long contactId)
1643 throws NoSuchUserException, SystemException {
1644 User user = fetchByContactId(contactId);
1645
1646 if (user == null) {
1647 StringBundler msg = new StringBundler(4);
1648
1649 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1650
1651 msg.append("contactId=");
1652 msg.append(contactId);
1653
1654 msg.append(StringPool.CLOSE_CURLY_BRACE);
1655
1656 if (_log.isWarnEnabled()) {
1657 _log.warn(msg.toString());
1658 }
1659
1660 throw new NoSuchUserException(msg.toString());
1661 }
1662
1663 return user;
1664 }
1665
1666
1673 public User fetchByContactId(long contactId) throws SystemException {
1674 return fetchByContactId(contactId, true);
1675 }
1676
1677
1685 public User fetchByContactId(long contactId, boolean retrieveFromCache)
1686 throws SystemException {
1687 Object[] finderArgs = new Object[] { contactId };
1688
1689 Object result = null;
1690
1691 if (retrieveFromCache) {
1692 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_CONTACTID,
1693 finderArgs, this);
1694 }
1695
1696 if (result instanceof User) {
1697 User user = (User)result;
1698
1699 if ((contactId != user.getContactId())) {
1700 result = null;
1701 }
1702 }
1703
1704 if (result == null) {
1705 StringBundler query = new StringBundler(3);
1706
1707 query.append(_SQL_SELECT_USER_WHERE);
1708
1709 query.append(_FINDER_COLUMN_CONTACTID_CONTACTID_2);
1710
1711 String sql = query.toString();
1712
1713 Session session = null;
1714
1715 try {
1716 session = openSession();
1717
1718 Query q = session.createQuery(sql);
1719
1720 QueryPos qPos = QueryPos.getInstance(q);
1721
1722 qPos.add(contactId);
1723
1724 List<User> list = q.list();
1725
1726 if (list.isEmpty()) {
1727 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID,
1728 finderArgs, list);
1729 }
1730 else {
1731 User user = list.get(0);
1732
1733 result = user;
1734
1735 cacheResult(user);
1736
1737 if ((user.getContactId() != contactId)) {
1738 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID,
1739 finderArgs, user);
1740 }
1741 }
1742 }
1743 catch (Exception e) {
1744 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CONTACTID,
1745 finderArgs);
1746
1747 throw processException(e);
1748 }
1749 finally {
1750 closeSession(session);
1751 }
1752 }
1753
1754 if (result instanceof List<?>) {
1755 return null;
1756 }
1757 else {
1758 return (User)result;
1759 }
1760 }
1761
1762
1769 public User removeByContactId(long contactId)
1770 throws NoSuchUserException, SystemException {
1771 User user = findByContactId(contactId);
1772
1773 return remove(user);
1774 }
1775
1776
1783 public int countByContactId(long contactId) throws SystemException {
1784 FinderPath finderPath = FINDER_PATH_COUNT_BY_CONTACTID;
1785
1786 Object[] finderArgs = new Object[] { contactId };
1787
1788 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1789 this);
1790
1791 if (count == null) {
1792 StringBundler query = new StringBundler(2);
1793
1794 query.append(_SQL_COUNT_USER_WHERE);
1795
1796 query.append(_FINDER_COLUMN_CONTACTID_CONTACTID_2);
1797
1798 String sql = query.toString();
1799
1800 Session session = null;
1801
1802 try {
1803 session = openSession();
1804
1805 Query q = session.createQuery(sql);
1806
1807 QueryPos qPos = QueryPos.getInstance(q);
1808
1809 qPos.add(contactId);
1810
1811 count = (Long)q.uniqueResult();
1812
1813 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1814 }
1815 catch (Exception e) {
1816 FinderCacheUtil.removeResult(finderPath, finderArgs);
1817
1818 throw processException(e);
1819 }
1820 finally {
1821 closeSession(session);
1822 }
1823 }
1824
1825 return count.intValue();
1826 }
1827
1828 private static final String _FINDER_COLUMN_CONTACTID_CONTACTID_2 = "user.contactId = ?";
1829 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_EMAILADDRESS =
1830 new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
1831 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
1832 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByEmailAddress",
1833 new String[] {
1834 String.class.getName(),
1835
1836 Integer.class.getName(), Integer.class.getName(),
1837 OrderByComparator.class.getName()
1838 });
1839 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EMAILADDRESS =
1840 new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
1841 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
1842 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByEmailAddress",
1843 new String[] { String.class.getName() },
1844 UserModelImpl.EMAILADDRESS_COLUMN_BITMASK);
1845 public static final FinderPath FINDER_PATH_COUNT_BY_EMAILADDRESS = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
1846 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
1847 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByEmailAddress",
1848 new String[] { String.class.getName() });
1849
1850
1857 public List<User> findByEmailAddress(String emailAddress)
1858 throws SystemException {
1859 return findByEmailAddress(emailAddress, QueryUtil.ALL_POS,
1860 QueryUtil.ALL_POS, null);
1861 }
1862
1863
1876 public List<User> findByEmailAddress(String emailAddress, int start, int end)
1877 throws SystemException {
1878 return findByEmailAddress(emailAddress, start, end, null);
1879 }
1880
1881
1895 public List<User> findByEmailAddress(String emailAddress, int start,
1896 int end, OrderByComparator orderByComparator) throws SystemException {
1897 boolean pagination = true;
1898 FinderPath finderPath = null;
1899 Object[] finderArgs = null;
1900
1901 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1902 (orderByComparator == null)) {
1903 pagination = false;
1904 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EMAILADDRESS;
1905 finderArgs = new Object[] { emailAddress };
1906 }
1907 else {
1908 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_EMAILADDRESS;
1909 finderArgs = new Object[] {
1910 emailAddress,
1911
1912 start, end, orderByComparator
1913 };
1914 }
1915
1916 List<User> list = (List<User>)FinderCacheUtil.getResult(finderPath,
1917 finderArgs, this);
1918
1919 if ((list != null) && !list.isEmpty()) {
1920 for (User user : list) {
1921 if (!Validator.equals(emailAddress, user.getEmailAddress())) {
1922 list = null;
1923
1924 break;
1925 }
1926 }
1927 }
1928
1929 if (list == null) {
1930 StringBundler query = null;
1931
1932 if (orderByComparator != null) {
1933 query = new StringBundler(3 +
1934 (orderByComparator.getOrderByFields().length * 3));
1935 }
1936 else {
1937 query = new StringBundler(3);
1938 }
1939
1940 query.append(_SQL_SELECT_USER_WHERE);
1941
1942 if (emailAddress == null) {
1943 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_1);
1944 }
1945 else {
1946 if (emailAddress.equals(StringPool.BLANK)) {
1947 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_3);
1948 }
1949 else {
1950 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_2);
1951 }
1952 }
1953
1954 if (orderByComparator != null) {
1955 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1956 orderByComparator);
1957 }
1958 else
1959 if (pagination) {
1960 query.append(UserModelImpl.ORDER_BY_JPQL);
1961 }
1962
1963 String sql = query.toString();
1964
1965 Session session = null;
1966
1967 try {
1968 session = openSession();
1969
1970 Query q = session.createQuery(sql);
1971
1972 QueryPos qPos = QueryPos.getInstance(q);
1973
1974 if (emailAddress != null) {
1975 qPos.add(emailAddress);
1976 }
1977
1978 if (!pagination) {
1979 list = (List<User>)QueryUtil.list(q, getDialect(), start,
1980 end, false);
1981
1982 Collections.sort(list);
1983
1984 list = new UnmodifiableList<User>(list);
1985 }
1986 else {
1987 list = (List<User>)QueryUtil.list(q, getDialect(), start,
1988 end);
1989 }
1990
1991 cacheResult(list);
1992
1993 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1994 }
1995 catch (Exception e) {
1996 FinderCacheUtil.removeResult(finderPath, finderArgs);
1997
1998 throw processException(e);
1999 }
2000 finally {
2001 closeSession(session);
2002 }
2003 }
2004
2005 return list;
2006 }
2007
2008
2017 public User findByEmailAddress_First(String emailAddress,
2018 OrderByComparator orderByComparator)
2019 throws NoSuchUserException, SystemException {
2020 User user = fetchByEmailAddress_First(emailAddress, orderByComparator);
2021
2022 if (user != null) {
2023 return user;
2024 }
2025
2026 StringBundler msg = new StringBundler(4);
2027
2028 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2029
2030 msg.append("emailAddress=");
2031 msg.append(emailAddress);
2032
2033 msg.append(StringPool.CLOSE_CURLY_BRACE);
2034
2035 throw new NoSuchUserException(msg.toString());
2036 }
2037
2038
2046 public User fetchByEmailAddress_First(String emailAddress,
2047 OrderByComparator orderByComparator) throws SystemException {
2048 List<User> list = findByEmailAddress(emailAddress, 0, 1,
2049 orderByComparator);
2050
2051 if (!list.isEmpty()) {
2052 return list.get(0);
2053 }
2054
2055 return null;
2056 }
2057
2058
2067 public User findByEmailAddress_Last(String emailAddress,
2068 OrderByComparator orderByComparator)
2069 throws NoSuchUserException, SystemException {
2070 User user = fetchByEmailAddress_Last(emailAddress, orderByComparator);
2071
2072 if (user != null) {
2073 return user;
2074 }
2075
2076 StringBundler msg = new StringBundler(4);
2077
2078 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2079
2080 msg.append("emailAddress=");
2081 msg.append(emailAddress);
2082
2083 msg.append(StringPool.CLOSE_CURLY_BRACE);
2084
2085 throw new NoSuchUserException(msg.toString());
2086 }
2087
2088
2096 public User fetchByEmailAddress_Last(String emailAddress,
2097 OrderByComparator orderByComparator) throws SystemException {
2098 int count = countByEmailAddress(emailAddress);
2099
2100 List<User> list = findByEmailAddress(emailAddress, count - 1, count,
2101 orderByComparator);
2102
2103 if (!list.isEmpty()) {
2104 return list.get(0);
2105 }
2106
2107 return null;
2108 }
2109
2110
2120 public User[] findByEmailAddress_PrevAndNext(long userId,
2121 String emailAddress, OrderByComparator orderByComparator)
2122 throws NoSuchUserException, SystemException {
2123 User user = findByPrimaryKey(userId);
2124
2125 Session session = null;
2126
2127 try {
2128 session = openSession();
2129
2130 User[] array = new UserImpl[3];
2131
2132 array[0] = getByEmailAddress_PrevAndNext(session, user,
2133 emailAddress, orderByComparator, true);
2134
2135 array[1] = user;
2136
2137 array[2] = getByEmailAddress_PrevAndNext(session, user,
2138 emailAddress, orderByComparator, false);
2139
2140 return array;
2141 }
2142 catch (Exception e) {
2143 throw processException(e);
2144 }
2145 finally {
2146 closeSession(session);
2147 }
2148 }
2149
2150 protected User getByEmailAddress_PrevAndNext(Session session, User user,
2151 String emailAddress, OrderByComparator orderByComparator,
2152 boolean previous) {
2153 StringBundler query = null;
2154
2155 if (orderByComparator != null) {
2156 query = new StringBundler(6 +
2157 (orderByComparator.getOrderByFields().length * 6));
2158 }
2159 else {
2160 query = new StringBundler(3);
2161 }
2162
2163 query.append(_SQL_SELECT_USER_WHERE);
2164
2165 if (emailAddress == null) {
2166 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_1);
2167 }
2168 else {
2169 if (emailAddress.equals(StringPool.BLANK)) {
2170 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_3);
2171 }
2172 else {
2173 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_2);
2174 }
2175 }
2176
2177 if (orderByComparator != null) {
2178 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2179
2180 if (orderByConditionFields.length > 0) {
2181 query.append(WHERE_AND);
2182 }
2183
2184 for (int i = 0; i < orderByConditionFields.length; i++) {
2185 query.append(_ORDER_BY_ENTITY_ALIAS);
2186 query.append(orderByConditionFields[i]);
2187
2188 if ((i + 1) < orderByConditionFields.length) {
2189 if (orderByComparator.isAscending() ^ previous) {
2190 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2191 }
2192 else {
2193 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2194 }
2195 }
2196 else {
2197 if (orderByComparator.isAscending() ^ previous) {
2198 query.append(WHERE_GREATER_THAN);
2199 }
2200 else {
2201 query.append(WHERE_LESSER_THAN);
2202 }
2203 }
2204 }
2205
2206 query.append(ORDER_BY_CLAUSE);
2207
2208 String[] orderByFields = orderByComparator.getOrderByFields();
2209
2210 for (int i = 0; i < orderByFields.length; i++) {
2211 query.append(_ORDER_BY_ENTITY_ALIAS);
2212 query.append(orderByFields[i]);
2213
2214 if ((i + 1) < orderByFields.length) {
2215 if (orderByComparator.isAscending() ^ previous) {
2216 query.append(ORDER_BY_ASC_HAS_NEXT);
2217 }
2218 else {
2219 query.append(ORDER_BY_DESC_HAS_NEXT);
2220 }
2221 }
2222 else {
2223 if (orderByComparator.isAscending() ^ previous) {
2224 query.append(ORDER_BY_ASC);
2225 }
2226 else {
2227 query.append(ORDER_BY_DESC);
2228 }
2229 }
2230 }
2231 }
2232 else {
2233 query.append(UserModelImpl.ORDER_BY_JPQL);
2234 }
2235
2236 String sql = query.toString();
2237
2238 Query q = session.createQuery(sql);
2239
2240 q.setFirstResult(0);
2241 q.setMaxResults(2);
2242
2243 QueryPos qPos = QueryPos.getInstance(q);
2244
2245 if (emailAddress != null) {
2246 qPos.add(emailAddress);
2247 }
2248
2249 if (orderByComparator != null) {
2250 Object[] values = orderByComparator.getOrderByConditionValues(user);
2251
2252 for (Object value : values) {
2253 qPos.add(value);
2254 }
2255 }
2256
2257 List<User> list = q.list();
2258
2259 if (list.size() == 2) {
2260 return list.get(1);
2261 }
2262 else {
2263 return null;
2264 }
2265 }
2266
2267
2273 public void removeByEmailAddress(String emailAddress)
2274 throws SystemException {
2275 for (User user : findByEmailAddress(emailAddress, QueryUtil.ALL_POS,
2276 QueryUtil.ALL_POS, null)) {
2277 remove(user);
2278 }
2279 }
2280
2281
2288 public int countByEmailAddress(String emailAddress)
2289 throws SystemException {
2290 FinderPath finderPath = FINDER_PATH_COUNT_BY_EMAILADDRESS;
2291
2292 Object[] finderArgs = new Object[] { emailAddress };
2293
2294 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2295 this);
2296
2297 if (count == null) {
2298 StringBundler query = new StringBundler(2);
2299
2300 query.append(_SQL_COUNT_USER_WHERE);
2301
2302 if (emailAddress == null) {
2303 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_1);
2304 }
2305 else {
2306 if (emailAddress.equals(StringPool.BLANK)) {
2307 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_3);
2308 }
2309 else {
2310 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_2);
2311 }
2312 }
2313
2314 String sql = query.toString();
2315
2316 Session session = null;
2317
2318 try {
2319 session = openSession();
2320
2321 Query q = session.createQuery(sql);
2322
2323 QueryPos qPos = QueryPos.getInstance(q);
2324
2325 if (emailAddress != null) {
2326 qPos.add(emailAddress);
2327 }
2328
2329 count = (Long)q.uniqueResult();
2330
2331 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2332 }
2333 catch (Exception e) {
2334 FinderCacheUtil.removeResult(finderPath, finderArgs);
2335
2336 throw processException(e);
2337 }
2338 finally {
2339 closeSession(session);
2340 }
2341 }
2342
2343 return count.intValue();
2344 }
2345
2346 private static final String _FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_1 = "user.emailAddress IS NULL";
2347 private static final String _FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_2 = "user.emailAddress = ?";
2348 private static final String _FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_3 = "(user.emailAddress IS NULL OR user.emailAddress = ?)";
2349 public static final FinderPath FINDER_PATH_FETCH_BY_PORTRAITID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
2350 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
2351 FINDER_CLASS_NAME_ENTITY, "fetchByPortraitId",
2352 new String[] { Long.class.getName() },
2353 UserModelImpl.PORTRAITID_COLUMN_BITMASK);
2354 public static final FinderPath FINDER_PATH_COUNT_BY_PORTRAITID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
2355 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
2356 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByPortraitId",
2357 new String[] { Long.class.getName() });
2358
2359
2367 public User findByPortraitId(long portraitId)
2368 throws NoSuchUserException, SystemException {
2369 User user = fetchByPortraitId(portraitId);
2370
2371 if (user == null) {
2372 StringBundler msg = new StringBundler(4);
2373
2374 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2375
2376 msg.append("portraitId=");
2377 msg.append(portraitId);
2378
2379 msg.append(StringPool.CLOSE_CURLY_BRACE);
2380
2381 if (_log.isWarnEnabled()) {
2382 _log.warn(msg.toString());
2383 }
2384
2385 throw new NoSuchUserException(msg.toString());
2386 }
2387
2388 return user;
2389 }
2390
2391
2398 public User fetchByPortraitId(long portraitId) throws SystemException {
2399 return fetchByPortraitId(portraitId, true);
2400 }
2401
2402
2410 public User fetchByPortraitId(long portraitId, boolean retrieveFromCache)
2411 throws SystemException {
2412 Object[] finderArgs = new Object[] { portraitId };
2413
2414 Object result = null;
2415
2416 if (retrieveFromCache) {
2417 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_PORTRAITID,
2418 finderArgs, this);
2419 }
2420
2421 if (result instanceof User) {
2422 User user = (User)result;
2423
2424 if ((portraitId != user.getPortraitId())) {
2425 result = null;
2426 }
2427 }
2428
2429 if (result == null) {
2430 StringBundler query = new StringBundler(3);
2431
2432 query.append(_SQL_SELECT_USER_WHERE);
2433
2434 query.append(_FINDER_COLUMN_PORTRAITID_PORTRAITID_2);
2435
2436 String sql = query.toString();
2437
2438 Session session = null;
2439
2440 try {
2441 session = openSession();
2442
2443 Query q = session.createQuery(sql);
2444
2445 QueryPos qPos = QueryPos.getInstance(q);
2446
2447 qPos.add(portraitId);
2448
2449 List<User> list = q.list();
2450
2451 if (list.isEmpty()) {
2452 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PORTRAITID,
2453 finderArgs, list);
2454 }
2455 else {
2456 if ((list.size() > 1) && _log.isWarnEnabled()) {
2457 _log.warn(
2458 "UserPersistenceImpl.fetchByPortraitId(long, boolean) with parameters (" +
2459 StringUtil.merge(finderArgs) +
2460 ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder.");
2461 }
2462
2463 User user = list.get(0);
2464
2465 result = user;
2466
2467 cacheResult(user);
2468
2469 if ((user.getPortraitId() != portraitId)) {
2470 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PORTRAITID,
2471 finderArgs, user);
2472 }
2473 }
2474 }
2475 catch (Exception e) {
2476 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_PORTRAITID,
2477 finderArgs);
2478
2479 throw processException(e);
2480 }
2481 finally {
2482 closeSession(session);
2483 }
2484 }
2485
2486 if (result instanceof List<?>) {
2487 return null;
2488 }
2489 else {
2490 return (User)result;
2491 }
2492 }
2493
2494
2501 public User removeByPortraitId(long portraitId)
2502 throws NoSuchUserException, SystemException {
2503 User user = findByPortraitId(portraitId);
2504
2505 return remove(user);
2506 }
2507
2508
2515 public int countByPortraitId(long portraitId) throws SystemException {
2516 FinderPath finderPath = FINDER_PATH_COUNT_BY_PORTRAITID;
2517
2518 Object[] finderArgs = new Object[] { portraitId };
2519
2520 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2521 this);
2522
2523 if (count == null) {
2524 StringBundler query = new StringBundler(2);
2525
2526 query.append(_SQL_COUNT_USER_WHERE);
2527
2528 query.append(_FINDER_COLUMN_PORTRAITID_PORTRAITID_2);
2529
2530 String sql = query.toString();
2531
2532 Session session = null;
2533
2534 try {
2535 session = openSession();
2536
2537 Query q = session.createQuery(sql);
2538
2539 QueryPos qPos = QueryPos.getInstance(q);
2540
2541 qPos.add(portraitId);
2542
2543 count = (Long)q.uniqueResult();
2544
2545 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2546 }
2547 catch (Exception e) {
2548 FinderCacheUtil.removeResult(finderPath, finderArgs);
2549
2550 throw processException(e);
2551 }
2552 finally {
2553 closeSession(session);
2554 }
2555 }
2556
2557 return count.intValue();
2558 }
2559
2560 private static final String _FINDER_COLUMN_PORTRAITID_PORTRAITID_2 = "user.portraitId = ?";
2561 public static final FinderPath FINDER_PATH_FETCH_BY_C_U = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
2562 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
2563 FINDER_CLASS_NAME_ENTITY, "fetchByC_U",
2564 new String[] { Long.class.getName(), Long.class.getName() },
2565 UserModelImpl.COMPANYID_COLUMN_BITMASK |
2566 UserModelImpl.USERID_COLUMN_BITMASK);
2567 public static final FinderPath FINDER_PATH_COUNT_BY_C_U = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
2568 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
2569 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U",
2570 new String[] { Long.class.getName(), Long.class.getName() });
2571
2572
2581 public User findByC_U(long companyId, long userId)
2582 throws NoSuchUserException, SystemException {
2583 User user = fetchByC_U(companyId, userId);
2584
2585 if (user == null) {
2586 StringBundler msg = new StringBundler(6);
2587
2588 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2589
2590 msg.append("companyId=");
2591 msg.append(companyId);
2592
2593 msg.append(", userId=");
2594 msg.append(userId);
2595
2596 msg.append(StringPool.CLOSE_CURLY_BRACE);
2597
2598 if (_log.isWarnEnabled()) {
2599 _log.warn(msg.toString());
2600 }
2601
2602 throw new NoSuchUserException(msg.toString());
2603 }
2604
2605 return user;
2606 }
2607
2608
2616 public User fetchByC_U(long companyId, long userId)
2617 throws SystemException {
2618 return fetchByC_U(companyId, userId, true);
2619 }
2620
2621
2630 public User fetchByC_U(long companyId, long userId,
2631 boolean retrieveFromCache) throws SystemException {
2632 Object[] finderArgs = new Object[] { companyId, userId };
2633
2634 Object result = null;
2635
2636 if (retrieveFromCache) {
2637 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_U,
2638 finderArgs, this);
2639 }
2640
2641 if (result instanceof User) {
2642 User user = (User)result;
2643
2644 if ((companyId != user.getCompanyId()) ||
2645 (userId != user.getUserId())) {
2646 result = null;
2647 }
2648 }
2649
2650 if (result == null) {
2651 StringBundler query = new StringBundler(4);
2652
2653 query.append(_SQL_SELECT_USER_WHERE);
2654
2655 query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
2656
2657 query.append(_FINDER_COLUMN_C_U_USERID_2);
2658
2659 String sql = query.toString();
2660
2661 Session session = null;
2662
2663 try {
2664 session = openSession();
2665
2666 Query q = session.createQuery(sql);
2667
2668 QueryPos qPos = QueryPos.getInstance(q);
2669
2670 qPos.add(companyId);
2671
2672 qPos.add(userId);
2673
2674 List<User> list = q.list();
2675
2676 if (list.isEmpty()) {
2677 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U,
2678 finderArgs, list);
2679 }
2680 else {
2681 User user = list.get(0);
2682
2683 result = user;
2684
2685 cacheResult(user);
2686
2687 if ((user.getCompanyId() != companyId) ||
2688 (user.getUserId() != userId)) {
2689 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U,
2690 finderArgs, user);
2691 }
2692 }
2693 }
2694 catch (Exception e) {
2695 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U,
2696 finderArgs);
2697
2698 throw processException(e);
2699 }
2700 finally {
2701 closeSession(session);
2702 }
2703 }
2704
2705 if (result instanceof List<?>) {
2706 return null;
2707 }
2708 else {
2709 return (User)result;
2710 }
2711 }
2712
2713
2721 public User removeByC_U(long companyId, long userId)
2722 throws NoSuchUserException, SystemException {
2723 User user = findByC_U(companyId, userId);
2724
2725 return remove(user);
2726 }
2727
2728
2736 public int countByC_U(long companyId, long userId)
2737 throws SystemException {
2738 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_U;
2739
2740 Object[] finderArgs = new Object[] { companyId, userId };
2741
2742 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2743 this);
2744
2745 if (count == null) {
2746 StringBundler query = new StringBundler(3);
2747
2748 query.append(_SQL_COUNT_USER_WHERE);
2749
2750 query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
2751
2752 query.append(_FINDER_COLUMN_C_U_USERID_2);
2753
2754 String sql = query.toString();
2755
2756 Session session = null;
2757
2758 try {
2759 session = openSession();
2760
2761 Query q = session.createQuery(sql);
2762
2763 QueryPos qPos = QueryPos.getInstance(q);
2764
2765 qPos.add(companyId);
2766
2767 qPos.add(userId);
2768
2769 count = (Long)q.uniqueResult();
2770
2771 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2772 }
2773 catch (Exception e) {
2774 FinderCacheUtil.removeResult(finderPath, finderArgs);
2775
2776 throw processException(e);
2777 }
2778 finally {
2779 closeSession(session);
2780 }
2781 }
2782
2783 return count.intValue();
2784 }
2785
2786 private static final String _FINDER_COLUMN_C_U_COMPANYID_2 = "user.companyId = ? AND ";
2787 private static final String _FINDER_COLUMN_C_U_USERID_2 = "user.userId = ?";
2788 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_CD = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
2789 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
2790 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_CD",
2791 new String[] {
2792 Long.class.getName(), Date.class.getName(),
2793
2794 Integer.class.getName(), Integer.class.getName(),
2795 OrderByComparator.class.getName()
2796 });
2797 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_CD = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
2798 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
2799 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_CD",
2800 new String[] { Long.class.getName(), Date.class.getName() },
2801 UserModelImpl.COMPANYID_COLUMN_BITMASK |
2802 UserModelImpl.CREATEDATE_COLUMN_BITMASK);
2803 public static final FinderPath FINDER_PATH_COUNT_BY_C_CD = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
2804 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
2805 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_CD",
2806 new String[] { Long.class.getName(), Date.class.getName() });
2807
2808
2816 public List<User> findByC_CD(long companyId, Date createDate)
2817 throws SystemException {
2818 return findByC_CD(companyId, createDate, QueryUtil.ALL_POS,
2819 QueryUtil.ALL_POS, null);
2820 }
2821
2822
2836 public List<User> findByC_CD(long companyId, Date createDate, int start,
2837 int end) throws SystemException {
2838 return findByC_CD(companyId, createDate, start, end, null);
2839 }
2840
2841
2856 public List<User> findByC_CD(long companyId, Date createDate, int start,
2857 int end, OrderByComparator orderByComparator) throws SystemException {
2858 boolean pagination = true;
2859 FinderPath finderPath = null;
2860 Object[] finderArgs = null;
2861
2862 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2863 (orderByComparator == null)) {
2864 pagination = false;
2865 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_CD;
2866 finderArgs = new Object[] { companyId, createDate };
2867 }
2868 else {
2869 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_CD;
2870 finderArgs = new Object[] {
2871 companyId, createDate,
2872
2873 start, end, orderByComparator
2874 };
2875 }
2876
2877 List<User> list = (List<User>)FinderCacheUtil.getResult(finderPath,
2878 finderArgs, this);
2879
2880 if ((list != null) && !list.isEmpty()) {
2881 for (User user : list) {
2882 if ((companyId != user.getCompanyId()) ||
2883 !Validator.equals(createDate, user.getCreateDate())) {
2884 list = null;
2885
2886 break;
2887 }
2888 }
2889 }
2890
2891 if (list == null) {
2892 StringBundler query = null;
2893
2894 if (orderByComparator != null) {
2895 query = new StringBundler(4 +
2896 (orderByComparator.getOrderByFields().length * 3));
2897 }
2898 else {
2899 query = new StringBundler(4);
2900 }
2901
2902 query.append(_SQL_SELECT_USER_WHERE);
2903
2904 query.append(_FINDER_COLUMN_C_CD_COMPANYID_2);
2905
2906 if (createDate == null) {
2907 query.append(_FINDER_COLUMN_C_CD_CREATEDATE_1);
2908 }
2909 else {
2910 query.append(_FINDER_COLUMN_C_CD_CREATEDATE_2);
2911 }
2912
2913 if (orderByComparator != null) {
2914 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2915 orderByComparator);
2916 }
2917 else
2918 if (pagination) {
2919 query.append(UserModelImpl.ORDER_BY_JPQL);
2920 }
2921
2922 String sql = query.toString();
2923
2924 Session session = null;
2925
2926 try {
2927 session = openSession();
2928
2929 Query q = session.createQuery(sql);
2930
2931 QueryPos qPos = QueryPos.getInstance(q);
2932
2933 qPos.add(companyId);
2934
2935 if (createDate != null) {
2936 qPos.add(CalendarUtil.getTimestamp(createDate));
2937 }
2938
2939 if (!pagination) {
2940 list = (List<User>)QueryUtil.list(q, getDialect(), start,
2941 end, false);
2942
2943 Collections.sort(list);
2944
2945 list = new UnmodifiableList<User>(list);
2946 }
2947 else {
2948 list = (List<User>)QueryUtil.list(q, getDialect(), start,
2949 end);
2950 }
2951
2952 cacheResult(list);
2953
2954 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2955 }
2956 catch (Exception e) {
2957 FinderCacheUtil.removeResult(finderPath, finderArgs);
2958
2959 throw processException(e);
2960 }
2961 finally {
2962 closeSession(session);
2963 }
2964 }
2965
2966 return list;
2967 }
2968
2969
2979 public User findByC_CD_First(long companyId, Date createDate,
2980 OrderByComparator orderByComparator)
2981 throws NoSuchUserException, SystemException {
2982 User user = fetchByC_CD_First(companyId, createDate, orderByComparator);
2983
2984 if (user != null) {
2985 return user;
2986 }
2987
2988 StringBundler msg = new StringBundler(6);
2989
2990 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2991
2992 msg.append("companyId=");
2993 msg.append(companyId);
2994
2995 msg.append(", createDate=");
2996 msg.append(createDate);
2997
2998 msg.append(StringPool.CLOSE_CURLY_BRACE);
2999
3000 throw new NoSuchUserException(msg.toString());
3001 }
3002
3003
3012 public User fetchByC_CD_First(long companyId, Date createDate,
3013 OrderByComparator orderByComparator) throws SystemException {
3014 List<User> list = findByC_CD(companyId, createDate, 0, 1,
3015 orderByComparator);
3016
3017 if (!list.isEmpty()) {
3018 return list.get(0);
3019 }
3020
3021 return null;
3022 }
3023
3024
3034 public User findByC_CD_Last(long companyId, Date createDate,
3035 OrderByComparator orderByComparator)
3036 throws NoSuchUserException, SystemException {
3037 User user = fetchByC_CD_Last(companyId, createDate, orderByComparator);
3038
3039 if (user != null) {
3040 return user;
3041 }
3042
3043 StringBundler msg = new StringBundler(6);
3044
3045 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3046
3047 msg.append("companyId=");
3048 msg.append(companyId);
3049
3050 msg.append(", createDate=");
3051 msg.append(createDate);
3052
3053 msg.append(StringPool.CLOSE_CURLY_BRACE);
3054
3055 throw new NoSuchUserException(msg.toString());
3056 }
3057
3058
3067 public User fetchByC_CD_Last(long companyId, Date createDate,
3068 OrderByComparator orderByComparator) throws SystemException {
3069 int count = countByC_CD(companyId, createDate);
3070
3071 List<User> list = findByC_CD(companyId, createDate, count - 1, count,
3072 orderByComparator);
3073
3074 if (!list.isEmpty()) {
3075 return list.get(0);
3076 }
3077
3078 return null;
3079 }
3080
3081
3092 public User[] findByC_CD_PrevAndNext(long userId, long companyId,
3093 Date createDate, OrderByComparator orderByComparator)
3094 throws NoSuchUserException, SystemException {
3095 User user = findByPrimaryKey(userId);
3096
3097 Session session = null;
3098
3099 try {
3100 session = openSession();
3101
3102 User[] array = new UserImpl[3];
3103
3104 array[0] = getByC_CD_PrevAndNext(session, user, companyId,
3105 createDate, orderByComparator, true);
3106
3107 array[1] = user;
3108
3109 array[2] = getByC_CD_PrevAndNext(session, user, companyId,
3110 createDate, orderByComparator, false);
3111
3112 return array;
3113 }
3114 catch (Exception e) {
3115 throw processException(e);
3116 }
3117 finally {
3118 closeSession(session);
3119 }
3120 }
3121
3122 protected User getByC_CD_PrevAndNext(Session session, User user,
3123 long companyId, Date createDate, OrderByComparator orderByComparator,
3124 boolean previous) {
3125 StringBundler query = null;
3126
3127 if (orderByComparator != null) {
3128 query = new StringBundler(6 +
3129 (orderByComparator.getOrderByFields().length * 6));
3130 }
3131 else {
3132 query = new StringBundler(3);
3133 }
3134
3135 query.append(_SQL_SELECT_USER_WHERE);
3136
3137 query.append(_FINDER_COLUMN_C_CD_COMPANYID_2);
3138
3139 if (createDate == null) {
3140 query.append(_FINDER_COLUMN_C_CD_CREATEDATE_1);
3141 }
3142 else {
3143 query.append(_FINDER_COLUMN_C_CD_CREATEDATE_2);
3144 }
3145
3146 if (orderByComparator != null) {
3147 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3148
3149 if (orderByConditionFields.length > 0) {
3150 query.append(WHERE_AND);
3151 }
3152
3153 for (int i = 0; i < orderByConditionFields.length; i++) {
3154 query.append(_ORDER_BY_ENTITY_ALIAS);
3155 query.append(orderByConditionFields[i]);
3156
3157 if ((i + 1) < orderByConditionFields.length) {
3158 if (orderByComparator.isAscending() ^ previous) {
3159 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3160 }
3161 else {
3162 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3163 }
3164 }
3165 else {
3166 if (orderByComparator.isAscending() ^ previous) {
3167 query.append(WHERE_GREATER_THAN);
3168 }
3169 else {
3170 query.append(WHERE_LESSER_THAN);
3171 }
3172 }
3173 }
3174
3175 query.append(ORDER_BY_CLAUSE);
3176
3177 String[] orderByFields = orderByComparator.getOrderByFields();
3178
3179 for (int i = 0; i < orderByFields.length; i++) {
3180 query.append(_ORDER_BY_ENTITY_ALIAS);
3181 query.append(orderByFields[i]);
3182
3183 if ((i + 1) < orderByFields.length) {
3184 if (orderByComparator.isAscending() ^ previous) {
3185 query.append(ORDER_BY_ASC_HAS_NEXT);
3186 }
3187 else {
3188 query.append(ORDER_BY_DESC_HAS_NEXT);
3189 }
3190 }
3191 else {
3192 if (orderByComparator.isAscending() ^ previous) {
3193 query.append(ORDER_BY_ASC);
3194 }
3195 else {
3196 query.append(ORDER_BY_DESC);
3197 }
3198 }
3199 }
3200 }
3201 else {
3202 query.append(UserModelImpl.ORDER_BY_JPQL);
3203 }
3204
3205 String sql = query.toString();
3206
3207 Query q = session.createQuery(sql);
3208
3209 q.setFirstResult(0);
3210 q.setMaxResults(2);
3211
3212 QueryPos qPos = QueryPos.getInstance(q);
3213
3214 qPos.add(companyId);
3215
3216 if (createDate != null) {
3217 qPos.add(CalendarUtil.getTimestamp(createDate));
3218 }
3219
3220 if (orderByComparator != null) {
3221 Object[] values = orderByComparator.getOrderByConditionValues(user);
3222
3223 for (Object value : values) {
3224 qPos.add(value);
3225 }
3226 }
3227
3228 List<User> list = q.list();
3229
3230 if (list.size() == 2) {
3231 return list.get(1);
3232 }
3233 else {
3234 return null;
3235 }
3236 }
3237
3238
3245 public void removeByC_CD(long companyId, Date createDate)
3246 throws SystemException {
3247 for (User user : findByC_CD(companyId, createDate, QueryUtil.ALL_POS,
3248 QueryUtil.ALL_POS, null)) {
3249 remove(user);
3250 }
3251 }
3252
3253
3261 public int countByC_CD(long companyId, Date createDate)
3262 throws SystemException {
3263 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_CD;
3264
3265 Object[] finderArgs = new Object[] { companyId, createDate };
3266
3267 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3268 this);
3269
3270 if (count == null) {
3271 StringBundler query = new StringBundler(3);
3272
3273 query.append(_SQL_COUNT_USER_WHERE);
3274
3275 query.append(_FINDER_COLUMN_C_CD_COMPANYID_2);
3276
3277 if (createDate == null) {
3278 query.append(_FINDER_COLUMN_C_CD_CREATEDATE_1);
3279 }
3280 else {
3281 query.append(_FINDER_COLUMN_C_CD_CREATEDATE_2);
3282 }
3283
3284 String sql = query.toString();
3285
3286 Session session = null;
3287
3288 try {
3289 session = openSession();
3290
3291 Query q = session.createQuery(sql);
3292
3293 QueryPos qPos = QueryPos.getInstance(q);
3294
3295 qPos.add(companyId);
3296
3297 if (createDate != null) {
3298 qPos.add(CalendarUtil.getTimestamp(createDate));
3299 }
3300
3301 count = (Long)q.uniqueResult();
3302
3303 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3304 }
3305 catch (Exception e) {
3306 FinderCacheUtil.removeResult(finderPath, finderArgs);
3307
3308 throw processException(e);
3309 }
3310 finally {
3311 closeSession(session);
3312 }
3313 }
3314
3315 return count.intValue();
3316 }
3317
3318 private static final String _FINDER_COLUMN_C_CD_COMPANYID_2 = "user.companyId = ? AND ";
3319 private static final String _FINDER_COLUMN_C_CD_CREATEDATE_1 = "user.createDate IS NULL";
3320 private static final String _FINDER_COLUMN_C_CD_CREATEDATE_2 = "user.createDate = ?";
3321 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_MD = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
3322 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
3323 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_MD",
3324 new String[] {
3325 Long.class.getName(), Date.class.getName(),
3326
3327 Integer.class.getName(), Integer.class.getName(),
3328 OrderByComparator.class.getName()
3329 });
3330 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_MD = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
3331 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
3332 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_MD",
3333 new String[] { Long.class.getName(), Date.class.getName() },
3334 UserModelImpl.COMPANYID_COLUMN_BITMASK |
3335 UserModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
3336 public static final FinderPath FINDER_PATH_COUNT_BY_C_MD = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
3337 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
3338 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_MD",
3339 new String[] { Long.class.getName(), Date.class.getName() });
3340
3341
3349 public List<User> findByC_MD(long companyId, Date modifiedDate)
3350 throws SystemException {
3351 return findByC_MD(companyId, modifiedDate, QueryUtil.ALL_POS,
3352 QueryUtil.ALL_POS, null);
3353 }
3354
3355
3369 public List<User> findByC_MD(long companyId, Date modifiedDate, int start,
3370 int end) throws SystemException {
3371 return findByC_MD(companyId, modifiedDate, start, end, null);
3372 }
3373
3374
3389 public List<User> findByC_MD(long companyId, Date modifiedDate, int start,
3390 int end, OrderByComparator orderByComparator) throws SystemException {
3391 boolean pagination = true;
3392 FinderPath finderPath = null;
3393 Object[] finderArgs = null;
3394
3395 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3396 (orderByComparator == null)) {
3397 pagination = false;
3398 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_MD;
3399 finderArgs = new Object[] { companyId, modifiedDate };
3400 }
3401 else {
3402 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_MD;
3403 finderArgs = new Object[] {
3404 companyId, modifiedDate,
3405
3406 start, end, orderByComparator
3407 };
3408 }
3409
3410 List<User> list = (List<User>)FinderCacheUtil.getResult(finderPath,
3411 finderArgs, this);
3412
3413 if ((list != null) && !list.isEmpty()) {
3414 for (User user : list) {
3415 if ((companyId != user.getCompanyId()) ||
3416 !Validator.equals(modifiedDate, user.getModifiedDate())) {
3417 list = null;
3418
3419 break;
3420 }
3421 }
3422 }
3423
3424 if (list == null) {
3425 StringBundler query = null;
3426
3427 if (orderByComparator != null) {
3428 query = new StringBundler(4 +
3429 (orderByComparator.getOrderByFields().length * 3));
3430 }
3431 else {
3432 query = new StringBundler(4);
3433 }
3434
3435 query.append(_SQL_SELECT_USER_WHERE);
3436
3437 query.append(_FINDER_COLUMN_C_MD_COMPANYID_2);
3438
3439 if (modifiedDate == null) {
3440 query.append(_FINDER_COLUMN_C_MD_MODIFIEDDATE_1);
3441 }
3442 else {
3443 query.append(_FINDER_COLUMN_C_MD_MODIFIEDDATE_2);
3444 }
3445
3446 if (orderByComparator != null) {
3447 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3448 orderByComparator);
3449 }
3450 else
3451 if (pagination) {
3452 query.append(UserModelImpl.ORDER_BY_JPQL);
3453 }
3454
3455 String sql = query.toString();
3456
3457 Session session = null;
3458
3459 try {
3460 session = openSession();
3461
3462 Query q = session.createQuery(sql);
3463
3464 QueryPos qPos = QueryPos.getInstance(q);
3465
3466 qPos.add(companyId);
3467
3468 if (modifiedDate != null) {
3469 qPos.add(CalendarUtil.getTimestamp(modifiedDate));
3470 }
3471
3472 if (!pagination) {
3473 list = (List<User>)QueryUtil.list(q, getDialect(), start,
3474 end, false);
3475
3476 Collections.sort(list);
3477
3478 list = new UnmodifiableList<User>(list);
3479 }
3480 else {
3481 list = (List<User>)QueryUtil.list(q, getDialect(), start,
3482 end);
3483 }
3484
3485 cacheResult(list);
3486
3487 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3488 }
3489 catch (Exception e) {
3490 FinderCacheUtil.removeResult(finderPath, finderArgs);
3491
3492 throw processException(e);
3493 }
3494 finally {
3495 closeSession(session);
3496 }
3497 }
3498
3499 return list;
3500 }
3501
3502
3512 public User findByC_MD_First(long companyId, Date modifiedDate,
3513 OrderByComparator orderByComparator)
3514 throws NoSuchUserException, SystemException {
3515 User user = fetchByC_MD_First(companyId, modifiedDate, orderByComparator);
3516
3517 if (user != null) {
3518 return user;
3519 }
3520
3521 StringBundler msg = new StringBundler(6);
3522
3523 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3524
3525 msg.append("companyId=");
3526 msg.append(companyId);
3527
3528 msg.append(", modifiedDate=");
3529 msg.append(modifiedDate);
3530
3531 msg.append(StringPool.CLOSE_CURLY_BRACE);
3532
3533 throw new NoSuchUserException(msg.toString());
3534 }
3535
3536
3545 public User fetchByC_MD_First(long companyId, Date modifiedDate,
3546 OrderByComparator orderByComparator) throws SystemException {
3547 List<User> list = findByC_MD(companyId, modifiedDate, 0, 1,
3548 orderByComparator);
3549
3550 if (!list.isEmpty()) {
3551 return list.get(0);
3552 }
3553
3554 return null;
3555 }
3556
3557
3567 public User findByC_MD_Last(long companyId, Date modifiedDate,
3568 OrderByComparator orderByComparator)
3569 throws NoSuchUserException, SystemException {
3570 User user = fetchByC_MD_Last(companyId, modifiedDate, orderByComparator);
3571
3572 if (user != null) {
3573 return user;
3574 }
3575
3576 StringBundler msg = new StringBundler(6);
3577
3578 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3579
3580 msg.append("companyId=");
3581 msg.append(companyId);
3582
3583 msg.append(", modifiedDate=");
3584 msg.append(modifiedDate);
3585
3586 msg.append(StringPool.CLOSE_CURLY_BRACE);
3587
3588 throw new NoSuchUserException(msg.toString());
3589 }
3590
3591
3600 public User fetchByC_MD_Last(long companyId, Date modifiedDate,
3601 OrderByComparator orderByComparator) throws SystemException {
3602 int count = countByC_MD(companyId, modifiedDate);
3603
3604 List<User> list = findByC_MD(companyId, modifiedDate, count - 1, count,
3605 orderByComparator);
3606
3607 if (!list.isEmpty()) {
3608 return list.get(0);
3609 }
3610
3611 return null;
3612 }
3613
3614
3625 public User[] findByC_MD_PrevAndNext(long userId, long companyId,
3626 Date modifiedDate, OrderByComparator orderByComparator)
3627 throws NoSuchUserException, SystemException {
3628 User user = findByPrimaryKey(userId);
3629
3630 Session session = null;
3631
3632 try {
3633 session = openSession();
3634
3635 User[] array = new UserImpl[3];
3636
3637 array[0] = getByC_MD_PrevAndNext(session, user, companyId,
3638 modifiedDate, orderByComparator, true);
3639
3640 array[1] = user;
3641
3642 array[2] = getByC_MD_PrevAndNext(session, user, companyId,
3643 modifiedDate, orderByComparator, false);
3644
3645 return array;
3646 }
3647 catch (Exception e) {
3648 throw processException(e);
3649 }
3650 finally {
3651 closeSession(session);
3652 }
3653 }
3654
3655 protected User getByC_MD_PrevAndNext(Session session, User user,
3656 long companyId, Date modifiedDate, OrderByComparator orderByComparator,
3657 boolean previous) {
3658 StringBundler query = null;
3659
3660 if (orderByComparator != null) {
3661 query = new StringBundler(6 +
3662 (orderByComparator.getOrderByFields().length * 6));
3663 }
3664 else {
3665 query = new StringBundler(3);
3666 }
3667
3668 query.append(_SQL_SELECT_USER_WHERE);
3669
3670 query.append(_FINDER_COLUMN_C_MD_COMPANYID_2);
3671
3672 if (modifiedDate == null) {
3673 query.append(_FINDER_COLUMN_C_MD_MODIFIEDDATE_1);
3674 }
3675 else {
3676 query.append(_FINDER_COLUMN_C_MD_MODIFIEDDATE_2);
3677 }
3678
3679 if (orderByComparator != null) {
3680 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3681
3682 if (orderByConditionFields.length > 0) {
3683 query.append(WHERE_AND);
3684 }
3685
3686 for (int i = 0; i < orderByConditionFields.length; i++) {
3687 query.append(_ORDER_BY_ENTITY_ALIAS);
3688 query.append(orderByConditionFields[i]);
3689
3690 if ((i + 1) < orderByConditionFields.length) {
3691 if (orderByComparator.isAscending() ^ previous) {
3692 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3693 }
3694 else {
3695 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3696 }
3697 }
3698 else {
3699 if (orderByComparator.isAscending() ^ previous) {
3700 query.append(WHERE_GREATER_THAN);
3701 }
3702 else {
3703 query.append(WHERE_LESSER_THAN);
3704 }
3705 }
3706 }
3707
3708 query.append(ORDER_BY_CLAUSE);
3709
3710 String[] orderByFields = orderByComparator.getOrderByFields();
3711
3712 for (int i = 0; i < orderByFields.length; i++) {
3713 query.append(_ORDER_BY_ENTITY_ALIAS);
3714 query.append(orderByFields[i]);
3715
3716 if ((i + 1) < orderByFields.length) {
3717 if (orderByComparator.isAscending() ^ previous) {
3718 query.append(ORDER_BY_ASC_HAS_NEXT);
3719 }
3720 else {
3721 query.append(ORDER_BY_DESC_HAS_NEXT);
3722 }
3723 }
3724 else {
3725 if (orderByComparator.isAscending() ^ previous) {
3726 query.append(ORDER_BY_ASC);
3727 }
3728 else {
3729 query.append(ORDER_BY_DESC);
3730 }
3731 }
3732 }
3733 }
3734 else {
3735 query.append(UserModelImpl.ORDER_BY_JPQL);
3736 }
3737
3738 String sql = query.toString();
3739
3740 Query q = session.createQuery(sql);
3741
3742 q.setFirstResult(0);
3743 q.setMaxResults(2);
3744
3745 QueryPos qPos = QueryPos.getInstance(q);
3746
3747 qPos.add(companyId);
3748
3749 if (modifiedDate != null) {
3750 qPos.add(CalendarUtil.getTimestamp(modifiedDate));
3751 }
3752
3753 if (orderByComparator != null) {
3754 Object[] values = orderByComparator.getOrderByConditionValues(user);
3755
3756 for (Object value : values) {
3757 qPos.add(value);
3758 }
3759 }
3760
3761 List<User> list = q.list();
3762
3763 if (list.size() == 2) {
3764 return list.get(1);
3765 }
3766 else {
3767 return null;
3768 }
3769 }
3770
3771
3778 public void removeByC_MD(long companyId, Date modifiedDate)
3779 throws SystemException {
3780 for (User user : findByC_MD(companyId, modifiedDate, QueryUtil.ALL_POS,
3781 QueryUtil.ALL_POS, null)) {
3782 remove(user);
3783 }
3784 }
3785
3786
3794 public int countByC_MD(long companyId, Date modifiedDate)
3795 throws SystemException {
3796 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_MD;
3797
3798 Object[] finderArgs = new Object[] { companyId, modifiedDate };
3799
3800 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3801 this);
3802
3803 if (count == null) {
3804 StringBundler query = new StringBundler(3);
3805
3806 query.append(_SQL_COUNT_USER_WHERE);
3807
3808 query.append(_FINDER_COLUMN_C_MD_COMPANYID_2);
3809
3810 if (modifiedDate == null) {
3811 query.append(_FINDER_COLUMN_C_MD_MODIFIEDDATE_1);
3812 }
3813 else {
3814 query.append(_FINDER_COLUMN_C_MD_MODIFIEDDATE_2);
3815 }
3816
3817 String sql = query.toString();
3818
3819 Session session = null;
3820
3821 try {
3822 session = openSession();
3823
3824 Query q = session.createQuery(sql);
3825
3826 QueryPos qPos = QueryPos.getInstance(q);
3827
3828 qPos.add(companyId);
3829
3830 if (modifiedDate != null) {
3831 qPos.add(CalendarUtil.getTimestamp(modifiedDate));
3832 }
3833
3834 count = (Long)q.uniqueResult();
3835
3836 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3837 }
3838 catch (Exception e) {
3839 FinderCacheUtil.removeResult(finderPath, finderArgs);
3840
3841 throw processException(e);
3842 }
3843 finally {
3844 closeSession(session);
3845 }
3846 }
3847
3848 return count.intValue();
3849 }
3850
3851 private static final String _FINDER_COLUMN_C_MD_COMPANYID_2 = "user.companyId = ? AND ";
3852 private static final String _FINDER_COLUMN_C_MD_MODIFIEDDATE_1 = "user.modifiedDate IS NULL";
3853 private static final String _FINDER_COLUMN_C_MD_MODIFIEDDATE_2 = "user.modifiedDate = ?";
3854 public static final FinderPath FINDER_PATH_FETCH_BY_C_DU = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
3855 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
3856 FINDER_CLASS_NAME_ENTITY, "fetchByC_DU",
3857 new String[] { Long.class.getName(), Boolean.class.getName() },
3858 UserModelImpl.COMPANYID_COLUMN_BITMASK |
3859 UserModelImpl.DEFAULTUSER_COLUMN_BITMASK);
3860 public static final FinderPath FINDER_PATH_COUNT_BY_C_DU = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
3861 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
3862 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_DU",
3863 new String[] { Long.class.getName(), Boolean.class.getName() });
3864
3865
3874 public User findByC_DU(long companyId, boolean defaultUser)
3875 throws NoSuchUserException, SystemException {
3876 User user = fetchByC_DU(companyId, defaultUser);
3877
3878 if (user == null) {
3879 StringBundler msg = new StringBundler(6);
3880
3881 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3882
3883 msg.append("companyId=");
3884 msg.append(companyId);
3885
3886 msg.append(", defaultUser=");
3887 msg.append(defaultUser);
3888
3889 msg.append(StringPool.CLOSE_CURLY_BRACE);
3890
3891 if (_log.isWarnEnabled()) {
3892 _log.warn(msg.toString());
3893 }
3894
3895 throw new NoSuchUserException(msg.toString());
3896 }
3897
3898 return user;
3899 }
3900
3901
3909 public User fetchByC_DU(long companyId, boolean defaultUser)
3910 throws SystemException {
3911 return fetchByC_DU(companyId, defaultUser, true);
3912 }
3913
3914
3923 public User fetchByC_DU(long companyId, boolean defaultUser,
3924 boolean retrieveFromCache) throws SystemException {
3925 Object[] finderArgs = new Object[] { companyId, defaultUser };
3926
3927 Object result = null;
3928
3929 if (retrieveFromCache) {
3930 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_DU,
3931 finderArgs, this);
3932 }
3933
3934 if (result instanceof User) {
3935 User user = (User)result;
3936
3937 if ((companyId != user.getCompanyId()) ||
3938 (defaultUser != user.getDefaultUser())) {
3939 result = null;
3940 }
3941 }
3942
3943 if (result == null) {
3944 StringBundler query = new StringBundler(4);
3945
3946 query.append(_SQL_SELECT_USER_WHERE);
3947
3948 query.append(_FINDER_COLUMN_C_DU_COMPANYID_2);
3949
3950 query.append(_FINDER_COLUMN_C_DU_DEFAULTUSER_2);
3951
3952 String sql = query.toString();
3953
3954 Session session = null;
3955
3956 try {
3957 session = openSession();
3958
3959 Query q = session.createQuery(sql);
3960
3961 QueryPos qPos = QueryPos.getInstance(q);
3962
3963 qPos.add(companyId);
3964
3965 qPos.add(defaultUser);
3966
3967 List<User> list = q.list();
3968
3969 if (list.isEmpty()) {
3970 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DU,
3971 finderArgs, list);
3972 }
3973 else {
3974 if ((list.size() > 1) && _log.isWarnEnabled()) {
3975 _log.warn(
3976 "UserPersistenceImpl.fetchByC_DU(long, boolean, boolean) with parameters (" +
3977 StringUtil.merge(finderArgs) +
3978 ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder.");
3979 }
3980
3981 User user = list.get(0);
3982
3983 result = user;
3984
3985 cacheResult(user);
3986
3987 if ((user.getCompanyId() != companyId) ||
3988 (user.getDefaultUser() != defaultUser)) {
3989 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DU,
3990 finderArgs, user);
3991 }
3992 }
3993 }
3994 catch (Exception e) {
3995 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_DU,
3996 finderArgs);
3997
3998 throw processException(e);
3999 }
4000 finally {
4001 closeSession(session);
4002 }
4003 }
4004
4005 if (result instanceof List<?>) {
4006 return null;
4007 }
4008 else {
4009 return (User)result;
4010 }
4011 }
4012
4013
4021 public User removeByC_DU(long companyId, boolean defaultUser)
4022 throws NoSuchUserException, SystemException {
4023 User user = findByC_DU(companyId, defaultUser);
4024
4025 return remove(user);
4026 }
4027
4028
4036 public int countByC_DU(long companyId, boolean defaultUser)
4037 throws SystemException {
4038 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_DU;
4039
4040 Object[] finderArgs = new Object[] { companyId, defaultUser };
4041
4042 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4043 this);
4044
4045 if (count == null) {
4046 StringBundler query = new StringBundler(3);
4047
4048 query.append(_SQL_COUNT_USER_WHERE);
4049
4050 query.append(_FINDER_COLUMN_C_DU_COMPANYID_2);
4051
4052 query.append(_FINDER_COLUMN_C_DU_DEFAULTUSER_2);
4053
4054 String sql = query.toString();
4055
4056 Session session = null;
4057
4058 try {
4059 session = openSession();
4060
4061 Query q = session.createQuery(sql);
4062
4063 QueryPos qPos = QueryPos.getInstance(q);
4064
4065 qPos.add(companyId);
4066
4067 qPos.add(defaultUser);
4068
4069 count = (Long)q.uniqueResult();
4070
4071 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4072 }
4073 catch (Exception e) {
4074 FinderCacheUtil.removeResult(finderPath, finderArgs);
4075
4076 throw processException(e);
4077 }
4078 finally {
4079 closeSession(session);
4080 }
4081 }
4082
4083 return count.intValue();
4084 }
4085
4086 private static final String _FINDER_COLUMN_C_DU_COMPANYID_2 = "user.companyId = ? AND ";
4087 private static final String _FINDER_COLUMN_C_DU_DEFAULTUSER_2 = "user.defaultUser = ?";
4088 public static final FinderPath FINDER_PATH_FETCH_BY_C_SN = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
4089 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
4090 FINDER_CLASS_NAME_ENTITY, "fetchByC_SN",
4091 new String[] { Long.class.getName(), String.class.getName() },
4092 UserModelImpl.COMPANYID_COLUMN_BITMASK |
4093 UserModelImpl.SCREENNAME_COLUMN_BITMASK);
4094 public static final FinderPath FINDER_PATH_COUNT_BY_C_SN = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
4095 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
4096 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_SN",
4097 new String[] { Long.class.getName(), String.class.getName() });
4098
4099
4108 public User findByC_SN(long companyId, String screenName)
4109 throws NoSuchUserException, SystemException {
4110 User user = fetchByC_SN(companyId, screenName);
4111
4112 if (user == null) {
4113 StringBundler msg = new StringBundler(6);
4114
4115 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4116
4117 msg.append("companyId=");
4118 msg.append(companyId);
4119
4120 msg.append(", screenName=");
4121 msg.append(screenName);
4122
4123 msg.append(StringPool.CLOSE_CURLY_BRACE);
4124
4125 if (_log.isWarnEnabled()) {
4126 _log.warn(msg.toString());
4127 }
4128
4129 throw new NoSuchUserException(msg.toString());
4130 }
4131
4132 return user;
4133 }
4134
4135
4143 public User fetchByC_SN(long companyId, String screenName)
4144 throws SystemException {
4145 return fetchByC_SN(companyId, screenName, true);
4146 }
4147
4148
4157 public User fetchByC_SN(long companyId, String screenName,
4158 boolean retrieveFromCache) throws SystemException {
4159 Object[] finderArgs = new Object[] { companyId, screenName };
4160
4161 Object result = null;
4162
4163 if (retrieveFromCache) {
4164 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_SN,
4165 finderArgs, this);
4166 }
4167
4168 if (result instanceof User) {
4169 User user = (User)result;
4170
4171 if ((companyId != user.getCompanyId()) ||
4172 !Validator.equals(screenName, user.getScreenName())) {
4173 result = null;
4174 }
4175 }
4176
4177 if (result == null) {
4178 StringBundler query = new StringBundler(4);
4179
4180 query.append(_SQL_SELECT_USER_WHERE);
4181
4182 query.append(_FINDER_COLUMN_C_SN_COMPANYID_2);
4183
4184 if (screenName == null) {
4185 query.append(_FINDER_COLUMN_C_SN_SCREENNAME_1);
4186 }
4187 else {
4188 if (screenName.equals(StringPool.BLANK)) {
4189 query.append(_FINDER_COLUMN_C_SN_SCREENNAME_3);
4190 }
4191 else {
4192 query.append(_FINDER_COLUMN_C_SN_SCREENNAME_2);
4193 }
4194 }
4195
4196 String sql = query.toString();
4197
4198 Session session = null;
4199
4200 try {
4201 session = openSession();
4202
4203 Query q = session.createQuery(sql);
4204
4205 QueryPos qPos = QueryPos.getInstance(q);
4206
4207 qPos.add(companyId);
4208
4209 if (screenName != null) {
4210 qPos.add(screenName);
4211 }
4212
4213 List<User> list = q.list();
4214
4215 if (list.isEmpty()) {
4216 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_SN,
4217 finderArgs, list);
4218 }
4219 else {
4220 User user = list.get(0);
4221
4222 result = user;
4223
4224 cacheResult(user);
4225
4226 if ((user.getCompanyId() != companyId) ||
4227 (user.getScreenName() == null) ||
4228 !user.getScreenName().equals(screenName)) {
4229 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_SN,
4230 finderArgs, user);
4231 }
4232 }
4233 }
4234 catch (Exception e) {
4235 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_SN,
4236 finderArgs);
4237
4238 throw processException(e);
4239 }
4240 finally {
4241 closeSession(session);
4242 }
4243 }
4244
4245 if (result instanceof List<?>) {
4246 return null;
4247 }
4248 else {
4249 return (User)result;
4250 }
4251 }
4252
4253
4261 public User removeByC_SN(long companyId, String screenName)
4262 throws NoSuchUserException, SystemException {
4263 User user = findByC_SN(companyId, screenName);
4264
4265 return remove(user);
4266 }
4267
4268
4276 public int countByC_SN(long companyId, String screenName)
4277 throws SystemException {
4278 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_SN;
4279
4280 Object[] finderArgs = new Object[] { companyId, screenName };
4281
4282 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4283 this);
4284
4285 if (count == null) {
4286 StringBundler query = new StringBundler(3);
4287
4288 query.append(_SQL_COUNT_USER_WHERE);
4289
4290 query.append(_FINDER_COLUMN_C_SN_COMPANYID_2);
4291
4292 if (screenName == null) {
4293 query.append(_FINDER_COLUMN_C_SN_SCREENNAME_1);
4294 }
4295 else {
4296 if (screenName.equals(StringPool.BLANK)) {
4297 query.append(_FINDER_COLUMN_C_SN_SCREENNAME_3);
4298 }
4299 else {
4300 query.append(_FINDER_COLUMN_C_SN_SCREENNAME_2);
4301 }
4302 }
4303
4304 String sql = query.toString();
4305
4306 Session session = null;
4307
4308 try {
4309 session = openSession();
4310
4311 Query q = session.createQuery(sql);
4312
4313 QueryPos qPos = QueryPos.getInstance(q);
4314
4315 qPos.add(companyId);
4316
4317 if (screenName != null) {
4318 qPos.add(screenName);
4319 }
4320
4321 count = (Long)q.uniqueResult();
4322
4323 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4324 }
4325 catch (Exception e) {
4326 FinderCacheUtil.removeResult(finderPath, finderArgs);
4327
4328 throw processException(e);
4329 }
4330 finally {
4331 closeSession(session);
4332 }
4333 }
4334
4335 return count.intValue();
4336 }
4337
4338 private static final String _FINDER_COLUMN_C_SN_COMPANYID_2 = "user.companyId = ? AND ";
4339 private static final String _FINDER_COLUMN_C_SN_SCREENNAME_1 = "user.screenName IS NULL";
4340 private static final String _FINDER_COLUMN_C_SN_SCREENNAME_2 = "user.screenName = ?";
4341 private static final String _FINDER_COLUMN_C_SN_SCREENNAME_3 = "(user.screenName IS NULL OR user.screenName = ?)";
4342 public static final FinderPath FINDER_PATH_FETCH_BY_C_EA = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
4343 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
4344 FINDER_CLASS_NAME_ENTITY, "fetchByC_EA",
4345 new String[] { Long.class.getName(), String.class.getName() },
4346 UserModelImpl.COMPANYID_COLUMN_BITMASK |
4347 UserModelImpl.EMAILADDRESS_COLUMN_BITMASK);
4348 public static final FinderPath FINDER_PATH_COUNT_BY_C_EA = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
4349 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
4350 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_EA",
4351 new String[] { Long.class.getName(), String.class.getName() });
4352
4353
4362 public User findByC_EA(long companyId, String emailAddress)
4363 throws NoSuchUserException, SystemException {
4364 User user = fetchByC_EA(companyId, emailAddress);
4365
4366 if (user == null) {
4367 StringBundler msg = new StringBundler(6);
4368
4369 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4370
4371 msg.append("companyId=");
4372 msg.append(companyId);
4373
4374 msg.append(", emailAddress=");
4375 msg.append(emailAddress);
4376
4377 msg.append(StringPool.CLOSE_CURLY_BRACE);
4378
4379 if (_log.isWarnEnabled()) {
4380 _log.warn(msg.toString());
4381 }
4382
4383 throw new NoSuchUserException(msg.toString());
4384 }
4385
4386 return user;
4387 }
4388
4389
4397 public User fetchByC_EA(long companyId, String emailAddress)
4398 throws SystemException {
4399 return fetchByC_EA(companyId, emailAddress, true);
4400 }
4401
4402
4411 public User fetchByC_EA(long companyId, String emailAddress,
4412 boolean retrieveFromCache) throws SystemException {
4413 Object[] finderArgs = new Object[] { companyId, emailAddress };
4414
4415 Object result = null;
4416
4417 if (retrieveFromCache) {
4418 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_EA,
4419 finderArgs, this);
4420 }
4421
4422 if (result instanceof User) {
4423 User user = (User)result;
4424
4425 if ((companyId != user.getCompanyId()) ||
4426 !Validator.equals(emailAddress, user.getEmailAddress())) {
4427 result = null;
4428 }
4429 }
4430
4431 if (result == null) {
4432 StringBundler query = new StringBundler(4);
4433
4434 query.append(_SQL_SELECT_USER_WHERE);
4435
4436 query.append(_FINDER_COLUMN_C_EA_COMPANYID_2);
4437
4438 if (emailAddress == null) {
4439 query.append(_FINDER_COLUMN_C_EA_EMAILADDRESS_1);
4440 }
4441 else {
4442 if (emailAddress.equals(StringPool.BLANK)) {
4443 query.append(_FINDER_COLUMN_C_EA_EMAILADDRESS_3);
4444 }
4445 else {
4446 query.append(_FINDER_COLUMN_C_EA_EMAILADDRESS_2);
4447 }
4448 }
4449
4450 String sql = query.toString();
4451
4452 Session session = null;
4453
4454 try {
4455 session = openSession();
4456
4457 Query q = session.createQuery(sql);
4458
4459 QueryPos qPos = QueryPos.getInstance(q);
4460
4461 qPos.add(companyId);
4462
4463 if (emailAddress != null) {
4464 qPos.add(emailAddress);
4465 }
4466
4467 List<User> list = q.list();
4468
4469 if (list.isEmpty()) {
4470 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_EA,
4471 finderArgs, list);
4472 }
4473 else {
4474 User user = list.get(0);
4475
4476 result = user;
4477
4478 cacheResult(user);
4479
4480 if ((user.getCompanyId() != companyId) ||
4481 (user.getEmailAddress() == null) ||
4482 !user.getEmailAddress().equals(emailAddress)) {
4483 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_EA,
4484 finderArgs, user);
4485 }
4486 }
4487 }
4488 catch (Exception e) {
4489 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_EA,
4490 finderArgs);
4491
4492 throw processException(e);
4493 }
4494 finally {
4495 closeSession(session);
4496 }
4497 }
4498
4499 if (result instanceof List<?>) {
4500 return null;
4501 }
4502 else {
4503 return (User)result;
4504 }
4505 }
4506
4507
4515 public User removeByC_EA(long companyId, String emailAddress)
4516 throws NoSuchUserException, SystemException {
4517 User user = findByC_EA(companyId, emailAddress);
4518
4519 return remove(user);
4520 }
4521
4522
4530 public int countByC_EA(long companyId, String emailAddress)
4531 throws SystemException {
4532 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_EA;
4533
4534 Object[] finderArgs = new Object[] { companyId, emailAddress };
4535
4536 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4537 this);
4538
4539 if (count == null) {
4540 StringBundler query = new StringBundler(3);
4541
4542 query.append(_SQL_COUNT_USER_WHERE);
4543
4544 query.append(_FINDER_COLUMN_C_EA_COMPANYID_2);
4545
4546 if (emailAddress == null) {
4547 query.append(_FINDER_COLUMN_C_EA_EMAILADDRESS_1);
4548 }
4549 else {
4550 if (emailAddress.equals(StringPool.BLANK)) {
4551 query.append(_FINDER_COLUMN_C_EA_EMAILADDRESS_3);
4552 }
4553 else {
4554 query.append(_FINDER_COLUMN_C_EA_EMAILADDRESS_2);
4555 }
4556 }
4557
4558 String sql = query.toString();
4559
4560 Session session = null;
4561
4562 try {
4563 session = openSession();
4564
4565 Query q = session.createQuery(sql);
4566
4567 QueryPos qPos = QueryPos.getInstance(q);
4568
4569 qPos.add(companyId);
4570
4571 if (emailAddress != null) {
4572 qPos.add(emailAddress);
4573 }
4574
4575 count = (Long)q.uniqueResult();
4576
4577 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4578 }
4579 catch (Exception e) {
4580 FinderCacheUtil.removeResult(finderPath, finderArgs);
4581
4582 throw processException(e);
4583 }
4584 finally {
4585 closeSession(session);
4586 }
4587 }
4588
4589 return count.intValue();
4590 }
4591
4592 private static final String _FINDER_COLUMN_C_EA_COMPANYID_2 = "user.companyId = ? AND ";
4593 private static final String _FINDER_COLUMN_C_EA_EMAILADDRESS_1 = "user.emailAddress IS NULL";
4594 private static final String _FINDER_COLUMN_C_EA_EMAILADDRESS_2 = "user.emailAddress = ?";
4595 private static final String _FINDER_COLUMN_C_EA_EMAILADDRESS_3 = "(user.emailAddress IS NULL OR user.emailAddress = ?)";
4596 public static final FinderPath FINDER_PATH_FETCH_BY_C_FID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
4597 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
4598 FINDER_CLASS_NAME_ENTITY, "fetchByC_FID",
4599 new String[] { Long.class.getName(), Long.class.getName() },
4600 UserModelImpl.COMPANYID_COLUMN_BITMASK |
4601 UserModelImpl.FACEBOOKID_COLUMN_BITMASK);
4602 public static final FinderPath FINDER_PATH_COUNT_BY_C_FID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
4603 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
4604 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_FID",
4605 new String[] { Long.class.getName(), Long.class.getName() });
4606
4607
4616 public User findByC_FID(long companyId, long facebookId)
4617 throws NoSuchUserException, SystemException {
4618 User user = fetchByC_FID(companyId, facebookId);
4619
4620 if (user == null) {
4621 StringBundler msg = new StringBundler(6);
4622
4623 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4624
4625 msg.append("companyId=");
4626 msg.append(companyId);
4627
4628 msg.append(", facebookId=");
4629 msg.append(facebookId);
4630
4631 msg.append(StringPool.CLOSE_CURLY_BRACE);
4632
4633 if (_log.isWarnEnabled()) {
4634 _log.warn(msg.toString());
4635 }
4636
4637 throw new NoSuchUserException(msg.toString());
4638 }
4639
4640 return user;
4641 }
4642
4643
4651 public User fetchByC_FID(long companyId, long facebookId)
4652 throws SystemException {
4653 return fetchByC_FID(companyId, facebookId, true);
4654 }
4655
4656
4665 public User fetchByC_FID(long companyId, long facebookId,
4666 boolean retrieveFromCache) throws SystemException {
4667 Object[] finderArgs = new Object[] { companyId, facebookId };
4668
4669 Object result = null;
4670
4671 if (retrieveFromCache) {
4672 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_FID,
4673 finderArgs, this);
4674 }
4675
4676 if (result instanceof User) {
4677 User user = (User)result;
4678
4679 if ((companyId != user.getCompanyId()) ||
4680 (facebookId != user.getFacebookId())) {
4681 result = null;
4682 }
4683 }
4684
4685 if (result == null) {
4686 StringBundler query = new StringBundler(4);
4687
4688 query.append(_SQL_SELECT_USER_WHERE);
4689
4690 query.append(_FINDER_COLUMN_C_FID_COMPANYID_2);
4691
4692 query.append(_FINDER_COLUMN_C_FID_FACEBOOKID_2);
4693
4694 String sql = query.toString();
4695
4696 Session session = null;
4697
4698 try {
4699 session = openSession();
4700
4701 Query q = session.createQuery(sql);
4702
4703 QueryPos qPos = QueryPos.getInstance(q);
4704
4705 qPos.add(companyId);
4706
4707 qPos.add(facebookId);
4708
4709 List<User> list = q.list();
4710
4711 if (list.isEmpty()) {
4712 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_FID,
4713 finderArgs, list);
4714 }
4715 else {
4716 if ((list.size() > 1) && _log.isWarnEnabled()) {
4717 _log.warn(
4718 "UserPersistenceImpl.fetchByC_FID(long, long, boolean) with parameters (" +
4719 StringUtil.merge(finderArgs) +
4720 ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder.");
4721 }
4722
4723 User user = list.get(0);
4724
4725 result = user;
4726
4727 cacheResult(user);
4728
4729 if ((user.getCompanyId() != companyId) ||
4730 (user.getFacebookId() != facebookId)) {
4731 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_FID,
4732 finderArgs, user);
4733 }
4734 }
4735 }
4736 catch (Exception e) {
4737 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_FID,
4738 finderArgs);
4739
4740 throw processException(e);
4741 }
4742 finally {
4743 closeSession(session);
4744 }
4745 }
4746
4747 if (result instanceof List<?>) {
4748 return null;
4749 }
4750 else {
4751 return (User)result;
4752 }
4753 }
4754
4755
4763 public User removeByC_FID(long companyId, long facebookId)
4764 throws NoSuchUserException, SystemException {
4765 User user = findByC_FID(companyId, facebookId);
4766
4767 return remove(user);
4768 }
4769
4770
4778 public int countByC_FID(long companyId, long facebookId)
4779 throws SystemException {
4780 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_FID;
4781
4782 Object[] finderArgs = new Object[] { companyId, facebookId };
4783
4784 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4785 this);
4786
4787 if (count == null) {
4788 StringBundler query = new StringBundler(3);
4789
4790 query.append(_SQL_COUNT_USER_WHERE);
4791
4792 query.append(_FINDER_COLUMN_C_FID_COMPANYID_2);
4793
4794 query.append(_FINDER_COLUMN_C_FID_FACEBOOKID_2);
4795
4796 String sql = query.toString();
4797
4798 Session session = null;
4799
4800 try {
4801 session = openSession();
4802
4803 Query q = session.createQuery(sql);
4804
4805 QueryPos qPos = QueryPos.getInstance(q);
4806
4807 qPos.add(companyId);
4808
4809 qPos.add(facebookId);
4810
4811 count = (Long)q.uniqueResult();
4812
4813 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4814 }
4815 catch (Exception e) {
4816 FinderCacheUtil.removeResult(finderPath, finderArgs);
4817
4818 throw processException(e);
4819 }
4820 finally {
4821 closeSession(session);
4822 }
4823 }
4824
4825 return count.intValue();
4826 }
4827
4828 private static final String _FINDER_COLUMN_C_FID_COMPANYID_2 = "user.companyId = ? AND ";
4829 private static final String _FINDER_COLUMN_C_FID_FACEBOOKID_2 = "user.facebookId = ?";
4830 public static final FinderPath FINDER_PATH_FETCH_BY_C_O = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
4831 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
4832 FINDER_CLASS_NAME_ENTITY, "fetchByC_O",
4833 new String[] { Long.class.getName(), String.class.getName() },
4834 UserModelImpl.COMPANYID_COLUMN_BITMASK |
4835 UserModelImpl.OPENID_COLUMN_BITMASK);
4836 public static final FinderPath FINDER_PATH_COUNT_BY_C_O = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
4837 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
4838 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_O",
4839 new String[] { Long.class.getName(), String.class.getName() });
4840
4841
4850 public User findByC_O(long companyId, String openId)
4851 throws NoSuchUserException, SystemException {
4852 User user = fetchByC_O(companyId, openId);
4853
4854 if (user == null) {
4855 StringBundler msg = new StringBundler(6);
4856
4857 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4858
4859 msg.append("companyId=");
4860 msg.append(companyId);
4861
4862 msg.append(", openId=");
4863 msg.append(openId);
4864
4865 msg.append(StringPool.CLOSE_CURLY_BRACE);
4866
4867 if (_log.isWarnEnabled()) {
4868 _log.warn(msg.toString());
4869 }
4870
4871 throw new NoSuchUserException(msg.toString());
4872 }
4873
4874 return user;
4875 }
4876
4877
4885 public User fetchByC_O(long companyId, String openId)
4886 throws SystemException {
4887 return fetchByC_O(companyId, openId, true);
4888 }
4889
4890
4899 public User fetchByC_O(long companyId, String openId,
4900 boolean retrieveFromCache) throws SystemException {
4901 Object[] finderArgs = new Object[] { companyId, openId };
4902
4903 Object result = null;
4904
4905 if (retrieveFromCache) {
4906 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_O,
4907 finderArgs, this);
4908 }
4909
4910 if (result instanceof User) {
4911 User user = (User)result;
4912
4913 if ((companyId != user.getCompanyId()) ||
4914 !Validator.equals(openId, user.getOpenId())) {
4915 result = null;
4916 }
4917 }
4918
4919 if (result == null) {
4920 StringBundler query = new StringBundler(4);
4921
4922 query.append(_SQL_SELECT_USER_WHERE);
4923
4924 query.append(_FINDER_COLUMN_C_O_COMPANYID_2);
4925
4926 if (openId == null) {
4927 query.append(_FINDER_COLUMN_C_O_OPENID_1);
4928 }
4929 else {
4930 if (openId.equals(StringPool.BLANK)) {
4931 query.append(_FINDER_COLUMN_C_O_OPENID_3);
4932 }
4933 else {
4934 query.append(_FINDER_COLUMN_C_O_OPENID_2);
4935 }
4936 }
4937
4938 String sql = query.toString();
4939
4940 Session session = null;
4941
4942 try {
4943 session = openSession();
4944
4945 Query q = session.createQuery(sql);
4946
4947 QueryPos qPos = QueryPos.getInstance(q);
4948
4949 qPos.add(companyId);
4950
4951 if (openId != null) {
4952 qPos.add(openId);
4953 }
4954
4955 List<User> list = q.list();
4956
4957 if (list.isEmpty()) {
4958 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_O,
4959 finderArgs, list);
4960 }
4961 else {
4962 if ((list.size() > 1) && _log.isWarnEnabled()) {
4963 _log.warn(
4964 "UserPersistenceImpl.fetchByC_O(long, String, boolean) with parameters (" +
4965 StringUtil.merge(finderArgs) +
4966 ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder.");
4967 }
4968
4969 User user = list.get(0);
4970
4971 result = user;
4972
4973 cacheResult(user);
4974
4975 if ((user.getCompanyId() != companyId) ||
4976 (user.getOpenId() == null) ||
4977 !user.getOpenId().equals(openId)) {
4978 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_O,
4979 finderArgs, user);
4980 }
4981 }
4982 }
4983 catch (Exception e) {
4984 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_O,
4985 finderArgs);
4986
4987 throw processException(e);
4988 }
4989 finally {
4990 closeSession(session);
4991 }
4992 }
4993
4994 if (result instanceof List<?>) {
4995 return null;
4996 }
4997 else {
4998 return (User)result;
4999 }
5000 }
5001
5002
5010 public User removeByC_O(long companyId, String openId)
5011 throws NoSuchUserException, SystemException {
5012 User user = findByC_O(companyId, openId);
5013
5014 return remove(user);
5015 }
5016
5017
5025 public int countByC_O(long companyId, String openId)
5026 throws SystemException {
5027 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_O;
5028
5029 Object[] finderArgs = new Object[] { companyId, openId };
5030
5031 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5032 this);
5033
5034 if (count == null) {
5035 StringBundler query = new StringBundler(3);
5036
5037 query.append(_SQL_COUNT_USER_WHERE);
5038
5039 query.append(_FINDER_COLUMN_C_O_COMPANYID_2);
5040
5041 if (openId == null) {
5042 query.append(_FINDER_COLUMN_C_O_OPENID_1);
5043 }
5044 else {
5045 if (openId.equals(StringPool.BLANK)) {
5046 query.append(_FINDER_COLUMN_C_O_OPENID_3);
5047 }
5048 else {
5049 query.append(_FINDER_COLUMN_C_O_OPENID_2);
5050 }
5051 }
5052
5053 String sql = query.toString();
5054
5055 Session session = null;
5056
5057 try {
5058 session = openSession();
5059
5060 Query q = session.createQuery(sql);
5061
5062 QueryPos qPos = QueryPos.getInstance(q);
5063
5064 qPos.add(companyId);
5065
5066 if (openId != null) {
5067 qPos.add(openId);
5068 }
5069
5070 count = (Long)q.uniqueResult();
5071
5072 FinderCacheUtil.putResult(finderPath, finderArgs, count);
5073 }
5074 catch (Exception e) {
5075 FinderCacheUtil.removeResult(finderPath, finderArgs);
5076
5077 throw processException(e);
5078 }
5079 finally {
5080 closeSession(session);
5081 }
5082 }
5083
5084 return count.intValue();
5085 }
5086
5087 private static final String _FINDER_COLUMN_C_O_COMPANYID_2 = "user.companyId = ? AND ";
5088 private static final String _FINDER_COLUMN_C_O_OPENID_1 = "user.openId IS NULL";
5089 private static final String _FINDER_COLUMN_C_O_OPENID_2 = "user.openId = ?";
5090 private static final String _FINDER_COLUMN_C_O_OPENID_3 = "(user.openId IS NULL OR user.openId = ?)";
5091 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
5092 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
5093 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_S",
5094 new String[] {
5095 Long.class.getName(), Integer.class.getName(),
5096
5097 Integer.class.getName(), Integer.class.getName(),
5098 OrderByComparator.class.getName()
5099 });
5100 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
5101 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
5102 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_S",
5103 new String[] { Long.class.getName(), Integer.class.getName() },
5104 UserModelImpl.COMPANYID_COLUMN_BITMASK |
5105 UserModelImpl.STATUS_COLUMN_BITMASK);
5106 public static final FinderPath FINDER_PATH_COUNT_BY_C_S = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
5107 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
5108 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_S",
5109 new String[] { Long.class.getName(), Integer.class.getName() });
5110
5111
5119 public List<User> findByC_S(long companyId, int status)
5120 throws SystemException {
5121 return findByC_S(companyId, status, QueryUtil.ALL_POS,
5122 QueryUtil.ALL_POS, null);
5123 }
5124
5125
5139 public List<User> findByC_S(long companyId, int status, int start, int end)
5140 throws SystemException {
5141 return findByC_S(companyId, status, start, end, null);
5142 }
5143
5144
5159 public List<User> findByC_S(long companyId, int status, int start, int end,
5160 OrderByComparator orderByComparator) throws SystemException {
5161 boolean pagination = true;
5162 FinderPath finderPath = null;
5163 Object[] finderArgs = null;
5164
5165 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5166 (orderByComparator == null)) {
5167 pagination = false;
5168 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S;
5169 finderArgs = new Object[] { companyId, status };
5170 }
5171 else {
5172 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S;
5173 finderArgs = new Object[] {
5174 companyId, status,
5175
5176 start, end, orderByComparator
5177 };
5178 }
5179
5180 List<User> list = (List<User>)FinderCacheUtil.getResult(finderPath,
5181 finderArgs, this);
5182
5183 if ((list != null) && !list.isEmpty()) {
5184 for (User user : list) {
5185 if ((companyId != user.getCompanyId()) ||
5186 (status != user.getStatus())) {
5187 list = null;
5188
5189 break;
5190 }
5191 }
5192 }
5193
5194 if (list == null) {
5195 StringBundler query = null;
5196
5197 if (orderByComparator != null) {
5198 query = new StringBundler(4 +
5199 (orderByComparator.getOrderByFields().length * 3));
5200 }
5201 else {
5202 query = new StringBundler(4);
5203 }
5204
5205 query.append(_SQL_SELECT_USER_WHERE);
5206
5207 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
5208
5209 query.append(_FINDER_COLUMN_C_S_STATUS_2);
5210
5211 if (orderByComparator != null) {
5212 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5213 orderByComparator);
5214 }
5215 else
5216 if (pagination) {
5217 query.append(UserModelImpl.ORDER_BY_JPQL);
5218 }
5219
5220 String sql = query.toString();
5221
5222 Session session = null;
5223
5224 try {
5225 session = openSession();
5226
5227 Query q = session.createQuery(sql);
5228
5229 QueryPos qPos = QueryPos.getInstance(q);
5230
5231 qPos.add(companyId);
5232
5233 qPos.add(status);
5234
5235 if (!pagination) {
5236 list = (List<User>)QueryUtil.list(q, getDialect(), start,
5237 end, false);
5238
5239 Collections.sort(list);
5240
5241 list = new UnmodifiableList<User>(list);
5242 }
5243 else {
5244 list = (List<User>)QueryUtil.list(q, getDialect(), start,
5245 end);
5246 }
5247
5248 cacheResult(list);
5249
5250 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5251 }
5252 catch (Exception e) {
5253 FinderCacheUtil.removeResult(finderPath, finderArgs);
5254
5255 throw processException(e);
5256 }
5257 finally {
5258 closeSession(session);
5259 }
5260 }
5261
5262 return list;
5263 }
5264
5265
5275 public User findByC_S_First(long companyId, int status,
5276 OrderByComparator orderByComparator)
5277 throws NoSuchUserException, SystemException {
5278 User user = fetchByC_S_First(companyId, status, orderByComparator);
5279
5280 if (user != null) {
5281 return user;
5282 }
5283
5284 StringBundler msg = new StringBundler(6);
5285
5286 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5287
5288 msg.append("companyId=");
5289 msg.append(companyId);
5290
5291 msg.append(", status=");
5292 msg.append(status);
5293
5294 msg.append(StringPool.CLOSE_CURLY_BRACE);
5295
5296 throw new NoSuchUserException(msg.toString());
5297 }
5298
5299
5308 public User fetchByC_S_First(long companyId, int status,
5309 OrderByComparator orderByComparator) throws SystemException {
5310 List<User> list = findByC_S(companyId, status, 0, 1, orderByComparator);
5311
5312 if (!list.isEmpty()) {
5313 return list.get(0);
5314 }
5315
5316 return null;
5317 }
5318
5319
5329 public User findByC_S_Last(long companyId, int status,
5330 OrderByComparator orderByComparator)
5331 throws NoSuchUserException, SystemException {
5332 User user = fetchByC_S_Last(companyId, status, orderByComparator);
5333
5334 if (user != null) {
5335 return user;
5336 }
5337
5338 StringBundler msg = new StringBundler(6);
5339
5340 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5341
5342 msg.append("companyId=");
5343 msg.append(companyId);
5344
5345 msg.append(", status=");
5346 msg.append(status);
5347
5348 msg.append(StringPool.CLOSE_CURLY_BRACE);
5349
5350 throw new NoSuchUserException(msg.toString());
5351 }
5352
5353
5362 public User fetchByC_S_Last(long companyId, int status,
5363 OrderByComparator orderByComparator) throws SystemException {
5364 int count = countByC_S(companyId, status);
5365
5366 List<User> list = findByC_S(companyId, status, count - 1, count,
5367 orderByComparator);
5368
5369 if (!list.isEmpty()) {
5370 return list.get(0);
5371 }
5372
5373 return null;
5374 }
5375
5376
5387 public User[] findByC_S_PrevAndNext(long userId, long companyId,
5388 int status, OrderByComparator orderByComparator)
5389 throws NoSuchUserException, SystemException {
5390 User user = findByPrimaryKey(userId);
5391
5392 Session session = null;
5393
5394 try {
5395 session = openSession();
5396
5397 User[] array = new UserImpl[3];
5398
5399 array[0] = getByC_S_PrevAndNext(session, user, companyId, status,
5400 orderByComparator, true);
5401
5402 array[1] = user;
5403
5404 array[2] = getByC_S_PrevAndNext(session, user, companyId, status,
5405 orderByComparator, false);
5406
5407 return array;
5408 }
5409 catch (Exception e) {
5410 throw processException(e);
5411 }
5412 finally {
5413 closeSession(session);
5414 }
5415 }
5416
5417 protected User getByC_S_PrevAndNext(Session session, User user,
5418 long companyId, int status, OrderByComparator orderByComparator,
5419 boolean previous) {
5420 StringBundler query = null;
5421
5422 if (orderByComparator != null) {
5423 query = new StringBundler(6 +
5424 (orderByComparator.getOrderByFields().length * 6));
5425 }
5426 else {
5427 query = new StringBundler(3);
5428 }
5429
5430 query.append(_SQL_SELECT_USER_WHERE);
5431
5432 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
5433
5434 query.append(_FINDER_COLUMN_C_S_STATUS_2);
5435
5436 if (orderByComparator != null) {
5437 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5438
5439 if (orderByConditionFields.length > 0) {
5440 query.append(WHERE_AND);
5441 }
5442
5443 for (int i = 0; i < orderByConditionFields.length; i++) {
5444 query.append(_ORDER_BY_ENTITY_ALIAS);
5445 query.append(orderByConditionFields[i]);
5446
5447 if ((i + 1) < orderByConditionFields.length) {
5448 if (orderByComparator.isAscending() ^ previous) {
5449 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5450 }
5451 else {
5452 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5453 }
5454 }
5455 else {
5456 if (orderByComparator.isAscending() ^ previous) {
5457 query.append(WHERE_GREATER_THAN);
5458 }
5459 else {
5460 query.append(WHERE_LESSER_THAN);
5461 }
5462 }
5463 }
5464
5465 query.append(ORDER_BY_CLAUSE);
5466
5467 String[] orderByFields = orderByComparator.getOrderByFields();
5468
5469 for (int i = 0; i < orderByFields.length; i++) {
5470 query.append(_ORDER_BY_ENTITY_ALIAS);
5471 query.append(orderByFields[i]);
5472
5473 if ((i + 1) < orderByFields.length) {
5474 if (orderByComparator.isAscending() ^ previous) {
5475 query.append(ORDER_BY_ASC_HAS_NEXT);
5476 }
5477 else {
5478 query.append(ORDER_BY_DESC_HAS_NEXT);
5479 }
5480 }
5481 else {
5482 if (orderByComparator.isAscending() ^ previous) {
5483 query.append(ORDER_BY_ASC);
5484 }
5485 else {
5486 query.append(ORDER_BY_DESC);
5487 }
5488 }
5489 }
5490 }
5491 else {
5492 query.append(UserModelImpl.ORDER_BY_JPQL);
5493 }
5494
5495 String sql = query.toString();
5496
5497 Query q = session.createQuery(sql);
5498
5499 q.setFirstResult(0);
5500 q.setMaxResults(2);
5501
5502 QueryPos qPos = QueryPos.getInstance(q);
5503
5504 qPos.add(companyId);
5505
5506 qPos.add(status);
5507
5508 if (orderByComparator != null) {
5509 Object[] values = orderByComparator.getOrderByConditionValues(user);
5510
5511 for (Object value : values) {
5512 qPos.add(value);
5513 }
5514 }
5515
5516 List<User> list = q.list();
5517
5518 if (list.size() == 2) {
5519 return list.get(1);
5520 }
5521 else {
5522 return null;
5523 }
5524 }
5525
5526
5533 public void removeByC_S(long companyId, int status)
5534 throws SystemException {
5535 for (User user : findByC_S(companyId, status, QueryUtil.ALL_POS,
5536 QueryUtil.ALL_POS, null)) {
5537 remove(user);
5538 }
5539 }
5540
5541
5549 public int countByC_S(long companyId, int status) throws SystemException {
5550 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_S;
5551
5552 Object[] finderArgs = new Object[] { companyId, status };
5553
5554 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5555 this);
5556
5557 if (count == null) {
5558 StringBundler query = new StringBundler(3);
5559
5560 query.append(_SQL_COUNT_USER_WHERE);
5561
5562 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
5563
5564 query.append(_FINDER_COLUMN_C_S_STATUS_2);
5565
5566 String sql = query.toString();
5567
5568 Session session = null;
5569
5570 try {
5571 session = openSession();
5572
5573 Query q = session.createQuery(sql);
5574
5575 QueryPos qPos = QueryPos.getInstance(q);
5576
5577 qPos.add(companyId);
5578
5579 qPos.add(status);
5580
5581 count = (Long)q.uniqueResult();
5582
5583 FinderCacheUtil.putResult(finderPath, finderArgs, count);
5584 }
5585 catch (Exception e) {
5586 FinderCacheUtil.removeResult(finderPath, finderArgs);
5587
5588 throw processException(e);
5589 }
5590 finally {
5591 closeSession(session);
5592 }
5593 }
5594
5595 return count.intValue();
5596 }
5597
5598 private static final String _FINDER_COLUMN_C_S_COMPANYID_2 = "user.companyId = ? AND ";
5599 private static final String _FINDER_COLUMN_C_S_STATUS_2 = "user.status = ?";
5600 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_CD_MD = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
5601 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
5602 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_CD_MD",
5603 new String[] {
5604 Long.class.getName(), Date.class.getName(), Date.class.getName(),
5605
5606 Integer.class.getName(), Integer.class.getName(),
5607 OrderByComparator.class.getName()
5608 });
5609 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_CD_MD =
5610 new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
5611 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
5612 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_CD_MD",
5613 new String[] {
5614 Long.class.getName(), Date.class.getName(), Date.class.getName()
5615 },
5616 UserModelImpl.COMPANYID_COLUMN_BITMASK |
5617 UserModelImpl.CREATEDATE_COLUMN_BITMASK |
5618 UserModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
5619 public static final FinderPath FINDER_PATH_COUNT_BY_C_CD_MD = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
5620 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
5621 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_CD_MD",
5622 new String[] {
5623 Long.class.getName(), Date.class.getName(), Date.class.getName()
5624 });
5625
5626
5635 public List<User> findByC_CD_MD(long companyId, Date createDate,
5636 Date modifiedDate) throws SystemException {
5637 return findByC_CD_MD(companyId, createDate, modifiedDate,
5638 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5639 }
5640
5641
5656 public List<User> findByC_CD_MD(long companyId, Date createDate,
5657 Date modifiedDate, int start, int end) throws SystemException {
5658 return findByC_CD_MD(companyId, createDate, modifiedDate, start, end,
5659 null);
5660 }
5661
5662
5678 public List<User> findByC_CD_MD(long companyId, Date createDate,
5679 Date modifiedDate, int start, int end,
5680 OrderByComparator orderByComparator) throws SystemException {
5681 boolean pagination = true;
5682 FinderPath finderPath = null;
5683 Object[] finderArgs = null;
5684
5685 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5686 (orderByComparator == null)) {
5687 pagination = false;
5688 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_CD_MD;
5689 finderArgs = new Object[] { companyId, createDate, modifiedDate };
5690 }
5691 else {
5692 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_CD_MD;
5693 finderArgs = new Object[] {
5694 companyId, createDate, modifiedDate,
5695
5696 start, end, orderByComparator
5697 };
5698 }
5699
5700 List<User> list = (List<User>)FinderCacheUtil.getResult(finderPath,
5701 finderArgs, this);
5702
5703 if ((list != null) && !list.isEmpty()) {
5704 for (User user : list) {
5705 if ((companyId != user.getCompanyId()) ||
5706 !Validator.equals(createDate, user.getCreateDate()) ||
5707 !Validator.equals(modifiedDate, user.getModifiedDate())) {
5708 list = null;
5709
5710 break;
5711 }
5712 }
5713 }
5714
5715 if (list == null) {
5716 StringBundler query = null;
5717
5718 if (orderByComparator != null) {
5719 query = new StringBundler(5 +
5720 (orderByComparator.getOrderByFields().length * 3));
5721 }
5722 else {
5723 query = new StringBundler(5);
5724 }
5725
5726 query.append(_SQL_SELECT_USER_WHERE);
5727
5728 query.append(_FINDER_COLUMN_C_CD_MD_COMPANYID_2);
5729
5730 if (createDate == null) {
5731 query.append(_FINDER_COLUMN_C_CD_MD_CREATEDATE_1);
5732 }
5733 else {
5734 query.append(_FINDER_COLUMN_C_CD_MD_CREATEDATE_2);
5735 }
5736
5737 if (modifiedDate == null) {
5738 query.append(_FINDER_COLUMN_C_CD_MD_MODIFIEDDATE_1);
5739 }
5740 else {
5741 query.append(_FINDER_COLUMN_C_CD_MD_MODIFIEDDATE_2);
5742 }
5743
5744 if (orderByComparator != null) {
5745 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5746 orderByComparator);
5747 }
5748 else
5749 if (pagination) {
5750 query.append(UserModelImpl.ORDER_BY_JPQL);
5751 }
5752
5753 String sql = query.toString();
5754
5755 Session session = null;
5756
5757 try {
5758 session = openSession();
5759
5760 Query q = session.createQuery(sql);
5761
5762 QueryPos qPos = QueryPos.getInstance(q);
5763
5764 qPos.add(companyId);
5765
5766 if (createDate != null) {
5767 qPos.add(CalendarUtil.getTimestamp(createDate));
5768 }
5769
5770 if (modifiedDate != null) {
5771 qPos.add(CalendarUtil.getTimestamp(modifiedDate));
5772 }
5773
5774 if (!pagination) {
5775 list = (List<User>)QueryUtil.list(q, getDialect(), start,
5776 end, false);
5777
5778 Collections.sort(list);
5779
5780 list = new UnmodifiableList<User>(list);
5781 }
5782 else {
5783 list = (List<User>)QueryUtil.list(q, getDialect(), start,
5784 end);
5785 }
5786
5787 cacheResult(list);
5788
5789 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5790 }
5791 catch (Exception e) {
5792 FinderCacheUtil.removeResult(finderPath, finderArgs);
5793
5794 throw processException(e);
5795 }
5796 finally {
5797 closeSession(session);
5798 }
5799 }
5800
5801 return list;
5802 }
5803
5804
5815 public User findByC_CD_MD_First(long companyId, Date createDate,
5816 Date modifiedDate, OrderByComparator orderByComparator)
5817 throws NoSuchUserException, SystemException {
5818 User user = fetchByC_CD_MD_First(companyId, createDate, modifiedDate,
5819 orderByComparator);
5820
5821 if (user != null) {
5822 return user;
5823 }
5824
5825 StringBundler msg = new StringBundler(8);
5826
5827 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5828
5829 msg.append("companyId=");
5830 msg.append(companyId);
5831
5832 msg.append(", createDate=");
5833 msg.append(createDate);
5834
5835 msg.append(", modifiedDate=");
5836 msg.append(modifiedDate);
5837
5838 msg.append(StringPool.CLOSE_CURLY_BRACE);
5839
5840 throw new NoSuchUserException(msg.toString());
5841 }
5842
5843
5853 public User fetchByC_CD_MD_First(long companyId, Date createDate,
5854 Date modifiedDate, OrderByComparator orderByComparator)
5855 throws SystemException {
5856 List<User> list = findByC_CD_MD(companyId, createDate, modifiedDate, 0,
5857 1, orderByComparator);
5858
5859 if (!list.isEmpty()) {
5860 return list.get(0);
5861 }
5862
5863 return null;
5864 }
5865
5866
5877 public User findByC_CD_MD_Last(long companyId, Date createDate,
5878 Date modifiedDate, OrderByComparator orderByComparator)
5879 throws NoSuchUserException, SystemException {
5880 User user = fetchByC_CD_MD_Last(companyId, createDate, modifiedDate,
5881 orderByComparator);
5882
5883 if (user != null) {
5884 return user;
5885 }
5886
5887 StringBundler msg = new StringBundler(8);
5888
5889 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5890
5891 msg.append("companyId=");
5892 msg.append(companyId);
5893
5894 msg.append(", createDate=");
5895 msg.append(createDate);
5896
5897 msg.append(", modifiedDate=");
5898 msg.append(modifiedDate);
5899
5900 msg.append(StringPool.CLOSE_CURLY_BRACE);
5901
5902 throw new NoSuchUserException(msg.toString());
5903 }
5904
5905
5915 public User fetchByC_CD_MD_Last(long companyId, Date createDate,
5916 Date modifiedDate, OrderByComparator orderByComparator)
5917 throws SystemException {
5918 int count = countByC_CD_MD(companyId, createDate, modifiedDate);
5919
5920 List<User> list = findByC_CD_MD(companyId, createDate, modifiedDate,
5921 count - 1, count, orderByComparator);
5922
5923 if (!list.isEmpty()) {
5924 return list.get(0);
5925 }
5926
5927 return null;
5928 }
5929
5930
5942 public User[] findByC_CD_MD_PrevAndNext(long userId, long companyId,
5943 Date createDate, Date modifiedDate, OrderByComparator orderByComparator)
5944 throws NoSuchUserException, SystemException {
5945 User user = findByPrimaryKey(userId);
5946
5947 Session session = null;
5948
5949 try {
5950 session = openSession();
5951
5952 User[] array = new UserImpl[3];
5953
5954 array[0] = getByC_CD_MD_PrevAndNext(session, user, companyId,
5955 createDate, modifiedDate, orderByComparator, true);
5956
5957 array[1] = user;
5958
5959 array[2] = getByC_CD_MD_PrevAndNext(session, user, companyId,
5960 createDate, modifiedDate, orderByComparator, false);
5961
5962 return array;
5963 }
5964 catch (Exception e) {
5965 throw processException(e);
5966 }
5967 finally {
5968 closeSession(session);
5969 }
5970 }
5971
5972 protected User getByC_CD_MD_PrevAndNext(Session session, User user,
5973 long companyId, Date createDate, Date modifiedDate,
5974 OrderByComparator orderByComparator, boolean previous) {
5975 StringBundler query = null;
5976
5977 if (orderByComparator != null) {
5978 query = new StringBundler(6 +
5979 (orderByComparator.getOrderByFields().length * 6));
5980 }
5981 else {
5982 query = new StringBundler(3);
5983 }
5984
5985 query.append(_SQL_SELECT_USER_WHERE);
5986
5987 query.append(_FINDER_COLUMN_C_CD_MD_COMPANYID_2);
5988
5989 if (createDate == null) {
5990 query.append(_FINDER_COLUMN_C_CD_MD_CREATEDATE_1);
5991 }
5992 else {
5993 query.append(_FINDER_COLUMN_C_CD_MD_CREATEDATE_2);
5994 }
5995
5996 if (modifiedDate == null) {
5997 query.append(_FINDER_COLUMN_C_CD_MD_MODIFIEDDATE_1);
5998 }
5999 else {
6000 query.append(_FINDER_COLUMN_C_CD_MD_MODIFIEDDATE_2);
6001 }
6002
6003 if (orderByComparator != null) {
6004 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6005
6006 if (orderByConditionFields.length > 0) {
6007 query.append(WHERE_AND);
6008 }
6009
6010 for (int i = 0; i < orderByConditionFields.length; i++) {
6011 query.append(_ORDER_BY_ENTITY_ALIAS);
6012 query.append(orderByConditionFields[i]);
6013
6014 if ((i + 1) < orderByConditionFields.length) {
6015 if (orderByComparator.isAscending() ^ previous) {
6016 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6017 }
6018 else {
6019 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6020 }
6021 }
6022 else {
6023 if (orderByComparator.isAscending() ^ previous) {
6024 query.append(WHERE_GREATER_THAN);
6025 }
6026 else {
6027 query.append(WHERE_LESSER_THAN);
6028 }
6029 }
6030 }
6031
6032 query.append(ORDER_BY_CLAUSE);
6033
6034 String[] orderByFields = orderByComparator.getOrderByFields();
6035
6036 for (int i = 0; i < orderByFields.length; i++) {
6037 query.append(_ORDER_BY_ENTITY_ALIAS);
6038 query.append(orderByFields[i]);
6039
6040 if ((i + 1) < orderByFields.length) {
6041 if (orderByComparator.isAscending() ^ previous) {
6042 query.append(ORDER_BY_ASC_HAS_NEXT);
6043 }
6044 else {
6045 query.append(ORDER_BY_DESC_HAS_NEXT);
6046 }
6047 }
6048 else {
6049 if (orderByComparator.isAscending() ^ previous) {
6050 query.append(ORDER_BY_ASC);
6051 }
6052 else {
6053 query.append(ORDER_BY_DESC);
6054 }
6055 }
6056 }
6057 }
6058 else {
6059 query.append(UserModelImpl.ORDER_BY_JPQL);
6060 }
6061
6062 String sql = query.toString();
6063
6064 Query q = session.createQuery(sql);
6065
6066 q.setFirstResult(0);
6067 q.setMaxResults(2);
6068
6069 QueryPos qPos = QueryPos.getInstance(q);
6070
6071 qPos.add(companyId);
6072
6073 if (createDate != null) {
6074 qPos.add(CalendarUtil.getTimestamp(createDate));
6075 }
6076
6077 if (modifiedDate != null) {
6078 qPos.add(CalendarUtil.getTimestamp(modifiedDate));
6079 }
6080
6081 if (orderByComparator != null) {
6082 Object[] values = orderByComparator.getOrderByConditionValues(user);
6083
6084 for (Object value : values) {
6085 qPos.add(value);
6086 }
6087 }
6088
6089 List<User> list = q.list();
6090
6091 if (list.size() == 2) {
6092 return list.get(1);
6093 }
6094 else {
6095 return null;
6096 }
6097 }
6098
6099
6107 public void removeByC_CD_MD(long companyId, Date createDate,
6108 Date modifiedDate) throws SystemException {
6109 for (User user : findByC_CD_MD(companyId, createDate, modifiedDate,
6110 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6111 remove(user);
6112 }
6113 }
6114
6115
6124 public int countByC_CD_MD(long companyId, Date createDate, Date modifiedDate)
6125 throws SystemException {
6126 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_CD_MD;
6127
6128 Object[] finderArgs = new Object[] { companyId, createDate, modifiedDate };
6129
6130 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6131 this);
6132
6133 if (count == null) {
6134 StringBundler query = new StringBundler(4);
6135
6136 query.append(_SQL_COUNT_USER_WHERE);
6137
6138 query.append(_FINDER_COLUMN_C_CD_MD_COMPANYID_2);
6139
6140 if (createDate == null) {
6141 query.append(_FINDER_COLUMN_C_CD_MD_CREATEDATE_1);
6142 }
6143 else {
6144 query.append(_FINDER_COLUMN_C_CD_MD_CREATEDATE_2);
6145 }
6146
6147 if (modifiedDate == null) {
6148 query.append(_FINDER_COLUMN_C_CD_MD_MODIFIEDDATE_1);
6149 }
6150 else {
6151 query.append(_FINDER_COLUMN_C_CD_MD_MODIFIEDDATE_2);
6152 }
6153
6154 String sql = query.toString();
6155
6156 Session session = null;
6157
6158 try {
6159 session = openSession();
6160
6161 Query q = session.createQuery(sql);
6162
6163 QueryPos qPos = QueryPos.getInstance(q);
6164
6165 qPos.add(companyId);
6166
6167 if (createDate != null) {
6168 qPos.add(CalendarUtil.getTimestamp(createDate));
6169 }
6170
6171 if (modifiedDate != null) {
6172 qPos.add(CalendarUtil.getTimestamp(modifiedDate));
6173 }
6174
6175 count = (Long)q.uniqueResult();
6176
6177 FinderCacheUtil.putResult(finderPath, finderArgs, count);
6178 }
6179 catch (Exception e) {
6180 FinderCacheUtil.removeResult(finderPath, finderArgs);
6181
6182 throw processException(e);
6183 }
6184 finally {
6185 closeSession(session);
6186 }
6187 }
6188
6189 return count.intValue();
6190 }
6191
6192 private static final String _FINDER_COLUMN_C_CD_MD_COMPANYID_2 = "user.companyId = ? AND ";
6193 private static final String _FINDER_COLUMN_C_CD_MD_CREATEDATE_1 = "user.createDate IS NULL AND ";
6194 private static final String _FINDER_COLUMN_C_CD_MD_CREATEDATE_2 = "user.createDate = ? AND ";
6195 private static final String _FINDER_COLUMN_C_CD_MD_MODIFIEDDATE_1 = "user.modifiedDate IS NULL";
6196 private static final String _FINDER_COLUMN_C_CD_MD_MODIFIEDDATE_2 = "user.modifiedDate = ?";
6197
6198
6203 public void cacheResult(User user) {
6204 EntityCacheUtil.putResult(UserModelImpl.ENTITY_CACHE_ENABLED,
6205 UserImpl.class, user.getPrimaryKey(), user);
6206
6207 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID,
6208 new Object[] { Long.valueOf(user.getContactId()) }, user);
6209
6210 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PORTRAITID,
6211 new Object[] { Long.valueOf(user.getPortraitId()) }, user);
6212
6213 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U,
6214 new Object[] {
6215 Long.valueOf(user.getCompanyId()),
6216 Long.valueOf(user.getUserId())
6217 }, user);
6218
6219 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DU,
6220 new Object[] {
6221 Long.valueOf(user.getCompanyId()),
6222 Boolean.valueOf(user.getDefaultUser())
6223 }, user);
6224
6225 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_SN,
6226 new Object[] { Long.valueOf(user.getCompanyId()), user.getScreenName() },
6227 user);
6228
6229 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_EA,
6230 new Object[] {
6231 Long.valueOf(user.getCompanyId()),
6232
6233 user.getEmailAddress()
6234 }, user);
6235
6236 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_FID,
6237 new Object[] {
6238 Long.valueOf(user.getCompanyId()),
6239 Long.valueOf(user.getFacebookId())
6240 }, user);
6241
6242 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_O,
6243 new Object[] { Long.valueOf(user.getCompanyId()), user.getOpenId() },
6244 user);
6245
6246 user.resetOriginalValues();
6247 }
6248
6249
6254 public void cacheResult(List<User> users) {
6255 for (User user : users) {
6256 if (EntityCacheUtil.getResult(UserModelImpl.ENTITY_CACHE_ENABLED,
6257 UserImpl.class, user.getPrimaryKey()) == null) {
6258 cacheResult(user);
6259 }
6260 else {
6261 user.resetOriginalValues();
6262 }
6263 }
6264 }
6265
6266
6273 @Override
6274 public void clearCache() {
6275 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
6276 CacheRegistryUtil.clear(UserImpl.class.getName());
6277 }
6278
6279 EntityCacheUtil.clearCache(UserImpl.class.getName());
6280
6281 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
6282 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
6283 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6284 }
6285
6286
6293 @Override
6294 public void clearCache(User user) {
6295 EntityCacheUtil.removeResult(UserModelImpl.ENTITY_CACHE_ENABLED,
6296 UserImpl.class, user.getPrimaryKey());
6297
6298 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
6299 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6300
6301 clearUniqueFindersCache(user);
6302 }
6303
6304 @Override
6305 public void clearCache(List<User> users) {
6306 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
6307 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6308
6309 for (User user : users) {
6310 EntityCacheUtil.removeResult(UserModelImpl.ENTITY_CACHE_ENABLED,
6311 UserImpl.class, user.getPrimaryKey());
6312
6313 clearUniqueFindersCache(user);
6314 }
6315 }
6316
6317 protected void cacheUniqueFindersCache(User user) {
6318 if (user.isNew()) {
6319 Object[] args = new Object[] { Long.valueOf(user.getContactId()) };
6320
6321 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CONTACTID, args,
6322 Long.valueOf(1));
6323 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID, args, user);
6324
6325 args = new Object[] { Long.valueOf(user.getPortraitId()) };
6326
6327 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PORTRAITID, args,
6328 Long.valueOf(1));
6329 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PORTRAITID, args,
6330 user);
6331
6332 args = new Object[] {
6333 Long.valueOf(user.getCompanyId()),
6334 Long.valueOf(user.getUserId())
6335 };
6336
6337 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_U, args,
6338 Long.valueOf(1));
6339 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U, args, user);
6340
6341 args = new Object[] {
6342 Long.valueOf(user.getCompanyId()),
6343 Boolean.valueOf(user.getDefaultUser())
6344 };
6345
6346 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_DU, args,
6347 Long.valueOf(1));
6348 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DU, args, user);
6349
6350 args = new Object[] {
6351 Long.valueOf(user.getCompanyId()),
6352
6353 user.getScreenName()
6354 };
6355
6356 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_SN, args,
6357 Long.valueOf(1));
6358 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_SN, args, user);
6359
6360 args = new Object[] {
6361 Long.valueOf(user.getCompanyId()),
6362
6363 user.getEmailAddress()
6364 };
6365
6366 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_EA, args,
6367 Long.valueOf(1));
6368 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_EA, args, user);
6369
6370 args = new Object[] {
6371 Long.valueOf(user.getCompanyId()),
6372 Long.valueOf(user.getFacebookId())
6373 };
6374
6375 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_FID, args,
6376 Long.valueOf(1));
6377 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_FID, args, user);
6378
6379 args = new Object[] {
6380 Long.valueOf(user.getCompanyId()),
6381
6382 user.getOpenId()
6383 };
6384
6385 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_O, args,
6386 Long.valueOf(1));
6387 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_O, args, user);
6388 }
6389 else {
6390 UserModelImpl userModelImpl = (UserModelImpl)user;
6391
6392 if ((userModelImpl.getColumnBitmask() &
6393 FINDER_PATH_FETCH_BY_CONTACTID.getColumnBitmask()) != 0) {
6394 Object[] args = new Object[] { Long.valueOf(user.getContactId()) };
6395
6396 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CONTACTID, args,
6397 Long.valueOf(1));
6398 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID, args,
6399 user);
6400 }
6401
6402 if ((userModelImpl.getColumnBitmask() &
6403 FINDER_PATH_FETCH_BY_PORTRAITID.getColumnBitmask()) != 0) {
6404 Object[] args = new Object[] { Long.valueOf(user.getPortraitId()) };
6405
6406 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PORTRAITID,
6407 args, Long.valueOf(1));
6408 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PORTRAITID,
6409 args, user);
6410 }
6411
6412 if ((userModelImpl.getColumnBitmask() &
6413 FINDER_PATH_FETCH_BY_C_U.getColumnBitmask()) != 0) {
6414 Object[] args = new Object[] {
6415 Long.valueOf(user.getCompanyId()),
6416 Long.valueOf(user.getUserId())
6417 };
6418
6419 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_U, args,
6420 Long.valueOf(1));
6421 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U, args, user);
6422 }
6423
6424 if ((userModelImpl.getColumnBitmask() &
6425 FINDER_PATH_FETCH_BY_C_DU.getColumnBitmask()) != 0) {
6426 Object[] args = new Object[] {
6427 Long.valueOf(user.getCompanyId()),
6428 Boolean.valueOf(user.getDefaultUser())
6429 };
6430
6431 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_DU, args,
6432 Long.valueOf(1));
6433 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DU, args, user);
6434 }
6435
6436 if ((userModelImpl.getColumnBitmask() &
6437 FINDER_PATH_FETCH_BY_C_SN.getColumnBitmask()) != 0) {
6438 Object[] args = new Object[] {
6439 Long.valueOf(user.getCompanyId()),
6440
6441 user.getScreenName()
6442 };
6443
6444 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_SN, args,
6445 Long.valueOf(1));
6446 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_SN, args, user);
6447 }
6448
6449 if ((userModelImpl.getColumnBitmask() &
6450 FINDER_PATH_FETCH_BY_C_EA.getColumnBitmask()) != 0) {
6451 Object[] args = new Object[] {
6452 Long.valueOf(user.getCompanyId()),
6453
6454 user.getEmailAddress()
6455 };
6456
6457 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_EA, args,
6458 Long.valueOf(1));
6459 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_EA, args, user);
6460 }
6461
6462 if ((userModelImpl.getColumnBitmask() &
6463 FINDER_PATH_FETCH_BY_C_FID.getColumnBitmask()) != 0) {
6464 Object[] args = new Object[] {
6465 Long.valueOf(user.getCompanyId()),
6466 Long.valueOf(user.getFacebookId())
6467 };
6468
6469 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_FID, args,
6470 Long.valueOf(1));
6471 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_FID, args, user);
6472 }
6473
6474 if ((userModelImpl.getColumnBitmask() &
6475 FINDER_PATH_FETCH_BY_C_O.getColumnBitmask()) != 0) {
6476 Object[] args = new Object[] {
6477 Long.valueOf(user.getCompanyId()),
6478
6479 user.getOpenId()
6480 };
6481
6482 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_O, args,
6483 Long.valueOf(1));
6484 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_O, args, user);
6485 }
6486 }
6487 }
6488
6489 protected void clearUniqueFindersCache(User user) {
6490 UserModelImpl userModelImpl = (UserModelImpl)user;
6491
6492 Object[] args = new Object[] { Long.valueOf(user.getContactId()) };
6493
6494 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CONTACTID, args);
6495 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CONTACTID, args);
6496
6497 if ((userModelImpl.getColumnBitmask() &
6498 FINDER_PATH_FETCH_BY_CONTACTID.getColumnBitmask()) != 0) {
6499 args = new Object[] {
6500 Long.valueOf(userModelImpl.getOriginalContactId())
6501 };
6502
6503 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CONTACTID, args);
6504 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CONTACTID, args);
6505 }
6506
6507 args = new Object[] { Long.valueOf(user.getPortraitId()) };
6508
6509 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PORTRAITID, args);
6510 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_PORTRAITID, args);
6511
6512 if ((userModelImpl.getColumnBitmask() &
6513 FINDER_PATH_FETCH_BY_PORTRAITID.getColumnBitmask()) != 0) {
6514 args = new Object[] {
6515 Long.valueOf(userModelImpl.getOriginalPortraitId())
6516 };
6517
6518 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PORTRAITID, args);
6519 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_PORTRAITID, args);
6520 }
6521
6522 args = new Object[] {
6523 Long.valueOf(user.getCompanyId()),
6524 Long.valueOf(user.getUserId())
6525 };
6526
6527 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
6528 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U, args);
6529
6530 if ((userModelImpl.getColumnBitmask() &
6531 FINDER_PATH_FETCH_BY_C_U.getColumnBitmask()) != 0) {
6532 args = new Object[] {
6533 Long.valueOf(userModelImpl.getOriginalCompanyId()),
6534 Long.valueOf(userModelImpl.getOriginalUserId())
6535 };
6536
6537 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
6538 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U, args);
6539 }
6540
6541 args = new Object[] {
6542 Long.valueOf(user.getCompanyId()),
6543 Boolean.valueOf(user.getDefaultUser())
6544 };
6545
6546 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_DU, args);
6547 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_DU, args);
6548
6549 if ((userModelImpl.getColumnBitmask() &
6550 FINDER_PATH_FETCH_BY_C_DU.getColumnBitmask()) != 0) {
6551 args = new Object[] {
6552 Long.valueOf(userModelImpl.getOriginalCompanyId()),
6553 Boolean.valueOf(userModelImpl.getOriginalDefaultUser())
6554 };
6555
6556 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_DU, args);
6557 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_DU, args);
6558 }
6559
6560 args = new Object[] {
6561 Long.valueOf(user.getCompanyId()),
6562
6563 user.getScreenName()
6564 };
6565
6566 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_SN, args);
6567 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_SN, args);
6568
6569 if ((userModelImpl.getColumnBitmask() &
6570 FINDER_PATH_FETCH_BY_C_SN.getColumnBitmask()) != 0) {
6571 args = new Object[] {
6572 Long.valueOf(userModelImpl.getOriginalCompanyId()),
6573
6574 userModelImpl.getOriginalScreenName()
6575 };
6576
6577 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_SN, args);
6578 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_SN, args);
6579 }
6580
6581 args = new Object[] {
6582 Long.valueOf(user.getCompanyId()),
6583
6584 user.getEmailAddress()
6585 };
6586
6587 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_EA, args);
6588 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_EA, args);
6589
6590 if ((userModelImpl.getColumnBitmask() &
6591 FINDER_PATH_FETCH_BY_C_EA.getColumnBitmask()) != 0) {
6592 args = new Object[] {
6593 Long.valueOf(userModelImpl.getOriginalCompanyId()),
6594
6595 userModelImpl.getOriginalEmailAddress()
6596 };
6597
6598 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_EA, args);
6599 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_EA, args);
6600 }
6601
6602 args = new Object[] {
6603 Long.valueOf(user.getCompanyId()),
6604 Long.valueOf(user.getFacebookId())
6605 };
6606
6607 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_FID, args);
6608 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_FID, args);
6609
6610 if ((userModelImpl.getColumnBitmask() &
6611 FINDER_PATH_FETCH_BY_C_FID.getColumnBitmask()) != 0) {
6612 args = new Object[] {
6613 Long.valueOf(userModelImpl.getOriginalCompanyId()),
6614 Long.valueOf(userModelImpl.getOriginalFacebookId())
6615 };
6616
6617 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_FID, args);
6618 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_FID, args);
6619 }
6620
6621 args = new Object[] { Long.valueOf(user.getCompanyId()), user.getOpenId() };
6622
6623 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_O, args);
6624 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_O, args);
6625
6626 if ((userModelImpl.getColumnBitmask() &
6627 FINDER_PATH_FETCH_BY_C_O.getColumnBitmask()) != 0) {
6628 args = new Object[] {
6629 Long.valueOf(userModelImpl.getOriginalCompanyId()),
6630
6631 userModelImpl.getOriginalOpenId()
6632 };
6633
6634 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_O, args);
6635 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_O, args);
6636 }
6637 }
6638
6639
6645 public User create(long userId) {
6646 User user = new UserImpl();
6647
6648 user.setNew(true);
6649 user.setPrimaryKey(userId);
6650
6651 String uuid = PortalUUIDUtil.generate();
6652
6653 user.setUuid(uuid);
6654
6655 return user;
6656 }
6657
6658
6666 public User remove(long userId) throws NoSuchUserException, SystemException {
6667 return remove(Long.valueOf(userId));
6668 }
6669
6670
6678 @Override
6679 public User remove(Serializable primaryKey)
6680 throws NoSuchUserException, SystemException {
6681 Session session = null;
6682
6683 try {
6684 session = openSession();
6685
6686 User user = (User)session.get(UserImpl.class, primaryKey);
6687
6688 if (user == null) {
6689 if (_log.isWarnEnabled()) {
6690 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
6691 }
6692
6693 throw new NoSuchUserException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
6694 primaryKey);
6695 }
6696
6697 return remove(user);
6698 }
6699 catch (NoSuchUserException nsee) {
6700 throw nsee;
6701 }
6702 catch (Exception e) {
6703 throw processException(e);
6704 }
6705 finally {
6706 closeSession(session);
6707 }
6708 }
6709
6710 @Override
6711 protected User removeImpl(User user) throws SystemException {
6712 user = toUnwrappedModel(user);
6713
6714 try {
6715 clearGroups.clear(user.getPrimaryKey());
6716 }
6717 catch (Exception e) {
6718 throw processException(e);
6719 }
6720 finally {
6721 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
6722 }
6723
6724 try {
6725 clearOrganizations.clear(user.getPrimaryKey());
6726 }
6727 catch (Exception e) {
6728 throw processException(e);
6729 }
6730 finally {
6731 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
6732 }
6733
6734 try {
6735 clearRoles.clear(user.getPrimaryKey());
6736 }
6737 catch (Exception e) {
6738 throw processException(e);
6739 }
6740 finally {
6741 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6742 }
6743
6744 try {
6745 clearTeams.clear(user.getPrimaryKey());
6746 }
6747 catch (Exception e) {
6748 throw processException(e);
6749 }
6750 finally {
6751 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
6752 }
6753
6754 try {
6755 clearUserGroups.clear(user.getPrimaryKey());
6756 }
6757 catch (Exception e) {
6758 throw processException(e);
6759 }
6760 finally {
6761 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
6762 }
6763
6764 Session session = null;
6765
6766 try {
6767 session = openSession();
6768
6769 if (!session.contains(user)) {
6770 user = (User)session.get(UserImpl.class, user.getPrimaryKeyObj());
6771 }
6772
6773 if (user != null) {
6774 session.delete(user);
6775 }
6776 }
6777 catch (Exception e) {
6778 throw processException(e);
6779 }
6780 finally {
6781 closeSession(session);
6782 }
6783
6784 if (user != null) {
6785 clearCache(user);
6786 }
6787
6788 return user;
6789 }
6790
6791 @Override
6792 public User updateImpl(com.liferay.portal.model.User user)
6793 throws SystemException {
6794 user = toUnwrappedModel(user);
6795
6796 boolean isNew = user.isNew();
6797
6798 UserModelImpl userModelImpl = (UserModelImpl)user;
6799
6800 if (Validator.isNull(user.getUuid())) {
6801 String uuid = PortalUUIDUtil.generate();
6802
6803 user.setUuid(uuid);
6804 }
6805
6806 Session session = null;
6807
6808 try {
6809 session = openSession();
6810
6811 if (user.isNew()) {
6812 session.save(user);
6813
6814 user.setNew(false);
6815 }
6816 else {
6817 session.merge(user);
6818 }
6819 }
6820 catch (Exception e) {
6821 throw processException(e);
6822 }
6823 finally {
6824 closeSession(session);
6825 }
6826
6827 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
6828
6829 if (isNew || !UserModelImpl.COLUMN_BITMASK_ENABLED) {
6830 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6831 }
6832
6833 else {
6834 if ((userModelImpl.getColumnBitmask() &
6835 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
6836 Object[] args = new Object[] { userModelImpl.getOriginalUuid() };
6837
6838 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
6839 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
6840 args);
6841
6842 args = new Object[] { userModelImpl.getUuid() };
6843
6844 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
6845 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
6846 args);
6847 }
6848
6849 if ((userModelImpl.getColumnBitmask() &
6850 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
6851 Object[] args = new Object[] {
6852 userModelImpl.getOriginalUuid(),
6853 Long.valueOf(userModelImpl.getOriginalCompanyId())
6854 };
6855
6856 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
6857 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
6858 args);
6859
6860 args = new Object[] {
6861 userModelImpl.getUuid(),
6862 Long.valueOf(userModelImpl.getCompanyId())
6863 };
6864
6865 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
6866 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
6867 args);
6868 }
6869
6870 if ((userModelImpl.getColumnBitmask() &
6871 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
6872 Object[] args = new Object[] {
6873 Long.valueOf(userModelImpl.getOriginalCompanyId())
6874 };
6875
6876 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
6877 args);
6878 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
6879 args);
6880
6881 args = new Object[] { Long.valueOf(userModelImpl.getCompanyId()) };
6882
6883 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
6884 args);
6885 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
6886 args);
6887 }
6888
6889 if ((userModelImpl.getColumnBitmask() &
6890 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EMAILADDRESS.getColumnBitmask()) != 0) {
6891 Object[] args = new Object[] {
6892 userModelImpl.getOriginalEmailAddress()
6893 };
6894
6895 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_EMAILADDRESS,
6896 args);
6897 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EMAILADDRESS,
6898 args);
6899
6900 args = new Object[] { userModelImpl.getEmailAddress() };
6901
6902 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_EMAILADDRESS,
6903 args);
6904 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EMAILADDRESS,
6905 args);
6906 }
6907
6908 if ((userModelImpl.getColumnBitmask() &
6909 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_CD.getColumnBitmask()) != 0) {
6910 Object[] args = new Object[] {
6911 Long.valueOf(userModelImpl.getOriginalCompanyId()),
6912
6913 userModelImpl.getOriginalCreateDate()
6914 };
6915
6916 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_CD, args);
6917 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_CD,
6918 args);
6919
6920 args = new Object[] {
6921 Long.valueOf(userModelImpl.getCompanyId()),
6922
6923 userModelImpl.getCreateDate()
6924 };
6925
6926 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_CD, args);
6927 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_CD,
6928 args);
6929 }
6930
6931 if ((userModelImpl.getColumnBitmask() &
6932 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_MD.getColumnBitmask()) != 0) {
6933 Object[] args = new Object[] {
6934 Long.valueOf(userModelImpl.getOriginalCompanyId()),
6935
6936 userModelImpl.getOriginalModifiedDate()
6937 };
6938
6939 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_MD, args);
6940 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_MD,
6941 args);
6942
6943 args = new Object[] {
6944 Long.valueOf(userModelImpl.getCompanyId()),
6945
6946 userModelImpl.getModifiedDate()
6947 };
6948
6949 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_MD, args);
6950 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_MD,
6951 args);
6952 }
6953
6954 if ((userModelImpl.getColumnBitmask() &
6955 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S.getColumnBitmask()) != 0) {
6956 Object[] args = new Object[] {
6957 Long.valueOf(userModelImpl.getOriginalCompanyId()),
6958 Integer.valueOf(userModelImpl.getOriginalStatus())
6959 };
6960
6961 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
6962 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
6963 args);
6964
6965 args = new Object[] {
6966 Long.valueOf(userModelImpl.getCompanyId()),
6967 Integer.valueOf(userModelImpl.getStatus())
6968 };
6969
6970 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
6971 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
6972 args);
6973 }
6974
6975 if ((userModelImpl.getColumnBitmask() &
6976 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_CD_MD.getColumnBitmask()) != 0) {
6977 Object[] args = new Object[] {
6978 Long.valueOf(userModelImpl.getOriginalCompanyId()),
6979
6980 userModelImpl.getOriginalCreateDate(),
6981
6982 userModelImpl.getOriginalModifiedDate()
6983 };
6984
6985 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_CD_MD, args);
6986 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_CD_MD,
6987 args);
6988
6989 args = new Object[] {
6990 Long.valueOf(userModelImpl.getCompanyId()),
6991
6992 userModelImpl.getCreateDate(),
6993
6994 userModelImpl.getModifiedDate()
6995 };
6996
6997 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_CD_MD, args);
6998 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_CD_MD,
6999 args);
7000 }
7001 }
7002
7003 EntityCacheUtil.putResult(UserModelImpl.ENTITY_CACHE_ENABLED,
7004 UserImpl.class, user.getPrimaryKey(), user);
7005
7006 clearUniqueFindersCache(user);
7007 cacheUniqueFindersCache(user);
7008
7009 return user;
7010 }
7011
7012 protected User toUnwrappedModel(User user) {
7013 if (user instanceof UserImpl) {
7014 return user;
7015 }
7016
7017 UserImpl userImpl = new UserImpl();
7018
7019 userImpl.setNew(user.isNew());
7020 userImpl.setPrimaryKey(user.getPrimaryKey());
7021
7022 userImpl.setUuid(user.getUuid());
7023 userImpl.setUserId(user.getUserId());
7024 userImpl.setCompanyId(user.getCompanyId());
7025 userImpl.setCreateDate(user.getCreateDate());
7026 userImpl.setModifiedDate(user.getModifiedDate());
7027 userImpl.setDefaultUser(user.isDefaultUser());
7028 userImpl.setContactId(user.getContactId());
7029 userImpl.setPassword(user.getPassword());
7030 userImpl.setPasswordEncrypted(user.isPasswordEncrypted());
7031 userImpl.setPasswordReset(user.isPasswordReset());
7032 userImpl.setPasswordModifiedDate(user.getPasswordModifiedDate());
7033 userImpl.setDigest(user.getDigest());
7034 userImpl.setReminderQueryQuestion(user.getReminderQueryQuestion());
7035 userImpl.setReminderQueryAnswer(user.getReminderQueryAnswer());
7036 userImpl.setGraceLoginCount(user.getGraceLoginCount());
7037 userImpl.setScreenName(user.getScreenName());
7038 userImpl.setEmailAddress(user.getEmailAddress());
7039 userImpl.setFacebookId(user.getFacebookId());
7040 userImpl.setLdapServerId(user.getLdapServerId());
7041 userImpl.setOpenId(user.getOpenId());
7042 userImpl.setPortraitId(user.getPortraitId());
7043 userImpl.setLanguageId(user.getLanguageId());
7044 userImpl.setTimeZoneId(user.getTimeZoneId());
7045 userImpl.setGreeting(user.getGreeting());
7046 userImpl.setComments(user.getComments());
7047 userImpl.setFirstName(user.getFirstName());
7048 userImpl.setMiddleName(user.getMiddleName());
7049 userImpl.setLastName(user.getLastName());
7050 userImpl.setJobTitle(user.getJobTitle());
7051 userImpl.setLoginDate(user.getLoginDate());
7052 userImpl.setLoginIP(user.getLoginIP());
7053 userImpl.setLastLoginDate(user.getLastLoginDate());
7054 userImpl.setLastLoginIP(user.getLastLoginIP());
7055 userImpl.setLastFailedLoginDate(user.getLastFailedLoginDate());
7056 userImpl.setFailedLoginAttempts(user.getFailedLoginAttempts());
7057 userImpl.setLockout(user.isLockout());
7058 userImpl.setLockoutDate(user.getLockoutDate());
7059 userImpl.setAgreedToTermsOfUse(user.isAgreedToTermsOfUse());
7060 userImpl.setEmailAddressVerified(user.isEmailAddressVerified());
7061 userImpl.setStatus(user.getStatus());
7062
7063 return userImpl;
7064 }
7065
7066
7074 @Override
7075 public User findByPrimaryKey(Serializable primaryKey)
7076 throws NoSuchModelException, SystemException {
7077 return findByPrimaryKey(((Long)primaryKey).longValue());
7078 }
7079
7080
7088 public User findByPrimaryKey(long userId)
7089 throws NoSuchUserException, SystemException {
7090 User user = fetchByPrimaryKey(userId);
7091
7092 if (user == null) {
7093 if (_log.isWarnEnabled()) {
7094 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + userId);
7095 }
7096
7097 throw new NoSuchUserException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
7098 userId);
7099 }
7100
7101 return user;
7102 }
7103
7104
7111 @Override
7112 public User fetchByPrimaryKey(Serializable primaryKey)
7113 throws SystemException {
7114 return fetchByPrimaryKey(((Long)primaryKey).longValue());
7115 }
7116
7117
7124 public User fetchByPrimaryKey(long userId) throws SystemException {
7125 User user = (User)EntityCacheUtil.getResult(UserModelImpl.ENTITY_CACHE_ENABLED,
7126 UserImpl.class, userId);
7127
7128 if (user == _nullUser) {
7129 return null;
7130 }
7131
7132 if (user == null) {
7133 Session session = null;
7134
7135 try {
7136 session = openSession();
7137
7138 user = (User)session.get(UserImpl.class, Long.valueOf(userId));
7139
7140 if (user != null) {
7141 cacheResult(user);
7142 }
7143 else {
7144 EntityCacheUtil.putResult(UserModelImpl.ENTITY_CACHE_ENABLED,
7145 UserImpl.class, userId, _nullUser);
7146 }
7147 }
7148 catch (Exception e) {
7149 EntityCacheUtil.removeResult(UserModelImpl.ENTITY_CACHE_ENABLED,
7150 UserImpl.class, userId);
7151
7152 throw processException(e);
7153 }
7154 finally {
7155 closeSession(session);
7156 }
7157 }
7158
7159 return user;
7160 }
7161
7162
7168 public List<User> findAll() throws SystemException {
7169 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7170 }
7171
7172
7184 public List<User> findAll(int start, int end) throws SystemException {
7185 return findAll(start, end, null);
7186 }
7187
7188
7201 public List<User> findAll(int start, int end,
7202 OrderByComparator orderByComparator) throws SystemException {
7203 boolean pagination = true;
7204 FinderPath finderPath = null;
7205 Object[] finderArgs = null;
7206
7207 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7208 (orderByComparator == null)) {
7209 pagination = false;
7210 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
7211 finderArgs = FINDER_ARGS_EMPTY;
7212 }
7213 else {
7214 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
7215 finderArgs = new Object[] { start, end, orderByComparator };
7216 }
7217
7218 List<User> list = (List<User>)FinderCacheUtil.getResult(finderPath,
7219 finderArgs, this);
7220
7221 if (list == null) {
7222 StringBundler query = null;
7223 String sql = null;
7224
7225 if (orderByComparator != null) {
7226 query = new StringBundler(2 +
7227 (orderByComparator.getOrderByFields().length * 3));
7228
7229 query.append(_SQL_SELECT_USER);
7230
7231 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7232 orderByComparator);
7233
7234 sql = query.toString();
7235 }
7236 else {
7237 sql = _SQL_SELECT_USER;
7238
7239 if (pagination) {
7240 sql = sql.concat(UserModelImpl.ORDER_BY_JPQL);
7241 }
7242 }
7243
7244 Session session = null;
7245
7246 try {
7247 session = openSession();
7248
7249 Query q = session.createQuery(sql);
7250
7251 if (!pagination) {
7252 list = (List<User>)QueryUtil.list(q, getDialect(), start,
7253 end, false);
7254
7255 Collections.sort(list);
7256
7257 list = new UnmodifiableList<User>(list);
7258 }
7259 else {
7260 list = (List<User>)QueryUtil.list(q, getDialect(), start,
7261 end);
7262 }
7263
7264 cacheResult(list);
7265
7266 FinderCacheUtil.putResult(finderPath, finderArgs, list);
7267 }
7268 catch (Exception e) {
7269 FinderCacheUtil.removeResult(finderPath, finderArgs);
7270
7271 throw processException(e);
7272 }
7273 finally {
7274 closeSession(session);
7275 }
7276 }
7277
7278 return list;
7279 }
7280
7281
7286 public void removeAll() throws SystemException {
7287 for (User user : findAll()) {
7288 remove(user);
7289 }
7290 }
7291
7292
7298 public int countAll() throws SystemException {
7299 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
7300 FINDER_ARGS_EMPTY, this);
7301
7302 if (count == null) {
7303 Session session = null;
7304
7305 try {
7306 session = openSession();
7307
7308 Query q = session.createQuery(_SQL_COUNT_USER);
7309
7310 count = (Long)q.uniqueResult();
7311
7312 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
7313 FINDER_ARGS_EMPTY, count);
7314 }
7315 catch (Exception e) {
7316 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
7317 FINDER_ARGS_EMPTY);
7318
7319 throw processException(e);
7320 }
7321 finally {
7322 closeSession(session);
7323 }
7324 }
7325
7326 return count.intValue();
7327 }
7328
7329
7336 public List<com.liferay.portal.model.Group> getGroups(long pk)
7337 throws SystemException {
7338 return getGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
7339 }
7340
7341
7354 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
7355 int end) throws SystemException {
7356 return getGroups(pk, start, end, null);
7357 }
7358
7359 public static final FinderPath FINDER_PATH_GET_GROUPS = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
7360 UserModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS,
7361 com.liferay.portal.model.impl.GroupImpl.class,
7362 UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "getGroups",
7363 new String[] {
7364 Long.class.getName(), Integer.class.getName(),
7365 Integer.class.getName(), OrderByComparator.class.getName()
7366 });
7367
7368 static {
7369 FINDER_PATH_GET_GROUPS.setCacheKeyGeneratorCacheName(null);
7370 }
7371
7372
7386 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
7387 int end, OrderByComparator orderByComparator) throws SystemException {
7388 boolean pagination = true;
7389 Object[] finderArgs = null;
7390
7391 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7392 (orderByComparator == null)) {
7393 pagination = false;
7394 finderArgs = new Object[] { pk };
7395 }
7396 else {
7397 finderArgs = new Object[] { pk, start, end, orderByComparator };
7398 }
7399
7400 List<com.liferay.portal.model.Group> list = (List<com.liferay.portal.model.Group>)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS,
7401 finderArgs, this);
7402
7403 if (list == null) {
7404 Session session = null;
7405
7406 try {
7407 session = openSession();
7408
7409 String sql = null;
7410
7411 if (orderByComparator != null) {
7412 sql = _SQL_GETGROUPS.concat(ORDER_BY_CLAUSE)
7413 .concat(orderByComparator.getOrderBy());
7414 }
7415 else {
7416 sql = _SQL_GETGROUPS;
7417
7418 if (pagination) {
7419 sql = sql.concat(com.liferay.portal.model.impl.GroupModelImpl.ORDER_BY_SQL);
7420 }
7421 }
7422
7423 SQLQuery q = session.createSQLQuery(sql);
7424
7425 q.addEntity("Group_",
7426 com.liferay.portal.model.impl.GroupImpl.class);
7427
7428 QueryPos qPos = QueryPos.getInstance(q);
7429
7430 qPos.add(pk);
7431
7432 if (!pagination) {
7433 list = (List<com.liferay.portal.model.Group>)QueryUtil.list(q,
7434 getDialect(), start, end, false);
7435
7436 Collections.sort(list);
7437
7438 list = new UnmodifiableList<com.liferay.portal.model.Group>(list);
7439 }
7440 else {
7441 list = (List<com.liferay.portal.model.Group>)QueryUtil.list(q,
7442 getDialect(), start, end);
7443 }
7444
7445 groupPersistence.cacheResult(list);
7446
7447 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS, finderArgs,
7448 list);
7449 }
7450 catch (Exception e) {
7451 FinderCacheUtil.removeResult(FINDER_PATH_GET_GROUPS, finderArgs);
7452
7453 throw processException(e);
7454 }
7455 finally {
7456 closeSession(session);
7457 }
7458 }
7459
7460 return list;
7461 }
7462
7463 public static final FinderPath FINDER_PATH_GET_GROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
7464 UserModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS, Long.class,
7465 UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "getGroupsSize",
7466 new String[] { Long.class.getName() });
7467
7468 static {
7469 FINDER_PATH_GET_GROUPS_SIZE.setCacheKeyGeneratorCacheName(null);
7470 }
7471
7472
7479 public int getGroupsSize(long pk) throws SystemException {
7480 Object[] finderArgs = new Object[] { pk };
7481
7482 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS_SIZE,
7483 finderArgs, this);
7484
7485 if (count == null) {
7486 Session session = null;
7487
7488 try {
7489 session = openSession();
7490
7491 SQLQuery q = session.createSQLQuery(_SQL_GETGROUPSSIZE);
7492
7493 q.addScalar(COUNT_COLUMN_NAME,
7494 com.liferay.portal.kernel.dao.orm.Type.LONG);
7495
7496 QueryPos qPos = QueryPos.getInstance(q);
7497
7498 qPos.add(pk);
7499
7500 count = (Long)q.uniqueResult();
7501
7502 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS_SIZE,
7503 finderArgs, count);
7504 }
7505 catch (Exception e) {
7506 FinderCacheUtil.removeResult(FINDER_PATH_GET_GROUPS_SIZE,
7507 finderArgs);
7508
7509 throw processException(e);
7510 }
7511 finally {
7512 closeSession(session);
7513 }
7514 }
7515
7516 return count.intValue();
7517 }
7518
7519 public static final FinderPath FINDER_PATH_CONTAINS_GROUP = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
7520 UserModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS, Boolean.class,
7521 UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "containsGroup",
7522 new String[] { Long.class.getName(), Long.class.getName() });
7523
7524
7532 public boolean containsGroup(long pk, long groupPK)
7533 throws SystemException {
7534 Object[] finderArgs = new Object[] { pk, groupPK };
7535
7536 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_GROUP,
7537 finderArgs, this);
7538
7539 if (value == null) {
7540 try {
7541 value = Boolean.valueOf(containsGroup.contains(pk, groupPK));
7542
7543 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_GROUP,
7544 finderArgs, value);
7545 }
7546 catch (Exception e) {
7547 FinderCacheUtil.removeResult(FINDER_PATH_CONTAINS_GROUP,
7548 finderArgs);
7549
7550 throw processException(e);
7551 }
7552 }
7553
7554 return value.booleanValue();
7555 }
7556
7557
7564 public boolean containsGroups(long pk) throws SystemException {
7565 if (getGroupsSize(pk) > 0) {
7566 return true;
7567 }
7568 else {
7569 return false;
7570 }
7571 }
7572
7573
7580 public void addGroup(long pk, long groupPK) throws SystemException {
7581 try {
7582 addGroup.add(pk, groupPK);
7583 }
7584 catch (Exception e) {
7585 throw processException(e);
7586 }
7587 finally {
7588 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
7589 }
7590 }
7591
7592
7599 public void addGroup(long pk, com.liferay.portal.model.Group group)
7600 throws SystemException {
7601 try {
7602 addGroup.add(pk, group.getPrimaryKey());
7603 }
7604 catch (Exception e) {
7605 throw processException(e);
7606 }
7607 finally {
7608 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
7609 }
7610 }
7611
7612
7619 public void addGroups(long pk, long[] groupPKs) throws SystemException {
7620 try {
7621 for (long groupPK : groupPKs) {
7622 addGroup.add(pk, groupPK);
7623 }
7624 }
7625 catch (Exception e) {
7626 throw processException(e);
7627 }
7628 finally {
7629 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
7630 }
7631 }
7632
7633
7640 public void addGroups(long pk, List<com.liferay.portal.model.Group> groups)
7641 throws SystemException {
7642 try {
7643 for (com.liferay.portal.model.Group group : groups) {
7644 addGroup.add(pk, group.getPrimaryKey());
7645 }
7646 }
7647 catch (Exception e) {
7648 throw processException(e);
7649 }
7650 finally {
7651 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
7652 }
7653 }
7654
7655
7661 public void clearGroups(long pk) throws SystemException {
7662 try {
7663 clearGroups.clear(pk);
7664 }
7665 catch (Exception e) {
7666 throw processException(e);
7667 }
7668 finally {
7669 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
7670 }
7671 }
7672
7673
7680 public void removeGroup(long pk, long groupPK) throws SystemException {
7681 try {
7682 removeGroup.remove(pk, groupPK);
7683 }
7684 catch (Exception e) {
7685 throw processException(e);
7686 }
7687 finally {
7688 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
7689 }
7690 }
7691
7692
7699 public void removeGroup(long pk, com.liferay.portal.model.Group group)
7700 throws SystemException {
7701 try {
7702 removeGroup.remove(pk, group.getPrimaryKey());
7703 }
7704 catch (Exception e) {
7705 throw processException(e);
7706 }
7707 finally {
7708 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
7709 }
7710 }
7711
7712
7719 public void removeGroups(long pk, long[] groupPKs)
7720 throws SystemException {
7721 try {
7722 for (long groupPK : groupPKs) {
7723 removeGroup.remove(pk, groupPK);
7724 }
7725 }
7726 catch (Exception e) {
7727 throw processException(e);
7728 }
7729 finally {
7730 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
7731 }
7732 }
7733
7734
7741 public void removeGroups(long pk,
7742 List<com.liferay.portal.model.Group> groups) throws SystemException {
7743 try {
7744 for (com.liferay.portal.model.Group group : groups) {
7745 removeGroup.remove(pk, group.getPrimaryKey());
7746 }
7747 }
7748 catch (Exception e) {
7749 throw processException(e);
7750 }
7751 finally {
7752 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
7753 }
7754 }
7755
7756
7763 public void setGroups(long pk, long[] groupPKs) throws SystemException {
7764 try {
7765 Set<Long> groupPKSet = SetUtil.fromArray(groupPKs);
7766
7767 List<com.liferay.portal.model.Group> groups = getGroups(pk);
7768
7769 for (com.liferay.portal.model.Group group : groups) {
7770 if (!groupPKSet.remove(group.getPrimaryKey())) {
7771 removeGroup.remove(pk, group.getPrimaryKey());
7772 }
7773 }
7774
7775 for (Long groupPK : groupPKSet) {
7776 addGroup.add(pk, groupPK);
7777 }
7778 }
7779 catch (Exception e) {
7780 throw processException(e);
7781 }
7782 finally {
7783 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
7784 }
7785 }
7786
7787
7794 public void setGroups(long pk, List<com.liferay.portal.model.Group> groups)
7795 throws SystemException {
7796 try {
7797 long[] groupPKs = new long[groups.size()];
7798
7799 for (int i = 0; i < groups.size(); i++) {
7800 com.liferay.portal.model.Group group = groups.get(i);
7801
7802 groupPKs[i] = group.getPrimaryKey();
7803 }
7804
7805 setGroups(pk, groupPKs);
7806 }
7807 catch (Exception e) {
7808 throw processException(e);
7809 }
7810 finally {
7811 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
7812 }
7813 }
7814
7815
7822 public List<com.liferay.portal.model.Organization> getOrganizations(long pk)
7823 throws SystemException {
7824 return getOrganizations(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
7825 }
7826
7827
7840 public List<com.liferay.portal.model.Organization> getOrganizations(
7841 long pk, int start, int end) throws SystemException {
7842 return getOrganizations(pk, start, end, null);
7843 }
7844
7845 public static final FinderPath FINDER_PATH_GET_ORGANIZATIONS = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
7846 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ORGS,
7847 com.liferay.portal.model.impl.OrganizationImpl.class,
7848 UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME, "getOrganizations",
7849 new String[] {
7850 Long.class.getName(), Integer.class.getName(),
7851 Integer.class.getName(), OrderByComparator.class.getName()
7852 });
7853
7854 static {
7855 FINDER_PATH_GET_ORGANIZATIONS.setCacheKeyGeneratorCacheName(null);
7856 }
7857
7858
7872 public List<com.liferay.portal.model.Organization> getOrganizations(
7873 long pk, int start, int end, OrderByComparator orderByComparator)
7874 throws SystemException {
7875 boolean pagination = true;
7876 Object[] finderArgs = null;
7877
7878 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7879 (orderByComparator == null)) {
7880 pagination = false;
7881 finderArgs = new Object[] { pk };
7882 }
7883 else {
7884 finderArgs = new Object[] { pk, start, end, orderByComparator };
7885 }
7886
7887 List<com.liferay.portal.model.Organization> list = (List<com.liferay.portal.model.Organization>)FinderCacheUtil.getResult(FINDER_PATH_GET_ORGANIZATIONS,
7888 finderArgs, this);
7889
7890 if (list == null) {
7891 Session session = null;
7892
7893 try {
7894 session = openSession();
7895
7896 String sql = null;
7897
7898 if (orderByComparator != null) {
7899 sql = _SQL_GETORGANIZATIONS.concat(ORDER_BY_CLAUSE)
7900 .concat(orderByComparator.getOrderBy());
7901 }
7902 else {
7903 sql = _SQL_GETORGANIZATIONS;
7904
7905 if (pagination) {
7906 sql = sql.concat(com.liferay.portal.model.impl.OrganizationModelImpl.ORDER_BY_SQL);
7907 }
7908 }
7909
7910 SQLQuery q = session.createSQLQuery(sql);
7911
7912 q.addEntity("Organization_",
7913 com.liferay.portal.model.impl.OrganizationImpl.class);
7914
7915 QueryPos qPos = QueryPos.getInstance(q);
7916
7917 qPos.add(pk);
7918
7919 if (!pagination) {
7920 list = (List<com.liferay.portal.model.Organization>)QueryUtil.list(q,
7921 getDialect(), start, end, false);
7922
7923 Collections.sort(list);
7924
7925 list = new UnmodifiableList<com.liferay.portal.model.Organization>(list);
7926 }
7927 else {
7928 list = (List<com.liferay.portal.model.Organization>)QueryUtil.list(q,
7929 getDialect(), start, end);
7930 }
7931
7932 organizationPersistence.cacheResult(list);
7933
7934 FinderCacheUtil.putResult(FINDER_PATH_GET_ORGANIZATIONS,
7935 finderArgs, list);
7936 }
7937 catch (Exception e) {
7938 FinderCacheUtil.removeResult(FINDER_PATH_GET_ORGANIZATIONS,
7939 finderArgs);
7940
7941 throw processException(e);
7942 }
7943 finally {
7944 closeSession(session);
7945 }
7946 }
7947
7948 return list;
7949 }
7950
7951 public static final FinderPath FINDER_PATH_GET_ORGANIZATIONS_SIZE = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
7952 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ORGS, Long.class,
7953 UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME,
7954 "getOrganizationsSize", new String[] { Long.class.getName() });
7955
7956 static {
7957 FINDER_PATH_GET_ORGANIZATIONS_SIZE.setCacheKeyGeneratorCacheName(null);
7958 }
7959
7960
7967 public int getOrganizationsSize(long pk) throws SystemException {
7968 Object[] finderArgs = new Object[] { pk };
7969
7970 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ORGANIZATIONS_SIZE,
7971 finderArgs, this);
7972
7973 if (count == null) {
7974 Session session = null;
7975
7976 try {
7977 session = openSession();
7978
7979 SQLQuery q = session.createSQLQuery(_SQL_GETORGANIZATIONSSIZE);
7980
7981 q.addScalar(COUNT_COLUMN_NAME,
7982 com.liferay.portal.kernel.dao.orm.Type.LONG);
7983
7984 QueryPos qPos = QueryPos.getInstance(q);
7985
7986 qPos.add(pk);
7987
7988 count = (Long)q.uniqueResult();
7989
7990 FinderCacheUtil.putResult(FINDER_PATH_GET_ORGANIZATIONS_SIZE,
7991 finderArgs, count);
7992 }
7993 catch (Exception e) {
7994 FinderCacheUtil.removeResult(FINDER_PATH_GET_ORGANIZATIONS_SIZE,
7995 finderArgs);
7996
7997 throw processException(e);
7998 }
7999 finally {
8000 closeSession(session);
8001 }
8002 }
8003
8004 return count.intValue();
8005 }
8006
8007 public static final FinderPath FINDER_PATH_CONTAINS_ORGANIZATION = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
8008 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ORGS, Boolean.class,
8009 UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME,
8010 "containsOrganization",
8011 new String[] { Long.class.getName(), Long.class.getName() });
8012
8013
8021 public boolean containsOrganization(long pk, long organizationPK)
8022 throws SystemException {
8023 Object[] finderArgs = new Object[] { pk, organizationPK };
8024
8025 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ORGANIZATION,
8026 finderArgs, this);
8027
8028 if (value == null) {
8029 try {
8030 value = Boolean.valueOf(containsOrganization.contains(pk,
8031 organizationPK));
8032
8033 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ORGANIZATION,
8034 finderArgs, value);
8035 }
8036 catch (Exception e) {
8037 FinderCacheUtil.removeResult(FINDER_PATH_CONTAINS_ORGANIZATION,
8038 finderArgs);
8039
8040 throw processException(e);
8041 }
8042 }
8043
8044 return value.booleanValue();
8045 }
8046
8047
8054 public boolean containsOrganizations(long pk) throws SystemException {
8055 if (getOrganizationsSize(pk) > 0) {
8056 return true;
8057 }
8058 else {
8059 return false;
8060 }
8061 }
8062
8063
8070 public void addOrganization(long pk, long organizationPK)
8071 throws SystemException {
8072 try {
8073 addOrganization.add(pk, organizationPK);
8074 }
8075 catch (Exception e) {
8076 throw processException(e);
8077 }
8078 finally {
8079 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
8080 }
8081 }
8082
8083
8090 public void addOrganization(long pk,
8091 com.liferay.portal.model.Organization organization)
8092 throws SystemException {
8093 try {
8094 addOrganization.add(pk, organization.getPrimaryKey());
8095 }
8096 catch (Exception e) {
8097 throw processException(e);
8098 }
8099 finally {
8100 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
8101 }
8102 }
8103
8104
8111 public void addOrganizations(long pk, long[] organizationPKs)
8112 throws SystemException {
8113 try {
8114 for (long organizationPK : organizationPKs) {
8115 addOrganization.add(pk, organizationPK);
8116 }
8117 }
8118 catch (Exception e) {
8119 throw processException(e);
8120 }
8121 finally {
8122 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
8123 }
8124 }
8125
8126
8133 public void addOrganizations(long pk,
8134 List<com.liferay.portal.model.Organization> organizations)
8135 throws SystemException {
8136 try {
8137 for (com.liferay.portal.model.Organization organization : organizations) {
8138 addOrganization.add(pk, organization.getPrimaryKey());
8139 }
8140 }
8141 catch (Exception e) {
8142 throw processException(e);
8143 }
8144 finally {
8145 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
8146 }
8147 }
8148
8149
8155 public void clearOrganizations(long pk) throws SystemException {
8156 try {
8157 clearOrganizations.clear(pk);
8158 }
8159 catch (Exception e) {
8160 throw processException(e);
8161 }
8162 finally {
8163 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
8164 }
8165 }
8166
8167
8174 public void removeOrganization(long pk, long organizationPK)
8175 throws SystemException {
8176 try {
8177 removeOrganization.remove(pk, organizationPK);
8178 }
8179 catch (Exception e) {
8180 throw processException(e);
8181 }
8182 finally {
8183 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
8184 }
8185 }
8186
8187
8194 public void removeOrganization(long pk,
8195 com.liferay.portal.model.Organization organization)
8196 throws SystemException {
8197 try {
8198 removeOrganization.remove(pk, organization.getPrimaryKey());
8199 }
8200 catch (Exception e) {
8201 throw processException(e);
8202 }
8203 finally {
8204 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
8205 }
8206 }
8207
8208
8215 public void removeOrganizations(long pk, long[] organizationPKs)
8216 throws SystemException {
8217 try {
8218 for (long organizationPK : organizationPKs) {
8219 removeOrganization.remove(pk, organizationPK);
8220 }
8221 }
8222 catch (Exception e) {
8223 throw processException(e);
8224 }
8225 finally {
8226 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
8227 }
8228 }
8229
8230
8237 public void removeOrganizations(long pk,
8238 List<com.liferay.portal.model.Organization> organizations)
8239 throws SystemException {
8240 try {
8241 for (com.liferay.portal.model.Organization organization : organizations) {
8242 removeOrganization.remove(pk, organization.getPrimaryKey());
8243 }
8244 }
8245 catch (Exception e) {
8246 throw processException(e);
8247 }
8248 finally {
8249 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
8250 }
8251 }
8252
8253
8260 public void setOrganizations(long pk, long[] organizationPKs)
8261 throws SystemException {
8262 try {
8263 Set<Long> organizationPKSet = SetUtil.fromArray(organizationPKs);
8264
8265 List<com.liferay.portal.model.Organization> organizations = getOrganizations(pk);
8266
8267 for (com.liferay.portal.model.Organization organization : organizations) {
8268 if (!organizationPKSet.remove(organization.getPrimaryKey())) {
8269 removeOrganization.remove(pk, organization.getPrimaryKey());
8270 }
8271 }
8272
8273 for (Long organizationPK : organizationPKSet) {
8274 addOrganization.add(pk, organizationPK);
8275 }
8276 }
8277 catch (Exception e) {
8278 throw processException(e);
8279 }
8280 finally {
8281 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
8282 }
8283 }
8284
8285
8292 public void setOrganizations(long pk,
8293 List<com.liferay.portal.model.Organization> organizations)
8294 throws SystemException {
8295 try {
8296 long[] organizationPKs = new long[organizations.size()];
8297
8298 for (int i = 0; i < organizations.size(); i++) {
8299 com.liferay.portal.model.Organization organization = organizations.get(i);
8300
8301 organizationPKs[i] = organization.getPrimaryKey();
8302 }
8303
8304 setOrganizations(pk, organizationPKs);
8305 }
8306 catch (Exception e) {
8307 throw processException(e);
8308 }
8309 finally {
8310 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
8311 }
8312 }
8313
8314
8321 public List<com.liferay.portal.model.Role> getRoles(long pk)
8322 throws SystemException {
8323 return getRoles(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
8324 }
8325
8326
8339 public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
8340 int end) throws SystemException {
8341 return getRoles(pk, start, end, null);
8342 }
8343
8344 public static final FinderPath FINDER_PATH_GET_ROLES = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
8345 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES,
8346 com.liferay.portal.model.impl.RoleImpl.class,
8347 UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "getRoles",
8348 new String[] {
8349 Long.class.getName(), Integer.class.getName(),
8350 Integer.class.getName(), OrderByComparator.class.getName()
8351 });
8352
8353 static {
8354 FINDER_PATH_GET_ROLES.setCacheKeyGeneratorCacheName(null);
8355 }
8356
8357
8371 public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
8372 int end, OrderByComparator orderByComparator) throws SystemException {
8373 boolean pagination = true;
8374 Object[] finderArgs = null;
8375
8376 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8377 (orderByComparator == null)) {
8378 pagination = false;
8379 finderArgs = new Object[] { pk };
8380 }
8381 else {
8382 finderArgs = new Object[] { pk, start, end, orderByComparator };
8383 }
8384
8385 List<com.liferay.portal.model.Role> list = (List<com.liferay.portal.model.Role>)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES,
8386 finderArgs, this);
8387
8388 if (list == null) {
8389 Session session = null;
8390
8391 try {
8392 session = openSession();
8393
8394 String sql = null;
8395
8396 if (orderByComparator != null) {
8397 sql = _SQL_GETROLES.concat(ORDER_BY_CLAUSE)
8398 .concat(orderByComparator.getOrderBy());
8399 }
8400 else {
8401 sql = _SQL_GETROLES;
8402
8403 if (pagination) {
8404 sql = sql.concat(com.liferay.portal.model.impl.RoleModelImpl.ORDER_BY_SQL);
8405 }
8406 }
8407
8408 SQLQuery q = session.createSQLQuery(sql);
8409
8410 q.addEntity("Role_",
8411 com.liferay.portal.model.impl.RoleImpl.class);
8412
8413 QueryPos qPos = QueryPos.getInstance(q);
8414
8415 qPos.add(pk);
8416
8417 if (!pagination) {
8418 list = (List<com.liferay.portal.model.Role>)QueryUtil.list(q,
8419 getDialect(), start, end, false);
8420
8421 Collections.sort(list);
8422
8423 list = new UnmodifiableList<com.liferay.portal.model.Role>(list);
8424 }
8425 else {
8426 list = (List<com.liferay.portal.model.Role>)QueryUtil.list(q,
8427 getDialect(), start, end);
8428 }
8429
8430 rolePersistence.cacheResult(list);
8431
8432 FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES, finderArgs,
8433 list);
8434 }
8435 catch (Exception e) {
8436 FinderCacheUtil.removeResult(FINDER_PATH_GET_ROLES, finderArgs);
8437
8438 throw processException(e);
8439 }
8440 finally {
8441 closeSession(session);
8442 }
8443 }
8444
8445 return list;
8446 }
8447
8448 public static final FinderPath FINDER_PATH_GET_ROLES_SIZE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
8449 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES, Long.class,
8450 UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "getRolesSize",
8451 new String[] { Long.class.getName() });
8452
8453 static {
8454 FINDER_PATH_GET_ROLES_SIZE.setCacheKeyGeneratorCacheName(null);
8455 }
8456
8457
8464 public int getRolesSize(long pk) throws SystemException {
8465 Object[] finderArgs = new Object[] { pk };
8466
8467 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES_SIZE,
8468 finderArgs, this);
8469
8470 if (count == null) {
8471 Session session = null;
8472
8473 try {
8474 session = openSession();
8475
8476 SQLQuery q = session.createSQLQuery(_SQL_GETROLESSIZE);
8477
8478 q.addScalar(COUNT_COLUMN_NAME,
8479 com.liferay.portal.kernel.dao.orm.Type.LONG);
8480
8481 QueryPos qPos = QueryPos.getInstance(q);
8482
8483 qPos.add(pk);
8484
8485 count = (Long)q.uniqueResult();
8486
8487 FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES_SIZE,
8488 finderArgs, count);
8489 }
8490 catch (Exception e) {
8491 FinderCacheUtil.removeResult(FINDER_PATH_GET_ROLES_SIZE,
8492 finderArgs);
8493
8494 throw processException(e);
8495 }
8496 finally {
8497 closeSession(session);
8498 }
8499 }
8500
8501 return count.intValue();
8502 }
8503
8504 public static final FinderPath FINDER_PATH_CONTAINS_ROLE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
8505 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES, Boolean.class,
8506 UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "containsRole",
8507 new String[] { Long.class.getName(), Long.class.getName() });
8508
8509
8517 public boolean containsRole(long pk, long rolePK) throws SystemException {
8518 Object[] finderArgs = new Object[] { pk, rolePK };
8519
8520 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ROLE,
8521 finderArgs, this);
8522
8523 if (value == null) {
8524 try {
8525 value = Boolean.valueOf(containsRole.contains(pk, rolePK));
8526
8527 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ROLE,
8528 finderArgs, value);
8529 }
8530 catch (Exception e) {
8531 FinderCacheUtil.removeResult(FINDER_PATH_CONTAINS_ROLE,
8532 finderArgs);
8533
8534 throw processException(e);
8535 }
8536 }
8537
8538 return value.booleanValue();
8539 }
8540
8541
8548 public boolean containsRoles(long pk) throws SystemException {
8549 if (getRolesSize(pk) > 0) {
8550 return true;
8551 }
8552 else {
8553 return false;
8554 }
8555 }
8556
8557
8564 public void addRole(long pk, long rolePK) throws SystemException {
8565 try {
8566 addRole.add(pk, rolePK);
8567 }
8568 catch (Exception e) {
8569 throw processException(e);
8570 }
8571 finally {
8572 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
8573 }
8574 }
8575
8576
8583 public void addRole(long pk, com.liferay.portal.model.Role role)
8584 throws SystemException {
8585 try {
8586 addRole.add(pk, role.getPrimaryKey());
8587 }
8588 catch (Exception e) {
8589 throw processException(e);
8590 }
8591 finally {
8592 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
8593 }
8594 }
8595
8596
8603 public void addRoles(long pk, long[] rolePKs) throws SystemException {
8604 try {
8605 for (long rolePK : rolePKs) {
8606 addRole.add(pk, rolePK);
8607 }
8608 }
8609 catch (Exception e) {
8610 throw processException(e);
8611 }
8612 finally {
8613 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
8614 }
8615 }
8616
8617
8624 public void addRoles(long pk, List<com.liferay.portal.model.Role> roles)
8625 throws SystemException {
8626 try {
8627 for (com.liferay.portal.model.Role role : roles) {
8628 addRole.add(pk, role.getPrimaryKey());
8629 }
8630 }
8631 catch (Exception e) {
8632 throw processException(e);
8633 }
8634 finally {
8635 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
8636 }
8637 }
8638
8639
8645 public void clearRoles(long pk) throws SystemException {
8646 try {
8647 clearRoles.clear(pk);
8648 }
8649 catch (Exception e) {
8650 throw processException(e);
8651 }
8652 finally {
8653 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
8654 }
8655 }
8656
8657
8664 public void removeRole(long pk, long rolePK) throws SystemException {
8665 try {
8666 removeRole.remove(pk, rolePK);
8667 }
8668 catch (Exception e) {
8669 throw processException(e);
8670 }
8671 finally {
8672 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
8673 }
8674 }
8675
8676
8683 public void removeRole(long pk, com.liferay.portal.model.Role role)
8684 throws SystemException {
8685 try {
8686 removeRole.remove(pk, role.getPrimaryKey());
8687 }
8688 catch (Exception e) {
8689 throw processException(e);
8690 }
8691 finally {
8692 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
8693 }
8694 }
8695
8696
8703 public void removeRoles(long pk, long[] rolePKs) throws SystemException {
8704 try {
8705 for (long rolePK : rolePKs) {
8706 removeRole.remove(pk, rolePK);
8707 }
8708 }
8709 catch (Exception e) {
8710 throw processException(e);
8711 }
8712 finally {
8713 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
8714 }
8715 }
8716
8717
8724 public void removeRoles(long pk, List<com.liferay.portal.model.Role> roles)
8725 throws SystemException {
8726 try {
8727 for (com.liferay.portal.model.Role role : roles) {
8728 removeRole.remove(pk, role.getPrimaryKey());
8729 }
8730 }
8731 catch (Exception e) {
8732 throw processException(e);
8733 }
8734 finally {
8735 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
8736 }
8737 }
8738
8739
8746 public void setRoles(long pk, long[] rolePKs) throws SystemException {
8747 try {
8748 Set<Long> rolePKSet = SetUtil.fromArray(rolePKs);
8749
8750 List<com.liferay.portal.model.Role> roles = getRoles(pk);
8751
8752 for (com.liferay.portal.model.Role role : roles) {
8753 if (!rolePKSet.remove(role.getPrimaryKey())) {
8754 removeRole.remove(pk, role.getPrimaryKey());
8755 }
8756 }
8757
8758 for (Long rolePK : rolePKSet) {
8759 addRole.add(pk, rolePK);
8760 }
8761 }
8762 catch (Exception e) {
8763 throw processException(e);
8764 }
8765 finally {
8766 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
8767 }
8768 }
8769
8770
8777 public void setRoles(long pk, List<com.liferay.portal.model.Role> roles)
8778 throws SystemException {
8779 try {
8780 long[] rolePKs = new long[roles.size()];
8781
8782 for (int i = 0; i < roles.size(); i++) {
8783 com.liferay.portal.model.Role role = roles.get(i);
8784
8785 rolePKs[i] = role.getPrimaryKey();
8786 }
8787
8788 setRoles(pk, rolePKs);
8789 }
8790 catch (Exception e) {
8791 throw processException(e);
8792 }
8793 finally {
8794 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
8795 }
8796 }
8797
8798
8805 public List<com.liferay.portal.model.Team> getTeams(long pk)
8806 throws SystemException {
8807 return getTeams(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
8808 }
8809
8810
8823 public List<com.liferay.portal.model.Team> getTeams(long pk, int start,
8824 int end) throws SystemException {
8825 return getTeams(pk, start, end, null);
8826 }
8827
8828 public static final FinderPath FINDER_PATH_GET_TEAMS = new FinderPath(com.liferay.portal.model.impl.TeamModelImpl.ENTITY_CACHE_ENABLED,
8829 UserModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS,
8830 com.liferay.portal.model.impl.TeamImpl.class,
8831 UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME, "getTeams",
8832 new String[] {
8833 Long.class.getName(), Integer.class.getName(),
8834 Integer.class.getName(), OrderByComparator.class.getName()
8835 });
8836
8837 static {
8838 FINDER_PATH_GET_TEAMS.setCacheKeyGeneratorCacheName(null);
8839 }
8840
8841
8855 public List<com.liferay.portal.model.Team> getTeams(long pk, int start,
8856 int end, OrderByComparator orderByComparator) throws SystemException {
8857 boolean pagination = true;
8858 Object[] finderArgs = null;
8859
8860 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8861 (orderByComparator == null)) {
8862 pagination = false;
8863 finderArgs = new Object[] { pk };
8864 }
8865 else {
8866 finderArgs = new Object[] { pk, start, end, orderByComparator };
8867 }
8868
8869 List<com.liferay.portal.model.Team> list = (List<com.liferay.portal.model.Team>)FinderCacheUtil.getResult(FINDER_PATH_GET_TEAMS,
8870 finderArgs, this);
8871
8872 if (list == null) {
8873 Session session = null;
8874
8875 try {
8876 session = openSession();
8877
8878 String sql = null;
8879
8880 if (orderByComparator != null) {
8881 sql = _SQL_GETTEAMS.concat(ORDER_BY_CLAUSE)
8882 .concat(orderByComparator.getOrderBy());
8883 }
8884 else {
8885 sql = _SQL_GETTEAMS;
8886
8887 if (pagination) {
8888 sql = sql.concat(com.liferay.portal.model.impl.TeamModelImpl.ORDER_BY_SQL);
8889 }
8890 }
8891
8892 SQLQuery q = session.createSQLQuery(sql);
8893
8894 q.addEntity("Team", com.liferay.portal.model.impl.TeamImpl.class);
8895
8896 QueryPos qPos = QueryPos.getInstance(q);
8897
8898 qPos.add(pk);
8899
8900 if (!pagination) {
8901 list = (List<com.liferay.portal.model.Team>)QueryUtil.list(q,
8902 getDialect(), start, end, false);
8903
8904 Collections.sort(list);
8905
8906 list = new UnmodifiableList<com.liferay.portal.model.Team>(list);
8907 }
8908 else {
8909 list = (List<com.liferay.portal.model.Team>)QueryUtil.list(q,
8910 getDialect(), start, end);
8911 }
8912
8913 teamPersistence.cacheResult(list);
8914
8915 FinderCacheUtil.putResult(FINDER_PATH_GET_TEAMS, finderArgs,
8916 list);
8917 }
8918 catch (Exception e) {
8919 FinderCacheUtil.removeResult(FINDER_PATH_GET_TEAMS, finderArgs);
8920
8921 throw processException(e);
8922 }
8923 finally {
8924 closeSession(session);
8925 }
8926 }
8927
8928 return list;
8929 }
8930
8931 public static final FinderPath FINDER_PATH_GET_TEAMS_SIZE = new FinderPath(com.liferay.portal.model.impl.TeamModelImpl.ENTITY_CACHE_ENABLED,
8932 UserModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS, Long.class,
8933 UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME, "getTeamsSize",
8934 new String[] { Long.class.getName() });
8935
8936 static {
8937 FINDER_PATH_GET_TEAMS_SIZE.setCacheKeyGeneratorCacheName(null);
8938 }
8939
8940
8947 public int getTeamsSize(long pk) throws SystemException {
8948 Object[] finderArgs = new Object[] { pk };
8949
8950 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_TEAMS_SIZE,
8951 finderArgs, this);
8952
8953 if (count == null) {
8954 Session session = null;
8955
8956 try {
8957 session = openSession();
8958
8959 SQLQuery q = session.createSQLQuery(_SQL_GETTEAMSSIZE);
8960
8961 q.addScalar(COUNT_COLUMN_NAME,
8962 com.liferay.portal.kernel.dao.orm.Type.LONG);
8963
8964 QueryPos qPos = QueryPos.getInstance(q);
8965
8966 qPos.add(pk);
8967
8968 count = (Long)q.uniqueResult();
8969
8970 FinderCacheUtil.putResult(FINDER_PATH_GET_TEAMS_SIZE,
8971 finderArgs, count);
8972 }
8973 catch (Exception e) {
8974 FinderCacheUtil.removeResult(FINDER_PATH_GET_TEAMS_SIZE,
8975 finderArgs);
8976
8977 throw processException(e);
8978 }
8979 finally {
8980 closeSession(session);
8981 }
8982 }
8983
8984 return count.intValue();
8985 }
8986
8987 public static final FinderPath FINDER_PATH_CONTAINS_TEAM = new FinderPath(com.liferay.portal.model.impl.TeamModelImpl.ENTITY_CACHE_ENABLED,
8988 UserModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS, Boolean.class,
8989 UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME, "containsTeam",
8990 new String[] { Long.class.getName(), Long.class.getName() });
8991
8992
9000 public boolean containsTeam(long pk, long teamPK) throws SystemException {
9001 Object[] finderArgs = new Object[] { pk, teamPK };
9002
9003 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_TEAM,
9004 finderArgs, this);
9005
9006 if (value == null) {
9007 try {
9008 value = Boolean.valueOf(containsTeam.contains(pk, teamPK));
9009
9010 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_TEAM,
9011 finderArgs, value);
9012 }
9013 catch (Exception e) {
9014 FinderCacheUtil.removeResult(FINDER_PATH_CONTAINS_TEAM,
9015 finderArgs);
9016
9017 throw processException(e);
9018 }
9019 }
9020
9021 return value.booleanValue();
9022 }
9023
9024
9031 public boolean containsTeams(long pk) throws SystemException {
9032 if (getTeamsSize(pk) > 0) {
9033 return true;
9034 }
9035 else {
9036 return false;
9037 }
9038 }
9039
9040
9047 public void addTeam(long pk, long teamPK) throws SystemException {
9048 try {
9049 addTeam.add(pk, teamPK);
9050 }
9051 catch (Exception e) {
9052 throw processException(e);
9053 }
9054 finally {
9055 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
9056 }
9057 }
9058
9059
9066 public void addTeam(long pk, com.liferay.portal.model.Team team)
9067 throws SystemException {
9068 try {
9069 addTeam.add(pk, team.getPrimaryKey());
9070 }
9071 catch (Exception e) {
9072 throw processException(e);
9073 }
9074 finally {
9075 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
9076 }
9077 }
9078
9079
9086 public void addTeams(long pk, long[] teamPKs) throws SystemException {
9087 try {
9088 for (long teamPK : teamPKs) {
9089 addTeam.add(pk, teamPK);
9090 }
9091 }
9092 catch (Exception e) {
9093 throw processException(e);
9094 }
9095 finally {
9096 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
9097 }
9098 }
9099
9100
9107 public void addTeams(long pk, List<com.liferay.portal.model.Team> teams)
9108 throws SystemException {
9109 try {
9110 for (com.liferay.portal.model.Team team : teams) {
9111 addTeam.add(pk, team.getPrimaryKey());
9112 }
9113 }
9114 catch (Exception e) {
9115 throw processException(e);
9116 }
9117 finally {
9118 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
9119 }
9120 }
9121
9122
9128 public void clearTeams(long pk) throws SystemException {
9129 try {
9130 clearTeams.clear(pk);
9131 }
9132 catch (Exception e) {
9133 throw processException(e);
9134 }
9135 finally {
9136 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
9137 }
9138 }
9139
9140
9147 public void removeTeam(long pk, long teamPK) throws SystemException {
9148 try {
9149 removeTeam.remove(pk, teamPK);
9150 }
9151 catch (Exception e) {
9152 throw processException(e);
9153 }
9154 finally {
9155 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
9156 }
9157 }
9158
9159
9166 public void removeTeam(long pk, com.liferay.portal.model.Team team)
9167 throws SystemException {
9168 try {
9169 removeTeam.remove(pk, team.getPrimaryKey());
9170 }
9171 catch (Exception e) {
9172 throw processException(e);
9173 }
9174 finally {
9175 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
9176 }
9177 }
9178
9179
9186 public void removeTeams(long pk, long[] teamPKs) throws SystemException {
9187 try {
9188 for (long teamPK : teamPKs) {
9189 removeTeam.remove(pk, teamPK);
9190 }
9191 }
9192 catch (Exception e) {
9193 throw processException(e);
9194 }
9195 finally {
9196 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
9197 }
9198 }
9199
9200
9207 public void removeTeams(long pk, List<com.liferay.portal.model.Team> teams)
9208 throws SystemException {
9209 try {
9210 for (com.liferay.portal.model.Team team : teams) {
9211 removeTeam.remove(pk, team.getPrimaryKey());
9212 }
9213 }
9214 catch (Exception e) {
9215 throw processException(e);
9216 }
9217 finally {
9218 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
9219 }
9220 }
9221
9222
9229 public void setTeams(long pk, long[] teamPKs) throws SystemException {
9230 try {
9231 Set<Long> teamPKSet = SetUtil.fromArray(teamPKs);
9232
9233 List<com.liferay.portal.model.Team> teams = getTeams(pk);
9234
9235 for (com.liferay.portal.model.Team team : teams) {
9236 if (!teamPKSet.remove(team.getPrimaryKey())) {
9237 removeTeam.remove(pk, team.getPrimaryKey());
9238 }
9239 }
9240
9241 for (Long teamPK : teamPKSet) {
9242 addTeam.add(pk, teamPK);
9243 }
9244 }
9245 catch (Exception e) {
9246 throw processException(e);
9247 }
9248 finally {
9249 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
9250 }
9251 }
9252
9253
9260 public void setTeams(long pk, List<com.liferay.portal.model.Team> teams)
9261 throws SystemException {
9262 try {
9263 long[] teamPKs = new long[teams.size()];
9264
9265 for (int i = 0; i < teams.size(); i++) {
9266 com.liferay.portal.model.Team team = teams.get(i);
9267
9268 teamPKs[i] = team.getPrimaryKey();
9269 }
9270
9271 setTeams(pk, teamPKs);
9272 }
9273 catch (Exception e) {
9274 throw processException(e);
9275 }
9276 finally {
9277 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
9278 }
9279 }
9280
9281
9288 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk)
9289 throws SystemException {
9290 return getUserGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
9291 }
9292
9293
9306 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
9307 int start, int end) throws SystemException {
9308 return getUserGroups(pk, start, end, null);
9309 }
9310
9311 public static final FinderPath FINDER_PATH_GET_USERGROUPS = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
9312 UserModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS,
9313 com.liferay.portal.model.impl.UserGroupImpl.class,
9314 UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME, "getUserGroups",
9315 new String[] {
9316 Long.class.getName(), Integer.class.getName(),
9317 Integer.class.getName(), OrderByComparator.class.getName()
9318 });
9319
9320 static {
9321 FINDER_PATH_GET_USERGROUPS.setCacheKeyGeneratorCacheName(null);
9322 }
9323
9324
9338 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
9339 int start, int end, OrderByComparator orderByComparator)
9340 throws SystemException {
9341 boolean pagination = true;
9342 Object[] finderArgs = null;
9343
9344 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9345 (orderByComparator == null)) {
9346 pagination = false;
9347 finderArgs = new Object[] { pk };
9348 }
9349 else {
9350 finderArgs = new Object[] { pk, start, end, orderByComparator };
9351 }
9352
9353 List<com.liferay.portal.model.UserGroup> list = (List<com.liferay.portal.model.UserGroup>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS,
9354 finderArgs, this);
9355
9356 if (list == null) {
9357 Session session = null;
9358
9359 try {
9360 session = openSession();
9361
9362 String sql = null;
9363
9364 if (orderByComparator != null) {
9365 sql = _SQL_GETUSERGROUPS.concat(ORDER_BY_CLAUSE)
9366 .concat(orderByComparator.getOrderBy());
9367 }
9368 else {
9369 sql = _SQL_GETUSERGROUPS;
9370
9371 if (pagination) {
9372 sql = sql.concat(com.liferay.portal.model.impl.UserGroupModelImpl.ORDER_BY_SQL);
9373 }
9374 }
9375
9376 SQLQuery q = session.createSQLQuery(sql);
9377
9378 q.addEntity("UserGroup",
9379 com.liferay.portal.model.impl.UserGroupImpl.class);
9380
9381 QueryPos qPos = QueryPos.getInstance(q);
9382
9383 qPos.add(pk);
9384
9385 if (!pagination) {
9386 list = (List<com.liferay.portal.model.UserGroup>)QueryUtil.list(q,
9387 getDialect(), start, end, false);
9388
9389 Collections.sort(list);
9390
9391 list = new UnmodifiableList<com.liferay.portal.model.UserGroup>(list);
9392 }
9393 else {
9394 list = (List<com.liferay.portal.model.UserGroup>)QueryUtil.list(q,
9395 getDialect(), start, end);
9396 }
9397
9398 userGroupPersistence.cacheResult(list);
9399
9400 FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS,
9401 finderArgs, list);
9402 }
9403 catch (Exception e) {
9404 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERGROUPS,
9405 finderArgs);
9406
9407 throw processException(e);
9408 }
9409 finally {
9410 closeSession(session);
9411 }
9412 }
9413
9414 return list;
9415 }
9416
9417 public static final FinderPath FINDER_PATH_GET_USERGROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
9418 UserModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS, Long.class,
9419 UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME,
9420 "getUserGroupsSize", new String[] { Long.class.getName() });
9421
9422 static {
9423 FINDER_PATH_GET_USERGROUPS_SIZE.setCacheKeyGeneratorCacheName(null);
9424 }
9425
9426
9433 public int getUserGroupsSize(long pk) throws SystemException {
9434 Object[] finderArgs = new Object[] { pk };
9435
9436 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS_SIZE,
9437 finderArgs, this);
9438
9439 if (count == null) {
9440 Session session = null;
9441
9442 try {
9443 session = openSession();
9444
9445 SQLQuery q = session.createSQLQuery(_SQL_GETUSERGROUPSSIZE);
9446
9447 q.addScalar(COUNT_COLUMN_NAME,
9448 com.liferay.portal.kernel.dao.orm.Type.LONG);
9449
9450 QueryPos qPos = QueryPos.getInstance(q);
9451
9452 qPos.add(pk);
9453
9454 count = (Long)q.uniqueResult();
9455
9456 FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS_SIZE,
9457 finderArgs, count);
9458 }
9459 catch (Exception e) {
9460 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERGROUPS_SIZE,
9461 finderArgs);
9462
9463 throw processException(e);
9464 }
9465 finally {
9466 closeSession(session);
9467 }
9468 }
9469
9470 return count.intValue();
9471 }
9472
9473 public static final FinderPath FINDER_PATH_CONTAINS_USERGROUP = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
9474 UserModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS, Boolean.class,
9475 UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME,
9476 "containsUserGroup",
9477 new String[] { Long.class.getName(), Long.class.getName() });
9478
9479
9487 public boolean containsUserGroup(long pk, long userGroupPK)
9488 throws SystemException {
9489 Object[] finderArgs = new Object[] { pk, userGroupPK };
9490
9491 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USERGROUP,
9492 finderArgs, this);
9493
9494 if (value == null) {
9495 try {
9496 value = Boolean.valueOf(containsUserGroup.contains(pk,
9497 userGroupPK));
9498
9499 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USERGROUP,
9500 finderArgs, value);
9501 }
9502 catch (Exception e) {
9503 FinderCacheUtil.removeResult(FINDER_PATH_CONTAINS_USERGROUP,
9504 finderArgs);
9505
9506 throw processException(e);
9507 }
9508 }
9509
9510 return value.booleanValue();
9511 }
9512
9513
9520 public boolean containsUserGroups(long pk) throws SystemException {
9521 if (getUserGroupsSize(pk) > 0) {
9522 return true;
9523 }
9524 else {
9525 return false;
9526 }
9527 }
9528
9529
9536 public void addUserGroup(long pk, long userGroupPK)
9537 throws SystemException {
9538 try {
9539 addUserGroup.add(pk, userGroupPK);
9540 }
9541 catch (Exception e) {
9542 throw processException(e);
9543 }
9544 finally {
9545 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
9546 }
9547 }
9548
9549
9556 public void addUserGroup(long pk,
9557 com.liferay.portal.model.UserGroup userGroup) throws SystemException {
9558 try {
9559 addUserGroup.add(pk, userGroup.getPrimaryKey());
9560 }
9561 catch (Exception e) {
9562 throw processException(e);
9563 }
9564 finally {
9565 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
9566 }
9567 }
9568
9569
9576 public void addUserGroups(long pk, long[] userGroupPKs)
9577 throws SystemException {
9578 try {
9579 for (long userGroupPK : userGroupPKs) {
9580 addUserGroup.add(pk, userGroupPK);
9581 }
9582 }
9583 catch (Exception e) {
9584 throw processException(e);
9585 }
9586 finally {
9587 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
9588 }
9589 }
9590
9591
9598 public void addUserGroups(long pk,
9599 List<com.liferay.portal.model.UserGroup> userGroups)
9600 throws SystemException {
9601 try {
9602 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
9603 addUserGroup.add(pk, userGroup.getPrimaryKey());
9604 }
9605 }
9606 catch (Exception e) {
9607 throw processException(e);
9608 }
9609 finally {
9610 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
9611 }
9612 }
9613
9614
9620 public void clearUserGroups(long pk) throws SystemException {
9621 try {
9622 clearUserGroups.clear(pk);
9623 }
9624 catch (Exception e) {
9625 throw processException(e);
9626 }
9627 finally {
9628 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
9629 }
9630 }
9631
9632
9639 public void removeUserGroup(long pk, long userGroupPK)
9640 throws SystemException {
9641 try {
9642 removeUserGroup.remove(pk, userGroupPK);
9643 }
9644 catch (Exception e) {
9645 throw processException(e);
9646 }
9647 finally {
9648 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
9649 }
9650 }
9651
9652
9659 public void removeUserGroup(long pk,
9660 com.liferay.portal.model.UserGroup userGroup) throws SystemException {
9661 try {
9662 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
9663 }
9664 catch (Exception e) {
9665 throw processException(e);
9666 }
9667 finally {
9668 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
9669 }
9670 }
9671
9672
9679 public void removeUserGroups(long pk, long[] userGroupPKs)
9680 throws SystemException {
9681 try {
9682 for (long userGroupPK : userGroupPKs) {
9683 removeUserGroup.remove(pk, userGroupPK);
9684 }
9685 }
9686 catch (Exception e) {
9687 throw processException(e);
9688 }
9689 finally {
9690 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
9691 }
9692 }
9693
9694
9701 public void removeUserGroups(long pk,
9702 List<com.liferay.portal.model.UserGroup> userGroups)
9703 throws SystemException {
9704 try {
9705 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
9706 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
9707 }
9708 }
9709 catch (Exception e) {
9710 throw processException(e);
9711 }
9712 finally {
9713 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
9714 }
9715 }
9716
9717
9724 public void setUserGroups(long pk, long[] userGroupPKs)
9725 throws SystemException {
9726 try {
9727 Set<Long> userGroupPKSet = SetUtil.fromArray(userGroupPKs);
9728
9729 List<com.liferay.portal.model.UserGroup> userGroups = getUserGroups(pk);
9730
9731 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
9732 if (!userGroupPKSet.remove(userGroup.getPrimaryKey())) {
9733 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
9734 }
9735 }
9736
9737 for (Long userGroupPK : userGroupPKSet) {
9738 addUserGroup.add(pk, userGroupPK);
9739 }
9740 }
9741 catch (Exception e) {
9742 throw processException(e);
9743 }
9744 finally {
9745 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
9746 }
9747 }
9748
9749
9756 public void setUserGroups(long pk,
9757 List<com.liferay.portal.model.UserGroup> userGroups)
9758 throws SystemException {
9759 try {
9760 long[] userGroupPKs = new long[userGroups.size()];
9761
9762 for (int i = 0; i < userGroups.size(); i++) {
9763 com.liferay.portal.model.UserGroup userGroup = userGroups.get(i);
9764
9765 userGroupPKs[i] = userGroup.getPrimaryKey();
9766 }
9767
9768 setUserGroups(pk, userGroupPKs);
9769 }
9770 catch (Exception e) {
9771 throw processException(e);
9772 }
9773 finally {
9774 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
9775 }
9776 }
9777
9778
9781 public void afterPropertiesSet() {
9782 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
9783 com.liferay.portal.util.PropsUtil.get(
9784 "value.object.listener.com.liferay.portal.model.User")));
9785
9786 if (listenerClassNames.length > 0) {
9787 try {
9788 List<ModelListener<User>> listenersList = new ArrayList<ModelListener<User>>();
9789
9790 for (String listenerClassName : listenerClassNames) {
9791 listenersList.add((ModelListener<User>)InstanceFactory.newInstance(
9792 listenerClassName));
9793 }
9794
9795 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
9796 }
9797 catch (Exception e) {
9798 _log.error(e);
9799 }
9800 }
9801
9802 containsGroup = new ContainsGroup();
9803
9804 addGroup = new AddGroup();
9805 clearGroups = new ClearGroups();
9806 removeGroup = new RemoveGroup();
9807
9808 containsOrganization = new ContainsOrganization();
9809
9810 addOrganization = new AddOrganization();
9811 clearOrganizations = new ClearOrganizations();
9812 removeOrganization = new RemoveOrganization();
9813
9814 containsRole = new ContainsRole();
9815
9816 addRole = new AddRole();
9817 clearRoles = new ClearRoles();
9818 removeRole = new RemoveRole();
9819
9820 containsTeam = new ContainsTeam();
9821
9822 addTeam = new AddTeam();
9823 clearTeams = new ClearTeams();
9824 removeTeam = new RemoveTeam();
9825
9826 containsUserGroup = new ContainsUserGroup();
9827
9828 addUserGroup = new AddUserGroup();
9829 clearUserGroups = new ClearUserGroups();
9830 removeUserGroup = new RemoveUserGroup();
9831 }
9832
9833 public void destroy() {
9834 EntityCacheUtil.removeCache(UserImpl.class.getName());
9835 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
9836 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
9837 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
9838 }
9839
9840 @BeanReference(type = GroupPersistence.class)
9841 protected GroupPersistence groupPersistence;
9842 protected ContainsGroup containsGroup;
9843 protected AddGroup addGroup;
9844 protected ClearGroups clearGroups;
9845 protected RemoveGroup removeGroup;
9846 @BeanReference(type = OrganizationPersistence.class)
9847 protected OrganizationPersistence organizationPersistence;
9848 protected ContainsOrganization containsOrganization;
9849 protected AddOrganization addOrganization;
9850 protected ClearOrganizations clearOrganizations;
9851 protected RemoveOrganization removeOrganization;
9852 @BeanReference(type = RolePersistence.class)
9853 protected RolePersistence rolePersistence;
9854 protected ContainsRole containsRole;
9855 protected AddRole addRole;
9856 protected ClearRoles clearRoles;
9857 protected RemoveRole removeRole;
9858 @BeanReference(type = TeamPersistence.class)
9859 protected TeamPersistence teamPersistence;
9860 protected ContainsTeam containsTeam;
9861 protected AddTeam addTeam;
9862 protected ClearTeams clearTeams;
9863 protected RemoveTeam removeTeam;
9864 @BeanReference(type = UserGroupPersistence.class)
9865 protected UserGroupPersistence userGroupPersistence;
9866 protected ContainsUserGroup containsUserGroup;
9867 protected AddUserGroup addUserGroup;
9868 protected ClearUserGroups clearUserGroups;
9869 protected RemoveUserGroup removeUserGroup;
9870
9871 protected class ContainsGroup {
9872 protected ContainsGroup() {
9873 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
9874 _SQL_CONTAINSGROUP,
9875 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
9876 RowMapper.COUNT);
9877 }
9878
9879 protected boolean contains(long userId, long groupId) {
9880 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
9881 new Long(userId), new Long(groupId)
9882 });
9883
9884 if (results.size() > 0) {
9885 Integer count = results.get(0);
9886
9887 if (count.intValue() > 0) {
9888 return true;
9889 }
9890 }
9891
9892 return false;
9893 }
9894
9895 private MappingSqlQuery<Integer> _mappingSqlQuery;
9896 }
9897
9898 protected class AddGroup {
9899 protected AddGroup() {
9900 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
9901 "INSERT INTO Users_Groups (userId, groupId) VALUES (?, ?)",
9902 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
9903 }
9904
9905 protected void add(long userId, long groupId) throws SystemException {
9906 if (!containsGroup.contains(userId, groupId)) {
9907 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
9908
9909 for (ModelListener<User> listener : listeners) {
9910 listener.onBeforeAddAssociation(userId,
9911 com.liferay.portal.model.Group.class.getName(), groupId);
9912 }
9913
9914 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
9915 listener.onBeforeAddAssociation(groupId,
9916 User.class.getName(), userId);
9917 }
9918
9919 _sqlUpdate.update(new Object[] {
9920 new Long(userId), new Long(groupId)
9921 });
9922
9923 for (ModelListener<User> listener : listeners) {
9924 listener.onAfterAddAssociation(userId,
9925 com.liferay.portal.model.Group.class.getName(), groupId);
9926 }
9927
9928 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
9929 listener.onAfterAddAssociation(groupId,
9930 User.class.getName(), userId);
9931 }
9932 }
9933 }
9934
9935 private SqlUpdate _sqlUpdate;
9936 }
9937
9938 protected class ClearGroups {
9939 protected ClearGroups() {
9940 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
9941 "DELETE FROM Users_Groups WHERE userId = ?",
9942 new int[] { java.sql.Types.BIGINT });
9943 }
9944
9945 protected void clear(long userId) throws SystemException {
9946 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
9947
9948 List<com.liferay.portal.model.Group> groups = null;
9949
9950 if ((listeners.length > 0) || (groupListeners.length > 0)) {
9951 groups = getGroups(userId);
9952
9953 for (com.liferay.portal.model.Group group : groups) {
9954 for (ModelListener<User> listener : listeners) {
9955 listener.onBeforeRemoveAssociation(userId,
9956 com.liferay.portal.model.Group.class.getName(),
9957 group.getPrimaryKey());
9958 }
9959
9960 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
9961 listener.onBeforeRemoveAssociation(group.getPrimaryKey(),
9962 User.class.getName(), userId);
9963 }
9964 }
9965 }
9966
9967 _sqlUpdate.update(new Object[] { new Long(userId) });
9968
9969 if ((listeners.length > 0) || (groupListeners.length > 0)) {
9970 for (com.liferay.portal.model.Group group : groups) {
9971 for (ModelListener<User> listener : listeners) {
9972 listener.onAfterRemoveAssociation(userId,
9973 com.liferay.portal.model.Group.class.getName(),
9974 group.getPrimaryKey());
9975 }
9976
9977 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
9978 listener.onAfterRemoveAssociation(group.getPrimaryKey(),
9979 User.class.getName(), userId);
9980 }
9981 }
9982 }
9983 }
9984
9985 private SqlUpdate _sqlUpdate;
9986 }
9987
9988 protected class RemoveGroup {
9989 protected RemoveGroup() {
9990 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
9991 "DELETE FROM Users_Groups WHERE userId = ? AND groupId = ?",
9992 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
9993 }
9994
9995 protected void remove(long userId, long groupId)
9996 throws SystemException {
9997 if (containsGroup.contains(userId, groupId)) {
9998 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
9999
10000 for (ModelListener<User> listener : listeners) {
10001 listener.onBeforeRemoveAssociation(userId,
10002 com.liferay.portal.model.Group.class.getName(), groupId);
10003 }
10004
10005 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
10006 listener.onBeforeRemoveAssociation(groupId,
10007 User.class.getName(), userId);
10008 }
10009
10010 _sqlUpdate.update(new Object[] {
10011 new Long(userId), new Long(groupId)
10012 });
10013
10014 for (ModelListener<User> listener : listeners) {
10015 listener.onAfterRemoveAssociation(userId,
10016 com.liferay.portal.model.Group.class.getName(), groupId);
10017 }
10018
10019 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
10020 listener.onAfterRemoveAssociation(groupId,
10021 User.class.getName(), userId);
10022 }
10023 }
10024 }
10025
10026 private SqlUpdate _sqlUpdate;
10027 }
10028
10029 protected class ContainsOrganization {
10030 protected ContainsOrganization() {
10031 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
10032 _SQL_CONTAINSORGANIZATION,
10033 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
10034 RowMapper.COUNT);
10035 }
10036
10037 protected boolean contains(long userId, long organizationId) {
10038 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
10039 new Long(userId), new Long(organizationId)
10040 });
10041
10042 if (results.size() > 0) {
10043 Integer count = results.get(0);
10044
10045 if (count.intValue() > 0) {
10046 return true;
10047 }
10048 }
10049
10050 return false;
10051 }
10052
10053 private MappingSqlQuery<Integer> _mappingSqlQuery;
10054 }
10055
10056 protected class AddOrganization {
10057 protected AddOrganization() {
10058 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
10059 "INSERT INTO Users_Orgs (userId, organizationId) VALUES (?, ?)",
10060 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
10061 }
10062
10063 protected void add(long userId, long organizationId)
10064 throws SystemException {
10065 if (!containsOrganization.contains(userId, organizationId)) {
10066 ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
10067 organizationPersistence.getListeners();
10068
10069 for (ModelListener<User> listener : listeners) {
10070 listener.onBeforeAddAssociation(userId,
10071 com.liferay.portal.model.Organization.class.getName(),
10072 organizationId);
10073 }
10074
10075 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
10076 listener.onBeforeAddAssociation(organizationId,
10077 User.class.getName(), userId);
10078 }
10079
10080 _sqlUpdate.update(new Object[] {
10081 new Long(userId), new Long(organizationId)
10082 });
10083
10084 for (ModelListener<User> listener : listeners) {
10085 listener.onAfterAddAssociation(userId,
10086 com.liferay.portal.model.Organization.class.getName(),
10087 organizationId);
10088 }
10089
10090 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
10091 listener.onAfterAddAssociation(organizationId,
10092 User.class.getName(), userId);
10093 }
10094 }
10095 }
10096
10097 private SqlUpdate _sqlUpdate;
10098 }
10099
10100 protected class ClearOrganizations {
10101 protected ClearOrganizations() {
10102 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
10103 "DELETE FROM Users_Orgs WHERE userId = ?",
10104 new int[] { java.sql.Types.BIGINT });
10105 }
10106
10107 protected void clear(long userId) throws SystemException {
10108 ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
10109 organizationPersistence.getListeners();
10110
10111 List<com.liferay.portal.model.Organization> organizations = null;
10112
10113 if ((listeners.length > 0) || (organizationListeners.length > 0)) {
10114 organizations = getOrganizations(userId);
10115
10116 for (com.liferay.portal.model.Organization organization : organizations) {
10117 for (ModelListener<User> listener : listeners) {
10118 listener.onBeforeRemoveAssociation(userId,
10119 com.liferay.portal.model.Organization.class.getName(),
10120 organization.getPrimaryKey());
10121 }
10122
10123 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
10124 listener.onBeforeRemoveAssociation(organization.getPrimaryKey(),
10125 User.class.getName(), userId);
10126 }
10127 }
10128 }
10129
10130 _sqlUpdate.update(new Object[] { new Long(userId) });
10131
10132 if ((listeners.length > 0) || (organizationListeners.length > 0)) {
10133 for (com.liferay.portal.model.Organization organization : organizations) {
10134 for (ModelListener<User> listener : listeners) {
10135 listener.onAfterRemoveAssociation(userId,
10136 com.liferay.portal.model.Organization.class.getName(),
10137 organization.getPrimaryKey());
10138 }
10139
10140 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
10141 listener.onAfterRemoveAssociation(organization.getPrimaryKey(),
10142 User.class.getName(), userId);
10143 }
10144 }
10145 }
10146 }
10147
10148 private SqlUpdate _sqlUpdate;
10149 }
10150
10151 protected class RemoveOrganization {
10152 protected RemoveOrganization() {
10153 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
10154 "DELETE FROM Users_Orgs WHERE userId = ? AND organizationId = ?",
10155 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
10156 }
10157
10158 protected void remove(long userId, long organizationId)
10159 throws SystemException {
10160 if (containsOrganization.contains(userId, organizationId)) {
10161 ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
10162 organizationPersistence.getListeners();
10163
10164 for (ModelListener<User> listener : listeners) {
10165 listener.onBeforeRemoveAssociation(userId,
10166 com.liferay.portal.model.Organization.class.getName(),
10167 organizationId);
10168 }
10169
10170 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
10171 listener.onBeforeRemoveAssociation(organizationId,
10172 User.class.getName(), userId);
10173 }
10174
10175 _sqlUpdate.update(new Object[] {
10176 new Long(userId), new Long(organizationId)
10177 });
10178
10179 for (ModelListener<User> listener : listeners) {
10180 listener.onAfterRemoveAssociation(userId,
10181 com.liferay.portal.model.Organization.class.getName(),
10182 organizationId);
10183 }
10184
10185 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
10186 listener.onAfterRemoveAssociation(organizationId,
10187 User.class.getName(), userId);
10188 }
10189 }
10190 }
10191
10192 private SqlUpdate _sqlUpdate;
10193 }
10194
10195 protected class ContainsRole {
10196 protected ContainsRole() {
10197 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
10198 _SQL_CONTAINSROLE,
10199 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
10200 RowMapper.COUNT);
10201 }
10202
10203 protected boolean contains(long userId, long roleId) {
10204 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
10205 new Long(userId), new Long(roleId)
10206 });
10207
10208 if (results.size() > 0) {
10209 Integer count = results.get(0);
10210
10211 if (count.intValue() > 0) {
10212 return true;
10213 }
10214 }
10215
10216 return false;
10217 }
10218
10219 private MappingSqlQuery<Integer> _mappingSqlQuery;
10220 }
10221
10222 protected class AddRole {
10223 protected AddRole() {
10224 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
10225 "INSERT INTO Users_Roles (userId, roleId) VALUES (?, ?)",
10226 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
10227 }
10228
10229 protected void add(long userId, long roleId) throws SystemException {
10230 if (!containsRole.contains(userId, roleId)) {
10231 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
10232
10233 for (ModelListener<User> listener : listeners) {
10234 listener.onBeforeAddAssociation(userId,
10235 com.liferay.portal.model.Role.class.getName(), roleId);
10236 }
10237
10238 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
10239 listener.onBeforeAddAssociation(roleId,
10240 User.class.getName(), userId);
10241 }
10242
10243 _sqlUpdate.update(new Object[] {
10244 new Long(userId), new Long(roleId)
10245 });
10246
10247 for (ModelListener<User> listener : listeners) {
10248 listener.onAfterAddAssociation(userId,
10249 com.liferay.portal.model.Role.class.getName(), roleId);
10250 }
10251
10252 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
10253 listener.onAfterAddAssociation(roleId,
10254 User.class.getName(), userId);
10255 }
10256 }
10257 }
10258
10259 private SqlUpdate _sqlUpdate;
10260 }
10261
10262 protected class ClearRoles {
10263 protected ClearRoles() {
10264 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
10265 "DELETE FROM Users_Roles WHERE userId = ?",
10266 new int[] { java.sql.Types.BIGINT });
10267 }
10268
10269 protected void clear(long userId) throws SystemException {
10270 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
10271
10272 List<com.liferay.portal.model.Role> roles = null;
10273
10274 if ((listeners.length > 0) || (roleListeners.length > 0)) {
10275 roles = getRoles(userId);
10276
10277 for (com.liferay.portal.model.Role role : roles) {
10278 for (ModelListener<User> listener : listeners) {
10279 listener.onBeforeRemoveAssociation(userId,
10280 com.liferay.portal.model.Role.class.getName(),
10281 role.getPrimaryKey());
10282 }
10283
10284 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
10285 listener.onBeforeRemoveAssociation(role.getPrimaryKey(),
10286 User.class.getName(), userId);
10287 }
10288 }
10289 }
10290
10291 _sqlUpdate.update(new Object[] { new Long(userId) });
10292
10293 if ((listeners.length > 0) || (roleListeners.length > 0)) {
10294 for (com.liferay.portal.model.Role role : roles) {
10295 for (ModelListener<User> listener : listeners) {
10296 listener.onAfterRemoveAssociation(userId,
10297 com.liferay.portal.model.Role.class.getName(),
10298 role.getPrimaryKey());
10299 }
10300
10301 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
10302 listener.onAfterRemoveAssociation(role.getPrimaryKey(),
10303 User.class.getName(), userId);
10304 }
10305 }
10306 }
10307 }
10308
10309 private SqlUpdate _sqlUpdate;
10310 }
10311
10312 protected class RemoveRole {
10313 protected RemoveRole() {
10314 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
10315 "DELETE FROM Users_Roles WHERE userId = ? AND roleId = ?",
10316 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
10317 }
10318
10319 protected void remove(long userId, long roleId)
10320 throws SystemException {
10321 if (containsRole.contains(userId, roleId)) {
10322 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
10323
10324 for (ModelListener<User> listener : listeners) {
10325 listener.onBeforeRemoveAssociation(userId,
10326 com.liferay.portal.model.Role.class.getName(), roleId);
10327 }
10328
10329 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
10330 listener.onBeforeRemoveAssociation(roleId,
10331 User.class.getName(), userId);
10332 }
10333
10334 _sqlUpdate.update(new Object[] {
10335 new Long(userId), new Long(roleId)
10336 });
10337
10338 for (ModelListener<User> listener : listeners) {
10339 listener.onAfterRemoveAssociation(userId,
10340 com.liferay.portal.model.Role.class.getName(), roleId);
10341 }
10342
10343 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
10344 listener.onAfterRemoveAssociation(roleId,
10345 User.class.getName(), userId);
10346 }
10347 }
10348 }
10349
10350 private SqlUpdate _sqlUpdate;
10351 }
10352
10353 protected class ContainsTeam {
10354 protected ContainsTeam() {
10355 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
10356 _SQL_CONTAINSTEAM,
10357 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
10358 RowMapper.COUNT);
10359 }
10360
10361 protected boolean contains(long userId, long teamId) {
10362 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
10363 new Long(userId), new Long(teamId)
10364 });
10365
10366 if (results.size() > 0) {
10367 Integer count = results.get(0);
10368
10369 if (count.intValue() > 0) {
10370 return true;
10371 }
10372 }
10373
10374 return false;
10375 }
10376
10377 private MappingSqlQuery<Integer> _mappingSqlQuery;
10378 }
10379
10380 protected class AddTeam {
10381 protected AddTeam() {
10382 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
10383 "INSERT INTO Users_Teams (userId, teamId) VALUES (?, ?)",
10384 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
10385 }
10386
10387 protected void add(long userId, long teamId) throws SystemException {
10388 if (!containsTeam.contains(userId, teamId)) {
10389 ModelListener<com.liferay.portal.model.Team>[] teamListeners = teamPersistence.getListeners();
10390
10391 for (ModelListener<User> listener : listeners) {
10392 listener.onBeforeAddAssociation(userId,
10393 com.liferay.portal.model.Team.class.getName(), teamId);
10394 }
10395
10396 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
10397 listener.onBeforeAddAssociation(teamId,
10398 User.class.getName(), userId);
10399 }
10400
10401 _sqlUpdate.update(new Object[] {
10402 new Long(userId), new Long(teamId)
10403 });
10404
10405 for (ModelListener<User> listener : listeners) {
10406 listener.onAfterAddAssociation(userId,
10407 com.liferay.portal.model.Team.class.getName(), teamId);
10408 }
10409
10410 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
10411 listener.onAfterAddAssociation(teamId,
10412 User.class.getName(), userId);
10413 }
10414 }
10415 }
10416
10417 private SqlUpdate _sqlUpdate;
10418 }
10419
10420 protected class ClearTeams {
10421 protected ClearTeams() {
10422 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
10423 "DELETE FROM Users_Teams WHERE userId = ?",
10424 new int[] { java.sql.Types.BIGINT });
10425 }
10426
10427 protected void clear(long userId) throws SystemException {
10428 ModelListener<com.liferay.portal.model.Team>[] teamListeners = teamPersistence.getListeners();
10429
10430 List<com.liferay.portal.model.Team> teams = null;
10431
10432 if ((listeners.length > 0) || (teamListeners.length > 0)) {
10433 teams = getTeams(userId);
10434
10435 for (com.liferay.portal.model.Team team : teams) {
10436 for (ModelListener<User> listener : listeners) {
10437 listener.onBeforeRemoveAssociation(userId,
10438 com.liferay.portal.model.Team.class.getName(),
10439 team.getPrimaryKey());
10440 }
10441
10442 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
10443 listener.onBeforeRemoveAssociation(team.getPrimaryKey(),
10444 User.class.getName(), userId);
10445 }
10446 }
10447 }
10448
10449 _sqlUpdate.update(new Object[] { new Long(userId) });
10450
10451 if ((listeners.length > 0) || (teamListeners.length > 0)) {
10452 for (com.liferay.portal.model.Team team : teams) {
10453 for (ModelListener<User> listener : listeners) {
10454 listener.onAfterRemoveAssociation(userId,
10455 com.liferay.portal.model.Team.class.getName(),
10456 team.getPrimaryKey());
10457 }
10458
10459 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
10460 listener.onAfterRemoveAssociation(team.getPrimaryKey(),
10461 User.class.getName(), userId);
10462 }
10463 }
10464 }
10465 }
10466
10467 private SqlUpdate _sqlUpdate;
10468 }
10469
10470 protected class RemoveTeam {
10471 protected RemoveTeam() {
10472 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
10473 "DELETE FROM Users_Teams WHERE userId = ? AND teamId = ?",
10474 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
10475 }
10476
10477 protected void remove(long userId, long teamId)
10478 throws SystemException {
10479 if (containsTeam.contains(userId, teamId)) {
10480 ModelListener<com.liferay.portal.model.Team>[] teamListeners = teamPersistence.getListeners();
10481
10482 for (ModelListener<User> listener : listeners) {
10483 listener.onBeforeRemoveAssociation(userId,
10484 com.liferay.portal.model.Team.class.getName(), teamId);
10485 }
10486
10487 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
10488 listener.onBeforeRemoveAssociation(teamId,
10489 User.class.getName(), userId);
10490 }
10491
10492 _sqlUpdate.update(new Object[] {
10493 new Long(userId), new Long(teamId)
10494 });
10495
10496 for (ModelListener<User> listener : listeners) {
10497 listener.onAfterRemoveAssociation(userId,
10498 com.liferay.portal.model.Team.class.getName(), teamId);
10499 }
10500
10501 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
10502 listener.onAfterRemoveAssociation(teamId,
10503 User.class.getName(), userId);
10504 }
10505 }
10506 }
10507
10508 private SqlUpdate _sqlUpdate;
10509 }
10510
10511 protected class ContainsUserGroup {
10512 protected ContainsUserGroup() {
10513 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
10514 _SQL_CONTAINSUSERGROUP,
10515 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
10516 RowMapper.COUNT);
10517 }
10518
10519 protected boolean contains(long userId, long userGroupId) {
10520 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
10521 new Long(userId), new Long(userGroupId)
10522 });
10523
10524 if (results.size() > 0) {
10525 Integer count = results.get(0);
10526
10527 if (count.intValue() > 0) {
10528 return true;
10529 }
10530 }
10531
10532 return false;
10533 }
10534
10535 private MappingSqlQuery<Integer> _mappingSqlQuery;
10536 }
10537
10538 protected class AddUserGroup {
10539 protected AddUserGroup() {
10540 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
10541 "INSERT INTO Users_UserGroups (userId, userGroupId) VALUES (?, ?)",
10542 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
10543 }
10544
10545 protected void add(long userId, long userGroupId)
10546 throws SystemException {
10547 if (!containsUserGroup.contains(userId, userGroupId)) {
10548 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
10549 userGroupPersistence.getListeners();
10550
10551 for (ModelListener<User> listener : listeners) {
10552 listener.onBeforeAddAssociation(userId,
10553 com.liferay.portal.model.UserGroup.class.getName(),
10554 userGroupId);
10555 }
10556
10557 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
10558 listener.onBeforeAddAssociation(userGroupId,
10559 User.class.getName(), userId);
10560 }
10561
10562 _sqlUpdate.update(new Object[] {
10563 new Long(userId), new Long(userGroupId)
10564 });
10565
10566 for (ModelListener<User> listener : listeners) {
10567 listener.onAfterAddAssociation(userId,
10568 com.liferay.portal.model.UserGroup.class.getName(),
10569 userGroupId);
10570 }
10571
10572 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
10573 listener.onAfterAddAssociation(userGroupId,
10574 User.class.getName(), userId);
10575 }
10576 }
10577 }
10578
10579 private SqlUpdate _sqlUpdate;
10580 }
10581
10582 protected class ClearUserGroups {
10583 protected ClearUserGroups() {
10584 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
10585 "DELETE FROM Users_UserGroups WHERE userId = ?",
10586 new int[] { java.sql.Types.BIGINT });
10587 }
10588
10589 protected void clear(long userId) throws SystemException {
10590 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
10591 userGroupPersistence.getListeners();
10592
10593 List<com.liferay.portal.model.UserGroup> userGroups = null;
10594
10595 if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
10596 userGroups = getUserGroups(userId);
10597
10598 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
10599 for (ModelListener<User> listener : listeners) {
10600 listener.onBeforeRemoveAssociation(userId,
10601 com.liferay.portal.model.UserGroup.class.getName(),
10602 userGroup.getPrimaryKey());
10603 }
10604
10605 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
10606 listener.onBeforeRemoveAssociation(userGroup.getPrimaryKey(),
10607 User.class.getName(), userId);
10608 }
10609 }
10610 }
10611
10612 _sqlUpdate.update(new Object[] { new Long(userId) });
10613
10614 if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
10615 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
10616 for (ModelListener<User> listener : listeners) {
10617 listener.onAfterRemoveAssociation(userId,
10618 com.liferay.portal.model.UserGroup.class.getName(),
10619 userGroup.getPrimaryKey());
10620 }
10621
10622 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
10623 listener.onAfterRemoveAssociation(userGroup.getPrimaryKey(),
10624 User.class.getName(), userId);
10625 }
10626 }
10627 }
10628 }
10629
10630 private SqlUpdate _sqlUpdate;
10631 }
10632
10633 protected class RemoveUserGroup {
10634 protected RemoveUserGroup() {
10635 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
10636 "DELETE FROM Users_UserGroups WHERE userId = ? AND userGroupId = ?",
10637 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
10638 }
10639
10640 protected void remove(long userId, long userGroupId)
10641 throws SystemException {
10642 if (containsUserGroup.contains(userId, userGroupId)) {
10643 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
10644 userGroupPersistence.getListeners();
10645
10646 for (ModelListener<User> listener : listeners) {
10647 listener.onBeforeRemoveAssociation(userId,
10648 com.liferay.portal.model.UserGroup.class.getName(),
10649 userGroupId);
10650 }
10651
10652 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
10653 listener.onBeforeRemoveAssociation(userGroupId,
10654 User.class.getName(), userId);
10655 }
10656
10657 _sqlUpdate.update(new Object[] {
10658 new Long(userId), new Long(userGroupId)
10659 });
10660
10661 for (ModelListener<User> listener : listeners) {
10662 listener.onAfterRemoveAssociation(userId,
10663 com.liferay.portal.model.UserGroup.class.getName(),
10664 userGroupId);
10665 }
10666
10667 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
10668 listener.onAfterRemoveAssociation(userGroupId,
10669 User.class.getName(), userId);
10670 }
10671 }
10672 }
10673
10674 private SqlUpdate _sqlUpdate;
10675 }
10676
10677 private static final String _SQL_SELECT_USER = "SELECT user FROM User user";
10678 private static final String _SQL_SELECT_USER_WHERE = "SELECT user FROM User user WHERE ";
10679 private static final String _SQL_COUNT_USER = "SELECT COUNT(user) FROM User user";
10680 private static final String _SQL_COUNT_USER_WHERE = "SELECT COUNT(user) FROM User user WHERE ";
10681 private static final String _SQL_GETGROUPS = "SELECT {Group_.*} FROM Group_ INNER JOIN Users_Groups ON (Users_Groups.groupId = Group_.groupId) WHERE (Users_Groups.userId = ?)";
10682 private static final String _SQL_GETGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Groups WHERE userId = ?";
10683 private static final String _SQL_CONTAINSGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Groups WHERE userId = ? AND groupId = ?";
10684 private static final String _SQL_GETORGANIZATIONS = "SELECT {Organization_.*} FROM Organization_ INNER JOIN Users_Orgs ON (Users_Orgs.organizationId = Organization_.organizationId) WHERE (Users_Orgs.userId = ?)";
10685 private static final String _SQL_GETORGANIZATIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Orgs WHERE userId = ?";
10686 private static final String _SQL_CONTAINSORGANIZATION = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Orgs WHERE userId = ? AND organizationId = ?";
10687 private static final String _SQL_GETROLES = "SELECT {Role_.*} FROM Role_ INNER JOIN Users_Roles ON (Users_Roles.roleId = Role_.roleId) WHERE (Users_Roles.userId = ?)";
10688 private static final String _SQL_GETROLESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Roles WHERE userId = ?";
10689 private static final String _SQL_CONTAINSROLE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Roles WHERE userId = ? AND roleId = ?";
10690 private static final String _SQL_GETTEAMS = "SELECT {Team.*} FROM Team INNER JOIN Users_Teams ON (Users_Teams.teamId = Team.teamId) WHERE (Users_Teams.userId = ?)";
10691 private static final String _SQL_GETTEAMSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Teams WHERE userId = ?";
10692 private static final String _SQL_CONTAINSTEAM = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Teams WHERE userId = ? AND teamId = ?";
10693 private static final String _SQL_GETUSERGROUPS = "SELECT {UserGroup.*} FROM UserGroup INNER JOIN Users_UserGroups ON (Users_UserGroups.userGroupId = UserGroup.userGroupId) WHERE (Users_UserGroups.userId = ?)";
10694 private static final String _SQL_GETUSERGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_UserGroups WHERE userId = ?";
10695 private static final String _SQL_CONTAINSUSERGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_UserGroups WHERE userId = ? AND userGroupId = ?";
10696 private static final String _ORDER_BY_ENTITY_ALIAS = "user.";
10697 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No User exists with the primary key ";
10698 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No User exists with the key {";
10699 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
10700 private static Log _log = LogFactoryUtil.getLog(UserPersistenceImpl.class);
10701 private static User _nullUser = new UserImpl() {
10702 @Override
10703 public Object clone() {
10704 return this;
10705 }
10706
10707 @Override
10708 public CacheModel<User> toCacheModel() {
10709 return _nullUserCacheModel;
10710 }
10711 };
10712
10713 private static CacheModel<User> _nullUserCacheModel = new CacheModel<User>() {
10714 public User toEntityModel() {
10715 return _nullUser;
10716 }
10717 };
10718 }