001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.NoSuchUserGroupGroupRoleException;
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023 import com.liferay.portal.kernel.dao.orm.FinderPath;
024 import com.liferay.portal.kernel.dao.orm.Query;
025 import com.liferay.portal.kernel.dao.orm.QueryPos;
026 import com.liferay.portal.kernel.dao.orm.QueryUtil;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.model.CacheModel;
038 import com.liferay.portal.model.ModelListener;
039 import com.liferay.portal.model.UserGroupGroupRole;
040 import com.liferay.portal.model.impl.UserGroupGroupRoleImpl;
041 import com.liferay.portal.model.impl.UserGroupGroupRoleModelImpl;
042 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043
044 import java.io.Serializable;
045
046 import java.util.ArrayList;
047 import java.util.Collections;
048 import java.util.List;
049
050
062 public class UserGroupGroupRolePersistenceImpl extends BasePersistenceImpl<UserGroupGroupRole>
063 implements UserGroupGroupRolePersistence {
064
069 public static final String FINDER_CLASS_NAME_ENTITY = UserGroupGroupRoleImpl.class.getName();
070 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
071 ".List1";
072 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
073 ".List2";
074 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERGROUPID =
075 new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
076 UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED,
077 UserGroupGroupRoleImpl.class,
078 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserGroupId",
079 new String[] {
080 Long.class.getName(),
081
082 "java.lang.Integer", "java.lang.Integer",
083 "com.liferay.portal.kernel.util.OrderByComparator"
084 });
085 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERGROUPID =
086 new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
087 UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED,
088 UserGroupGroupRoleImpl.class,
089 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserGroupId",
090 new String[] { Long.class.getName() },
091 UserGroupGroupRoleModelImpl.USERGROUPID_COLUMN_BITMASK);
092 public static final FinderPath FINDER_PATH_COUNT_BY_USERGROUPID = new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
093 UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
094 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserGroupId",
095 new String[] { Long.class.getName() });
096 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
097 UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED,
098 UserGroupGroupRoleImpl.class,
099 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
100 new String[] {
101 Long.class.getName(),
102
103 "java.lang.Integer", "java.lang.Integer",
104 "com.liferay.portal.kernel.util.OrderByComparator"
105 });
106 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
107 new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
108 UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED,
109 UserGroupGroupRoleImpl.class,
110 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
111 new String[] { Long.class.getName() },
112 UserGroupGroupRoleModelImpl.GROUPID_COLUMN_BITMASK);
113 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
114 UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
115 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
116 new String[] { Long.class.getName() });
117 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_ROLEID = new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
118 UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED,
119 UserGroupGroupRoleImpl.class,
120 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByRoleId",
121 new String[] {
122 Long.class.getName(),
123
124 "java.lang.Integer", "java.lang.Integer",
125 "com.liferay.portal.kernel.util.OrderByComparator"
126 });
127 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ROLEID =
128 new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
129 UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED,
130 UserGroupGroupRoleImpl.class,
131 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByRoleId",
132 new String[] { Long.class.getName() },
133 UserGroupGroupRoleModelImpl.ROLEID_COLUMN_BITMASK);
134 public static final FinderPath FINDER_PATH_COUNT_BY_ROLEID = new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
135 UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
136 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByRoleId",
137 new String[] { Long.class.getName() });
138 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_G = new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
139 UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED,
140 UserGroupGroupRoleImpl.class,
141 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_G",
142 new String[] {
143 Long.class.getName(), Long.class.getName(),
144
145 "java.lang.Integer", "java.lang.Integer",
146 "com.liferay.portal.kernel.util.OrderByComparator"
147 });
148 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_G = new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
149 UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED,
150 UserGroupGroupRoleImpl.class,
151 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_G",
152 new String[] { Long.class.getName(), Long.class.getName() },
153 UserGroupGroupRoleModelImpl.USERGROUPID_COLUMN_BITMASK |
154 UserGroupGroupRoleModelImpl.GROUPID_COLUMN_BITMASK);
155 public static final FinderPath FINDER_PATH_COUNT_BY_U_G = new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
156 UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
157 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_G",
158 new String[] { Long.class.getName(), Long.class.getName() });
159 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_R = new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
160 UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED,
161 UserGroupGroupRoleImpl.class,
162 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_R",
163 new String[] {
164 Long.class.getName(), Long.class.getName(),
165
166 "java.lang.Integer", "java.lang.Integer",
167 "com.liferay.portal.kernel.util.OrderByComparator"
168 });
169 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_R = new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
170 UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED,
171 UserGroupGroupRoleImpl.class,
172 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_R",
173 new String[] { Long.class.getName(), Long.class.getName() },
174 UserGroupGroupRoleModelImpl.GROUPID_COLUMN_BITMASK |
175 UserGroupGroupRoleModelImpl.ROLEID_COLUMN_BITMASK);
176 public static final FinderPath FINDER_PATH_COUNT_BY_G_R = new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
177 UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
178 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_R",
179 new String[] { Long.class.getName(), Long.class.getName() });
180 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
181 UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED,
182 UserGroupGroupRoleImpl.class,
183 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
184 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
185 UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED,
186 UserGroupGroupRoleImpl.class,
187 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
188 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
189 UserGroupGroupRoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
190 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
191
192
197 public void cacheResult(UserGroupGroupRole userGroupGroupRole) {
198 EntityCacheUtil.putResult(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
199 UserGroupGroupRoleImpl.class, userGroupGroupRole.getPrimaryKey(),
200 userGroupGroupRole);
201
202 userGroupGroupRole.resetOriginalValues();
203 }
204
205
210 public void cacheResult(List<UserGroupGroupRole> userGroupGroupRoles) {
211 for (UserGroupGroupRole userGroupGroupRole : userGroupGroupRoles) {
212 if (EntityCacheUtil.getResult(
213 UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
214 UserGroupGroupRoleImpl.class,
215 userGroupGroupRole.getPrimaryKey()) == null) {
216 cacheResult(userGroupGroupRole);
217 }
218 else {
219 userGroupGroupRole.resetOriginalValues();
220 }
221 }
222 }
223
224
231 @Override
232 public void clearCache() {
233 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
234 CacheRegistryUtil.clear(UserGroupGroupRoleImpl.class.getName());
235 }
236
237 EntityCacheUtil.clearCache(UserGroupGroupRoleImpl.class.getName());
238
239 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
240 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
241 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
242 }
243
244
251 @Override
252 public void clearCache(UserGroupGroupRole userGroupGroupRole) {
253 EntityCacheUtil.removeResult(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
254 UserGroupGroupRoleImpl.class, userGroupGroupRole.getPrimaryKey());
255
256 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
257 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
258 }
259
260 @Override
261 public void clearCache(List<UserGroupGroupRole> userGroupGroupRoles) {
262 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
263 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
264
265 for (UserGroupGroupRole userGroupGroupRole : userGroupGroupRoles) {
266 EntityCacheUtil.removeResult(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
267 UserGroupGroupRoleImpl.class, userGroupGroupRole.getPrimaryKey());
268 }
269 }
270
271
277 public UserGroupGroupRole create(UserGroupGroupRolePK userGroupGroupRolePK) {
278 UserGroupGroupRole userGroupGroupRole = new UserGroupGroupRoleImpl();
279
280 userGroupGroupRole.setNew(true);
281 userGroupGroupRole.setPrimaryKey(userGroupGroupRolePK);
282
283 return userGroupGroupRole;
284 }
285
286
294 public UserGroupGroupRole remove(UserGroupGroupRolePK userGroupGroupRolePK)
295 throws NoSuchUserGroupGroupRoleException, SystemException {
296 return remove((Serializable)userGroupGroupRolePK);
297 }
298
299
307 @Override
308 public UserGroupGroupRole remove(Serializable primaryKey)
309 throws NoSuchUserGroupGroupRoleException, SystemException {
310 Session session = null;
311
312 try {
313 session = openSession();
314
315 UserGroupGroupRole userGroupGroupRole = (UserGroupGroupRole)session.get(UserGroupGroupRoleImpl.class,
316 primaryKey);
317
318 if (userGroupGroupRole == null) {
319 if (_log.isWarnEnabled()) {
320 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
321 }
322
323 throw new NoSuchUserGroupGroupRoleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
324 primaryKey);
325 }
326
327 return remove(userGroupGroupRole);
328 }
329 catch (NoSuchUserGroupGroupRoleException nsee) {
330 throw nsee;
331 }
332 catch (Exception e) {
333 throw processException(e);
334 }
335 finally {
336 closeSession(session);
337 }
338 }
339
340 @Override
341 protected UserGroupGroupRole removeImpl(
342 UserGroupGroupRole userGroupGroupRole) throws SystemException {
343 userGroupGroupRole = toUnwrappedModel(userGroupGroupRole);
344
345 Session session = null;
346
347 try {
348 session = openSession();
349
350 BatchSessionUtil.delete(session, userGroupGroupRole);
351 }
352 catch (Exception e) {
353 throw processException(e);
354 }
355 finally {
356 closeSession(session);
357 }
358
359 clearCache(userGroupGroupRole);
360
361 return userGroupGroupRole;
362 }
363
364 @Override
365 public UserGroupGroupRole updateImpl(
366 com.liferay.portal.model.UserGroupGroupRole userGroupGroupRole,
367 boolean merge) throws SystemException {
368 userGroupGroupRole = toUnwrappedModel(userGroupGroupRole);
369
370 boolean isNew = userGroupGroupRole.isNew();
371
372 UserGroupGroupRoleModelImpl userGroupGroupRoleModelImpl = (UserGroupGroupRoleModelImpl)userGroupGroupRole;
373
374 Session session = null;
375
376 try {
377 session = openSession();
378
379 BatchSessionUtil.update(session, userGroupGroupRole, merge);
380
381 userGroupGroupRole.setNew(false);
382 }
383 catch (Exception e) {
384 throw processException(e);
385 }
386 finally {
387 closeSession(session);
388 }
389
390 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
391
392 if (isNew || !UserGroupGroupRoleModelImpl.COLUMN_BITMASK_ENABLED) {
393 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
394 }
395
396 else {
397 if ((userGroupGroupRoleModelImpl.getColumnBitmask() &
398 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERGROUPID.getColumnBitmask()) != 0) {
399 Object[] args = new Object[] {
400 Long.valueOf(userGroupGroupRoleModelImpl.getOriginalUserGroupId())
401 };
402
403 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERGROUPID,
404 args);
405 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERGROUPID,
406 args);
407
408 args = new Object[] {
409 Long.valueOf(userGroupGroupRoleModelImpl.getUserGroupId())
410 };
411
412 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERGROUPID,
413 args);
414 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERGROUPID,
415 args);
416 }
417
418 if ((userGroupGroupRoleModelImpl.getColumnBitmask() &
419 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
420 Object[] args = new Object[] {
421 Long.valueOf(userGroupGroupRoleModelImpl.getOriginalGroupId())
422 };
423
424 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
425 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
426 args);
427
428 args = new Object[] {
429 Long.valueOf(userGroupGroupRoleModelImpl.getGroupId())
430 };
431
432 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
433 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
434 args);
435 }
436
437 if ((userGroupGroupRoleModelImpl.getColumnBitmask() &
438 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ROLEID.getColumnBitmask()) != 0) {
439 Object[] args = new Object[] {
440 Long.valueOf(userGroupGroupRoleModelImpl.getOriginalRoleId())
441 };
442
443 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ROLEID, args);
444 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ROLEID,
445 args);
446
447 args = new Object[] {
448 Long.valueOf(userGroupGroupRoleModelImpl.getRoleId())
449 };
450
451 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ROLEID, args);
452 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ROLEID,
453 args);
454 }
455
456 if ((userGroupGroupRoleModelImpl.getColumnBitmask() &
457 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_G.getColumnBitmask()) != 0) {
458 Object[] args = new Object[] {
459 Long.valueOf(userGroupGroupRoleModelImpl.getOriginalUserGroupId()),
460 Long.valueOf(userGroupGroupRoleModelImpl.getOriginalGroupId())
461 };
462
463 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_G, args);
464 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_G,
465 args);
466
467 args = new Object[] {
468 Long.valueOf(userGroupGroupRoleModelImpl.getUserGroupId()),
469 Long.valueOf(userGroupGroupRoleModelImpl.getGroupId())
470 };
471
472 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_G, args);
473 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_G,
474 args);
475 }
476
477 if ((userGroupGroupRoleModelImpl.getColumnBitmask() &
478 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_R.getColumnBitmask()) != 0) {
479 Object[] args = new Object[] {
480 Long.valueOf(userGroupGroupRoleModelImpl.getOriginalGroupId()),
481 Long.valueOf(userGroupGroupRoleModelImpl.getOriginalRoleId())
482 };
483
484 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_R, args);
485 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_R,
486 args);
487
488 args = new Object[] {
489 Long.valueOf(userGroupGroupRoleModelImpl.getGroupId()),
490 Long.valueOf(userGroupGroupRoleModelImpl.getRoleId())
491 };
492
493 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_R, args);
494 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_R,
495 args);
496 }
497 }
498
499 EntityCacheUtil.putResult(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
500 UserGroupGroupRoleImpl.class, userGroupGroupRole.getPrimaryKey(),
501 userGroupGroupRole);
502
503 return userGroupGroupRole;
504 }
505
506 protected UserGroupGroupRole toUnwrappedModel(
507 UserGroupGroupRole userGroupGroupRole) {
508 if (userGroupGroupRole instanceof UserGroupGroupRoleImpl) {
509 return userGroupGroupRole;
510 }
511
512 UserGroupGroupRoleImpl userGroupGroupRoleImpl = new UserGroupGroupRoleImpl();
513
514 userGroupGroupRoleImpl.setNew(userGroupGroupRole.isNew());
515 userGroupGroupRoleImpl.setPrimaryKey(userGroupGroupRole.getPrimaryKey());
516
517 userGroupGroupRoleImpl.setUserGroupId(userGroupGroupRole.getUserGroupId());
518 userGroupGroupRoleImpl.setGroupId(userGroupGroupRole.getGroupId());
519 userGroupGroupRoleImpl.setRoleId(userGroupGroupRole.getRoleId());
520
521 return userGroupGroupRoleImpl;
522 }
523
524
532 @Override
533 public UserGroupGroupRole findByPrimaryKey(Serializable primaryKey)
534 throws NoSuchModelException, SystemException {
535 return findByPrimaryKey((UserGroupGroupRolePK)primaryKey);
536 }
537
538
546 public UserGroupGroupRole findByPrimaryKey(
547 UserGroupGroupRolePK userGroupGroupRolePK)
548 throws NoSuchUserGroupGroupRoleException, SystemException {
549 UserGroupGroupRole userGroupGroupRole = fetchByPrimaryKey(userGroupGroupRolePK);
550
551 if (userGroupGroupRole == null) {
552 if (_log.isWarnEnabled()) {
553 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
554 userGroupGroupRolePK);
555 }
556
557 throw new NoSuchUserGroupGroupRoleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
558 userGroupGroupRolePK);
559 }
560
561 return userGroupGroupRole;
562 }
563
564
571 @Override
572 public UserGroupGroupRole fetchByPrimaryKey(Serializable primaryKey)
573 throws SystemException {
574 return fetchByPrimaryKey((UserGroupGroupRolePK)primaryKey);
575 }
576
577
584 public UserGroupGroupRole fetchByPrimaryKey(
585 UserGroupGroupRolePK userGroupGroupRolePK) throws SystemException {
586 UserGroupGroupRole userGroupGroupRole = (UserGroupGroupRole)EntityCacheUtil.getResult(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
587 UserGroupGroupRoleImpl.class, userGroupGroupRolePK);
588
589 if (userGroupGroupRole == _nullUserGroupGroupRole) {
590 return null;
591 }
592
593 if (userGroupGroupRole == null) {
594 Session session = null;
595
596 boolean hasException = false;
597
598 try {
599 session = openSession();
600
601 userGroupGroupRole = (UserGroupGroupRole)session.get(UserGroupGroupRoleImpl.class,
602 userGroupGroupRolePK);
603 }
604 catch (Exception e) {
605 hasException = true;
606
607 throw processException(e);
608 }
609 finally {
610 if (userGroupGroupRole != null) {
611 cacheResult(userGroupGroupRole);
612 }
613 else if (!hasException) {
614 EntityCacheUtil.putResult(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
615 UserGroupGroupRoleImpl.class, userGroupGroupRolePK,
616 _nullUserGroupGroupRole);
617 }
618
619 closeSession(session);
620 }
621 }
622
623 return userGroupGroupRole;
624 }
625
626
633 public List<UserGroupGroupRole> findByUserGroupId(long userGroupId)
634 throws SystemException {
635 return findByUserGroupId(userGroupId, QueryUtil.ALL_POS,
636 QueryUtil.ALL_POS, null);
637 }
638
639
652 public List<UserGroupGroupRole> findByUserGroupId(long userGroupId,
653 int start, int end) throws SystemException {
654 return findByUserGroupId(userGroupId, start, end, null);
655 }
656
657
671 public List<UserGroupGroupRole> findByUserGroupId(long userGroupId,
672 int start, int end, OrderByComparator orderByComparator)
673 throws SystemException {
674 FinderPath finderPath = null;
675 Object[] finderArgs = null;
676
677 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
678 (orderByComparator == null)) {
679 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERGROUPID;
680 finderArgs = new Object[] { userGroupId };
681 }
682 else {
683 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERGROUPID;
684 finderArgs = new Object[] { userGroupId, start, end, orderByComparator };
685 }
686
687 List<UserGroupGroupRole> list = (List<UserGroupGroupRole>)FinderCacheUtil.getResult(finderPath,
688 finderArgs, this);
689
690 if (list == null) {
691 StringBundler query = null;
692
693 if (orderByComparator != null) {
694 query = new StringBundler(3 +
695 (orderByComparator.getOrderByFields().length * 3));
696 }
697 else {
698 query = new StringBundler(2);
699 }
700
701 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
702
703 query.append(_FINDER_COLUMN_USERGROUPID_USERGROUPID_2);
704
705 if (orderByComparator != null) {
706 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
707 orderByComparator);
708 }
709
710 String sql = query.toString();
711
712 Session session = null;
713
714 try {
715 session = openSession();
716
717 Query q = session.createQuery(sql);
718
719 QueryPos qPos = QueryPos.getInstance(q);
720
721 qPos.add(userGroupId);
722
723 list = (List<UserGroupGroupRole>)QueryUtil.list(q,
724 getDialect(), start, end);
725 }
726 catch (Exception e) {
727 throw processException(e);
728 }
729 finally {
730 if (list == null) {
731 FinderCacheUtil.removeResult(finderPath, finderArgs);
732 }
733 else {
734 cacheResult(list);
735
736 FinderCacheUtil.putResult(finderPath, finderArgs, list);
737 }
738
739 closeSession(session);
740 }
741 }
742
743 return list;
744 }
745
746
759 public UserGroupGroupRole findByUserGroupId_First(long userGroupId,
760 OrderByComparator orderByComparator)
761 throws NoSuchUserGroupGroupRoleException, SystemException {
762 List<UserGroupGroupRole> list = findByUserGroupId(userGroupId, 0, 1,
763 orderByComparator);
764
765 if (list.isEmpty()) {
766 StringBundler msg = new StringBundler(4);
767
768 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
769
770 msg.append("userGroupId=");
771 msg.append(userGroupId);
772
773 msg.append(StringPool.CLOSE_CURLY_BRACE);
774
775 throw new NoSuchUserGroupGroupRoleException(msg.toString());
776 }
777 else {
778 return list.get(0);
779 }
780 }
781
782
795 public UserGroupGroupRole findByUserGroupId_Last(long userGroupId,
796 OrderByComparator orderByComparator)
797 throws NoSuchUserGroupGroupRoleException, SystemException {
798 int count = countByUserGroupId(userGroupId);
799
800 List<UserGroupGroupRole> list = findByUserGroupId(userGroupId,
801 count - 1, count, orderByComparator);
802
803 if (list.isEmpty()) {
804 StringBundler msg = new StringBundler(4);
805
806 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
807
808 msg.append("userGroupId=");
809 msg.append(userGroupId);
810
811 msg.append(StringPool.CLOSE_CURLY_BRACE);
812
813 throw new NoSuchUserGroupGroupRoleException(msg.toString());
814 }
815 else {
816 return list.get(0);
817 }
818 }
819
820
834 public UserGroupGroupRole[] findByUserGroupId_PrevAndNext(
835 UserGroupGroupRolePK userGroupGroupRolePK, long userGroupId,
836 OrderByComparator orderByComparator)
837 throws NoSuchUserGroupGroupRoleException, SystemException {
838 UserGroupGroupRole userGroupGroupRole = findByPrimaryKey(userGroupGroupRolePK);
839
840 Session session = null;
841
842 try {
843 session = openSession();
844
845 UserGroupGroupRole[] array = new UserGroupGroupRoleImpl[3];
846
847 array[0] = getByUserGroupId_PrevAndNext(session,
848 userGroupGroupRole, userGroupId, orderByComparator, true);
849
850 array[1] = userGroupGroupRole;
851
852 array[2] = getByUserGroupId_PrevAndNext(session,
853 userGroupGroupRole, userGroupId, orderByComparator, false);
854
855 return array;
856 }
857 catch (Exception e) {
858 throw processException(e);
859 }
860 finally {
861 closeSession(session);
862 }
863 }
864
865 protected UserGroupGroupRole getByUserGroupId_PrevAndNext(Session session,
866 UserGroupGroupRole userGroupGroupRole, long userGroupId,
867 OrderByComparator orderByComparator, boolean previous) {
868 StringBundler query = null;
869
870 if (orderByComparator != null) {
871 query = new StringBundler(6 +
872 (orderByComparator.getOrderByFields().length * 6));
873 }
874 else {
875 query = new StringBundler(3);
876 }
877
878 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
879
880 query.append(_FINDER_COLUMN_USERGROUPID_USERGROUPID_2);
881
882 if (orderByComparator != null) {
883 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
884
885 if (orderByConditionFields.length > 0) {
886 query.append(WHERE_AND);
887 }
888
889 for (int i = 0; i < orderByConditionFields.length; i++) {
890 query.append(_ORDER_BY_ENTITY_ALIAS);
891 query.append(orderByConditionFields[i]);
892
893 if ((i + 1) < orderByConditionFields.length) {
894 if (orderByComparator.isAscending() ^ previous) {
895 query.append(WHERE_GREATER_THAN_HAS_NEXT);
896 }
897 else {
898 query.append(WHERE_LESSER_THAN_HAS_NEXT);
899 }
900 }
901 else {
902 if (orderByComparator.isAscending() ^ previous) {
903 query.append(WHERE_GREATER_THAN);
904 }
905 else {
906 query.append(WHERE_LESSER_THAN);
907 }
908 }
909 }
910
911 query.append(ORDER_BY_CLAUSE);
912
913 String[] orderByFields = orderByComparator.getOrderByFields();
914
915 for (int i = 0; i < orderByFields.length; i++) {
916 query.append(_ORDER_BY_ENTITY_ALIAS);
917 query.append(orderByFields[i]);
918
919 if ((i + 1) < orderByFields.length) {
920 if (orderByComparator.isAscending() ^ previous) {
921 query.append(ORDER_BY_ASC_HAS_NEXT);
922 }
923 else {
924 query.append(ORDER_BY_DESC_HAS_NEXT);
925 }
926 }
927 else {
928 if (orderByComparator.isAscending() ^ previous) {
929 query.append(ORDER_BY_ASC);
930 }
931 else {
932 query.append(ORDER_BY_DESC);
933 }
934 }
935 }
936 }
937
938 String sql = query.toString();
939
940 Query q = session.createQuery(sql);
941
942 q.setFirstResult(0);
943 q.setMaxResults(2);
944
945 QueryPos qPos = QueryPos.getInstance(q);
946
947 qPos.add(userGroupId);
948
949 if (orderByComparator != null) {
950 Object[] values = orderByComparator.getOrderByConditionValues(userGroupGroupRole);
951
952 for (Object value : values) {
953 qPos.add(value);
954 }
955 }
956
957 List<UserGroupGroupRole> list = q.list();
958
959 if (list.size() == 2) {
960 return list.get(1);
961 }
962 else {
963 return null;
964 }
965 }
966
967
974 public List<UserGroupGroupRole> findByGroupId(long groupId)
975 throws SystemException {
976 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
977 }
978
979
992 public List<UserGroupGroupRole> findByGroupId(long groupId, int start,
993 int end) throws SystemException {
994 return findByGroupId(groupId, start, end, null);
995 }
996
997
1011 public List<UserGroupGroupRole> findByGroupId(long groupId, int start,
1012 int end, OrderByComparator orderByComparator) throws SystemException {
1013 FinderPath finderPath = null;
1014 Object[] finderArgs = null;
1015
1016 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1017 (orderByComparator == null)) {
1018 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1019 finderArgs = new Object[] { groupId };
1020 }
1021 else {
1022 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1023 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1024 }
1025
1026 List<UserGroupGroupRole> list = (List<UserGroupGroupRole>)FinderCacheUtil.getResult(finderPath,
1027 finderArgs, this);
1028
1029 if (list == null) {
1030 StringBundler query = null;
1031
1032 if (orderByComparator != null) {
1033 query = new StringBundler(3 +
1034 (orderByComparator.getOrderByFields().length * 3));
1035 }
1036 else {
1037 query = new StringBundler(2);
1038 }
1039
1040 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
1041
1042 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1043
1044 if (orderByComparator != null) {
1045 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1046 orderByComparator);
1047 }
1048
1049 String sql = query.toString();
1050
1051 Session session = null;
1052
1053 try {
1054 session = openSession();
1055
1056 Query q = session.createQuery(sql);
1057
1058 QueryPos qPos = QueryPos.getInstance(q);
1059
1060 qPos.add(groupId);
1061
1062 list = (List<UserGroupGroupRole>)QueryUtil.list(q,
1063 getDialect(), start, end);
1064 }
1065 catch (Exception e) {
1066 throw processException(e);
1067 }
1068 finally {
1069 if (list == null) {
1070 FinderCacheUtil.removeResult(finderPath, finderArgs);
1071 }
1072 else {
1073 cacheResult(list);
1074
1075 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1076 }
1077
1078 closeSession(session);
1079 }
1080 }
1081
1082 return list;
1083 }
1084
1085
1098 public UserGroupGroupRole findByGroupId_First(long groupId,
1099 OrderByComparator orderByComparator)
1100 throws NoSuchUserGroupGroupRoleException, SystemException {
1101 List<UserGroupGroupRole> list = findByGroupId(groupId, 0, 1,
1102 orderByComparator);
1103
1104 if (list.isEmpty()) {
1105 StringBundler msg = new StringBundler(4);
1106
1107 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1108
1109 msg.append("groupId=");
1110 msg.append(groupId);
1111
1112 msg.append(StringPool.CLOSE_CURLY_BRACE);
1113
1114 throw new NoSuchUserGroupGroupRoleException(msg.toString());
1115 }
1116 else {
1117 return list.get(0);
1118 }
1119 }
1120
1121
1134 public UserGroupGroupRole findByGroupId_Last(long groupId,
1135 OrderByComparator orderByComparator)
1136 throws NoSuchUserGroupGroupRoleException, SystemException {
1137 int count = countByGroupId(groupId);
1138
1139 List<UserGroupGroupRole> list = findByGroupId(groupId, count - 1,
1140 count, orderByComparator);
1141
1142 if (list.isEmpty()) {
1143 StringBundler msg = new StringBundler(4);
1144
1145 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1146
1147 msg.append("groupId=");
1148 msg.append(groupId);
1149
1150 msg.append(StringPool.CLOSE_CURLY_BRACE);
1151
1152 throw new NoSuchUserGroupGroupRoleException(msg.toString());
1153 }
1154 else {
1155 return list.get(0);
1156 }
1157 }
1158
1159
1173 public UserGroupGroupRole[] findByGroupId_PrevAndNext(
1174 UserGroupGroupRolePK userGroupGroupRolePK, long groupId,
1175 OrderByComparator orderByComparator)
1176 throws NoSuchUserGroupGroupRoleException, SystemException {
1177 UserGroupGroupRole userGroupGroupRole = findByPrimaryKey(userGroupGroupRolePK);
1178
1179 Session session = null;
1180
1181 try {
1182 session = openSession();
1183
1184 UserGroupGroupRole[] array = new UserGroupGroupRoleImpl[3];
1185
1186 array[0] = getByGroupId_PrevAndNext(session, userGroupGroupRole,
1187 groupId, orderByComparator, true);
1188
1189 array[1] = userGroupGroupRole;
1190
1191 array[2] = getByGroupId_PrevAndNext(session, userGroupGroupRole,
1192 groupId, orderByComparator, false);
1193
1194 return array;
1195 }
1196 catch (Exception e) {
1197 throw processException(e);
1198 }
1199 finally {
1200 closeSession(session);
1201 }
1202 }
1203
1204 protected UserGroupGroupRole getByGroupId_PrevAndNext(Session session,
1205 UserGroupGroupRole userGroupGroupRole, long groupId,
1206 OrderByComparator orderByComparator, boolean previous) {
1207 StringBundler query = null;
1208
1209 if (orderByComparator != null) {
1210 query = new StringBundler(6 +
1211 (orderByComparator.getOrderByFields().length * 6));
1212 }
1213 else {
1214 query = new StringBundler(3);
1215 }
1216
1217 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
1218
1219 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1220
1221 if (orderByComparator != null) {
1222 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1223
1224 if (orderByConditionFields.length > 0) {
1225 query.append(WHERE_AND);
1226 }
1227
1228 for (int i = 0; i < orderByConditionFields.length; i++) {
1229 query.append(_ORDER_BY_ENTITY_ALIAS);
1230 query.append(orderByConditionFields[i]);
1231
1232 if ((i + 1) < orderByConditionFields.length) {
1233 if (orderByComparator.isAscending() ^ previous) {
1234 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1235 }
1236 else {
1237 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1238 }
1239 }
1240 else {
1241 if (orderByComparator.isAscending() ^ previous) {
1242 query.append(WHERE_GREATER_THAN);
1243 }
1244 else {
1245 query.append(WHERE_LESSER_THAN);
1246 }
1247 }
1248 }
1249
1250 query.append(ORDER_BY_CLAUSE);
1251
1252 String[] orderByFields = orderByComparator.getOrderByFields();
1253
1254 for (int i = 0; i < orderByFields.length; i++) {
1255 query.append(_ORDER_BY_ENTITY_ALIAS);
1256 query.append(orderByFields[i]);
1257
1258 if ((i + 1) < orderByFields.length) {
1259 if (orderByComparator.isAscending() ^ previous) {
1260 query.append(ORDER_BY_ASC_HAS_NEXT);
1261 }
1262 else {
1263 query.append(ORDER_BY_DESC_HAS_NEXT);
1264 }
1265 }
1266 else {
1267 if (orderByComparator.isAscending() ^ previous) {
1268 query.append(ORDER_BY_ASC);
1269 }
1270 else {
1271 query.append(ORDER_BY_DESC);
1272 }
1273 }
1274 }
1275 }
1276
1277 String sql = query.toString();
1278
1279 Query q = session.createQuery(sql);
1280
1281 q.setFirstResult(0);
1282 q.setMaxResults(2);
1283
1284 QueryPos qPos = QueryPos.getInstance(q);
1285
1286 qPos.add(groupId);
1287
1288 if (orderByComparator != null) {
1289 Object[] values = orderByComparator.getOrderByConditionValues(userGroupGroupRole);
1290
1291 for (Object value : values) {
1292 qPos.add(value);
1293 }
1294 }
1295
1296 List<UserGroupGroupRole> list = q.list();
1297
1298 if (list.size() == 2) {
1299 return list.get(1);
1300 }
1301 else {
1302 return null;
1303 }
1304 }
1305
1306
1313 public List<UserGroupGroupRole> findByRoleId(long roleId)
1314 throws SystemException {
1315 return findByRoleId(roleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1316 }
1317
1318
1331 public List<UserGroupGroupRole> findByRoleId(long roleId, int start, int end)
1332 throws SystemException {
1333 return findByRoleId(roleId, start, end, null);
1334 }
1335
1336
1350 public List<UserGroupGroupRole> findByRoleId(long roleId, int start,
1351 int end, OrderByComparator orderByComparator) throws SystemException {
1352 FinderPath finderPath = null;
1353 Object[] finderArgs = null;
1354
1355 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1356 (orderByComparator == null)) {
1357 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ROLEID;
1358 finderArgs = new Object[] { roleId };
1359 }
1360 else {
1361 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_ROLEID;
1362 finderArgs = new Object[] { roleId, start, end, orderByComparator };
1363 }
1364
1365 List<UserGroupGroupRole> list = (List<UserGroupGroupRole>)FinderCacheUtil.getResult(finderPath,
1366 finderArgs, this);
1367
1368 if (list == null) {
1369 StringBundler query = null;
1370
1371 if (orderByComparator != null) {
1372 query = new StringBundler(3 +
1373 (orderByComparator.getOrderByFields().length * 3));
1374 }
1375 else {
1376 query = new StringBundler(2);
1377 }
1378
1379 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
1380
1381 query.append(_FINDER_COLUMN_ROLEID_ROLEID_2);
1382
1383 if (orderByComparator != null) {
1384 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1385 orderByComparator);
1386 }
1387
1388 String sql = query.toString();
1389
1390 Session session = null;
1391
1392 try {
1393 session = openSession();
1394
1395 Query q = session.createQuery(sql);
1396
1397 QueryPos qPos = QueryPos.getInstance(q);
1398
1399 qPos.add(roleId);
1400
1401 list = (List<UserGroupGroupRole>)QueryUtil.list(q,
1402 getDialect(), start, end);
1403 }
1404 catch (Exception e) {
1405 throw processException(e);
1406 }
1407 finally {
1408 if (list == null) {
1409 FinderCacheUtil.removeResult(finderPath, finderArgs);
1410 }
1411 else {
1412 cacheResult(list);
1413
1414 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1415 }
1416
1417 closeSession(session);
1418 }
1419 }
1420
1421 return list;
1422 }
1423
1424
1437 public UserGroupGroupRole findByRoleId_First(long roleId,
1438 OrderByComparator orderByComparator)
1439 throws NoSuchUserGroupGroupRoleException, SystemException {
1440 List<UserGroupGroupRole> list = findByRoleId(roleId, 0, 1,
1441 orderByComparator);
1442
1443 if (list.isEmpty()) {
1444 StringBundler msg = new StringBundler(4);
1445
1446 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1447
1448 msg.append("roleId=");
1449 msg.append(roleId);
1450
1451 msg.append(StringPool.CLOSE_CURLY_BRACE);
1452
1453 throw new NoSuchUserGroupGroupRoleException(msg.toString());
1454 }
1455 else {
1456 return list.get(0);
1457 }
1458 }
1459
1460
1473 public UserGroupGroupRole findByRoleId_Last(long roleId,
1474 OrderByComparator orderByComparator)
1475 throws NoSuchUserGroupGroupRoleException, SystemException {
1476 int count = countByRoleId(roleId);
1477
1478 List<UserGroupGroupRole> list = findByRoleId(roleId, count - 1, count,
1479 orderByComparator);
1480
1481 if (list.isEmpty()) {
1482 StringBundler msg = new StringBundler(4);
1483
1484 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1485
1486 msg.append("roleId=");
1487 msg.append(roleId);
1488
1489 msg.append(StringPool.CLOSE_CURLY_BRACE);
1490
1491 throw new NoSuchUserGroupGroupRoleException(msg.toString());
1492 }
1493 else {
1494 return list.get(0);
1495 }
1496 }
1497
1498
1512 public UserGroupGroupRole[] findByRoleId_PrevAndNext(
1513 UserGroupGroupRolePK userGroupGroupRolePK, long roleId,
1514 OrderByComparator orderByComparator)
1515 throws NoSuchUserGroupGroupRoleException, SystemException {
1516 UserGroupGroupRole userGroupGroupRole = findByPrimaryKey(userGroupGroupRolePK);
1517
1518 Session session = null;
1519
1520 try {
1521 session = openSession();
1522
1523 UserGroupGroupRole[] array = new UserGroupGroupRoleImpl[3];
1524
1525 array[0] = getByRoleId_PrevAndNext(session, userGroupGroupRole,
1526 roleId, orderByComparator, true);
1527
1528 array[1] = userGroupGroupRole;
1529
1530 array[2] = getByRoleId_PrevAndNext(session, userGroupGroupRole,
1531 roleId, orderByComparator, false);
1532
1533 return array;
1534 }
1535 catch (Exception e) {
1536 throw processException(e);
1537 }
1538 finally {
1539 closeSession(session);
1540 }
1541 }
1542
1543 protected UserGroupGroupRole getByRoleId_PrevAndNext(Session session,
1544 UserGroupGroupRole userGroupGroupRole, long roleId,
1545 OrderByComparator orderByComparator, boolean previous) {
1546 StringBundler query = null;
1547
1548 if (orderByComparator != null) {
1549 query = new StringBundler(6 +
1550 (orderByComparator.getOrderByFields().length * 6));
1551 }
1552 else {
1553 query = new StringBundler(3);
1554 }
1555
1556 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
1557
1558 query.append(_FINDER_COLUMN_ROLEID_ROLEID_2);
1559
1560 if (orderByComparator != null) {
1561 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1562
1563 if (orderByConditionFields.length > 0) {
1564 query.append(WHERE_AND);
1565 }
1566
1567 for (int i = 0; i < orderByConditionFields.length; i++) {
1568 query.append(_ORDER_BY_ENTITY_ALIAS);
1569 query.append(orderByConditionFields[i]);
1570
1571 if ((i + 1) < orderByConditionFields.length) {
1572 if (orderByComparator.isAscending() ^ previous) {
1573 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1574 }
1575 else {
1576 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1577 }
1578 }
1579 else {
1580 if (orderByComparator.isAscending() ^ previous) {
1581 query.append(WHERE_GREATER_THAN);
1582 }
1583 else {
1584 query.append(WHERE_LESSER_THAN);
1585 }
1586 }
1587 }
1588
1589 query.append(ORDER_BY_CLAUSE);
1590
1591 String[] orderByFields = orderByComparator.getOrderByFields();
1592
1593 for (int i = 0; i < orderByFields.length; i++) {
1594 query.append(_ORDER_BY_ENTITY_ALIAS);
1595 query.append(orderByFields[i]);
1596
1597 if ((i + 1) < orderByFields.length) {
1598 if (orderByComparator.isAscending() ^ previous) {
1599 query.append(ORDER_BY_ASC_HAS_NEXT);
1600 }
1601 else {
1602 query.append(ORDER_BY_DESC_HAS_NEXT);
1603 }
1604 }
1605 else {
1606 if (orderByComparator.isAscending() ^ previous) {
1607 query.append(ORDER_BY_ASC);
1608 }
1609 else {
1610 query.append(ORDER_BY_DESC);
1611 }
1612 }
1613 }
1614 }
1615
1616 String sql = query.toString();
1617
1618 Query q = session.createQuery(sql);
1619
1620 q.setFirstResult(0);
1621 q.setMaxResults(2);
1622
1623 QueryPos qPos = QueryPos.getInstance(q);
1624
1625 qPos.add(roleId);
1626
1627 if (orderByComparator != null) {
1628 Object[] values = orderByComparator.getOrderByConditionValues(userGroupGroupRole);
1629
1630 for (Object value : values) {
1631 qPos.add(value);
1632 }
1633 }
1634
1635 List<UserGroupGroupRole> list = q.list();
1636
1637 if (list.size() == 2) {
1638 return list.get(1);
1639 }
1640 else {
1641 return null;
1642 }
1643 }
1644
1645
1653 public List<UserGroupGroupRole> findByU_G(long userGroupId, long groupId)
1654 throws SystemException {
1655 return findByU_G(userGroupId, groupId, QueryUtil.ALL_POS,
1656 QueryUtil.ALL_POS, null);
1657 }
1658
1659
1673 public List<UserGroupGroupRole> findByU_G(long userGroupId, long groupId,
1674 int start, int end) throws SystemException {
1675 return findByU_G(userGroupId, groupId, start, end, null);
1676 }
1677
1678
1693 public List<UserGroupGroupRole> findByU_G(long userGroupId, long groupId,
1694 int start, int end, OrderByComparator orderByComparator)
1695 throws SystemException {
1696 FinderPath finderPath = null;
1697 Object[] finderArgs = null;
1698
1699 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1700 (orderByComparator == null)) {
1701 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_G;
1702 finderArgs = new Object[] { userGroupId, groupId };
1703 }
1704 else {
1705 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_G;
1706 finderArgs = new Object[] {
1707 userGroupId, groupId,
1708
1709 start, end, orderByComparator
1710 };
1711 }
1712
1713 List<UserGroupGroupRole> list = (List<UserGroupGroupRole>)FinderCacheUtil.getResult(finderPath,
1714 finderArgs, this);
1715
1716 if (list == null) {
1717 StringBundler query = null;
1718
1719 if (orderByComparator != null) {
1720 query = new StringBundler(4 +
1721 (orderByComparator.getOrderByFields().length * 3));
1722 }
1723 else {
1724 query = new StringBundler(3);
1725 }
1726
1727 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
1728
1729 query.append(_FINDER_COLUMN_U_G_USERGROUPID_2);
1730
1731 query.append(_FINDER_COLUMN_U_G_GROUPID_2);
1732
1733 if (orderByComparator != null) {
1734 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1735 orderByComparator);
1736 }
1737
1738 String sql = query.toString();
1739
1740 Session session = null;
1741
1742 try {
1743 session = openSession();
1744
1745 Query q = session.createQuery(sql);
1746
1747 QueryPos qPos = QueryPos.getInstance(q);
1748
1749 qPos.add(userGroupId);
1750
1751 qPos.add(groupId);
1752
1753 list = (List<UserGroupGroupRole>)QueryUtil.list(q,
1754 getDialect(), start, end);
1755 }
1756 catch (Exception e) {
1757 throw processException(e);
1758 }
1759 finally {
1760 if (list == null) {
1761 FinderCacheUtil.removeResult(finderPath, finderArgs);
1762 }
1763 else {
1764 cacheResult(list);
1765
1766 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1767 }
1768
1769 closeSession(session);
1770 }
1771 }
1772
1773 return list;
1774 }
1775
1776
1790 public UserGroupGroupRole findByU_G_First(long userGroupId, long groupId,
1791 OrderByComparator orderByComparator)
1792 throws NoSuchUserGroupGroupRoleException, SystemException {
1793 List<UserGroupGroupRole> list = findByU_G(userGroupId, groupId, 0, 1,
1794 orderByComparator);
1795
1796 if (list.isEmpty()) {
1797 StringBundler msg = new StringBundler(6);
1798
1799 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1800
1801 msg.append("userGroupId=");
1802 msg.append(userGroupId);
1803
1804 msg.append(", groupId=");
1805 msg.append(groupId);
1806
1807 msg.append(StringPool.CLOSE_CURLY_BRACE);
1808
1809 throw new NoSuchUserGroupGroupRoleException(msg.toString());
1810 }
1811 else {
1812 return list.get(0);
1813 }
1814 }
1815
1816
1830 public UserGroupGroupRole findByU_G_Last(long userGroupId, long groupId,
1831 OrderByComparator orderByComparator)
1832 throws NoSuchUserGroupGroupRoleException, SystemException {
1833 int count = countByU_G(userGroupId, groupId);
1834
1835 List<UserGroupGroupRole> list = findByU_G(userGroupId, groupId,
1836 count - 1, count, orderByComparator);
1837
1838 if (list.isEmpty()) {
1839 StringBundler msg = new StringBundler(6);
1840
1841 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1842
1843 msg.append("userGroupId=");
1844 msg.append(userGroupId);
1845
1846 msg.append(", groupId=");
1847 msg.append(groupId);
1848
1849 msg.append(StringPool.CLOSE_CURLY_BRACE);
1850
1851 throw new NoSuchUserGroupGroupRoleException(msg.toString());
1852 }
1853 else {
1854 return list.get(0);
1855 }
1856 }
1857
1858
1873 public UserGroupGroupRole[] findByU_G_PrevAndNext(
1874 UserGroupGroupRolePK userGroupGroupRolePK, long userGroupId,
1875 long groupId, OrderByComparator orderByComparator)
1876 throws NoSuchUserGroupGroupRoleException, SystemException {
1877 UserGroupGroupRole userGroupGroupRole = findByPrimaryKey(userGroupGroupRolePK);
1878
1879 Session session = null;
1880
1881 try {
1882 session = openSession();
1883
1884 UserGroupGroupRole[] array = new UserGroupGroupRoleImpl[3];
1885
1886 array[0] = getByU_G_PrevAndNext(session, userGroupGroupRole,
1887 userGroupId, groupId, orderByComparator, true);
1888
1889 array[1] = userGroupGroupRole;
1890
1891 array[2] = getByU_G_PrevAndNext(session, userGroupGroupRole,
1892 userGroupId, groupId, orderByComparator, false);
1893
1894 return array;
1895 }
1896 catch (Exception e) {
1897 throw processException(e);
1898 }
1899 finally {
1900 closeSession(session);
1901 }
1902 }
1903
1904 protected UserGroupGroupRole getByU_G_PrevAndNext(Session session,
1905 UserGroupGroupRole userGroupGroupRole, long userGroupId, long groupId,
1906 OrderByComparator orderByComparator, boolean previous) {
1907 StringBundler query = null;
1908
1909 if (orderByComparator != null) {
1910 query = new StringBundler(6 +
1911 (orderByComparator.getOrderByFields().length * 6));
1912 }
1913 else {
1914 query = new StringBundler(3);
1915 }
1916
1917 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
1918
1919 query.append(_FINDER_COLUMN_U_G_USERGROUPID_2);
1920
1921 query.append(_FINDER_COLUMN_U_G_GROUPID_2);
1922
1923 if (orderByComparator != null) {
1924 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1925
1926 if (orderByConditionFields.length > 0) {
1927 query.append(WHERE_AND);
1928 }
1929
1930 for (int i = 0; i < orderByConditionFields.length; i++) {
1931 query.append(_ORDER_BY_ENTITY_ALIAS);
1932 query.append(orderByConditionFields[i]);
1933
1934 if ((i + 1) < orderByConditionFields.length) {
1935 if (orderByComparator.isAscending() ^ previous) {
1936 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1937 }
1938 else {
1939 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1940 }
1941 }
1942 else {
1943 if (orderByComparator.isAscending() ^ previous) {
1944 query.append(WHERE_GREATER_THAN);
1945 }
1946 else {
1947 query.append(WHERE_LESSER_THAN);
1948 }
1949 }
1950 }
1951
1952 query.append(ORDER_BY_CLAUSE);
1953
1954 String[] orderByFields = orderByComparator.getOrderByFields();
1955
1956 for (int i = 0; i < orderByFields.length; i++) {
1957 query.append(_ORDER_BY_ENTITY_ALIAS);
1958 query.append(orderByFields[i]);
1959
1960 if ((i + 1) < orderByFields.length) {
1961 if (orderByComparator.isAscending() ^ previous) {
1962 query.append(ORDER_BY_ASC_HAS_NEXT);
1963 }
1964 else {
1965 query.append(ORDER_BY_DESC_HAS_NEXT);
1966 }
1967 }
1968 else {
1969 if (orderByComparator.isAscending() ^ previous) {
1970 query.append(ORDER_BY_ASC);
1971 }
1972 else {
1973 query.append(ORDER_BY_DESC);
1974 }
1975 }
1976 }
1977 }
1978
1979 String sql = query.toString();
1980
1981 Query q = session.createQuery(sql);
1982
1983 q.setFirstResult(0);
1984 q.setMaxResults(2);
1985
1986 QueryPos qPos = QueryPos.getInstance(q);
1987
1988 qPos.add(userGroupId);
1989
1990 qPos.add(groupId);
1991
1992 if (orderByComparator != null) {
1993 Object[] values = orderByComparator.getOrderByConditionValues(userGroupGroupRole);
1994
1995 for (Object value : values) {
1996 qPos.add(value);
1997 }
1998 }
1999
2000 List<UserGroupGroupRole> list = q.list();
2001
2002 if (list.size() == 2) {
2003 return list.get(1);
2004 }
2005 else {
2006 return null;
2007 }
2008 }
2009
2010
2018 public List<UserGroupGroupRole> findByG_R(long groupId, long roleId)
2019 throws SystemException {
2020 return findByG_R(groupId, roleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2021 null);
2022 }
2023
2024
2038 public List<UserGroupGroupRole> findByG_R(long groupId, long roleId,
2039 int start, int end) throws SystemException {
2040 return findByG_R(groupId, roleId, start, end, null);
2041 }
2042
2043
2058 public List<UserGroupGroupRole> findByG_R(long groupId, long roleId,
2059 int start, int end, OrderByComparator orderByComparator)
2060 throws SystemException {
2061 FinderPath finderPath = null;
2062 Object[] finderArgs = null;
2063
2064 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2065 (orderByComparator == null)) {
2066 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_R;
2067 finderArgs = new Object[] { groupId, roleId };
2068 }
2069 else {
2070 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_R;
2071 finderArgs = new Object[] {
2072 groupId, roleId,
2073
2074 start, end, orderByComparator
2075 };
2076 }
2077
2078 List<UserGroupGroupRole> list = (List<UserGroupGroupRole>)FinderCacheUtil.getResult(finderPath,
2079 finderArgs, this);
2080
2081 if (list == null) {
2082 StringBundler query = null;
2083
2084 if (orderByComparator != null) {
2085 query = new StringBundler(4 +
2086 (orderByComparator.getOrderByFields().length * 3));
2087 }
2088 else {
2089 query = new StringBundler(3);
2090 }
2091
2092 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
2093
2094 query.append(_FINDER_COLUMN_G_R_GROUPID_2);
2095
2096 query.append(_FINDER_COLUMN_G_R_ROLEID_2);
2097
2098 if (orderByComparator != null) {
2099 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2100 orderByComparator);
2101 }
2102
2103 String sql = query.toString();
2104
2105 Session session = null;
2106
2107 try {
2108 session = openSession();
2109
2110 Query q = session.createQuery(sql);
2111
2112 QueryPos qPos = QueryPos.getInstance(q);
2113
2114 qPos.add(groupId);
2115
2116 qPos.add(roleId);
2117
2118 list = (List<UserGroupGroupRole>)QueryUtil.list(q,
2119 getDialect(), start, end);
2120 }
2121 catch (Exception e) {
2122 throw processException(e);
2123 }
2124 finally {
2125 if (list == null) {
2126 FinderCacheUtil.removeResult(finderPath, finderArgs);
2127 }
2128 else {
2129 cacheResult(list);
2130
2131 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2132 }
2133
2134 closeSession(session);
2135 }
2136 }
2137
2138 return list;
2139 }
2140
2141
2155 public UserGroupGroupRole findByG_R_First(long groupId, long roleId,
2156 OrderByComparator orderByComparator)
2157 throws NoSuchUserGroupGroupRoleException, SystemException {
2158 List<UserGroupGroupRole> list = findByG_R(groupId, roleId, 0, 1,
2159 orderByComparator);
2160
2161 if (list.isEmpty()) {
2162 StringBundler msg = new StringBundler(6);
2163
2164 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2165
2166 msg.append("groupId=");
2167 msg.append(groupId);
2168
2169 msg.append(", roleId=");
2170 msg.append(roleId);
2171
2172 msg.append(StringPool.CLOSE_CURLY_BRACE);
2173
2174 throw new NoSuchUserGroupGroupRoleException(msg.toString());
2175 }
2176 else {
2177 return list.get(0);
2178 }
2179 }
2180
2181
2195 public UserGroupGroupRole findByG_R_Last(long groupId, long roleId,
2196 OrderByComparator orderByComparator)
2197 throws NoSuchUserGroupGroupRoleException, SystemException {
2198 int count = countByG_R(groupId, roleId);
2199
2200 List<UserGroupGroupRole> list = findByG_R(groupId, roleId, count - 1,
2201 count, orderByComparator);
2202
2203 if (list.isEmpty()) {
2204 StringBundler msg = new StringBundler(6);
2205
2206 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2207
2208 msg.append("groupId=");
2209 msg.append(groupId);
2210
2211 msg.append(", roleId=");
2212 msg.append(roleId);
2213
2214 msg.append(StringPool.CLOSE_CURLY_BRACE);
2215
2216 throw new NoSuchUserGroupGroupRoleException(msg.toString());
2217 }
2218 else {
2219 return list.get(0);
2220 }
2221 }
2222
2223
2238 public UserGroupGroupRole[] findByG_R_PrevAndNext(
2239 UserGroupGroupRolePK userGroupGroupRolePK, long groupId, long roleId,
2240 OrderByComparator orderByComparator)
2241 throws NoSuchUserGroupGroupRoleException, SystemException {
2242 UserGroupGroupRole userGroupGroupRole = findByPrimaryKey(userGroupGroupRolePK);
2243
2244 Session session = null;
2245
2246 try {
2247 session = openSession();
2248
2249 UserGroupGroupRole[] array = new UserGroupGroupRoleImpl[3];
2250
2251 array[0] = getByG_R_PrevAndNext(session, userGroupGroupRole,
2252 groupId, roleId, orderByComparator, true);
2253
2254 array[1] = userGroupGroupRole;
2255
2256 array[2] = getByG_R_PrevAndNext(session, userGroupGroupRole,
2257 groupId, roleId, orderByComparator, false);
2258
2259 return array;
2260 }
2261 catch (Exception e) {
2262 throw processException(e);
2263 }
2264 finally {
2265 closeSession(session);
2266 }
2267 }
2268
2269 protected UserGroupGroupRole getByG_R_PrevAndNext(Session session,
2270 UserGroupGroupRole userGroupGroupRole, long groupId, long roleId,
2271 OrderByComparator orderByComparator, boolean previous) {
2272 StringBundler query = null;
2273
2274 if (orderByComparator != null) {
2275 query = new StringBundler(6 +
2276 (orderByComparator.getOrderByFields().length * 6));
2277 }
2278 else {
2279 query = new StringBundler(3);
2280 }
2281
2282 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
2283
2284 query.append(_FINDER_COLUMN_G_R_GROUPID_2);
2285
2286 query.append(_FINDER_COLUMN_G_R_ROLEID_2);
2287
2288 if (orderByComparator != null) {
2289 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2290
2291 if (orderByConditionFields.length > 0) {
2292 query.append(WHERE_AND);
2293 }
2294
2295 for (int i = 0; i < orderByConditionFields.length; i++) {
2296 query.append(_ORDER_BY_ENTITY_ALIAS);
2297 query.append(orderByConditionFields[i]);
2298
2299 if ((i + 1) < orderByConditionFields.length) {
2300 if (orderByComparator.isAscending() ^ previous) {
2301 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2302 }
2303 else {
2304 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2305 }
2306 }
2307 else {
2308 if (orderByComparator.isAscending() ^ previous) {
2309 query.append(WHERE_GREATER_THAN);
2310 }
2311 else {
2312 query.append(WHERE_LESSER_THAN);
2313 }
2314 }
2315 }
2316
2317 query.append(ORDER_BY_CLAUSE);
2318
2319 String[] orderByFields = orderByComparator.getOrderByFields();
2320
2321 for (int i = 0; i < orderByFields.length; i++) {
2322 query.append(_ORDER_BY_ENTITY_ALIAS);
2323 query.append(orderByFields[i]);
2324
2325 if ((i + 1) < orderByFields.length) {
2326 if (orderByComparator.isAscending() ^ previous) {
2327 query.append(ORDER_BY_ASC_HAS_NEXT);
2328 }
2329 else {
2330 query.append(ORDER_BY_DESC_HAS_NEXT);
2331 }
2332 }
2333 else {
2334 if (orderByComparator.isAscending() ^ previous) {
2335 query.append(ORDER_BY_ASC);
2336 }
2337 else {
2338 query.append(ORDER_BY_DESC);
2339 }
2340 }
2341 }
2342 }
2343
2344 String sql = query.toString();
2345
2346 Query q = session.createQuery(sql);
2347
2348 q.setFirstResult(0);
2349 q.setMaxResults(2);
2350
2351 QueryPos qPos = QueryPos.getInstance(q);
2352
2353 qPos.add(groupId);
2354
2355 qPos.add(roleId);
2356
2357 if (orderByComparator != null) {
2358 Object[] values = orderByComparator.getOrderByConditionValues(userGroupGroupRole);
2359
2360 for (Object value : values) {
2361 qPos.add(value);
2362 }
2363 }
2364
2365 List<UserGroupGroupRole> list = q.list();
2366
2367 if (list.size() == 2) {
2368 return list.get(1);
2369 }
2370 else {
2371 return null;
2372 }
2373 }
2374
2375
2381 public List<UserGroupGroupRole> findAll() throws SystemException {
2382 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2383 }
2384
2385
2397 public List<UserGroupGroupRole> findAll(int start, int end)
2398 throws SystemException {
2399 return findAll(start, end, null);
2400 }
2401
2402
2415 public List<UserGroupGroupRole> findAll(int start, int end,
2416 OrderByComparator orderByComparator) throws SystemException {
2417 FinderPath finderPath = null;
2418 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2419
2420 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2421 (orderByComparator == null)) {
2422 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2423 finderArgs = FINDER_ARGS_EMPTY;
2424 }
2425 else {
2426 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2427 finderArgs = new Object[] { start, end, orderByComparator };
2428 }
2429
2430 List<UserGroupGroupRole> list = (List<UserGroupGroupRole>)FinderCacheUtil.getResult(finderPath,
2431 finderArgs, this);
2432
2433 if (list == null) {
2434 StringBundler query = null;
2435 String sql = null;
2436
2437 if (orderByComparator != null) {
2438 query = new StringBundler(2 +
2439 (orderByComparator.getOrderByFields().length * 3));
2440
2441 query.append(_SQL_SELECT_USERGROUPGROUPROLE);
2442
2443 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2444 orderByComparator);
2445
2446 sql = query.toString();
2447 }
2448 else {
2449 sql = _SQL_SELECT_USERGROUPGROUPROLE;
2450 }
2451
2452 Session session = null;
2453
2454 try {
2455 session = openSession();
2456
2457 Query q = session.createQuery(sql);
2458
2459 if (orderByComparator == null) {
2460 list = (List<UserGroupGroupRole>)QueryUtil.list(q,
2461 getDialect(), start, end, false);
2462
2463 Collections.sort(list);
2464 }
2465 else {
2466 list = (List<UserGroupGroupRole>)QueryUtil.list(q,
2467 getDialect(), start, end);
2468 }
2469 }
2470 catch (Exception e) {
2471 throw processException(e);
2472 }
2473 finally {
2474 if (list == null) {
2475 FinderCacheUtil.removeResult(finderPath, finderArgs);
2476 }
2477 else {
2478 cacheResult(list);
2479
2480 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2481 }
2482
2483 closeSession(session);
2484 }
2485 }
2486
2487 return list;
2488 }
2489
2490
2496 public void removeByUserGroupId(long userGroupId) throws SystemException {
2497 for (UserGroupGroupRole userGroupGroupRole : findByUserGroupId(
2498 userGroupId)) {
2499 remove(userGroupGroupRole);
2500 }
2501 }
2502
2503
2509 public void removeByGroupId(long groupId) throws SystemException {
2510 for (UserGroupGroupRole userGroupGroupRole : findByGroupId(groupId)) {
2511 remove(userGroupGroupRole);
2512 }
2513 }
2514
2515
2521 public void removeByRoleId(long roleId) throws SystemException {
2522 for (UserGroupGroupRole userGroupGroupRole : findByRoleId(roleId)) {
2523 remove(userGroupGroupRole);
2524 }
2525 }
2526
2527
2534 public void removeByU_G(long userGroupId, long groupId)
2535 throws SystemException {
2536 for (UserGroupGroupRole userGroupGroupRole : findByU_G(userGroupId,
2537 groupId)) {
2538 remove(userGroupGroupRole);
2539 }
2540 }
2541
2542
2549 public void removeByG_R(long groupId, long roleId)
2550 throws SystemException {
2551 for (UserGroupGroupRole userGroupGroupRole : findByG_R(groupId, roleId)) {
2552 remove(userGroupGroupRole);
2553 }
2554 }
2555
2556
2561 public void removeAll() throws SystemException {
2562 for (UserGroupGroupRole userGroupGroupRole : findAll()) {
2563 remove(userGroupGroupRole);
2564 }
2565 }
2566
2567
2574 public int countByUserGroupId(long userGroupId) throws SystemException {
2575 Object[] finderArgs = new Object[] { userGroupId };
2576
2577 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERGROUPID,
2578 finderArgs, this);
2579
2580 if (count == null) {
2581 StringBundler query = new StringBundler(2);
2582
2583 query.append(_SQL_COUNT_USERGROUPGROUPROLE_WHERE);
2584
2585 query.append(_FINDER_COLUMN_USERGROUPID_USERGROUPID_2);
2586
2587 String sql = query.toString();
2588
2589 Session session = null;
2590
2591 try {
2592 session = openSession();
2593
2594 Query q = session.createQuery(sql);
2595
2596 QueryPos qPos = QueryPos.getInstance(q);
2597
2598 qPos.add(userGroupId);
2599
2600 count = (Long)q.uniqueResult();
2601 }
2602 catch (Exception e) {
2603 throw processException(e);
2604 }
2605 finally {
2606 if (count == null) {
2607 count = Long.valueOf(0);
2608 }
2609
2610 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERGROUPID,
2611 finderArgs, count);
2612
2613 closeSession(session);
2614 }
2615 }
2616
2617 return count.intValue();
2618 }
2619
2620
2627 public int countByGroupId(long groupId) throws SystemException {
2628 Object[] finderArgs = new Object[] { groupId };
2629
2630 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2631 finderArgs, this);
2632
2633 if (count == null) {
2634 StringBundler query = new StringBundler(2);
2635
2636 query.append(_SQL_COUNT_USERGROUPGROUPROLE_WHERE);
2637
2638 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2639
2640 String sql = query.toString();
2641
2642 Session session = null;
2643
2644 try {
2645 session = openSession();
2646
2647 Query q = session.createQuery(sql);
2648
2649 QueryPos qPos = QueryPos.getInstance(q);
2650
2651 qPos.add(groupId);
2652
2653 count = (Long)q.uniqueResult();
2654 }
2655 catch (Exception e) {
2656 throw processException(e);
2657 }
2658 finally {
2659 if (count == null) {
2660 count = Long.valueOf(0);
2661 }
2662
2663 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2664 finderArgs, count);
2665
2666 closeSession(session);
2667 }
2668 }
2669
2670 return count.intValue();
2671 }
2672
2673
2680 public int countByRoleId(long roleId) throws SystemException {
2681 Object[] finderArgs = new Object[] { roleId };
2682
2683 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ROLEID,
2684 finderArgs, this);
2685
2686 if (count == null) {
2687 StringBundler query = new StringBundler(2);
2688
2689 query.append(_SQL_COUNT_USERGROUPGROUPROLE_WHERE);
2690
2691 query.append(_FINDER_COLUMN_ROLEID_ROLEID_2);
2692
2693 String sql = query.toString();
2694
2695 Session session = null;
2696
2697 try {
2698 session = openSession();
2699
2700 Query q = session.createQuery(sql);
2701
2702 QueryPos qPos = QueryPos.getInstance(q);
2703
2704 qPos.add(roleId);
2705
2706 count = (Long)q.uniqueResult();
2707 }
2708 catch (Exception e) {
2709 throw processException(e);
2710 }
2711 finally {
2712 if (count == null) {
2713 count = Long.valueOf(0);
2714 }
2715
2716 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ROLEID,
2717 finderArgs, count);
2718
2719 closeSession(session);
2720 }
2721 }
2722
2723 return count.intValue();
2724 }
2725
2726
2734 public int countByU_G(long userGroupId, long groupId)
2735 throws SystemException {
2736 Object[] finderArgs = new Object[] { userGroupId, groupId };
2737
2738 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_G,
2739 finderArgs, this);
2740
2741 if (count == null) {
2742 StringBundler query = new StringBundler(3);
2743
2744 query.append(_SQL_COUNT_USERGROUPGROUPROLE_WHERE);
2745
2746 query.append(_FINDER_COLUMN_U_G_USERGROUPID_2);
2747
2748 query.append(_FINDER_COLUMN_U_G_GROUPID_2);
2749
2750 String sql = query.toString();
2751
2752 Session session = null;
2753
2754 try {
2755 session = openSession();
2756
2757 Query q = session.createQuery(sql);
2758
2759 QueryPos qPos = QueryPos.getInstance(q);
2760
2761 qPos.add(userGroupId);
2762
2763 qPos.add(groupId);
2764
2765 count = (Long)q.uniqueResult();
2766 }
2767 catch (Exception e) {
2768 throw processException(e);
2769 }
2770 finally {
2771 if (count == null) {
2772 count = Long.valueOf(0);
2773 }
2774
2775 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_G, finderArgs,
2776 count);
2777
2778 closeSession(session);
2779 }
2780 }
2781
2782 return count.intValue();
2783 }
2784
2785
2793 public int countByG_R(long groupId, long roleId) throws SystemException {
2794 Object[] finderArgs = new Object[] { groupId, roleId };
2795
2796 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_R,
2797 finderArgs, this);
2798
2799 if (count == null) {
2800 StringBundler query = new StringBundler(3);
2801
2802 query.append(_SQL_COUNT_USERGROUPGROUPROLE_WHERE);
2803
2804 query.append(_FINDER_COLUMN_G_R_GROUPID_2);
2805
2806 query.append(_FINDER_COLUMN_G_R_ROLEID_2);
2807
2808 String sql = query.toString();
2809
2810 Session session = null;
2811
2812 try {
2813 session = openSession();
2814
2815 Query q = session.createQuery(sql);
2816
2817 QueryPos qPos = QueryPos.getInstance(q);
2818
2819 qPos.add(groupId);
2820
2821 qPos.add(roleId);
2822
2823 count = (Long)q.uniqueResult();
2824 }
2825 catch (Exception e) {
2826 throw processException(e);
2827 }
2828 finally {
2829 if (count == null) {
2830 count = Long.valueOf(0);
2831 }
2832
2833 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_R, finderArgs,
2834 count);
2835
2836 closeSession(session);
2837 }
2838 }
2839
2840 return count.intValue();
2841 }
2842
2843
2849 public int countAll() throws SystemException {
2850 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2851 FINDER_ARGS_EMPTY, this);
2852
2853 if (count == null) {
2854 Session session = null;
2855
2856 try {
2857 session = openSession();
2858
2859 Query q = session.createQuery(_SQL_COUNT_USERGROUPGROUPROLE);
2860
2861 count = (Long)q.uniqueResult();
2862 }
2863 catch (Exception e) {
2864 throw processException(e);
2865 }
2866 finally {
2867 if (count == null) {
2868 count = Long.valueOf(0);
2869 }
2870
2871 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2872 FINDER_ARGS_EMPTY, count);
2873
2874 closeSession(session);
2875 }
2876 }
2877
2878 return count.intValue();
2879 }
2880
2881
2884 public void afterPropertiesSet() {
2885 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2886 com.liferay.portal.util.PropsUtil.get(
2887 "value.object.listener.com.liferay.portal.model.UserGroupGroupRole")));
2888
2889 if (listenerClassNames.length > 0) {
2890 try {
2891 List<ModelListener<UserGroupGroupRole>> listenersList = new ArrayList<ModelListener<UserGroupGroupRole>>();
2892
2893 for (String listenerClassName : listenerClassNames) {
2894 listenersList.add((ModelListener<UserGroupGroupRole>)InstanceFactory.newInstance(
2895 listenerClassName));
2896 }
2897
2898 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2899 }
2900 catch (Exception e) {
2901 _log.error(e);
2902 }
2903 }
2904 }
2905
2906 public void destroy() {
2907 EntityCacheUtil.removeCache(UserGroupGroupRoleImpl.class.getName());
2908 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2909 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2910 }
2911
2912 @BeanReference(type = AccountPersistence.class)
2913 protected AccountPersistence accountPersistence;
2914 @BeanReference(type = AddressPersistence.class)
2915 protected AddressPersistence addressPersistence;
2916 @BeanReference(type = BrowserTrackerPersistence.class)
2917 protected BrowserTrackerPersistence browserTrackerPersistence;
2918 @BeanReference(type = ClassNamePersistence.class)
2919 protected ClassNamePersistence classNamePersistence;
2920 @BeanReference(type = ClusterGroupPersistence.class)
2921 protected ClusterGroupPersistence clusterGroupPersistence;
2922 @BeanReference(type = CompanyPersistence.class)
2923 protected CompanyPersistence companyPersistence;
2924 @BeanReference(type = ContactPersistence.class)
2925 protected ContactPersistence contactPersistence;
2926 @BeanReference(type = CountryPersistence.class)
2927 protected CountryPersistence countryPersistence;
2928 @BeanReference(type = EmailAddressPersistence.class)
2929 protected EmailAddressPersistence emailAddressPersistence;
2930 @BeanReference(type = GroupPersistence.class)
2931 protected GroupPersistence groupPersistence;
2932 @BeanReference(type = ImagePersistence.class)
2933 protected ImagePersistence imagePersistence;
2934 @BeanReference(type = LayoutPersistence.class)
2935 protected LayoutPersistence layoutPersistence;
2936 @BeanReference(type = LayoutBranchPersistence.class)
2937 protected LayoutBranchPersistence layoutBranchPersistence;
2938 @BeanReference(type = LayoutPrototypePersistence.class)
2939 protected LayoutPrototypePersistence layoutPrototypePersistence;
2940 @BeanReference(type = LayoutRevisionPersistence.class)
2941 protected LayoutRevisionPersistence layoutRevisionPersistence;
2942 @BeanReference(type = LayoutSetPersistence.class)
2943 protected LayoutSetPersistence layoutSetPersistence;
2944 @BeanReference(type = LayoutSetBranchPersistence.class)
2945 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
2946 @BeanReference(type = LayoutSetPrototypePersistence.class)
2947 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2948 @BeanReference(type = ListTypePersistence.class)
2949 protected ListTypePersistence listTypePersistence;
2950 @BeanReference(type = LockPersistence.class)
2951 protected LockPersistence lockPersistence;
2952 @BeanReference(type = MembershipRequestPersistence.class)
2953 protected MembershipRequestPersistence membershipRequestPersistence;
2954 @BeanReference(type = OrganizationPersistence.class)
2955 protected OrganizationPersistence organizationPersistence;
2956 @BeanReference(type = OrgGroupPermissionPersistence.class)
2957 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
2958 @BeanReference(type = OrgGroupRolePersistence.class)
2959 protected OrgGroupRolePersistence orgGroupRolePersistence;
2960 @BeanReference(type = OrgLaborPersistence.class)
2961 protected OrgLaborPersistence orgLaborPersistence;
2962 @BeanReference(type = PasswordPolicyPersistence.class)
2963 protected PasswordPolicyPersistence passwordPolicyPersistence;
2964 @BeanReference(type = PasswordPolicyRelPersistence.class)
2965 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2966 @BeanReference(type = PasswordTrackerPersistence.class)
2967 protected PasswordTrackerPersistence passwordTrackerPersistence;
2968 @BeanReference(type = PermissionPersistence.class)
2969 protected PermissionPersistence permissionPersistence;
2970 @BeanReference(type = PhonePersistence.class)
2971 protected PhonePersistence phonePersistence;
2972 @BeanReference(type = PluginSettingPersistence.class)
2973 protected PluginSettingPersistence pluginSettingPersistence;
2974 @BeanReference(type = PortalPreferencesPersistence.class)
2975 protected PortalPreferencesPersistence portalPreferencesPersistence;
2976 @BeanReference(type = PortletPersistence.class)
2977 protected PortletPersistence portletPersistence;
2978 @BeanReference(type = PortletItemPersistence.class)
2979 protected PortletItemPersistence portletItemPersistence;
2980 @BeanReference(type = PortletPreferencesPersistence.class)
2981 protected PortletPreferencesPersistence portletPreferencesPersistence;
2982 @BeanReference(type = RegionPersistence.class)
2983 protected RegionPersistence regionPersistence;
2984 @BeanReference(type = ReleasePersistence.class)
2985 protected ReleasePersistence releasePersistence;
2986 @BeanReference(type = RepositoryPersistence.class)
2987 protected RepositoryPersistence repositoryPersistence;
2988 @BeanReference(type = RepositoryEntryPersistence.class)
2989 protected RepositoryEntryPersistence repositoryEntryPersistence;
2990 @BeanReference(type = ResourcePersistence.class)
2991 protected ResourcePersistence resourcePersistence;
2992 @BeanReference(type = ResourceActionPersistence.class)
2993 protected ResourceActionPersistence resourceActionPersistence;
2994 @BeanReference(type = ResourceBlockPersistence.class)
2995 protected ResourceBlockPersistence resourceBlockPersistence;
2996 @BeanReference(type = ResourceBlockPermissionPersistence.class)
2997 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
2998 @BeanReference(type = ResourceCodePersistence.class)
2999 protected ResourceCodePersistence resourceCodePersistence;
3000 @BeanReference(type = ResourcePermissionPersistence.class)
3001 protected ResourcePermissionPersistence resourcePermissionPersistence;
3002 @BeanReference(type = ResourceTypePermissionPersistence.class)
3003 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
3004 @BeanReference(type = RolePersistence.class)
3005 protected RolePersistence rolePersistence;
3006 @BeanReference(type = ServiceComponentPersistence.class)
3007 protected ServiceComponentPersistence serviceComponentPersistence;
3008 @BeanReference(type = ShardPersistence.class)
3009 protected ShardPersistence shardPersistence;
3010 @BeanReference(type = SubscriptionPersistence.class)
3011 protected SubscriptionPersistence subscriptionPersistence;
3012 @BeanReference(type = TeamPersistence.class)
3013 protected TeamPersistence teamPersistence;
3014 @BeanReference(type = TicketPersistence.class)
3015 protected TicketPersistence ticketPersistence;
3016 @BeanReference(type = UserPersistence.class)
3017 protected UserPersistence userPersistence;
3018 @BeanReference(type = UserGroupPersistence.class)
3019 protected UserGroupPersistence userGroupPersistence;
3020 @BeanReference(type = UserGroupGroupRolePersistence.class)
3021 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
3022 @BeanReference(type = UserGroupRolePersistence.class)
3023 protected UserGroupRolePersistence userGroupRolePersistence;
3024 @BeanReference(type = UserIdMapperPersistence.class)
3025 protected UserIdMapperPersistence userIdMapperPersistence;
3026 @BeanReference(type = UserNotificationEventPersistence.class)
3027 protected UserNotificationEventPersistence userNotificationEventPersistence;
3028 @BeanReference(type = UserTrackerPersistence.class)
3029 protected UserTrackerPersistence userTrackerPersistence;
3030 @BeanReference(type = UserTrackerPathPersistence.class)
3031 protected UserTrackerPathPersistence userTrackerPathPersistence;
3032 @BeanReference(type = VirtualHostPersistence.class)
3033 protected VirtualHostPersistence virtualHostPersistence;
3034 @BeanReference(type = WebDAVPropsPersistence.class)
3035 protected WebDAVPropsPersistence webDAVPropsPersistence;
3036 @BeanReference(type = WebsitePersistence.class)
3037 protected WebsitePersistence websitePersistence;
3038 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
3039 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
3040 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
3041 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
3042 private static final String _SQL_SELECT_USERGROUPGROUPROLE = "SELECT userGroupGroupRole FROM UserGroupGroupRole userGroupGroupRole";
3043 private static final String _SQL_SELECT_USERGROUPGROUPROLE_WHERE = "SELECT userGroupGroupRole FROM UserGroupGroupRole userGroupGroupRole WHERE ";
3044 private static final String _SQL_COUNT_USERGROUPGROUPROLE = "SELECT COUNT(userGroupGroupRole) FROM UserGroupGroupRole userGroupGroupRole";
3045 private static final String _SQL_COUNT_USERGROUPGROUPROLE_WHERE = "SELECT COUNT(userGroupGroupRole) FROM UserGroupGroupRole userGroupGroupRole WHERE ";
3046 private static final String _FINDER_COLUMN_USERGROUPID_USERGROUPID_2 = "userGroupGroupRole.id.userGroupId = ?";
3047 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "userGroupGroupRole.id.groupId = ?";
3048 private static final String _FINDER_COLUMN_ROLEID_ROLEID_2 = "userGroupGroupRole.id.roleId = ?";
3049 private static final String _FINDER_COLUMN_U_G_USERGROUPID_2 = "userGroupGroupRole.id.userGroupId = ? AND ";
3050 private static final String _FINDER_COLUMN_U_G_GROUPID_2 = "userGroupGroupRole.id.groupId = ?";
3051 private static final String _FINDER_COLUMN_G_R_GROUPID_2 = "userGroupGroupRole.id.groupId = ? AND ";
3052 private static final String _FINDER_COLUMN_G_R_ROLEID_2 = "userGroupGroupRole.id.roleId = ?";
3053 private static final String _ORDER_BY_ENTITY_ALIAS = "userGroupGroupRole.";
3054 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserGroupGroupRole exists with the primary key ";
3055 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserGroupGroupRole exists with the key {";
3056 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3057 private static Log _log = LogFactoryUtil.getLog(UserGroupGroupRolePersistenceImpl.class);
3058 private static UserGroupGroupRole _nullUserGroupGroupRole = new UserGroupGroupRoleImpl() {
3059 @Override
3060 public Object clone() {
3061 return this;
3062 }
3063
3064 @Override
3065 public CacheModel<UserGroupGroupRole> toCacheModel() {
3066 return _nullUserGroupGroupRoleCacheModel;
3067 }
3068 };
3069
3070 private static CacheModel<UserGroupGroupRole> _nullUserGroupGroupRoleCacheModel =
3071 new CacheModel<UserGroupGroupRole>() {
3072 public UserGroupGroupRole toEntityModel() {
3073 return _nullUserGroupGroupRole;
3074 }
3075 };
3076 }