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