001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.NoSuchUserGroupException;
019 import com.liferay.portal.kernel.annotation.BeanReference;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
022 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
023 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
024 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
025 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
026 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
027 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
028 import com.liferay.portal.kernel.dao.orm.FinderPath;
029 import com.liferay.portal.kernel.dao.orm.Query;
030 import com.liferay.portal.kernel.dao.orm.QueryPos;
031 import com.liferay.portal.kernel.dao.orm.QueryUtil;
032 import com.liferay.portal.kernel.dao.orm.SQLQuery;
033 import com.liferay.portal.kernel.dao.orm.Session;
034 import com.liferay.portal.kernel.exception.SystemException;
035 import com.liferay.portal.kernel.log.Log;
036 import com.liferay.portal.kernel.log.LogFactoryUtil;
037 import com.liferay.portal.kernel.util.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.Validator;
045 import com.liferay.portal.model.ModelListener;
046 import com.liferay.portal.model.UserGroup;
047 import com.liferay.portal.model.impl.UserGroupImpl;
048 import com.liferay.portal.model.impl.UserGroupModelImpl;
049 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
050 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
051
052 import java.io.Serializable;
053
054 import java.util.ArrayList;
055 import java.util.Collections;
056 import java.util.List;
057 import java.util.Set;
058
059
075 public class UserGroupPersistenceImpl extends BasePersistenceImpl<UserGroup>
076 implements UserGroupPersistence {
077 public static final String FINDER_CLASS_NAME_ENTITY = UserGroupImpl.class.getName();
078 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
079 ".List";
080 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
081 UserGroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
082 "findByCompanyId",
083 new String[] {
084 Long.class.getName(),
085
086 "java.lang.Integer", "java.lang.Integer",
087 "com.liferay.portal.kernel.util.OrderByComparator"
088 });
089 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
090 UserGroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
091 "countByCompanyId", new String[] { Long.class.getName() });
092 public static final FinderPath FINDER_PATH_FIND_BY_C_P = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
093 UserGroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
094 "findByC_P",
095 new String[] {
096 Long.class.getName(), Long.class.getName(),
097
098 "java.lang.Integer", "java.lang.Integer",
099 "com.liferay.portal.kernel.util.OrderByComparator"
100 });
101 public static final FinderPath FINDER_PATH_COUNT_BY_C_P = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
102 UserGroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
103 "countByC_P",
104 new String[] { Long.class.getName(), Long.class.getName() });
105 public static final FinderPath FINDER_PATH_FETCH_BY_C_N = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
106 UserGroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
107 "fetchByC_N",
108 new String[] { Long.class.getName(), String.class.getName() });
109 public static final FinderPath FINDER_PATH_COUNT_BY_C_N = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
110 UserGroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
111 "countByC_N",
112 new String[] { Long.class.getName(), String.class.getName() });
113 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
114 UserGroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
115 "findAll", new String[0]);
116 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
117 UserGroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
118 "countAll", new String[0]);
119
120
125 public void cacheResult(UserGroup userGroup) {
126 EntityCacheUtil.putResult(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
127 UserGroupImpl.class, userGroup.getPrimaryKey(), userGroup);
128
129 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
130 new Object[] { new Long(userGroup.getCompanyId()), userGroup.getName() },
131 userGroup);
132 }
133
134
139 public void cacheResult(List<UserGroup> userGroups) {
140 for (UserGroup userGroup : userGroups) {
141 if (EntityCacheUtil.getResult(
142 UserGroupModelImpl.ENTITY_CACHE_ENABLED,
143 UserGroupImpl.class, userGroup.getPrimaryKey(), this) == null) {
144 cacheResult(userGroup);
145 }
146 }
147 }
148
149
156 public void clearCache() {
157 CacheRegistryUtil.clear(UserGroupImpl.class.getName());
158 EntityCacheUtil.clearCache(UserGroupImpl.class.getName());
159 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
160 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
161 }
162
163
170 public void clearCache(UserGroup userGroup) {
171 EntityCacheUtil.removeResult(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
172 UserGroupImpl.class, userGroup.getPrimaryKey());
173
174 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
175 new Object[] { new Long(userGroup.getCompanyId()), userGroup.getName() });
176 }
177
178
184 public UserGroup create(long userGroupId) {
185 UserGroup userGroup = new UserGroupImpl();
186
187 userGroup.setNew(true);
188 userGroup.setPrimaryKey(userGroupId);
189
190 return userGroup;
191 }
192
193
201 public UserGroup remove(Serializable primaryKey)
202 throws NoSuchModelException, SystemException {
203 return remove(((Long)primaryKey).longValue());
204 }
205
206
214 public UserGroup remove(long userGroupId)
215 throws NoSuchUserGroupException, SystemException {
216 Session session = null;
217
218 try {
219 session = openSession();
220
221 UserGroup userGroup = (UserGroup)session.get(UserGroupImpl.class,
222 new Long(userGroupId));
223
224 if (userGroup == null) {
225 if (_log.isWarnEnabled()) {
226 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + userGroupId);
227 }
228
229 throw new NoSuchUserGroupException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
230 userGroupId);
231 }
232
233 return remove(userGroup);
234 }
235 catch (NoSuchUserGroupException nsee) {
236 throw nsee;
237 }
238 catch (Exception e) {
239 throw processException(e);
240 }
241 finally {
242 closeSession(session);
243 }
244 }
245
246 protected UserGroup removeImpl(UserGroup userGroup)
247 throws SystemException {
248 userGroup = toUnwrappedModel(userGroup);
249
250 try {
251 clearGroups.clear(userGroup.getPrimaryKey());
252 }
253 catch (Exception e) {
254 throw processException(e);
255 }
256 finally {
257 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
258 }
259
260 try {
261 clearUsers.clear(userGroup.getPrimaryKey());
262 }
263 catch (Exception e) {
264 throw processException(e);
265 }
266 finally {
267 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
268 }
269
270 Session session = null;
271
272 try {
273 session = openSession();
274
275 BatchSessionUtil.delete(session, userGroup);
276 }
277 catch (Exception e) {
278 throw processException(e);
279 }
280 finally {
281 closeSession(session);
282 }
283
284 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
285
286 UserGroupModelImpl userGroupModelImpl = (UserGroupModelImpl)userGroup;
287
288 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
289 new Object[] {
290 new Long(userGroupModelImpl.getCompanyId()),
291
292 userGroupModelImpl.getName()
293 });
294
295 EntityCacheUtil.removeResult(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
296 UserGroupImpl.class, userGroup.getPrimaryKey());
297
298 return userGroup;
299 }
300
301 public UserGroup updateImpl(com.liferay.portal.model.UserGroup userGroup,
302 boolean merge) throws SystemException {
303 userGroup = toUnwrappedModel(userGroup);
304
305 boolean isNew = userGroup.isNew();
306
307 UserGroupModelImpl userGroupModelImpl = (UserGroupModelImpl)userGroup;
308
309 Session session = null;
310
311 try {
312 session = openSession();
313
314 BatchSessionUtil.update(session, userGroup, merge);
315
316 userGroup.setNew(false);
317 }
318 catch (Exception e) {
319 throw processException(e);
320 }
321 finally {
322 closeSession(session);
323 }
324
325 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
326
327 EntityCacheUtil.putResult(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
328 UserGroupImpl.class, userGroup.getPrimaryKey(), userGroup);
329
330 if (!isNew &&
331 ((userGroup.getCompanyId() != userGroupModelImpl.getOriginalCompanyId()) ||
332 !Validator.equals(userGroup.getName(),
333 userGroupModelImpl.getOriginalName()))) {
334 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
335 new Object[] {
336 new Long(userGroupModelImpl.getOriginalCompanyId()),
337
338 userGroupModelImpl.getOriginalName()
339 });
340 }
341
342 if (isNew ||
343 ((userGroup.getCompanyId() != userGroupModelImpl.getOriginalCompanyId()) ||
344 !Validator.equals(userGroup.getName(),
345 userGroupModelImpl.getOriginalName()))) {
346 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
347 new Object[] {
348 new Long(userGroup.getCompanyId()),
349
350 userGroup.getName()
351 }, userGroup);
352 }
353
354 return userGroup;
355 }
356
357 protected UserGroup toUnwrappedModel(UserGroup userGroup) {
358 if (userGroup instanceof UserGroupImpl) {
359 return userGroup;
360 }
361
362 UserGroupImpl userGroupImpl = new UserGroupImpl();
363
364 userGroupImpl.setNew(userGroup.isNew());
365 userGroupImpl.setPrimaryKey(userGroup.getPrimaryKey());
366
367 userGroupImpl.setUserGroupId(userGroup.getUserGroupId());
368 userGroupImpl.setCompanyId(userGroup.getCompanyId());
369 userGroupImpl.setParentUserGroupId(userGroup.getParentUserGroupId());
370 userGroupImpl.setName(userGroup.getName());
371 userGroupImpl.setDescription(userGroup.getDescription());
372
373 return userGroupImpl;
374 }
375
376
384 public UserGroup findByPrimaryKey(Serializable primaryKey)
385 throws NoSuchModelException, SystemException {
386 return findByPrimaryKey(((Long)primaryKey).longValue());
387 }
388
389
397 public UserGroup findByPrimaryKey(long userGroupId)
398 throws NoSuchUserGroupException, SystemException {
399 UserGroup userGroup = fetchByPrimaryKey(userGroupId);
400
401 if (userGroup == null) {
402 if (_log.isWarnEnabled()) {
403 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + userGroupId);
404 }
405
406 throw new NoSuchUserGroupException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
407 userGroupId);
408 }
409
410 return userGroup;
411 }
412
413
420 public UserGroup fetchByPrimaryKey(Serializable primaryKey)
421 throws SystemException {
422 return fetchByPrimaryKey(((Long)primaryKey).longValue());
423 }
424
425
432 public UserGroup fetchByPrimaryKey(long userGroupId)
433 throws SystemException {
434 UserGroup userGroup = (UserGroup)EntityCacheUtil.getResult(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
435 UserGroupImpl.class, userGroupId, this);
436
437 if (userGroup == null) {
438 Session session = null;
439
440 try {
441 session = openSession();
442
443 userGroup = (UserGroup)session.get(UserGroupImpl.class,
444 new Long(userGroupId));
445 }
446 catch (Exception e) {
447 throw processException(e);
448 }
449 finally {
450 if (userGroup != null) {
451 cacheResult(userGroup);
452 }
453
454 closeSession(session);
455 }
456 }
457
458 return userGroup;
459 }
460
461
468 public List<UserGroup> findByCompanyId(long companyId)
469 throws SystemException {
470 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
471 null);
472 }
473
474
487 public List<UserGroup> findByCompanyId(long companyId, int start, int end)
488 throws SystemException {
489 return findByCompanyId(companyId, start, end, null);
490 }
491
492
506 public List<UserGroup> findByCompanyId(long companyId, int start, int end,
507 OrderByComparator orderByComparator) throws SystemException {
508 Object[] finderArgs = new Object[] {
509 companyId,
510
511 String.valueOf(start), String.valueOf(end),
512 String.valueOf(orderByComparator)
513 };
514
515 List<UserGroup> list = (List<UserGroup>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
516 finderArgs, this);
517
518 if (list == null) {
519 StringBundler query = null;
520
521 if (orderByComparator != null) {
522 query = new StringBundler(3 +
523 (orderByComparator.getOrderByFields().length * 3));
524 }
525 else {
526 query = new StringBundler(3);
527 }
528
529 query.append(_SQL_SELECT_USERGROUP_WHERE);
530
531 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
532
533 if (orderByComparator != null) {
534 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
535 orderByComparator);
536 }
537
538 else {
539 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
540 }
541
542 String sql = query.toString();
543
544 Session session = null;
545
546 try {
547 session = openSession();
548
549 Query q = session.createQuery(sql);
550
551 QueryPos qPos = QueryPos.getInstance(q);
552
553 qPos.add(companyId);
554
555 list = (List<UserGroup>)QueryUtil.list(q, getDialect(), start,
556 end);
557 }
558 catch (Exception e) {
559 throw processException(e);
560 }
561 finally {
562 if (list == null) {
563 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_COMPANYID,
564 finderArgs);
565 }
566 else {
567 cacheResult(list);
568
569 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
570 finderArgs, list);
571 }
572
573 closeSession(session);
574 }
575 }
576
577 return list;
578 }
579
580
593 public UserGroup findByCompanyId_First(long companyId,
594 OrderByComparator orderByComparator)
595 throws NoSuchUserGroupException, SystemException {
596 List<UserGroup> list = findByCompanyId(companyId, 0, 1,
597 orderByComparator);
598
599 if (list.isEmpty()) {
600 StringBundler msg = new StringBundler(4);
601
602 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
603
604 msg.append("companyId=");
605 msg.append(companyId);
606
607 msg.append(StringPool.CLOSE_CURLY_BRACE);
608
609 throw new NoSuchUserGroupException(msg.toString());
610 }
611 else {
612 return list.get(0);
613 }
614 }
615
616
629 public UserGroup findByCompanyId_Last(long companyId,
630 OrderByComparator orderByComparator)
631 throws NoSuchUserGroupException, SystemException {
632 int count = countByCompanyId(companyId);
633
634 List<UserGroup> list = findByCompanyId(companyId, count - 1, count,
635 orderByComparator);
636
637 if (list.isEmpty()) {
638 StringBundler msg = new StringBundler(4);
639
640 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
641
642 msg.append("companyId=");
643 msg.append(companyId);
644
645 msg.append(StringPool.CLOSE_CURLY_BRACE);
646
647 throw new NoSuchUserGroupException(msg.toString());
648 }
649 else {
650 return list.get(0);
651 }
652 }
653
654
668 public UserGroup[] findByCompanyId_PrevAndNext(long userGroupId,
669 long companyId, OrderByComparator orderByComparator)
670 throws NoSuchUserGroupException, SystemException {
671 UserGroup userGroup = findByPrimaryKey(userGroupId);
672
673 Session session = null;
674
675 try {
676 session = openSession();
677
678 UserGroup[] array = new UserGroupImpl[3];
679
680 array[0] = getByCompanyId_PrevAndNext(session, userGroup,
681 companyId, orderByComparator, true);
682
683 array[1] = userGroup;
684
685 array[2] = getByCompanyId_PrevAndNext(session, userGroup,
686 companyId, orderByComparator, false);
687
688 return array;
689 }
690 catch (Exception e) {
691 throw processException(e);
692 }
693 finally {
694 closeSession(session);
695 }
696 }
697
698 protected UserGroup getByCompanyId_PrevAndNext(Session session,
699 UserGroup userGroup, long companyId,
700 OrderByComparator orderByComparator, boolean previous) {
701 StringBundler query = null;
702
703 if (orderByComparator != null) {
704 query = new StringBundler(6 +
705 (orderByComparator.getOrderByFields().length * 6));
706 }
707 else {
708 query = new StringBundler(3);
709 }
710
711 query.append(_SQL_SELECT_USERGROUP_WHERE);
712
713 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
714
715 if (orderByComparator != null) {
716 String[] orderByFields = orderByComparator.getOrderByFields();
717
718 if (orderByFields.length > 0) {
719 query.append(WHERE_AND);
720 }
721
722 for (int i = 0; i < orderByFields.length; i++) {
723 query.append(_ORDER_BY_ENTITY_ALIAS);
724 query.append(orderByFields[i]);
725
726 if ((i + 1) < orderByFields.length) {
727 if (orderByComparator.isAscending() ^ previous) {
728 query.append(WHERE_GREATER_THAN_HAS_NEXT);
729 }
730 else {
731 query.append(WHERE_LESSER_THAN_HAS_NEXT);
732 }
733 }
734 else {
735 if (orderByComparator.isAscending() ^ previous) {
736 query.append(WHERE_GREATER_THAN);
737 }
738 else {
739 query.append(WHERE_LESSER_THAN);
740 }
741 }
742 }
743
744 query.append(ORDER_BY_CLAUSE);
745
746 for (int i = 0; i < orderByFields.length; i++) {
747 query.append(_ORDER_BY_ENTITY_ALIAS);
748 query.append(orderByFields[i]);
749
750 if ((i + 1) < orderByFields.length) {
751 if (orderByComparator.isAscending() ^ previous) {
752 query.append(ORDER_BY_ASC_HAS_NEXT);
753 }
754 else {
755 query.append(ORDER_BY_DESC_HAS_NEXT);
756 }
757 }
758 else {
759 if (orderByComparator.isAscending() ^ previous) {
760 query.append(ORDER_BY_ASC);
761 }
762 else {
763 query.append(ORDER_BY_DESC);
764 }
765 }
766 }
767 }
768
769 else {
770 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
771 }
772
773 String sql = query.toString();
774
775 Query q = session.createQuery(sql);
776
777 q.setFirstResult(0);
778 q.setMaxResults(2);
779
780 QueryPos qPos = QueryPos.getInstance(q);
781
782 qPos.add(companyId);
783
784 if (orderByComparator != null) {
785 Object[] values = orderByComparator.getOrderByValues(userGroup);
786
787 for (Object value : values) {
788 qPos.add(value);
789 }
790 }
791
792 List<UserGroup> list = q.list();
793
794 if (list.size() == 2) {
795 return list.get(1);
796 }
797 else {
798 return null;
799 }
800 }
801
802
809 public List<UserGroup> filterFindByCompanyId(long companyId)
810 throws SystemException {
811 return filterFindByCompanyId(companyId, QueryUtil.ALL_POS,
812 QueryUtil.ALL_POS, null);
813 }
814
815
828 public List<UserGroup> filterFindByCompanyId(long companyId, int start,
829 int end) throws SystemException {
830 return filterFindByCompanyId(companyId, start, end, null);
831 }
832
833
847 public List<UserGroup> filterFindByCompanyId(long companyId, int start,
848 int end, OrderByComparator orderByComparator) throws SystemException {
849 if (!InlineSQLHelperUtil.isEnabled()) {
850 return findByCompanyId(companyId, start, end, orderByComparator);
851 }
852
853 StringBundler query = null;
854
855 if (orderByComparator != null) {
856 query = new StringBundler(3 +
857 (orderByComparator.getOrderByFields().length * 3));
858 }
859 else {
860 query = new StringBundler(3);
861 }
862
863 if (getDB().isSupportsInlineDistinct()) {
864 query.append(_FILTER_SQL_SELECT_USERGROUP_WHERE);
865 }
866 else {
867 query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_1);
868 }
869
870 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
871
872 if (!getDB().isSupportsInlineDistinct()) {
873 query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_2);
874 }
875
876 if (orderByComparator != null) {
877 if (getDB().isSupportsInlineDistinct()) {
878 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
879 orderByComparator);
880 }
881 else {
882 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
883 orderByComparator);
884 }
885 }
886
887 else {
888 if (getDB().isSupportsInlineDistinct()) {
889 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
890 }
891 else {
892 query.append(UserGroupModelImpl.ORDER_BY_SQL);
893 }
894 }
895
896 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
897 UserGroup.class.getName(), _FILTER_COLUMN_PK,
898 _FILTER_COLUMN_USERID);
899
900 Session session = null;
901
902 try {
903 session = openSession();
904
905 SQLQuery q = session.createSQLQuery(sql);
906
907 if (getDB().isSupportsInlineDistinct()) {
908 q.addEntity(_FILTER_ENTITY_ALIAS, UserGroupImpl.class);
909 }
910 else {
911 q.addEntity(_FILTER_ENTITY_TABLE, UserGroupImpl.class);
912 }
913
914 QueryPos qPos = QueryPos.getInstance(q);
915
916 qPos.add(companyId);
917
918 return (List<UserGroup>)QueryUtil.list(q, getDialect(), start, end);
919 }
920 catch (Exception e) {
921 throw processException(e);
922 }
923 finally {
924 closeSession(session);
925 }
926 }
927
928
936 public List<UserGroup> findByC_P(long companyId, long parentUserGroupId)
937 throws SystemException {
938 return findByC_P(companyId, parentUserGroupId, QueryUtil.ALL_POS,
939 QueryUtil.ALL_POS, null);
940 }
941
942
956 public List<UserGroup> findByC_P(long companyId, long parentUserGroupId,
957 int start, int end) throws SystemException {
958 return findByC_P(companyId, parentUserGroupId, start, end, null);
959 }
960
961
976 public List<UserGroup> findByC_P(long companyId, long parentUserGroupId,
977 int start, int end, OrderByComparator orderByComparator)
978 throws SystemException {
979 Object[] finderArgs = new Object[] {
980 companyId, parentUserGroupId,
981
982 String.valueOf(start), String.valueOf(end),
983 String.valueOf(orderByComparator)
984 };
985
986 List<UserGroup> list = (List<UserGroup>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_P,
987 finderArgs, this);
988
989 if (list == null) {
990 StringBundler query = null;
991
992 if (orderByComparator != null) {
993 query = new StringBundler(4 +
994 (orderByComparator.getOrderByFields().length * 3));
995 }
996 else {
997 query = new StringBundler(4);
998 }
999
1000 query.append(_SQL_SELECT_USERGROUP_WHERE);
1001
1002 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
1003
1004 query.append(_FINDER_COLUMN_C_P_PARENTUSERGROUPID_2);
1005
1006 if (orderByComparator != null) {
1007 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1008 orderByComparator);
1009 }
1010
1011 else {
1012 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
1013 }
1014
1015 String sql = query.toString();
1016
1017 Session session = null;
1018
1019 try {
1020 session = openSession();
1021
1022 Query q = session.createQuery(sql);
1023
1024 QueryPos qPos = QueryPos.getInstance(q);
1025
1026 qPos.add(companyId);
1027
1028 qPos.add(parentUserGroupId);
1029
1030 list = (List<UserGroup>)QueryUtil.list(q, getDialect(), start,
1031 end);
1032 }
1033 catch (Exception e) {
1034 throw processException(e);
1035 }
1036 finally {
1037 if (list == null) {
1038 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_C_P,
1039 finderArgs);
1040 }
1041 else {
1042 cacheResult(list);
1043
1044 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_P,
1045 finderArgs, list);
1046 }
1047
1048 closeSession(session);
1049 }
1050 }
1051
1052 return list;
1053 }
1054
1055
1069 public UserGroup findByC_P_First(long companyId, long parentUserGroupId,
1070 OrderByComparator orderByComparator)
1071 throws NoSuchUserGroupException, SystemException {
1072 List<UserGroup> list = findByC_P(companyId, parentUserGroupId, 0, 1,
1073 orderByComparator);
1074
1075 if (list.isEmpty()) {
1076 StringBundler msg = new StringBundler(6);
1077
1078 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1079
1080 msg.append("companyId=");
1081 msg.append(companyId);
1082
1083 msg.append(", parentUserGroupId=");
1084 msg.append(parentUserGroupId);
1085
1086 msg.append(StringPool.CLOSE_CURLY_BRACE);
1087
1088 throw new NoSuchUserGroupException(msg.toString());
1089 }
1090 else {
1091 return list.get(0);
1092 }
1093 }
1094
1095
1109 public UserGroup findByC_P_Last(long companyId, long parentUserGroupId,
1110 OrderByComparator orderByComparator)
1111 throws NoSuchUserGroupException, SystemException {
1112 int count = countByC_P(companyId, parentUserGroupId);
1113
1114 List<UserGroup> list = findByC_P(companyId, parentUserGroupId,
1115 count - 1, count, orderByComparator);
1116
1117 if (list.isEmpty()) {
1118 StringBundler msg = new StringBundler(6);
1119
1120 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1121
1122 msg.append("companyId=");
1123 msg.append(companyId);
1124
1125 msg.append(", parentUserGroupId=");
1126 msg.append(parentUserGroupId);
1127
1128 msg.append(StringPool.CLOSE_CURLY_BRACE);
1129
1130 throw new NoSuchUserGroupException(msg.toString());
1131 }
1132 else {
1133 return list.get(0);
1134 }
1135 }
1136
1137
1152 public UserGroup[] findByC_P_PrevAndNext(long userGroupId, long companyId,
1153 long parentUserGroupId, OrderByComparator orderByComparator)
1154 throws NoSuchUserGroupException, SystemException {
1155 UserGroup userGroup = findByPrimaryKey(userGroupId);
1156
1157 Session session = null;
1158
1159 try {
1160 session = openSession();
1161
1162 UserGroup[] array = new UserGroupImpl[3];
1163
1164 array[0] = getByC_P_PrevAndNext(session, userGroup, companyId,
1165 parentUserGroupId, orderByComparator, true);
1166
1167 array[1] = userGroup;
1168
1169 array[2] = getByC_P_PrevAndNext(session, userGroup, companyId,
1170 parentUserGroupId, orderByComparator, false);
1171
1172 return array;
1173 }
1174 catch (Exception e) {
1175 throw processException(e);
1176 }
1177 finally {
1178 closeSession(session);
1179 }
1180 }
1181
1182 protected UserGroup getByC_P_PrevAndNext(Session session,
1183 UserGroup userGroup, long companyId, long parentUserGroupId,
1184 OrderByComparator orderByComparator, boolean previous) {
1185 StringBundler query = null;
1186
1187 if (orderByComparator != null) {
1188 query = new StringBundler(6 +
1189 (orderByComparator.getOrderByFields().length * 6));
1190 }
1191 else {
1192 query = new StringBundler(3);
1193 }
1194
1195 query.append(_SQL_SELECT_USERGROUP_WHERE);
1196
1197 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
1198
1199 query.append(_FINDER_COLUMN_C_P_PARENTUSERGROUPID_2);
1200
1201 if (orderByComparator != null) {
1202 String[] orderByFields = orderByComparator.getOrderByFields();
1203
1204 if (orderByFields.length > 0) {
1205 query.append(WHERE_AND);
1206 }
1207
1208 for (int i = 0; i < orderByFields.length; i++) {
1209 query.append(_ORDER_BY_ENTITY_ALIAS);
1210 query.append(orderByFields[i]);
1211
1212 if ((i + 1) < orderByFields.length) {
1213 if (orderByComparator.isAscending() ^ previous) {
1214 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1215 }
1216 else {
1217 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1218 }
1219 }
1220 else {
1221 if (orderByComparator.isAscending() ^ previous) {
1222 query.append(WHERE_GREATER_THAN);
1223 }
1224 else {
1225 query.append(WHERE_LESSER_THAN);
1226 }
1227 }
1228 }
1229
1230 query.append(ORDER_BY_CLAUSE);
1231
1232 for (int i = 0; i < orderByFields.length; i++) {
1233 query.append(_ORDER_BY_ENTITY_ALIAS);
1234 query.append(orderByFields[i]);
1235
1236 if ((i + 1) < orderByFields.length) {
1237 if (orderByComparator.isAscending() ^ previous) {
1238 query.append(ORDER_BY_ASC_HAS_NEXT);
1239 }
1240 else {
1241 query.append(ORDER_BY_DESC_HAS_NEXT);
1242 }
1243 }
1244 else {
1245 if (orderByComparator.isAscending() ^ previous) {
1246 query.append(ORDER_BY_ASC);
1247 }
1248 else {
1249 query.append(ORDER_BY_DESC);
1250 }
1251 }
1252 }
1253 }
1254
1255 else {
1256 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
1257 }
1258
1259 String sql = query.toString();
1260
1261 Query q = session.createQuery(sql);
1262
1263 q.setFirstResult(0);
1264 q.setMaxResults(2);
1265
1266 QueryPos qPos = QueryPos.getInstance(q);
1267
1268 qPos.add(companyId);
1269
1270 qPos.add(parentUserGroupId);
1271
1272 if (orderByComparator != null) {
1273 Object[] values = orderByComparator.getOrderByValues(userGroup);
1274
1275 for (Object value : values) {
1276 qPos.add(value);
1277 }
1278 }
1279
1280 List<UserGroup> list = q.list();
1281
1282 if (list.size() == 2) {
1283 return list.get(1);
1284 }
1285 else {
1286 return null;
1287 }
1288 }
1289
1290
1298 public List<UserGroup> filterFindByC_P(long companyId,
1299 long parentUserGroupId) throws SystemException {
1300 return filterFindByC_P(companyId, parentUserGroupId, QueryUtil.ALL_POS,
1301 QueryUtil.ALL_POS, null);
1302 }
1303
1304
1318 public List<UserGroup> filterFindByC_P(long companyId,
1319 long parentUserGroupId, int start, int end) throws SystemException {
1320 return filterFindByC_P(companyId, parentUserGroupId, start, end, null);
1321 }
1322
1323
1338 public List<UserGroup> filterFindByC_P(long companyId,
1339 long parentUserGroupId, int start, int end,
1340 OrderByComparator orderByComparator) throws SystemException {
1341 if (!InlineSQLHelperUtil.isEnabled()) {
1342 return findByC_P(companyId, parentUserGroupId, start, end,
1343 orderByComparator);
1344 }
1345
1346 StringBundler query = null;
1347
1348 if (orderByComparator != null) {
1349 query = new StringBundler(4 +
1350 (orderByComparator.getOrderByFields().length * 3));
1351 }
1352 else {
1353 query = new StringBundler(4);
1354 }
1355
1356 if (getDB().isSupportsInlineDistinct()) {
1357 query.append(_FILTER_SQL_SELECT_USERGROUP_WHERE);
1358 }
1359 else {
1360 query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_1);
1361 }
1362
1363 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
1364
1365 query.append(_FINDER_COLUMN_C_P_PARENTUSERGROUPID_2);
1366
1367 if (!getDB().isSupportsInlineDistinct()) {
1368 query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_2);
1369 }
1370
1371 if (orderByComparator != null) {
1372 if (getDB().isSupportsInlineDistinct()) {
1373 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1374 orderByComparator);
1375 }
1376 else {
1377 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1378 orderByComparator);
1379 }
1380 }
1381
1382 else {
1383 if (getDB().isSupportsInlineDistinct()) {
1384 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
1385 }
1386 else {
1387 query.append(UserGroupModelImpl.ORDER_BY_SQL);
1388 }
1389 }
1390
1391 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1392 UserGroup.class.getName(), _FILTER_COLUMN_PK,
1393 _FILTER_COLUMN_USERID);
1394
1395 Session session = null;
1396
1397 try {
1398 session = openSession();
1399
1400 SQLQuery q = session.createSQLQuery(sql);
1401
1402 if (getDB().isSupportsInlineDistinct()) {
1403 q.addEntity(_FILTER_ENTITY_ALIAS, UserGroupImpl.class);
1404 }
1405 else {
1406 q.addEntity(_FILTER_ENTITY_TABLE, UserGroupImpl.class);
1407 }
1408
1409 QueryPos qPos = QueryPos.getInstance(q);
1410
1411 qPos.add(companyId);
1412
1413 qPos.add(parentUserGroupId);
1414
1415 return (List<UserGroup>)QueryUtil.list(q, getDialect(), start, end);
1416 }
1417 catch (Exception e) {
1418 throw processException(e);
1419 }
1420 finally {
1421 closeSession(session);
1422 }
1423 }
1424
1425
1434 public UserGroup findByC_N(long companyId, String name)
1435 throws NoSuchUserGroupException, SystemException {
1436 UserGroup userGroup = fetchByC_N(companyId, name);
1437
1438 if (userGroup == null) {
1439 StringBundler msg = new StringBundler(6);
1440
1441 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1442
1443 msg.append("companyId=");
1444 msg.append(companyId);
1445
1446 msg.append(", name=");
1447 msg.append(name);
1448
1449 msg.append(StringPool.CLOSE_CURLY_BRACE);
1450
1451 if (_log.isWarnEnabled()) {
1452 _log.warn(msg.toString());
1453 }
1454
1455 throw new NoSuchUserGroupException(msg.toString());
1456 }
1457
1458 return userGroup;
1459 }
1460
1461
1469 public UserGroup fetchByC_N(long companyId, String name)
1470 throws SystemException {
1471 return fetchByC_N(companyId, name, true);
1472 }
1473
1474
1482 public UserGroup fetchByC_N(long companyId, String name,
1483 boolean retrieveFromCache) throws SystemException {
1484 Object[] finderArgs = new Object[] { companyId, name };
1485
1486 Object result = null;
1487
1488 if (retrieveFromCache) {
1489 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_N,
1490 finderArgs, this);
1491 }
1492
1493 if (result == null) {
1494 StringBundler query = new StringBundler(4);
1495
1496 query.append(_SQL_SELECT_USERGROUP_WHERE);
1497
1498 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
1499
1500 if (name == null) {
1501 query.append(_FINDER_COLUMN_C_N_NAME_1);
1502 }
1503 else {
1504 if (name.equals(StringPool.BLANK)) {
1505 query.append(_FINDER_COLUMN_C_N_NAME_3);
1506 }
1507 else {
1508 query.append(_FINDER_COLUMN_C_N_NAME_2);
1509 }
1510 }
1511
1512 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
1513
1514 String sql = query.toString();
1515
1516 Session session = null;
1517
1518 try {
1519 session = openSession();
1520
1521 Query q = session.createQuery(sql);
1522
1523 QueryPos qPos = QueryPos.getInstance(q);
1524
1525 qPos.add(companyId);
1526
1527 if (name != null) {
1528 qPos.add(name);
1529 }
1530
1531 List<UserGroup> list = q.list();
1532
1533 result = list;
1534
1535 UserGroup userGroup = null;
1536
1537 if (list.isEmpty()) {
1538 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
1539 finderArgs, list);
1540 }
1541 else {
1542 userGroup = list.get(0);
1543
1544 cacheResult(userGroup);
1545
1546 if ((userGroup.getCompanyId() != companyId) ||
1547 (userGroup.getName() == null) ||
1548 !userGroup.getName().equals(name)) {
1549 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
1550 finderArgs, userGroup);
1551 }
1552 }
1553
1554 return userGroup;
1555 }
1556 catch (Exception e) {
1557 throw processException(e);
1558 }
1559 finally {
1560 if (result == null) {
1561 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
1562 finderArgs);
1563 }
1564
1565 closeSession(session);
1566 }
1567 }
1568 else {
1569 if (result instanceof List<?>) {
1570 return null;
1571 }
1572 else {
1573 return (UserGroup)result;
1574 }
1575 }
1576 }
1577
1578
1584 public List<UserGroup> findAll() throws SystemException {
1585 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1586 }
1587
1588
1600 public List<UserGroup> findAll(int start, int end)
1601 throws SystemException {
1602 return findAll(start, end, null);
1603 }
1604
1605
1618 public List<UserGroup> findAll(int start, int end,
1619 OrderByComparator orderByComparator) throws SystemException {
1620 Object[] finderArgs = new Object[] {
1621 String.valueOf(start), String.valueOf(end),
1622 String.valueOf(orderByComparator)
1623 };
1624
1625 List<UserGroup> list = (List<UserGroup>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1626 finderArgs, this);
1627
1628 if (list == null) {
1629 StringBundler query = null;
1630 String sql = null;
1631
1632 if (orderByComparator != null) {
1633 query = new StringBundler(2 +
1634 (orderByComparator.getOrderByFields().length * 3));
1635
1636 query.append(_SQL_SELECT_USERGROUP);
1637
1638 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1639 orderByComparator);
1640
1641 sql = query.toString();
1642 }
1643 else {
1644 sql = _SQL_SELECT_USERGROUP.concat(UserGroupModelImpl.ORDER_BY_JPQL);
1645 }
1646
1647 Session session = null;
1648
1649 try {
1650 session = openSession();
1651
1652 Query q = session.createQuery(sql);
1653
1654 if (orderByComparator == null) {
1655 list = (List<UserGroup>)QueryUtil.list(q, getDialect(),
1656 start, end, false);
1657
1658 Collections.sort(list);
1659 }
1660 else {
1661 list = (List<UserGroup>)QueryUtil.list(q, getDialect(),
1662 start, end);
1663 }
1664 }
1665 catch (Exception e) {
1666 throw processException(e);
1667 }
1668 finally {
1669 if (list == null) {
1670 FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL,
1671 finderArgs);
1672 }
1673 else {
1674 cacheResult(list);
1675
1676 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs,
1677 list);
1678 }
1679
1680 closeSession(session);
1681 }
1682 }
1683
1684 return list;
1685 }
1686
1687
1693 public void removeByCompanyId(long companyId) throws SystemException {
1694 for (UserGroup userGroup : findByCompanyId(companyId)) {
1695 remove(userGroup);
1696 }
1697 }
1698
1699
1706 public void removeByC_P(long companyId, long parentUserGroupId)
1707 throws SystemException {
1708 for (UserGroup userGroup : findByC_P(companyId, parentUserGroupId)) {
1709 remove(userGroup);
1710 }
1711 }
1712
1713
1720 public void removeByC_N(long companyId, String name)
1721 throws NoSuchUserGroupException, SystemException {
1722 UserGroup userGroup = findByC_N(companyId, name);
1723
1724 remove(userGroup);
1725 }
1726
1727
1732 public void removeAll() throws SystemException {
1733 for (UserGroup userGroup : findAll()) {
1734 remove(userGroup);
1735 }
1736 }
1737
1738
1745 public int countByCompanyId(long companyId) throws SystemException {
1746 Object[] finderArgs = new Object[] { companyId };
1747
1748 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1749 finderArgs, this);
1750
1751 if (count == null) {
1752 StringBundler query = new StringBundler(2);
1753
1754 query.append(_SQL_COUNT_USERGROUP_WHERE);
1755
1756 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1757
1758 String sql = query.toString();
1759
1760 Session session = null;
1761
1762 try {
1763 session = openSession();
1764
1765 Query q = session.createQuery(sql);
1766
1767 QueryPos qPos = QueryPos.getInstance(q);
1768
1769 qPos.add(companyId);
1770
1771 count = (Long)q.uniqueResult();
1772 }
1773 catch (Exception e) {
1774 throw processException(e);
1775 }
1776 finally {
1777 if (count == null) {
1778 count = Long.valueOf(0);
1779 }
1780
1781 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1782 finderArgs, count);
1783
1784 closeSession(session);
1785 }
1786 }
1787
1788 return count.intValue();
1789 }
1790
1791
1798 public int filterCountByCompanyId(long companyId) throws SystemException {
1799 if (!InlineSQLHelperUtil.isEnabled()) {
1800 return countByCompanyId(companyId);
1801 }
1802
1803 StringBundler query = new StringBundler(2);
1804
1805 query.append(_FILTER_SQL_COUNT_USERGROUP_WHERE);
1806
1807 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1808
1809 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1810 UserGroup.class.getName(), _FILTER_COLUMN_PK,
1811 _FILTER_COLUMN_USERID);
1812
1813 Session session = null;
1814
1815 try {
1816 session = openSession();
1817
1818 SQLQuery q = session.createSQLQuery(sql);
1819
1820 q.addScalar(COUNT_COLUMN_NAME,
1821 com.liferay.portal.kernel.dao.orm.Type.LONG);
1822
1823 QueryPos qPos = QueryPos.getInstance(q);
1824
1825 qPos.add(companyId);
1826
1827 Long count = (Long)q.uniqueResult();
1828
1829 return count.intValue();
1830 }
1831 catch (Exception e) {
1832 throw processException(e);
1833 }
1834 finally {
1835 closeSession(session);
1836 }
1837 }
1838
1839
1847 public int countByC_P(long companyId, long parentUserGroupId)
1848 throws SystemException {
1849 Object[] finderArgs = new Object[] { companyId, parentUserGroupId };
1850
1851 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_P,
1852 finderArgs, this);
1853
1854 if (count == null) {
1855 StringBundler query = new StringBundler(3);
1856
1857 query.append(_SQL_COUNT_USERGROUP_WHERE);
1858
1859 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
1860
1861 query.append(_FINDER_COLUMN_C_P_PARENTUSERGROUPID_2);
1862
1863 String sql = query.toString();
1864
1865 Session session = null;
1866
1867 try {
1868 session = openSession();
1869
1870 Query q = session.createQuery(sql);
1871
1872 QueryPos qPos = QueryPos.getInstance(q);
1873
1874 qPos.add(companyId);
1875
1876 qPos.add(parentUserGroupId);
1877
1878 count = (Long)q.uniqueResult();
1879 }
1880 catch (Exception e) {
1881 throw processException(e);
1882 }
1883 finally {
1884 if (count == null) {
1885 count = Long.valueOf(0);
1886 }
1887
1888 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_P, finderArgs,
1889 count);
1890
1891 closeSession(session);
1892 }
1893 }
1894
1895 return count.intValue();
1896 }
1897
1898
1906 public int filterCountByC_P(long companyId, long parentUserGroupId)
1907 throws SystemException {
1908 if (!InlineSQLHelperUtil.isEnabled()) {
1909 return countByC_P(companyId, parentUserGroupId);
1910 }
1911
1912 StringBundler query = new StringBundler(3);
1913
1914 query.append(_FILTER_SQL_COUNT_USERGROUP_WHERE);
1915
1916 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
1917
1918 query.append(_FINDER_COLUMN_C_P_PARENTUSERGROUPID_2);
1919
1920 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1921 UserGroup.class.getName(), _FILTER_COLUMN_PK,
1922 _FILTER_COLUMN_USERID);
1923
1924 Session session = null;
1925
1926 try {
1927 session = openSession();
1928
1929 SQLQuery q = session.createSQLQuery(sql);
1930
1931 q.addScalar(COUNT_COLUMN_NAME,
1932 com.liferay.portal.kernel.dao.orm.Type.LONG);
1933
1934 QueryPos qPos = QueryPos.getInstance(q);
1935
1936 qPos.add(companyId);
1937
1938 qPos.add(parentUserGroupId);
1939
1940 Long count = (Long)q.uniqueResult();
1941
1942 return count.intValue();
1943 }
1944 catch (Exception e) {
1945 throw processException(e);
1946 }
1947 finally {
1948 closeSession(session);
1949 }
1950 }
1951
1952
1960 public int countByC_N(long companyId, String name)
1961 throws SystemException {
1962 Object[] finderArgs = new Object[] { companyId, name };
1963
1964 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_N,
1965 finderArgs, this);
1966
1967 if (count == null) {
1968 StringBundler query = new StringBundler(3);
1969
1970 query.append(_SQL_COUNT_USERGROUP_WHERE);
1971
1972 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
1973
1974 if (name == null) {
1975 query.append(_FINDER_COLUMN_C_N_NAME_1);
1976 }
1977 else {
1978 if (name.equals(StringPool.BLANK)) {
1979 query.append(_FINDER_COLUMN_C_N_NAME_3);
1980 }
1981 else {
1982 query.append(_FINDER_COLUMN_C_N_NAME_2);
1983 }
1984 }
1985
1986 String sql = query.toString();
1987
1988 Session session = null;
1989
1990 try {
1991 session = openSession();
1992
1993 Query q = session.createQuery(sql);
1994
1995 QueryPos qPos = QueryPos.getInstance(q);
1996
1997 qPos.add(companyId);
1998
1999 if (name != null) {
2000 qPos.add(name);
2001 }
2002
2003 count = (Long)q.uniqueResult();
2004 }
2005 catch (Exception e) {
2006 throw processException(e);
2007 }
2008 finally {
2009 if (count == null) {
2010 count = Long.valueOf(0);
2011 }
2012
2013 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, finderArgs,
2014 count);
2015
2016 closeSession(session);
2017 }
2018 }
2019
2020 return count.intValue();
2021 }
2022
2023
2029 public int countAll() throws SystemException {
2030 Object[] finderArgs = new Object[0];
2031
2032 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2033 finderArgs, this);
2034
2035 if (count == null) {
2036 Session session = null;
2037
2038 try {
2039 session = openSession();
2040
2041 Query q = session.createQuery(_SQL_COUNT_USERGROUP);
2042
2043 count = (Long)q.uniqueResult();
2044 }
2045 catch (Exception e) {
2046 throw processException(e);
2047 }
2048 finally {
2049 if (count == null) {
2050 count = Long.valueOf(0);
2051 }
2052
2053 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
2054 count);
2055
2056 closeSession(session);
2057 }
2058 }
2059
2060 return count.intValue();
2061 }
2062
2063
2070 public List<com.liferay.portal.model.Group> getGroups(long pk)
2071 throws SystemException {
2072 return getGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2073 }
2074
2075
2088 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
2089 int end) throws SystemException {
2090 return getGroups(pk, start, end, null);
2091 }
2092
2093 public static final FinderPath FINDER_PATH_GET_GROUPS = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
2094 UserGroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS,
2095 UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
2096 "getGroups",
2097 new String[] {
2098 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2099 "com.liferay.portal.kernel.util.OrderByComparator"
2100 });
2101
2102
2116 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
2117 int end, OrderByComparator orderByComparator) throws SystemException {
2118 Object[] finderArgs = new Object[] {
2119 pk, String.valueOf(start), String.valueOf(end),
2120 String.valueOf(orderByComparator)
2121 };
2122
2123 List<com.liferay.portal.model.Group> list = (List<com.liferay.portal.model.Group>)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS,
2124 finderArgs, this);
2125
2126 if (list == null) {
2127 Session session = null;
2128
2129 try {
2130 session = openSession();
2131
2132 String sql = null;
2133
2134 if (orderByComparator != null) {
2135 sql = _SQL_GETGROUPS.concat(ORDER_BY_CLAUSE)
2136 .concat(orderByComparator.getOrderBy());
2137 }
2138 else {
2139 sql = _SQL_GETGROUPS.concat(com.liferay.portal.model.impl.GroupModelImpl.ORDER_BY_SQL);
2140 }
2141
2142 SQLQuery q = session.createSQLQuery(sql);
2143
2144 q.addEntity("Group_",
2145 com.liferay.portal.model.impl.GroupImpl.class);
2146
2147 QueryPos qPos = QueryPos.getInstance(q);
2148
2149 qPos.add(pk);
2150
2151 list = (List<com.liferay.portal.model.Group>)QueryUtil.list(q,
2152 getDialect(), start, end);
2153 }
2154 catch (Exception e) {
2155 throw processException(e);
2156 }
2157 finally {
2158 if (list == null) {
2159 FinderCacheUtil.removeResult(FINDER_PATH_GET_GROUPS,
2160 finderArgs);
2161 }
2162 else {
2163 groupPersistence.cacheResult(list);
2164
2165 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS,
2166 finderArgs, list);
2167 }
2168
2169 closeSession(session);
2170 }
2171 }
2172
2173 return list;
2174 }
2175
2176 public static final FinderPath FINDER_PATH_GET_GROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
2177 UserGroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS,
2178 UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
2179 "getGroupsSize", new String[] { Long.class.getName() });
2180
2181
2188 public int getGroupsSize(long pk) throws SystemException {
2189 Object[] finderArgs = new Object[] { pk };
2190
2191 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS_SIZE,
2192 finderArgs, this);
2193
2194 if (count == null) {
2195 Session session = null;
2196
2197 try {
2198 session = openSession();
2199
2200 SQLQuery q = session.createSQLQuery(_SQL_GETGROUPSSIZE);
2201
2202 q.addScalar(COUNT_COLUMN_NAME,
2203 com.liferay.portal.kernel.dao.orm.Type.LONG);
2204
2205 QueryPos qPos = QueryPos.getInstance(q);
2206
2207 qPos.add(pk);
2208
2209 count = (Long)q.uniqueResult();
2210 }
2211 catch (Exception e) {
2212 throw processException(e);
2213 }
2214 finally {
2215 if (count == null) {
2216 count = Long.valueOf(0);
2217 }
2218
2219 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS_SIZE,
2220 finderArgs, count);
2221
2222 closeSession(session);
2223 }
2224 }
2225
2226 return count.intValue();
2227 }
2228
2229 public static final FinderPath FINDER_PATH_CONTAINS_GROUP = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
2230 UserGroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS,
2231 UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
2232 "containsGroup",
2233 new String[] { Long.class.getName(), Long.class.getName() });
2234
2235
2243 public boolean containsGroup(long pk, long groupPK)
2244 throws SystemException {
2245 Object[] finderArgs = new Object[] { pk, groupPK };
2246
2247 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_GROUP,
2248 finderArgs, this);
2249
2250 if (value == null) {
2251 try {
2252 value = Boolean.valueOf(containsGroup.contains(pk, groupPK));
2253 }
2254 catch (Exception e) {
2255 throw processException(e);
2256 }
2257 finally {
2258 if (value == null) {
2259 value = Boolean.FALSE;
2260 }
2261
2262 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_GROUP,
2263 finderArgs, value);
2264 }
2265 }
2266
2267 return value.booleanValue();
2268 }
2269
2270
2277 public boolean containsGroups(long pk) throws SystemException {
2278 if (getGroupsSize(pk) > 0) {
2279 return true;
2280 }
2281 else {
2282 return false;
2283 }
2284 }
2285
2286
2293 public void addGroup(long pk, long groupPK) throws SystemException {
2294 try {
2295 addGroup.add(pk, groupPK);
2296 }
2297 catch (Exception e) {
2298 throw processException(e);
2299 }
2300 finally {
2301 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2302 }
2303 }
2304
2305
2312 public void addGroup(long pk, com.liferay.portal.model.Group group)
2313 throws SystemException {
2314 try {
2315 addGroup.add(pk, group.getPrimaryKey());
2316 }
2317 catch (Exception e) {
2318 throw processException(e);
2319 }
2320 finally {
2321 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2322 }
2323 }
2324
2325
2332 public void addGroups(long pk, long[] groupPKs) throws SystemException {
2333 try {
2334 for (long groupPK : groupPKs) {
2335 addGroup.add(pk, groupPK);
2336 }
2337 }
2338 catch (Exception e) {
2339 throw processException(e);
2340 }
2341 finally {
2342 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2343 }
2344 }
2345
2346
2353 public void addGroups(long pk, List<com.liferay.portal.model.Group> groups)
2354 throws SystemException {
2355 try {
2356 for (com.liferay.portal.model.Group group : groups) {
2357 addGroup.add(pk, group.getPrimaryKey());
2358 }
2359 }
2360 catch (Exception e) {
2361 throw processException(e);
2362 }
2363 finally {
2364 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2365 }
2366 }
2367
2368
2374 public void clearGroups(long pk) throws SystemException {
2375 try {
2376 clearGroups.clear(pk);
2377 }
2378 catch (Exception e) {
2379 throw processException(e);
2380 }
2381 finally {
2382 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2383 }
2384 }
2385
2386
2393 public void removeGroup(long pk, long groupPK) throws SystemException {
2394 try {
2395 removeGroup.remove(pk, groupPK);
2396 }
2397 catch (Exception e) {
2398 throw processException(e);
2399 }
2400 finally {
2401 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2402 }
2403 }
2404
2405
2412 public void removeGroup(long pk, com.liferay.portal.model.Group group)
2413 throws SystemException {
2414 try {
2415 removeGroup.remove(pk, group.getPrimaryKey());
2416 }
2417 catch (Exception e) {
2418 throw processException(e);
2419 }
2420 finally {
2421 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2422 }
2423 }
2424
2425
2432 public void removeGroups(long pk, long[] groupPKs)
2433 throws SystemException {
2434 try {
2435 for (long groupPK : groupPKs) {
2436 removeGroup.remove(pk, groupPK);
2437 }
2438 }
2439 catch (Exception e) {
2440 throw processException(e);
2441 }
2442 finally {
2443 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2444 }
2445 }
2446
2447
2454 public void removeGroups(long pk,
2455 List<com.liferay.portal.model.Group> groups) throws SystemException {
2456 try {
2457 for (com.liferay.portal.model.Group group : groups) {
2458 removeGroup.remove(pk, group.getPrimaryKey());
2459 }
2460 }
2461 catch (Exception e) {
2462 throw processException(e);
2463 }
2464 finally {
2465 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2466 }
2467 }
2468
2469
2476 public void setGroups(long pk, long[] groupPKs) throws SystemException {
2477 try {
2478 Set<Long> groupPKSet = SetUtil.fromArray(groupPKs);
2479
2480 List<com.liferay.portal.model.Group> groups = getGroups(pk);
2481
2482 for (com.liferay.portal.model.Group group : groups) {
2483 if (!groupPKSet.remove(group.getPrimaryKey())) {
2484 removeGroup.remove(pk, group.getPrimaryKey());
2485 }
2486 }
2487
2488 for (Long groupPK : groupPKSet) {
2489 addGroup.add(pk, groupPK);
2490 }
2491 }
2492 catch (Exception e) {
2493 throw processException(e);
2494 }
2495 finally {
2496 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2497 }
2498 }
2499
2500
2507 public void setGroups(long pk, List<com.liferay.portal.model.Group> groups)
2508 throws SystemException {
2509 try {
2510 long[] groupPKs = new long[groups.size()];
2511
2512 for (int i = 0; i < groups.size(); i++) {
2513 com.liferay.portal.model.Group group = groups.get(i);
2514
2515 groupPKs[i] = group.getPrimaryKey();
2516 }
2517
2518 setGroups(pk, groupPKs);
2519 }
2520 catch (Exception e) {
2521 throw processException(e);
2522 }
2523 finally {
2524 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2525 }
2526 }
2527
2528
2535 public List<com.liferay.portal.model.User> getUsers(long pk)
2536 throws SystemException {
2537 return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2538 }
2539
2540
2553 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
2554 int end) throws SystemException {
2555 return getUsers(pk, start, end, null);
2556 }
2557
2558 public static final FinderPath FINDER_PATH_GET_USERS = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
2559 UserGroupModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS,
2560 UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME, "getUsers",
2561 new String[] {
2562 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2563 "com.liferay.portal.kernel.util.OrderByComparator"
2564 });
2565
2566
2580 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
2581 int end, OrderByComparator orderByComparator) throws SystemException {
2582 Object[] finderArgs = new Object[] {
2583 pk, String.valueOf(start), String.valueOf(end),
2584 String.valueOf(orderByComparator)
2585 };
2586
2587 List<com.liferay.portal.model.User> list = (List<com.liferay.portal.model.User>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS,
2588 finderArgs, this);
2589
2590 if (list == null) {
2591 Session session = null;
2592
2593 try {
2594 session = openSession();
2595
2596 String sql = null;
2597
2598 if (orderByComparator != null) {
2599 sql = _SQL_GETUSERS.concat(ORDER_BY_CLAUSE)
2600 .concat(orderByComparator.getOrderBy());
2601 }
2602 else {
2603 sql = _SQL_GETUSERS;
2604 }
2605
2606 SQLQuery q = session.createSQLQuery(sql);
2607
2608 q.addEntity("User_",
2609 com.liferay.portal.model.impl.UserImpl.class);
2610
2611 QueryPos qPos = QueryPos.getInstance(q);
2612
2613 qPos.add(pk);
2614
2615 list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
2616 getDialect(), start, end);
2617 }
2618 catch (Exception e) {
2619 throw processException(e);
2620 }
2621 finally {
2622 if (list == null) {
2623 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERS,
2624 finderArgs);
2625 }
2626 else {
2627 userPersistence.cacheResult(list);
2628
2629 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS,
2630 finderArgs, list);
2631 }
2632
2633 closeSession(session);
2634 }
2635 }
2636
2637 return list;
2638 }
2639
2640 public static final FinderPath FINDER_PATH_GET_USERS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
2641 UserGroupModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS,
2642 UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME,
2643 "getUsersSize", new String[] { Long.class.getName() });
2644
2645
2652 public int getUsersSize(long pk) throws SystemException {
2653 Object[] finderArgs = new Object[] { pk };
2654
2655 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS_SIZE,
2656 finderArgs, this);
2657
2658 if (count == null) {
2659 Session session = null;
2660
2661 try {
2662 session = openSession();
2663
2664 SQLQuery q = session.createSQLQuery(_SQL_GETUSERSSIZE);
2665
2666 q.addScalar(COUNT_COLUMN_NAME,
2667 com.liferay.portal.kernel.dao.orm.Type.LONG);
2668
2669 QueryPos qPos = QueryPos.getInstance(q);
2670
2671 qPos.add(pk);
2672
2673 count = (Long)q.uniqueResult();
2674 }
2675 catch (Exception e) {
2676 throw processException(e);
2677 }
2678 finally {
2679 if (count == null) {
2680 count = Long.valueOf(0);
2681 }
2682
2683 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS_SIZE,
2684 finderArgs, count);
2685
2686 closeSession(session);
2687 }
2688 }
2689
2690 return count.intValue();
2691 }
2692
2693 public static final FinderPath FINDER_PATH_CONTAINS_USER = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
2694 UserGroupModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS,
2695 UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME,
2696 "containsUser",
2697 new String[] { Long.class.getName(), Long.class.getName() });
2698
2699
2707 public boolean containsUser(long pk, long userPK) throws SystemException {
2708 Object[] finderArgs = new Object[] { pk, userPK };
2709
2710 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USER,
2711 finderArgs, this);
2712
2713 if (value == null) {
2714 try {
2715 value = Boolean.valueOf(containsUser.contains(pk, userPK));
2716 }
2717 catch (Exception e) {
2718 throw processException(e);
2719 }
2720 finally {
2721 if (value == null) {
2722 value = Boolean.FALSE;
2723 }
2724
2725 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USER,
2726 finderArgs, value);
2727 }
2728 }
2729
2730 return value.booleanValue();
2731 }
2732
2733
2740 public boolean containsUsers(long pk) throws SystemException {
2741 if (getUsersSize(pk) > 0) {
2742 return true;
2743 }
2744 else {
2745 return false;
2746 }
2747 }
2748
2749
2756 public void addUser(long pk, long userPK) throws SystemException {
2757 try {
2758 addUser.add(pk, userPK);
2759 }
2760 catch (Exception e) {
2761 throw processException(e);
2762 }
2763 finally {
2764 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
2765 }
2766 }
2767
2768
2775 public void addUser(long pk, com.liferay.portal.model.User user)
2776 throws SystemException {
2777 try {
2778 addUser.add(pk, user.getPrimaryKey());
2779 }
2780 catch (Exception e) {
2781 throw processException(e);
2782 }
2783 finally {
2784 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
2785 }
2786 }
2787
2788
2795 public void addUsers(long pk, long[] userPKs) throws SystemException {
2796 try {
2797 for (long userPK : userPKs) {
2798 addUser.add(pk, userPK);
2799 }
2800 }
2801 catch (Exception e) {
2802 throw processException(e);
2803 }
2804 finally {
2805 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
2806 }
2807 }
2808
2809
2816 public void addUsers(long pk, List<com.liferay.portal.model.User> users)
2817 throws SystemException {
2818 try {
2819 for (com.liferay.portal.model.User user : users) {
2820 addUser.add(pk, user.getPrimaryKey());
2821 }
2822 }
2823 catch (Exception e) {
2824 throw processException(e);
2825 }
2826 finally {
2827 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
2828 }
2829 }
2830
2831
2837 public void clearUsers(long pk) throws SystemException {
2838 try {
2839 clearUsers.clear(pk);
2840 }
2841 catch (Exception e) {
2842 throw processException(e);
2843 }
2844 finally {
2845 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
2846 }
2847 }
2848
2849
2856 public void removeUser(long pk, long userPK) throws SystemException {
2857 try {
2858 removeUser.remove(pk, userPK);
2859 }
2860 catch (Exception e) {
2861 throw processException(e);
2862 }
2863 finally {
2864 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
2865 }
2866 }
2867
2868
2875 public void removeUser(long pk, com.liferay.portal.model.User user)
2876 throws SystemException {
2877 try {
2878 removeUser.remove(pk, user.getPrimaryKey());
2879 }
2880 catch (Exception e) {
2881 throw processException(e);
2882 }
2883 finally {
2884 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
2885 }
2886 }
2887
2888
2895 public void removeUsers(long pk, long[] userPKs) throws SystemException {
2896 try {
2897 for (long userPK : userPKs) {
2898 removeUser.remove(pk, userPK);
2899 }
2900 }
2901 catch (Exception e) {
2902 throw processException(e);
2903 }
2904 finally {
2905 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
2906 }
2907 }
2908
2909
2916 public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
2917 throws SystemException {
2918 try {
2919 for (com.liferay.portal.model.User user : users) {
2920 removeUser.remove(pk, user.getPrimaryKey());
2921 }
2922 }
2923 catch (Exception e) {
2924 throw processException(e);
2925 }
2926 finally {
2927 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
2928 }
2929 }
2930
2931
2938 public void setUsers(long pk, long[] userPKs) throws SystemException {
2939 try {
2940 Set<Long> userPKSet = SetUtil.fromArray(userPKs);
2941
2942 List<com.liferay.portal.model.User> users = getUsers(pk);
2943
2944 for (com.liferay.portal.model.User user : users) {
2945 if (!userPKSet.remove(user.getPrimaryKey())) {
2946 removeUser.remove(pk, user.getPrimaryKey());
2947 }
2948 }
2949
2950 for (Long userPK : userPKSet) {
2951 addUser.add(pk, userPK);
2952 }
2953 }
2954 catch (Exception e) {
2955 throw processException(e);
2956 }
2957 finally {
2958 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
2959 }
2960 }
2961
2962
2969 public void setUsers(long pk, List<com.liferay.portal.model.User> users)
2970 throws SystemException {
2971 try {
2972 long[] userPKs = new long[users.size()];
2973
2974 for (int i = 0; i < users.size(); i++) {
2975 com.liferay.portal.model.User user = users.get(i);
2976
2977 userPKs[i] = user.getPrimaryKey();
2978 }
2979
2980 setUsers(pk, userPKs);
2981 }
2982 catch (Exception e) {
2983 throw processException(e);
2984 }
2985 finally {
2986 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
2987 }
2988 }
2989
2990
2993 public void afterPropertiesSet() {
2994 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2995 com.liferay.portal.util.PropsUtil.get(
2996 "value.object.listener.com.liferay.portal.model.UserGroup")));
2997
2998 if (listenerClassNames.length > 0) {
2999 try {
3000 List<ModelListener<UserGroup>> listenersList = new ArrayList<ModelListener<UserGroup>>();
3001
3002 for (String listenerClassName : listenerClassNames) {
3003 listenersList.add((ModelListener<UserGroup>)InstanceFactory.newInstance(
3004 listenerClassName));
3005 }
3006
3007 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3008 }
3009 catch (Exception e) {
3010 _log.error(e);
3011 }
3012 }
3013
3014 containsGroup = new ContainsGroup(this);
3015
3016 addGroup = new AddGroup(this);
3017 clearGroups = new ClearGroups(this);
3018 removeGroup = new RemoveGroup(this);
3019
3020 containsUser = new ContainsUser(this);
3021
3022 addUser = new AddUser(this);
3023 clearUsers = new ClearUsers(this);
3024 removeUser = new RemoveUser(this);
3025 }
3026
3027 public void destroy() {
3028 EntityCacheUtil.removeCache(UserGroupImpl.class.getName());
3029 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3030 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
3031 }
3032
3033 @BeanReference(type = AccountPersistence.class)
3034 protected AccountPersistence accountPersistence;
3035 @BeanReference(type = AddressPersistence.class)
3036 protected AddressPersistence addressPersistence;
3037 @BeanReference(type = BrowserTrackerPersistence.class)
3038 protected BrowserTrackerPersistence browserTrackerPersistence;
3039 @BeanReference(type = ClassNamePersistence.class)
3040 protected ClassNamePersistence classNamePersistence;
3041 @BeanReference(type = ClusterGroupPersistence.class)
3042 protected ClusterGroupPersistence clusterGroupPersistence;
3043 @BeanReference(type = CompanyPersistence.class)
3044 protected CompanyPersistence companyPersistence;
3045 @BeanReference(type = ContactPersistence.class)
3046 protected ContactPersistence contactPersistence;
3047 @BeanReference(type = CountryPersistence.class)
3048 protected CountryPersistence countryPersistence;
3049 @BeanReference(type = EmailAddressPersistence.class)
3050 protected EmailAddressPersistence emailAddressPersistence;
3051 @BeanReference(type = GroupPersistence.class)
3052 protected GroupPersistence groupPersistence;
3053 @BeanReference(type = ImagePersistence.class)
3054 protected ImagePersistence imagePersistence;
3055 @BeanReference(type = LayoutPersistence.class)
3056 protected LayoutPersistence layoutPersistence;
3057 @BeanReference(type = LayoutPrototypePersistence.class)
3058 protected LayoutPrototypePersistence layoutPrototypePersistence;
3059 @BeanReference(type = LayoutSetPersistence.class)
3060 protected LayoutSetPersistence layoutSetPersistence;
3061 @BeanReference(type = LayoutSetPrototypePersistence.class)
3062 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
3063 @BeanReference(type = ListTypePersistence.class)
3064 protected ListTypePersistence listTypePersistence;
3065 @BeanReference(type = LockPersistence.class)
3066 protected LockPersistence lockPersistence;
3067 @BeanReference(type = MembershipRequestPersistence.class)
3068 protected MembershipRequestPersistence membershipRequestPersistence;
3069 @BeanReference(type = OrganizationPersistence.class)
3070 protected OrganizationPersistence organizationPersistence;
3071 @BeanReference(type = OrgGroupPermissionPersistence.class)
3072 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
3073 @BeanReference(type = OrgGroupRolePersistence.class)
3074 protected OrgGroupRolePersistence orgGroupRolePersistence;
3075 @BeanReference(type = OrgLaborPersistence.class)
3076 protected OrgLaborPersistence orgLaborPersistence;
3077 @BeanReference(type = PasswordPolicyPersistence.class)
3078 protected PasswordPolicyPersistence passwordPolicyPersistence;
3079 @BeanReference(type = PasswordPolicyRelPersistence.class)
3080 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
3081 @BeanReference(type = PasswordTrackerPersistence.class)
3082 protected PasswordTrackerPersistence passwordTrackerPersistence;
3083 @BeanReference(type = PermissionPersistence.class)
3084 protected PermissionPersistence permissionPersistence;
3085 @BeanReference(type = PhonePersistence.class)
3086 protected PhonePersistence phonePersistence;
3087 @BeanReference(type = PluginSettingPersistence.class)
3088 protected PluginSettingPersistence pluginSettingPersistence;
3089 @BeanReference(type = PortletPersistence.class)
3090 protected PortletPersistence portletPersistence;
3091 @BeanReference(type = PortletItemPersistence.class)
3092 protected PortletItemPersistence portletItemPersistence;
3093 @BeanReference(type = PortletPreferencesPersistence.class)
3094 protected PortletPreferencesPersistence portletPreferencesPersistence;
3095 @BeanReference(type = RegionPersistence.class)
3096 protected RegionPersistence regionPersistence;
3097 @BeanReference(type = ReleasePersistence.class)
3098 protected ReleasePersistence releasePersistence;
3099 @BeanReference(type = ResourcePersistence.class)
3100 protected ResourcePersistence resourcePersistence;
3101 @BeanReference(type = ResourceActionPersistence.class)
3102 protected ResourceActionPersistence resourceActionPersistence;
3103 @BeanReference(type = ResourceCodePersistence.class)
3104 protected ResourceCodePersistence resourceCodePersistence;
3105 @BeanReference(type = ResourcePermissionPersistence.class)
3106 protected ResourcePermissionPersistence resourcePermissionPersistence;
3107 @BeanReference(type = RolePersistence.class)
3108 protected RolePersistence rolePersistence;
3109 @BeanReference(type = ServiceComponentPersistence.class)
3110 protected ServiceComponentPersistence serviceComponentPersistence;
3111 @BeanReference(type = ShardPersistence.class)
3112 protected ShardPersistence shardPersistence;
3113 @BeanReference(type = SubscriptionPersistence.class)
3114 protected SubscriptionPersistence subscriptionPersistence;
3115 @BeanReference(type = TicketPersistence.class)
3116 protected TicketPersistence ticketPersistence;
3117 @BeanReference(type = TeamPersistence.class)
3118 protected TeamPersistence teamPersistence;
3119 @BeanReference(type = UserPersistence.class)
3120 protected UserPersistence userPersistence;
3121 @BeanReference(type = UserGroupPersistence.class)
3122 protected UserGroupPersistence userGroupPersistence;
3123 @BeanReference(type = UserGroupGroupRolePersistence.class)
3124 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
3125 @BeanReference(type = UserGroupRolePersistence.class)
3126 protected UserGroupRolePersistence userGroupRolePersistence;
3127 @BeanReference(type = UserIdMapperPersistence.class)
3128 protected UserIdMapperPersistence userIdMapperPersistence;
3129 @BeanReference(type = UserTrackerPersistence.class)
3130 protected UserTrackerPersistence userTrackerPersistence;
3131 @BeanReference(type = UserTrackerPathPersistence.class)
3132 protected UserTrackerPathPersistence userTrackerPathPersistence;
3133 @BeanReference(type = WebDAVPropsPersistence.class)
3134 protected WebDAVPropsPersistence webDAVPropsPersistence;
3135 @BeanReference(type = WebsitePersistence.class)
3136 protected WebsitePersistence websitePersistence;
3137 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
3138 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
3139 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
3140 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
3141 protected ContainsGroup containsGroup;
3142 protected AddGroup addGroup;
3143 protected ClearGroups clearGroups;
3144 protected RemoveGroup removeGroup;
3145 protected ContainsUser containsUser;
3146 protected AddUser addUser;
3147 protected ClearUsers clearUsers;
3148 protected RemoveUser removeUser;
3149
3150 protected class ContainsGroup {
3151 protected ContainsGroup(UserGroupPersistenceImpl persistenceImpl) {
3152 super();
3153
3154 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
3155 _SQL_CONTAINSGROUP,
3156 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
3157 RowMapper.COUNT);
3158 }
3159
3160 protected boolean contains(long userGroupId, long groupId) {
3161 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
3162 new Long(userGroupId), new Long(groupId)
3163 });
3164
3165 if (results.size() > 0) {
3166 Integer count = results.get(0);
3167
3168 if (count.intValue() > 0) {
3169 return true;
3170 }
3171 }
3172
3173 return false;
3174 }
3175
3176 private MappingSqlQuery<Integer> _mappingSqlQuery;
3177 }
3178
3179 protected class AddGroup {
3180 protected AddGroup(UserGroupPersistenceImpl persistenceImpl) {
3181 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3182 "INSERT INTO Groups_UserGroups (userGroupId, groupId) VALUES (?, ?)",
3183 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3184 _persistenceImpl = persistenceImpl;
3185 }
3186
3187 protected void add(long userGroupId, long groupId)
3188 throws SystemException {
3189 if (!_persistenceImpl.containsGroup.contains(userGroupId, groupId)) {
3190 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
3191
3192 for (ModelListener<UserGroup> listener : listeners) {
3193 listener.onBeforeAddAssociation(userGroupId,
3194 com.liferay.portal.model.Group.class.getName(), groupId);
3195 }
3196
3197 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
3198 listener.onBeforeAddAssociation(groupId,
3199 UserGroup.class.getName(), userGroupId);
3200 }
3201
3202 _sqlUpdate.update(new Object[] {
3203 new Long(userGroupId), new Long(groupId)
3204 });
3205
3206 for (ModelListener<UserGroup> listener : listeners) {
3207 listener.onAfterAddAssociation(userGroupId,
3208 com.liferay.portal.model.Group.class.getName(), groupId);
3209 }
3210
3211 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
3212 listener.onAfterAddAssociation(groupId,
3213 UserGroup.class.getName(), userGroupId);
3214 }
3215 }
3216 }
3217
3218 private SqlUpdate _sqlUpdate;
3219 private UserGroupPersistenceImpl _persistenceImpl;
3220 }
3221
3222 protected class ClearGroups {
3223 protected ClearGroups(UserGroupPersistenceImpl persistenceImpl) {
3224 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3225 "DELETE FROM Groups_UserGroups WHERE userGroupId = ?",
3226 new int[] { java.sql.Types.BIGINT });
3227 }
3228
3229 protected void clear(long userGroupId) throws SystemException {
3230 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
3231
3232 List<com.liferay.portal.model.Group> groups = null;
3233
3234 if ((listeners.length > 0) || (groupListeners.length > 0)) {
3235 groups = getGroups(userGroupId);
3236
3237 for (com.liferay.portal.model.Group group : groups) {
3238 for (ModelListener<UserGroup> listener : listeners) {
3239 listener.onBeforeRemoveAssociation(userGroupId,
3240 com.liferay.portal.model.Group.class.getName(),
3241 group.getPrimaryKey());
3242 }
3243
3244 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
3245 listener.onBeforeRemoveAssociation(group.getPrimaryKey(),
3246 UserGroup.class.getName(), userGroupId);
3247 }
3248 }
3249 }
3250
3251 _sqlUpdate.update(new Object[] { new Long(userGroupId) });
3252
3253 if ((listeners.length > 0) || (groupListeners.length > 0)) {
3254 for (com.liferay.portal.model.Group group : groups) {
3255 for (ModelListener<UserGroup> listener : listeners) {
3256 listener.onAfterRemoveAssociation(userGroupId,
3257 com.liferay.portal.model.Group.class.getName(),
3258 group.getPrimaryKey());
3259 }
3260
3261 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
3262 listener.onAfterRemoveAssociation(group.getPrimaryKey(),
3263 UserGroup.class.getName(), userGroupId);
3264 }
3265 }
3266 }
3267 }
3268
3269 private SqlUpdate _sqlUpdate;
3270 }
3271
3272 protected class RemoveGroup {
3273 protected RemoveGroup(UserGroupPersistenceImpl persistenceImpl) {
3274 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3275 "DELETE FROM Groups_UserGroups WHERE userGroupId = ? AND groupId = ?",
3276 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3277 _persistenceImpl = persistenceImpl;
3278 }
3279
3280 protected void remove(long userGroupId, long groupId)
3281 throws SystemException {
3282 if (_persistenceImpl.containsGroup.contains(userGroupId, groupId)) {
3283 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
3284
3285 for (ModelListener<UserGroup> listener : listeners) {
3286 listener.onBeforeRemoveAssociation(userGroupId,
3287 com.liferay.portal.model.Group.class.getName(), groupId);
3288 }
3289
3290 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
3291 listener.onBeforeRemoveAssociation(groupId,
3292 UserGroup.class.getName(), userGroupId);
3293 }
3294
3295 _sqlUpdate.update(new Object[] {
3296 new Long(userGroupId), new Long(groupId)
3297 });
3298
3299 for (ModelListener<UserGroup> listener : listeners) {
3300 listener.onAfterRemoveAssociation(userGroupId,
3301 com.liferay.portal.model.Group.class.getName(), groupId);
3302 }
3303
3304 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
3305 listener.onAfterRemoveAssociation(groupId,
3306 UserGroup.class.getName(), userGroupId);
3307 }
3308 }
3309 }
3310
3311 private SqlUpdate _sqlUpdate;
3312 private UserGroupPersistenceImpl _persistenceImpl;
3313 }
3314
3315 protected class ContainsUser {
3316 protected ContainsUser(UserGroupPersistenceImpl persistenceImpl) {
3317 super();
3318
3319 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
3320 _SQL_CONTAINSUSER,
3321 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
3322 RowMapper.COUNT);
3323 }
3324
3325 protected boolean contains(long userGroupId, long userId) {
3326 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
3327 new Long(userGroupId), new Long(userId)
3328 });
3329
3330 if (results.size() > 0) {
3331 Integer count = results.get(0);
3332
3333 if (count.intValue() > 0) {
3334 return true;
3335 }
3336 }
3337
3338 return false;
3339 }
3340
3341 private MappingSqlQuery<Integer> _mappingSqlQuery;
3342 }
3343
3344 protected class AddUser {
3345 protected AddUser(UserGroupPersistenceImpl persistenceImpl) {
3346 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3347 "INSERT INTO Users_UserGroups (userGroupId, userId) VALUES (?, ?)",
3348 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3349 _persistenceImpl = persistenceImpl;
3350 }
3351
3352 protected void add(long userGroupId, long userId)
3353 throws SystemException {
3354 if (!_persistenceImpl.containsUser.contains(userGroupId, userId)) {
3355 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
3356
3357 for (ModelListener<UserGroup> listener : listeners) {
3358 listener.onBeforeAddAssociation(userGroupId,
3359 com.liferay.portal.model.User.class.getName(), userId);
3360 }
3361
3362 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3363 listener.onBeforeAddAssociation(userId,
3364 UserGroup.class.getName(), userGroupId);
3365 }
3366
3367 _sqlUpdate.update(new Object[] {
3368 new Long(userGroupId), new Long(userId)
3369 });
3370
3371 for (ModelListener<UserGroup> listener : listeners) {
3372 listener.onAfterAddAssociation(userGroupId,
3373 com.liferay.portal.model.User.class.getName(), userId);
3374 }
3375
3376 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3377 listener.onAfterAddAssociation(userId,
3378 UserGroup.class.getName(), userGroupId);
3379 }
3380 }
3381 }
3382
3383 private SqlUpdate _sqlUpdate;
3384 private UserGroupPersistenceImpl _persistenceImpl;
3385 }
3386
3387 protected class ClearUsers {
3388 protected ClearUsers(UserGroupPersistenceImpl persistenceImpl) {
3389 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3390 "DELETE FROM Users_UserGroups WHERE userGroupId = ?",
3391 new int[] { java.sql.Types.BIGINT });
3392 }
3393
3394 protected void clear(long userGroupId) throws SystemException {
3395 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
3396
3397 List<com.liferay.portal.model.User> users = null;
3398
3399 if ((listeners.length > 0) || (userListeners.length > 0)) {
3400 users = getUsers(userGroupId);
3401
3402 for (com.liferay.portal.model.User user : users) {
3403 for (ModelListener<UserGroup> listener : listeners) {
3404 listener.onBeforeRemoveAssociation(userGroupId,
3405 com.liferay.portal.model.User.class.getName(),
3406 user.getPrimaryKey());
3407 }
3408
3409 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3410 listener.onBeforeRemoveAssociation(user.getPrimaryKey(),
3411 UserGroup.class.getName(), userGroupId);
3412 }
3413 }
3414 }
3415
3416 _sqlUpdate.update(new Object[] { new Long(userGroupId) });
3417
3418 if ((listeners.length > 0) || (userListeners.length > 0)) {
3419 for (com.liferay.portal.model.User user : users) {
3420 for (ModelListener<UserGroup> listener : listeners) {
3421 listener.onAfterRemoveAssociation(userGroupId,
3422 com.liferay.portal.model.User.class.getName(),
3423 user.getPrimaryKey());
3424 }
3425
3426 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3427 listener.onAfterRemoveAssociation(user.getPrimaryKey(),
3428 UserGroup.class.getName(), userGroupId);
3429 }
3430 }
3431 }
3432 }
3433
3434 private SqlUpdate _sqlUpdate;
3435 }
3436
3437 protected class RemoveUser {
3438 protected RemoveUser(UserGroupPersistenceImpl persistenceImpl) {
3439 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3440 "DELETE FROM Users_UserGroups WHERE userGroupId = ? AND userId = ?",
3441 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3442 _persistenceImpl = persistenceImpl;
3443 }
3444
3445 protected void remove(long userGroupId, long userId)
3446 throws SystemException {
3447 if (_persistenceImpl.containsUser.contains(userGroupId, userId)) {
3448 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
3449
3450 for (ModelListener<UserGroup> listener : listeners) {
3451 listener.onBeforeRemoveAssociation(userGroupId,
3452 com.liferay.portal.model.User.class.getName(), userId);
3453 }
3454
3455 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3456 listener.onBeforeRemoveAssociation(userId,
3457 UserGroup.class.getName(), userGroupId);
3458 }
3459
3460 _sqlUpdate.update(new Object[] {
3461 new Long(userGroupId), new Long(userId)
3462 });
3463
3464 for (ModelListener<UserGroup> listener : listeners) {
3465 listener.onAfterRemoveAssociation(userGroupId,
3466 com.liferay.portal.model.User.class.getName(), userId);
3467 }
3468
3469 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3470 listener.onAfterRemoveAssociation(userId,
3471 UserGroup.class.getName(), userGroupId);
3472 }
3473 }
3474 }
3475
3476 private SqlUpdate _sqlUpdate;
3477 private UserGroupPersistenceImpl _persistenceImpl;
3478 }
3479
3480 private static final String _SQL_SELECT_USERGROUP = "SELECT userGroup FROM UserGroup userGroup";
3481 private static final String _SQL_SELECT_USERGROUP_WHERE = "SELECT userGroup FROM UserGroup userGroup WHERE ";
3482 private static final String _SQL_COUNT_USERGROUP = "SELECT COUNT(userGroup) FROM UserGroup userGroup";
3483 private static final String _SQL_COUNT_USERGROUP_WHERE = "SELECT COUNT(userGroup) FROM UserGroup userGroup WHERE ";
3484 private static final String _SQL_GETGROUPS = "SELECT {Group_.*} FROM Group_ INNER JOIN Groups_UserGroups ON (Groups_UserGroups.groupId = Group_.groupId) WHERE (Groups_UserGroups.userGroupId = ?)";
3485 private static final String _SQL_GETGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_UserGroups WHERE userGroupId = ?";
3486 private static final String _SQL_CONTAINSGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_UserGroups WHERE userGroupId = ? AND groupId = ?";
3487 private static final String _SQL_GETUSERS = "SELECT {User_.*} FROM User_ INNER JOIN Users_UserGroups ON (Users_UserGroups.userId = User_.userId) WHERE (Users_UserGroups.userGroupId = ?)";
3488 private static final String _SQL_GETUSERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_UserGroups WHERE userGroupId = ?";
3489 private static final String _SQL_CONTAINSUSER = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_UserGroups WHERE userGroupId = ? AND userId = ?";
3490 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "userGroup.companyId = ?";
3491 private static final String _FINDER_COLUMN_C_P_COMPANYID_2 = "userGroup.companyId = ? AND ";
3492 private static final String _FINDER_COLUMN_C_P_PARENTUSERGROUPID_2 = "userGroup.parentUserGroupId = ?";
3493 private static final String _FINDER_COLUMN_C_N_COMPANYID_2 = "userGroup.companyId = ? AND ";
3494 private static final String _FINDER_COLUMN_C_N_NAME_1 = "userGroup.name IS NULL";
3495 private static final String _FINDER_COLUMN_C_N_NAME_2 = "userGroup.name = ?";
3496 private static final String _FINDER_COLUMN_C_N_NAME_3 = "(userGroup.name IS NULL OR userGroup.name = ?)";
3497 private static final String _FILTER_SQL_SELECT_USERGROUP_WHERE = "SELECT DISTINCT {userGroup.*} FROM UserGroup userGroup WHERE ";
3498 private static final String _FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_1 =
3499 "SELECT {UserGroup.*} FROM (SELECT DISTINCT userGroup.userGroupId FROM UserGroup userGroup WHERE ";
3500 private static final String _FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_2 =
3501 ") TEMP_TABLE INNER JOIN UserGroup ON TEMP_TABLE.userGroupId = UserGroup.userGroupId";
3502 private static final String _FILTER_SQL_COUNT_USERGROUP_WHERE = "SELECT COUNT(DISTINCT userGroup.userGroupId) AS COUNT_VALUE FROM UserGroup userGroup WHERE ";
3503 private static final String _FILTER_COLUMN_PK = "userGroup.userGroupId";
3504 private static final String _FILTER_COLUMN_USERID = null;
3505 private static final String _FILTER_ENTITY_ALIAS = "userGroup";
3506 private static final String _FILTER_ENTITY_TABLE = "UserGroup";
3507 private static final String _ORDER_BY_ENTITY_ALIAS = "userGroup.";
3508 private static final String _ORDER_BY_ENTITY_TABLE = "UserGroup.";
3509 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserGroup exists with the primary key ";
3510 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserGroup exists with the key {";
3511 private static Log _log = LogFactoryUtil.getLog(UserGroupPersistenceImpl.class);
3512 }