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_WITH_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_WITHOUT_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 else {
396 if ((userGroupGroupRoleModelImpl.getColumnBitmask() &
397 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERGROUPID.getColumnBitmask()) != 0) {
398 Object[] args = new Object[] {
399 Long.valueOf(userGroupGroupRoleModelImpl.getOriginalUserGroupId())
400 };
401
402 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERGROUPID,
403 args);
404 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERGROUPID,
405 args);
406
407 args = new Object[] {
408 Long.valueOf(userGroupGroupRoleModelImpl.getUserGroupId())
409 };
410
411 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERGROUPID,
412 args);
413 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERGROUPID,
414 args);
415 }
416
417 if ((userGroupGroupRoleModelImpl.getColumnBitmask() &
418 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
419 Object[] args = new Object[] {
420 Long.valueOf(userGroupGroupRoleModelImpl.getOriginalGroupId())
421 };
422
423 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
424 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
425 args);
426
427 args = new Object[] {
428 Long.valueOf(userGroupGroupRoleModelImpl.getGroupId())
429 };
430
431 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
432 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
433 args);
434 }
435
436 if ((userGroupGroupRoleModelImpl.getColumnBitmask() &
437 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ROLEID.getColumnBitmask()) != 0) {
438 Object[] args = new Object[] {
439 Long.valueOf(userGroupGroupRoleModelImpl.getOriginalRoleId())
440 };
441
442 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ROLEID, args);
443 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ROLEID,
444 args);
445
446 args = new Object[] {
447 Long.valueOf(userGroupGroupRoleModelImpl.getRoleId())
448 };
449
450 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ROLEID, args);
451 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ROLEID,
452 args);
453 }
454
455 if ((userGroupGroupRoleModelImpl.getColumnBitmask() &
456 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_G.getColumnBitmask()) != 0) {
457 Object[] args = new Object[] {
458 Long.valueOf(userGroupGroupRoleModelImpl.getOriginalUserGroupId()),
459 Long.valueOf(userGroupGroupRoleModelImpl.getOriginalGroupId())
460 };
461
462 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_G, args);
463 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_G,
464 args);
465
466 args = new Object[] {
467 Long.valueOf(userGroupGroupRoleModelImpl.getUserGroupId()),
468 Long.valueOf(userGroupGroupRoleModelImpl.getGroupId())
469 };
470
471 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_G, args);
472 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_G,
473 args);
474 }
475
476 if ((userGroupGroupRoleModelImpl.getColumnBitmask() &
477 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_R.getColumnBitmask()) != 0) {
478 Object[] args = new Object[] {
479 Long.valueOf(userGroupGroupRoleModelImpl.getOriginalGroupId()),
480 Long.valueOf(userGroupGroupRoleModelImpl.getOriginalRoleId())
481 };
482
483 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_R, args);
484 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_R,
485 args);
486
487 args = new Object[] {
488 Long.valueOf(userGroupGroupRoleModelImpl.getGroupId()),
489 Long.valueOf(userGroupGroupRoleModelImpl.getRoleId())
490 };
491
492 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_R, args);
493 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_R,
494 args);
495 }
496 }
497
498 EntityCacheUtil.putResult(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
499 UserGroupGroupRoleImpl.class, userGroupGroupRole.getPrimaryKey(),
500 userGroupGroupRole);
501
502 return userGroupGroupRole;
503 }
504
505 protected UserGroupGroupRole toUnwrappedModel(
506 UserGroupGroupRole userGroupGroupRole) {
507 if (userGroupGroupRole instanceof UserGroupGroupRoleImpl) {
508 return userGroupGroupRole;
509 }
510
511 UserGroupGroupRoleImpl userGroupGroupRoleImpl = new UserGroupGroupRoleImpl();
512
513 userGroupGroupRoleImpl.setNew(userGroupGroupRole.isNew());
514 userGroupGroupRoleImpl.setPrimaryKey(userGroupGroupRole.getPrimaryKey());
515
516 userGroupGroupRoleImpl.setUserGroupId(userGroupGroupRole.getUserGroupId());
517 userGroupGroupRoleImpl.setGroupId(userGroupGroupRole.getGroupId());
518 userGroupGroupRoleImpl.setRoleId(userGroupGroupRole.getRoleId());
519
520 return userGroupGroupRoleImpl;
521 }
522
523
531 @Override
532 public UserGroupGroupRole findByPrimaryKey(Serializable primaryKey)
533 throws NoSuchModelException, SystemException {
534 return findByPrimaryKey((UserGroupGroupRolePK)primaryKey);
535 }
536
537
545 public UserGroupGroupRole findByPrimaryKey(
546 UserGroupGroupRolePK userGroupGroupRolePK)
547 throws NoSuchUserGroupGroupRoleException, SystemException {
548 UserGroupGroupRole userGroupGroupRole = fetchByPrimaryKey(userGroupGroupRolePK);
549
550 if (userGroupGroupRole == null) {
551 if (_log.isWarnEnabled()) {
552 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
553 userGroupGroupRolePK);
554 }
555
556 throw new NoSuchUserGroupGroupRoleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
557 userGroupGroupRolePK);
558 }
559
560 return userGroupGroupRole;
561 }
562
563
570 @Override
571 public UserGroupGroupRole fetchByPrimaryKey(Serializable primaryKey)
572 throws SystemException {
573 return fetchByPrimaryKey((UserGroupGroupRolePK)primaryKey);
574 }
575
576
583 public UserGroupGroupRole fetchByPrimaryKey(
584 UserGroupGroupRolePK userGroupGroupRolePK) throws SystemException {
585 UserGroupGroupRole userGroupGroupRole = (UserGroupGroupRole)EntityCacheUtil.getResult(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
586 UserGroupGroupRoleImpl.class, userGroupGroupRolePK);
587
588 if (userGroupGroupRole == _nullUserGroupGroupRole) {
589 return null;
590 }
591
592 if (userGroupGroupRole == null) {
593 Session session = null;
594
595 boolean hasException = false;
596
597 try {
598 session = openSession();
599
600 userGroupGroupRole = (UserGroupGroupRole)session.get(UserGroupGroupRoleImpl.class,
601 userGroupGroupRolePK);
602 }
603 catch (Exception e) {
604 hasException = true;
605
606 throw processException(e);
607 }
608 finally {
609 if (userGroupGroupRole != null) {
610 cacheResult(userGroupGroupRole);
611 }
612 else if (!hasException) {
613 EntityCacheUtil.putResult(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
614 UserGroupGroupRoleImpl.class, userGroupGroupRolePK,
615 _nullUserGroupGroupRole);
616 }
617
618 closeSession(session);
619 }
620 }
621
622 return userGroupGroupRole;
623 }
624
625
632 public List<UserGroupGroupRole> findByUserGroupId(long userGroupId)
633 throws SystemException {
634 return findByUserGroupId(userGroupId, QueryUtil.ALL_POS,
635 QueryUtil.ALL_POS, null);
636 }
637
638
651 public List<UserGroupGroupRole> findByUserGroupId(long userGroupId,
652 int start, int end) throws SystemException {
653 return findByUserGroupId(userGroupId, start, end, null);
654 }
655
656
670 public List<UserGroupGroupRole> findByUserGroupId(long userGroupId,
671 int start, int end, OrderByComparator orderByComparator)
672 throws SystemException {
673 FinderPath finderPath = null;
674 Object[] finderArgs = null;
675
676 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
677 (orderByComparator == null)) {
678 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERGROUPID;
679 finderArgs = new Object[] { userGroupId };
680 }
681 else {
682 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERGROUPID;
683 finderArgs = new Object[] { userGroupId, start, end, orderByComparator };
684 }
685
686 List<UserGroupGroupRole> list = (List<UserGroupGroupRole>)FinderCacheUtil.getResult(finderPath,
687 finderArgs, this);
688
689 if ((list != null) && !list.isEmpty()) {
690 for (UserGroupGroupRole userGroupGroupRole : list) {
691 if ((userGroupId != userGroupGroupRole.getUserGroupId())) {
692 list = null;
693
694 break;
695 }
696 }
697 }
698
699 if (list == null) {
700 StringBundler query = null;
701
702 if (orderByComparator != null) {
703 query = new StringBundler(3 +
704 (orderByComparator.getOrderByFields().length * 3));
705 }
706 else {
707 query = new StringBundler(2);
708 }
709
710 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
711
712 query.append(_FINDER_COLUMN_USERGROUPID_USERGROUPID_2);
713
714 if (orderByComparator != null) {
715 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
716 orderByComparator);
717 }
718
719 String sql = query.toString();
720
721 Session session = null;
722
723 try {
724 session = openSession();
725
726 Query q = session.createQuery(sql);
727
728 QueryPos qPos = QueryPos.getInstance(q);
729
730 qPos.add(userGroupId);
731
732 list = (List<UserGroupGroupRole>)QueryUtil.list(q,
733 getDialect(), start, end);
734 }
735 catch (Exception e) {
736 throw processException(e);
737 }
738 finally {
739 if (list == null) {
740 FinderCacheUtil.removeResult(finderPath, finderArgs);
741 }
742 else {
743 cacheResult(list);
744
745 FinderCacheUtil.putResult(finderPath, finderArgs, list);
746 }
747
748 closeSession(session);
749 }
750 }
751
752 return list;
753 }
754
755
768 public UserGroupGroupRole findByUserGroupId_First(long userGroupId,
769 OrderByComparator orderByComparator)
770 throws NoSuchUserGroupGroupRoleException, SystemException {
771 List<UserGroupGroupRole> list = findByUserGroupId(userGroupId, 0, 1,
772 orderByComparator);
773
774 if (list.isEmpty()) {
775 StringBundler msg = new StringBundler(4);
776
777 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
778
779 msg.append("userGroupId=");
780 msg.append(userGroupId);
781
782 msg.append(StringPool.CLOSE_CURLY_BRACE);
783
784 throw new NoSuchUserGroupGroupRoleException(msg.toString());
785 }
786 else {
787 return list.get(0);
788 }
789 }
790
791
804 public UserGroupGroupRole findByUserGroupId_Last(long userGroupId,
805 OrderByComparator orderByComparator)
806 throws NoSuchUserGroupGroupRoleException, SystemException {
807 int count = countByUserGroupId(userGroupId);
808
809 List<UserGroupGroupRole> list = findByUserGroupId(userGroupId,
810 count - 1, count, orderByComparator);
811
812 if (list.isEmpty()) {
813 StringBundler msg = new StringBundler(4);
814
815 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
816
817 msg.append("userGroupId=");
818 msg.append(userGroupId);
819
820 msg.append(StringPool.CLOSE_CURLY_BRACE);
821
822 throw new NoSuchUserGroupGroupRoleException(msg.toString());
823 }
824 else {
825 return list.get(0);
826 }
827 }
828
829
843 public UserGroupGroupRole[] findByUserGroupId_PrevAndNext(
844 UserGroupGroupRolePK userGroupGroupRolePK, long userGroupId,
845 OrderByComparator orderByComparator)
846 throws NoSuchUserGroupGroupRoleException, SystemException {
847 UserGroupGroupRole userGroupGroupRole = findByPrimaryKey(userGroupGroupRolePK);
848
849 Session session = null;
850
851 try {
852 session = openSession();
853
854 UserGroupGroupRole[] array = new UserGroupGroupRoleImpl[3];
855
856 array[0] = getByUserGroupId_PrevAndNext(session,
857 userGroupGroupRole, userGroupId, orderByComparator, true);
858
859 array[1] = userGroupGroupRole;
860
861 array[2] = getByUserGroupId_PrevAndNext(session,
862 userGroupGroupRole, userGroupId, orderByComparator, false);
863
864 return array;
865 }
866 catch (Exception e) {
867 throw processException(e);
868 }
869 finally {
870 closeSession(session);
871 }
872 }
873
874 protected UserGroupGroupRole getByUserGroupId_PrevAndNext(Session session,
875 UserGroupGroupRole userGroupGroupRole, long userGroupId,
876 OrderByComparator orderByComparator, boolean previous) {
877 StringBundler query = null;
878
879 if (orderByComparator != null) {
880 query = new StringBundler(6 +
881 (orderByComparator.getOrderByFields().length * 6));
882 }
883 else {
884 query = new StringBundler(3);
885 }
886
887 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
888
889 query.append(_FINDER_COLUMN_USERGROUPID_USERGROUPID_2);
890
891 if (orderByComparator != null) {
892 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
893
894 if (orderByConditionFields.length > 0) {
895 query.append(WHERE_AND);
896 }
897
898 for (int i = 0; i < orderByConditionFields.length; i++) {
899 query.append(_ORDER_BY_ENTITY_ALIAS);
900 query.append(orderByConditionFields[i]);
901
902 if ((i + 1) < orderByConditionFields.length) {
903 if (orderByComparator.isAscending() ^ previous) {
904 query.append(WHERE_GREATER_THAN_HAS_NEXT);
905 }
906 else {
907 query.append(WHERE_LESSER_THAN_HAS_NEXT);
908 }
909 }
910 else {
911 if (orderByComparator.isAscending() ^ previous) {
912 query.append(WHERE_GREATER_THAN);
913 }
914 else {
915 query.append(WHERE_LESSER_THAN);
916 }
917 }
918 }
919
920 query.append(ORDER_BY_CLAUSE);
921
922 String[] orderByFields = orderByComparator.getOrderByFields();
923
924 for (int i = 0; i < orderByFields.length; i++) {
925 query.append(_ORDER_BY_ENTITY_ALIAS);
926 query.append(orderByFields[i]);
927
928 if ((i + 1) < orderByFields.length) {
929 if (orderByComparator.isAscending() ^ previous) {
930 query.append(ORDER_BY_ASC_HAS_NEXT);
931 }
932 else {
933 query.append(ORDER_BY_DESC_HAS_NEXT);
934 }
935 }
936 else {
937 if (orderByComparator.isAscending() ^ previous) {
938 query.append(ORDER_BY_ASC);
939 }
940 else {
941 query.append(ORDER_BY_DESC);
942 }
943 }
944 }
945 }
946
947 String sql = query.toString();
948
949 Query q = session.createQuery(sql);
950
951 q.setFirstResult(0);
952 q.setMaxResults(2);
953
954 QueryPos qPos = QueryPos.getInstance(q);
955
956 qPos.add(userGroupId);
957
958 if (orderByComparator != null) {
959 Object[] values = orderByComparator.getOrderByConditionValues(userGroupGroupRole);
960
961 for (Object value : values) {
962 qPos.add(value);
963 }
964 }
965
966 List<UserGroupGroupRole> list = q.list();
967
968 if (list.size() == 2) {
969 return list.get(1);
970 }
971 else {
972 return null;
973 }
974 }
975
976
983 public List<UserGroupGroupRole> findByGroupId(long groupId)
984 throws SystemException {
985 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
986 }
987
988
1001 public List<UserGroupGroupRole> findByGroupId(long groupId, int start,
1002 int end) throws SystemException {
1003 return findByGroupId(groupId, start, end, null);
1004 }
1005
1006
1020 public List<UserGroupGroupRole> findByGroupId(long groupId, int start,
1021 int end, OrderByComparator orderByComparator) throws SystemException {
1022 FinderPath finderPath = null;
1023 Object[] finderArgs = null;
1024
1025 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1026 (orderByComparator == null)) {
1027 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1028 finderArgs = new Object[] { groupId };
1029 }
1030 else {
1031 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1032 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1033 }
1034
1035 List<UserGroupGroupRole> list = (List<UserGroupGroupRole>)FinderCacheUtil.getResult(finderPath,
1036 finderArgs, this);
1037
1038 if ((list != null) && !list.isEmpty()) {
1039 for (UserGroupGroupRole userGroupGroupRole : list) {
1040 if ((groupId != userGroupGroupRole.getGroupId())) {
1041 list = null;
1042
1043 break;
1044 }
1045 }
1046 }
1047
1048 if (list == null) {
1049 StringBundler query = null;
1050
1051 if (orderByComparator != null) {
1052 query = new StringBundler(3 +
1053 (orderByComparator.getOrderByFields().length * 3));
1054 }
1055 else {
1056 query = new StringBundler(2);
1057 }
1058
1059 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
1060
1061 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1062
1063 if (orderByComparator != null) {
1064 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1065 orderByComparator);
1066 }
1067
1068 String sql = query.toString();
1069
1070 Session session = null;
1071
1072 try {
1073 session = openSession();
1074
1075 Query q = session.createQuery(sql);
1076
1077 QueryPos qPos = QueryPos.getInstance(q);
1078
1079 qPos.add(groupId);
1080
1081 list = (List<UserGroupGroupRole>)QueryUtil.list(q,
1082 getDialect(), start, end);
1083 }
1084 catch (Exception e) {
1085 throw processException(e);
1086 }
1087 finally {
1088 if (list == null) {
1089 FinderCacheUtil.removeResult(finderPath, finderArgs);
1090 }
1091 else {
1092 cacheResult(list);
1093
1094 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1095 }
1096
1097 closeSession(session);
1098 }
1099 }
1100
1101 return list;
1102 }
1103
1104
1117 public UserGroupGroupRole findByGroupId_First(long groupId,
1118 OrderByComparator orderByComparator)
1119 throws NoSuchUserGroupGroupRoleException, SystemException {
1120 List<UserGroupGroupRole> list = findByGroupId(groupId, 0, 1,
1121 orderByComparator);
1122
1123 if (list.isEmpty()) {
1124 StringBundler msg = new StringBundler(4);
1125
1126 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1127
1128 msg.append("groupId=");
1129 msg.append(groupId);
1130
1131 msg.append(StringPool.CLOSE_CURLY_BRACE);
1132
1133 throw new NoSuchUserGroupGroupRoleException(msg.toString());
1134 }
1135 else {
1136 return list.get(0);
1137 }
1138 }
1139
1140
1153 public UserGroupGroupRole findByGroupId_Last(long groupId,
1154 OrderByComparator orderByComparator)
1155 throws NoSuchUserGroupGroupRoleException, SystemException {
1156 int count = countByGroupId(groupId);
1157
1158 List<UserGroupGroupRole> list = findByGroupId(groupId, count - 1,
1159 count, orderByComparator);
1160
1161 if (list.isEmpty()) {
1162 StringBundler msg = new StringBundler(4);
1163
1164 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1165
1166 msg.append("groupId=");
1167 msg.append(groupId);
1168
1169 msg.append(StringPool.CLOSE_CURLY_BRACE);
1170
1171 throw new NoSuchUserGroupGroupRoleException(msg.toString());
1172 }
1173 else {
1174 return list.get(0);
1175 }
1176 }
1177
1178
1192 public UserGroupGroupRole[] findByGroupId_PrevAndNext(
1193 UserGroupGroupRolePK userGroupGroupRolePK, long groupId,
1194 OrderByComparator orderByComparator)
1195 throws NoSuchUserGroupGroupRoleException, SystemException {
1196 UserGroupGroupRole userGroupGroupRole = findByPrimaryKey(userGroupGroupRolePK);
1197
1198 Session session = null;
1199
1200 try {
1201 session = openSession();
1202
1203 UserGroupGroupRole[] array = new UserGroupGroupRoleImpl[3];
1204
1205 array[0] = getByGroupId_PrevAndNext(session, userGroupGroupRole,
1206 groupId, orderByComparator, true);
1207
1208 array[1] = userGroupGroupRole;
1209
1210 array[2] = getByGroupId_PrevAndNext(session, userGroupGroupRole,
1211 groupId, orderByComparator, false);
1212
1213 return array;
1214 }
1215 catch (Exception e) {
1216 throw processException(e);
1217 }
1218 finally {
1219 closeSession(session);
1220 }
1221 }
1222
1223 protected UserGroupGroupRole getByGroupId_PrevAndNext(Session session,
1224 UserGroupGroupRole userGroupGroupRole, long groupId,
1225 OrderByComparator orderByComparator, boolean previous) {
1226 StringBundler query = null;
1227
1228 if (orderByComparator != null) {
1229 query = new StringBundler(6 +
1230 (orderByComparator.getOrderByFields().length * 6));
1231 }
1232 else {
1233 query = new StringBundler(3);
1234 }
1235
1236 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
1237
1238 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1239
1240 if (orderByComparator != null) {
1241 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1242
1243 if (orderByConditionFields.length > 0) {
1244 query.append(WHERE_AND);
1245 }
1246
1247 for (int i = 0; i < orderByConditionFields.length; i++) {
1248 query.append(_ORDER_BY_ENTITY_ALIAS);
1249 query.append(orderByConditionFields[i]);
1250
1251 if ((i + 1) < orderByConditionFields.length) {
1252 if (orderByComparator.isAscending() ^ previous) {
1253 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1254 }
1255 else {
1256 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1257 }
1258 }
1259 else {
1260 if (orderByComparator.isAscending() ^ previous) {
1261 query.append(WHERE_GREATER_THAN);
1262 }
1263 else {
1264 query.append(WHERE_LESSER_THAN);
1265 }
1266 }
1267 }
1268
1269 query.append(ORDER_BY_CLAUSE);
1270
1271 String[] orderByFields = orderByComparator.getOrderByFields();
1272
1273 for (int i = 0; i < orderByFields.length; i++) {
1274 query.append(_ORDER_BY_ENTITY_ALIAS);
1275 query.append(orderByFields[i]);
1276
1277 if ((i + 1) < orderByFields.length) {
1278 if (orderByComparator.isAscending() ^ previous) {
1279 query.append(ORDER_BY_ASC_HAS_NEXT);
1280 }
1281 else {
1282 query.append(ORDER_BY_DESC_HAS_NEXT);
1283 }
1284 }
1285 else {
1286 if (orderByComparator.isAscending() ^ previous) {
1287 query.append(ORDER_BY_ASC);
1288 }
1289 else {
1290 query.append(ORDER_BY_DESC);
1291 }
1292 }
1293 }
1294 }
1295
1296 String sql = query.toString();
1297
1298 Query q = session.createQuery(sql);
1299
1300 q.setFirstResult(0);
1301 q.setMaxResults(2);
1302
1303 QueryPos qPos = QueryPos.getInstance(q);
1304
1305 qPos.add(groupId);
1306
1307 if (orderByComparator != null) {
1308 Object[] values = orderByComparator.getOrderByConditionValues(userGroupGroupRole);
1309
1310 for (Object value : values) {
1311 qPos.add(value);
1312 }
1313 }
1314
1315 List<UserGroupGroupRole> list = q.list();
1316
1317 if (list.size() == 2) {
1318 return list.get(1);
1319 }
1320 else {
1321 return null;
1322 }
1323 }
1324
1325
1332 public List<UserGroupGroupRole> findByRoleId(long roleId)
1333 throws SystemException {
1334 return findByRoleId(roleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1335 }
1336
1337
1350 public List<UserGroupGroupRole> findByRoleId(long roleId, int start, int end)
1351 throws SystemException {
1352 return findByRoleId(roleId, start, end, null);
1353 }
1354
1355
1369 public List<UserGroupGroupRole> findByRoleId(long roleId, int start,
1370 int end, OrderByComparator orderByComparator) throws SystemException {
1371 FinderPath finderPath = null;
1372 Object[] finderArgs = null;
1373
1374 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1375 (orderByComparator == null)) {
1376 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ROLEID;
1377 finderArgs = new Object[] { roleId };
1378 }
1379 else {
1380 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_ROLEID;
1381 finderArgs = new Object[] { roleId, start, end, orderByComparator };
1382 }
1383
1384 List<UserGroupGroupRole> list = (List<UserGroupGroupRole>)FinderCacheUtil.getResult(finderPath,
1385 finderArgs, this);
1386
1387 if ((list != null) && !list.isEmpty()) {
1388 for (UserGroupGroupRole userGroupGroupRole : list) {
1389 if ((roleId != userGroupGroupRole.getRoleId())) {
1390 list = null;
1391
1392 break;
1393 }
1394 }
1395 }
1396
1397 if (list == null) {
1398 StringBundler query = null;
1399
1400 if (orderByComparator != null) {
1401 query = new StringBundler(3 +
1402 (orderByComparator.getOrderByFields().length * 3));
1403 }
1404 else {
1405 query = new StringBundler(2);
1406 }
1407
1408 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
1409
1410 query.append(_FINDER_COLUMN_ROLEID_ROLEID_2);
1411
1412 if (orderByComparator != null) {
1413 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1414 orderByComparator);
1415 }
1416
1417 String sql = query.toString();
1418
1419 Session session = null;
1420
1421 try {
1422 session = openSession();
1423
1424 Query q = session.createQuery(sql);
1425
1426 QueryPos qPos = QueryPos.getInstance(q);
1427
1428 qPos.add(roleId);
1429
1430 list = (List<UserGroupGroupRole>)QueryUtil.list(q,
1431 getDialect(), start, end);
1432 }
1433 catch (Exception e) {
1434 throw processException(e);
1435 }
1436 finally {
1437 if (list == null) {
1438 FinderCacheUtil.removeResult(finderPath, finderArgs);
1439 }
1440 else {
1441 cacheResult(list);
1442
1443 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1444 }
1445
1446 closeSession(session);
1447 }
1448 }
1449
1450 return list;
1451 }
1452
1453
1466 public UserGroupGroupRole findByRoleId_First(long roleId,
1467 OrderByComparator orderByComparator)
1468 throws NoSuchUserGroupGroupRoleException, SystemException {
1469 List<UserGroupGroupRole> list = findByRoleId(roleId, 0, 1,
1470 orderByComparator);
1471
1472 if (list.isEmpty()) {
1473 StringBundler msg = new StringBundler(4);
1474
1475 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1476
1477 msg.append("roleId=");
1478 msg.append(roleId);
1479
1480 msg.append(StringPool.CLOSE_CURLY_BRACE);
1481
1482 throw new NoSuchUserGroupGroupRoleException(msg.toString());
1483 }
1484 else {
1485 return list.get(0);
1486 }
1487 }
1488
1489
1502 public UserGroupGroupRole findByRoleId_Last(long roleId,
1503 OrderByComparator orderByComparator)
1504 throws NoSuchUserGroupGroupRoleException, SystemException {
1505 int count = countByRoleId(roleId);
1506
1507 List<UserGroupGroupRole> list = findByRoleId(roleId, count - 1, count,
1508 orderByComparator);
1509
1510 if (list.isEmpty()) {
1511 StringBundler msg = new StringBundler(4);
1512
1513 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1514
1515 msg.append("roleId=");
1516 msg.append(roleId);
1517
1518 msg.append(StringPool.CLOSE_CURLY_BRACE);
1519
1520 throw new NoSuchUserGroupGroupRoleException(msg.toString());
1521 }
1522 else {
1523 return list.get(0);
1524 }
1525 }
1526
1527
1541 public UserGroupGroupRole[] findByRoleId_PrevAndNext(
1542 UserGroupGroupRolePK userGroupGroupRolePK, long roleId,
1543 OrderByComparator orderByComparator)
1544 throws NoSuchUserGroupGroupRoleException, SystemException {
1545 UserGroupGroupRole userGroupGroupRole = findByPrimaryKey(userGroupGroupRolePK);
1546
1547 Session session = null;
1548
1549 try {
1550 session = openSession();
1551
1552 UserGroupGroupRole[] array = new UserGroupGroupRoleImpl[3];
1553
1554 array[0] = getByRoleId_PrevAndNext(session, userGroupGroupRole,
1555 roleId, orderByComparator, true);
1556
1557 array[1] = userGroupGroupRole;
1558
1559 array[2] = getByRoleId_PrevAndNext(session, userGroupGroupRole,
1560 roleId, orderByComparator, false);
1561
1562 return array;
1563 }
1564 catch (Exception e) {
1565 throw processException(e);
1566 }
1567 finally {
1568 closeSession(session);
1569 }
1570 }
1571
1572 protected UserGroupGroupRole getByRoleId_PrevAndNext(Session session,
1573 UserGroupGroupRole userGroupGroupRole, long roleId,
1574 OrderByComparator orderByComparator, boolean previous) {
1575 StringBundler query = null;
1576
1577 if (orderByComparator != null) {
1578 query = new StringBundler(6 +
1579 (orderByComparator.getOrderByFields().length * 6));
1580 }
1581 else {
1582 query = new StringBundler(3);
1583 }
1584
1585 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
1586
1587 query.append(_FINDER_COLUMN_ROLEID_ROLEID_2);
1588
1589 if (orderByComparator != null) {
1590 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1591
1592 if (orderByConditionFields.length > 0) {
1593 query.append(WHERE_AND);
1594 }
1595
1596 for (int i = 0; i < orderByConditionFields.length; i++) {
1597 query.append(_ORDER_BY_ENTITY_ALIAS);
1598 query.append(orderByConditionFields[i]);
1599
1600 if ((i + 1) < orderByConditionFields.length) {
1601 if (orderByComparator.isAscending() ^ previous) {
1602 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1603 }
1604 else {
1605 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1606 }
1607 }
1608 else {
1609 if (orderByComparator.isAscending() ^ previous) {
1610 query.append(WHERE_GREATER_THAN);
1611 }
1612 else {
1613 query.append(WHERE_LESSER_THAN);
1614 }
1615 }
1616 }
1617
1618 query.append(ORDER_BY_CLAUSE);
1619
1620 String[] orderByFields = orderByComparator.getOrderByFields();
1621
1622 for (int i = 0; i < orderByFields.length; i++) {
1623 query.append(_ORDER_BY_ENTITY_ALIAS);
1624 query.append(orderByFields[i]);
1625
1626 if ((i + 1) < orderByFields.length) {
1627 if (orderByComparator.isAscending() ^ previous) {
1628 query.append(ORDER_BY_ASC_HAS_NEXT);
1629 }
1630 else {
1631 query.append(ORDER_BY_DESC_HAS_NEXT);
1632 }
1633 }
1634 else {
1635 if (orderByComparator.isAscending() ^ previous) {
1636 query.append(ORDER_BY_ASC);
1637 }
1638 else {
1639 query.append(ORDER_BY_DESC);
1640 }
1641 }
1642 }
1643 }
1644
1645 String sql = query.toString();
1646
1647 Query q = session.createQuery(sql);
1648
1649 q.setFirstResult(0);
1650 q.setMaxResults(2);
1651
1652 QueryPos qPos = QueryPos.getInstance(q);
1653
1654 qPos.add(roleId);
1655
1656 if (orderByComparator != null) {
1657 Object[] values = orderByComparator.getOrderByConditionValues(userGroupGroupRole);
1658
1659 for (Object value : values) {
1660 qPos.add(value);
1661 }
1662 }
1663
1664 List<UserGroupGroupRole> list = q.list();
1665
1666 if (list.size() == 2) {
1667 return list.get(1);
1668 }
1669 else {
1670 return null;
1671 }
1672 }
1673
1674
1682 public List<UserGroupGroupRole> findByU_G(long userGroupId, long groupId)
1683 throws SystemException {
1684 return findByU_G(userGroupId, groupId, QueryUtil.ALL_POS,
1685 QueryUtil.ALL_POS, null);
1686 }
1687
1688
1702 public List<UserGroupGroupRole> findByU_G(long userGroupId, long groupId,
1703 int start, int end) throws SystemException {
1704 return findByU_G(userGroupId, groupId, start, end, null);
1705 }
1706
1707
1722 public List<UserGroupGroupRole> findByU_G(long userGroupId, long groupId,
1723 int start, int end, OrderByComparator orderByComparator)
1724 throws SystemException {
1725 FinderPath finderPath = null;
1726 Object[] finderArgs = null;
1727
1728 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1729 (orderByComparator == null)) {
1730 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_G;
1731 finderArgs = new Object[] { userGroupId, groupId };
1732 }
1733 else {
1734 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_G;
1735 finderArgs = new Object[] {
1736 userGroupId, groupId,
1737
1738 start, end, orderByComparator
1739 };
1740 }
1741
1742 List<UserGroupGroupRole> list = (List<UserGroupGroupRole>)FinderCacheUtil.getResult(finderPath,
1743 finderArgs, this);
1744
1745 if ((list != null) && !list.isEmpty()) {
1746 for (UserGroupGroupRole userGroupGroupRole : list) {
1747 if ((userGroupId != userGroupGroupRole.getUserGroupId()) ||
1748 (groupId != userGroupGroupRole.getGroupId())) {
1749 list = null;
1750
1751 break;
1752 }
1753 }
1754 }
1755
1756 if (list == null) {
1757 StringBundler query = null;
1758
1759 if (orderByComparator != null) {
1760 query = new StringBundler(4 +
1761 (orderByComparator.getOrderByFields().length * 3));
1762 }
1763 else {
1764 query = new StringBundler(3);
1765 }
1766
1767 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
1768
1769 query.append(_FINDER_COLUMN_U_G_USERGROUPID_2);
1770
1771 query.append(_FINDER_COLUMN_U_G_GROUPID_2);
1772
1773 if (orderByComparator != null) {
1774 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1775 orderByComparator);
1776 }
1777
1778 String sql = query.toString();
1779
1780 Session session = null;
1781
1782 try {
1783 session = openSession();
1784
1785 Query q = session.createQuery(sql);
1786
1787 QueryPos qPos = QueryPos.getInstance(q);
1788
1789 qPos.add(userGroupId);
1790
1791 qPos.add(groupId);
1792
1793 list = (List<UserGroupGroupRole>)QueryUtil.list(q,
1794 getDialect(), start, end);
1795 }
1796 catch (Exception e) {
1797 throw processException(e);
1798 }
1799 finally {
1800 if (list == null) {
1801 FinderCacheUtil.removeResult(finderPath, finderArgs);
1802 }
1803 else {
1804 cacheResult(list);
1805
1806 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1807 }
1808
1809 closeSession(session);
1810 }
1811 }
1812
1813 return list;
1814 }
1815
1816
1830 public UserGroupGroupRole findByU_G_First(long userGroupId, long groupId,
1831 OrderByComparator orderByComparator)
1832 throws NoSuchUserGroupGroupRoleException, SystemException {
1833 List<UserGroupGroupRole> list = findByU_G(userGroupId, groupId, 0, 1,
1834 orderByComparator);
1835
1836 if (list.isEmpty()) {
1837 StringBundler msg = new StringBundler(6);
1838
1839 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1840
1841 msg.append("userGroupId=");
1842 msg.append(userGroupId);
1843
1844 msg.append(", groupId=");
1845 msg.append(groupId);
1846
1847 msg.append(StringPool.CLOSE_CURLY_BRACE);
1848
1849 throw new NoSuchUserGroupGroupRoleException(msg.toString());
1850 }
1851 else {
1852 return list.get(0);
1853 }
1854 }
1855
1856
1870 public UserGroupGroupRole findByU_G_Last(long userGroupId, long groupId,
1871 OrderByComparator orderByComparator)
1872 throws NoSuchUserGroupGroupRoleException, SystemException {
1873 int count = countByU_G(userGroupId, groupId);
1874
1875 List<UserGroupGroupRole> list = findByU_G(userGroupId, groupId,
1876 count - 1, count, orderByComparator);
1877
1878 if (list.isEmpty()) {
1879 StringBundler msg = new StringBundler(6);
1880
1881 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1882
1883 msg.append("userGroupId=");
1884 msg.append(userGroupId);
1885
1886 msg.append(", groupId=");
1887 msg.append(groupId);
1888
1889 msg.append(StringPool.CLOSE_CURLY_BRACE);
1890
1891 throw new NoSuchUserGroupGroupRoleException(msg.toString());
1892 }
1893 else {
1894 return list.get(0);
1895 }
1896 }
1897
1898
1913 public UserGroupGroupRole[] findByU_G_PrevAndNext(
1914 UserGroupGroupRolePK userGroupGroupRolePK, long userGroupId,
1915 long groupId, OrderByComparator orderByComparator)
1916 throws NoSuchUserGroupGroupRoleException, SystemException {
1917 UserGroupGroupRole userGroupGroupRole = findByPrimaryKey(userGroupGroupRolePK);
1918
1919 Session session = null;
1920
1921 try {
1922 session = openSession();
1923
1924 UserGroupGroupRole[] array = new UserGroupGroupRoleImpl[3];
1925
1926 array[0] = getByU_G_PrevAndNext(session, userGroupGroupRole,
1927 userGroupId, groupId, orderByComparator, true);
1928
1929 array[1] = userGroupGroupRole;
1930
1931 array[2] = getByU_G_PrevAndNext(session, userGroupGroupRole,
1932 userGroupId, groupId, orderByComparator, false);
1933
1934 return array;
1935 }
1936 catch (Exception e) {
1937 throw processException(e);
1938 }
1939 finally {
1940 closeSession(session);
1941 }
1942 }
1943
1944 protected UserGroupGroupRole getByU_G_PrevAndNext(Session session,
1945 UserGroupGroupRole userGroupGroupRole, long userGroupId, long groupId,
1946 OrderByComparator orderByComparator, boolean previous) {
1947 StringBundler query = null;
1948
1949 if (orderByComparator != null) {
1950 query = new StringBundler(6 +
1951 (orderByComparator.getOrderByFields().length * 6));
1952 }
1953 else {
1954 query = new StringBundler(3);
1955 }
1956
1957 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
1958
1959 query.append(_FINDER_COLUMN_U_G_USERGROUPID_2);
1960
1961 query.append(_FINDER_COLUMN_U_G_GROUPID_2);
1962
1963 if (orderByComparator != null) {
1964 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1965
1966 if (orderByConditionFields.length > 0) {
1967 query.append(WHERE_AND);
1968 }
1969
1970 for (int i = 0; i < orderByConditionFields.length; i++) {
1971 query.append(_ORDER_BY_ENTITY_ALIAS);
1972 query.append(orderByConditionFields[i]);
1973
1974 if ((i + 1) < orderByConditionFields.length) {
1975 if (orderByComparator.isAscending() ^ previous) {
1976 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1977 }
1978 else {
1979 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1980 }
1981 }
1982 else {
1983 if (orderByComparator.isAscending() ^ previous) {
1984 query.append(WHERE_GREATER_THAN);
1985 }
1986 else {
1987 query.append(WHERE_LESSER_THAN);
1988 }
1989 }
1990 }
1991
1992 query.append(ORDER_BY_CLAUSE);
1993
1994 String[] orderByFields = orderByComparator.getOrderByFields();
1995
1996 for (int i = 0; i < orderByFields.length; i++) {
1997 query.append(_ORDER_BY_ENTITY_ALIAS);
1998 query.append(orderByFields[i]);
1999
2000 if ((i + 1) < orderByFields.length) {
2001 if (orderByComparator.isAscending() ^ previous) {
2002 query.append(ORDER_BY_ASC_HAS_NEXT);
2003 }
2004 else {
2005 query.append(ORDER_BY_DESC_HAS_NEXT);
2006 }
2007 }
2008 else {
2009 if (orderByComparator.isAscending() ^ previous) {
2010 query.append(ORDER_BY_ASC);
2011 }
2012 else {
2013 query.append(ORDER_BY_DESC);
2014 }
2015 }
2016 }
2017 }
2018
2019 String sql = query.toString();
2020
2021 Query q = session.createQuery(sql);
2022
2023 q.setFirstResult(0);
2024 q.setMaxResults(2);
2025
2026 QueryPos qPos = QueryPos.getInstance(q);
2027
2028 qPos.add(userGroupId);
2029
2030 qPos.add(groupId);
2031
2032 if (orderByComparator != null) {
2033 Object[] values = orderByComparator.getOrderByConditionValues(userGroupGroupRole);
2034
2035 for (Object value : values) {
2036 qPos.add(value);
2037 }
2038 }
2039
2040 List<UserGroupGroupRole> list = q.list();
2041
2042 if (list.size() == 2) {
2043 return list.get(1);
2044 }
2045 else {
2046 return null;
2047 }
2048 }
2049
2050
2058 public List<UserGroupGroupRole> findByG_R(long groupId, long roleId)
2059 throws SystemException {
2060 return findByG_R(groupId, roleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2061 null);
2062 }
2063
2064
2078 public List<UserGroupGroupRole> findByG_R(long groupId, long roleId,
2079 int start, int end) throws SystemException {
2080 return findByG_R(groupId, roleId, start, end, null);
2081 }
2082
2083
2098 public List<UserGroupGroupRole> findByG_R(long groupId, long roleId,
2099 int start, int end, OrderByComparator orderByComparator)
2100 throws SystemException {
2101 FinderPath finderPath = null;
2102 Object[] finderArgs = null;
2103
2104 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2105 (orderByComparator == null)) {
2106 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_R;
2107 finderArgs = new Object[] { groupId, roleId };
2108 }
2109 else {
2110 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_R;
2111 finderArgs = new Object[] {
2112 groupId, roleId,
2113
2114 start, end, orderByComparator
2115 };
2116 }
2117
2118 List<UserGroupGroupRole> list = (List<UserGroupGroupRole>)FinderCacheUtil.getResult(finderPath,
2119 finderArgs, this);
2120
2121 if ((list != null) && !list.isEmpty()) {
2122 for (UserGroupGroupRole userGroupGroupRole : list) {
2123 if ((groupId != userGroupGroupRole.getGroupId()) ||
2124 (roleId != userGroupGroupRole.getRoleId())) {
2125 list = null;
2126
2127 break;
2128 }
2129 }
2130 }
2131
2132 if (list == null) {
2133 StringBundler query = null;
2134
2135 if (orderByComparator != null) {
2136 query = new StringBundler(4 +
2137 (orderByComparator.getOrderByFields().length * 3));
2138 }
2139 else {
2140 query = new StringBundler(3);
2141 }
2142
2143 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
2144
2145 query.append(_FINDER_COLUMN_G_R_GROUPID_2);
2146
2147 query.append(_FINDER_COLUMN_G_R_ROLEID_2);
2148
2149 if (orderByComparator != null) {
2150 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2151 orderByComparator);
2152 }
2153
2154 String sql = query.toString();
2155
2156 Session session = null;
2157
2158 try {
2159 session = openSession();
2160
2161 Query q = session.createQuery(sql);
2162
2163 QueryPos qPos = QueryPos.getInstance(q);
2164
2165 qPos.add(groupId);
2166
2167 qPos.add(roleId);
2168
2169 list = (List<UserGroupGroupRole>)QueryUtil.list(q,
2170 getDialect(), start, end);
2171 }
2172 catch (Exception e) {
2173 throw processException(e);
2174 }
2175 finally {
2176 if (list == null) {
2177 FinderCacheUtil.removeResult(finderPath, finderArgs);
2178 }
2179 else {
2180 cacheResult(list);
2181
2182 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2183 }
2184
2185 closeSession(session);
2186 }
2187 }
2188
2189 return list;
2190 }
2191
2192
2206 public UserGroupGroupRole findByG_R_First(long groupId, long roleId,
2207 OrderByComparator orderByComparator)
2208 throws NoSuchUserGroupGroupRoleException, SystemException {
2209 List<UserGroupGroupRole> list = findByG_R(groupId, roleId, 0, 1,
2210 orderByComparator);
2211
2212 if (list.isEmpty()) {
2213 StringBundler msg = new StringBundler(6);
2214
2215 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2216
2217 msg.append("groupId=");
2218 msg.append(groupId);
2219
2220 msg.append(", roleId=");
2221 msg.append(roleId);
2222
2223 msg.append(StringPool.CLOSE_CURLY_BRACE);
2224
2225 throw new NoSuchUserGroupGroupRoleException(msg.toString());
2226 }
2227 else {
2228 return list.get(0);
2229 }
2230 }
2231
2232
2246 public UserGroupGroupRole findByG_R_Last(long groupId, long roleId,
2247 OrderByComparator orderByComparator)
2248 throws NoSuchUserGroupGroupRoleException, SystemException {
2249 int count = countByG_R(groupId, roleId);
2250
2251 List<UserGroupGroupRole> list = findByG_R(groupId, roleId, count - 1,
2252 count, orderByComparator);
2253
2254 if (list.isEmpty()) {
2255 StringBundler msg = new StringBundler(6);
2256
2257 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2258
2259 msg.append("groupId=");
2260 msg.append(groupId);
2261
2262 msg.append(", roleId=");
2263 msg.append(roleId);
2264
2265 msg.append(StringPool.CLOSE_CURLY_BRACE);
2266
2267 throw new NoSuchUserGroupGroupRoleException(msg.toString());
2268 }
2269 else {
2270 return list.get(0);
2271 }
2272 }
2273
2274
2289 public UserGroupGroupRole[] findByG_R_PrevAndNext(
2290 UserGroupGroupRolePK userGroupGroupRolePK, long groupId, long roleId,
2291 OrderByComparator orderByComparator)
2292 throws NoSuchUserGroupGroupRoleException, SystemException {
2293 UserGroupGroupRole userGroupGroupRole = findByPrimaryKey(userGroupGroupRolePK);
2294
2295 Session session = null;
2296
2297 try {
2298 session = openSession();
2299
2300 UserGroupGroupRole[] array = new UserGroupGroupRoleImpl[3];
2301
2302 array[0] = getByG_R_PrevAndNext(session, userGroupGroupRole,
2303 groupId, roleId, orderByComparator, true);
2304
2305 array[1] = userGroupGroupRole;
2306
2307 array[2] = getByG_R_PrevAndNext(session, userGroupGroupRole,
2308 groupId, roleId, orderByComparator, false);
2309
2310 return array;
2311 }
2312 catch (Exception e) {
2313 throw processException(e);
2314 }
2315 finally {
2316 closeSession(session);
2317 }
2318 }
2319
2320 protected UserGroupGroupRole getByG_R_PrevAndNext(Session session,
2321 UserGroupGroupRole userGroupGroupRole, long groupId, long roleId,
2322 OrderByComparator orderByComparator, boolean previous) {
2323 StringBundler query = null;
2324
2325 if (orderByComparator != null) {
2326 query = new StringBundler(6 +
2327 (orderByComparator.getOrderByFields().length * 6));
2328 }
2329 else {
2330 query = new StringBundler(3);
2331 }
2332
2333 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
2334
2335 query.append(_FINDER_COLUMN_G_R_GROUPID_2);
2336
2337 query.append(_FINDER_COLUMN_G_R_ROLEID_2);
2338
2339 if (orderByComparator != null) {
2340 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2341
2342 if (orderByConditionFields.length > 0) {
2343 query.append(WHERE_AND);
2344 }
2345
2346 for (int i = 0; i < orderByConditionFields.length; i++) {
2347 query.append(_ORDER_BY_ENTITY_ALIAS);
2348 query.append(orderByConditionFields[i]);
2349
2350 if ((i + 1) < orderByConditionFields.length) {
2351 if (orderByComparator.isAscending() ^ previous) {
2352 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2353 }
2354 else {
2355 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2356 }
2357 }
2358 else {
2359 if (orderByComparator.isAscending() ^ previous) {
2360 query.append(WHERE_GREATER_THAN);
2361 }
2362 else {
2363 query.append(WHERE_LESSER_THAN);
2364 }
2365 }
2366 }
2367
2368 query.append(ORDER_BY_CLAUSE);
2369
2370 String[] orderByFields = orderByComparator.getOrderByFields();
2371
2372 for (int i = 0; i < orderByFields.length; i++) {
2373 query.append(_ORDER_BY_ENTITY_ALIAS);
2374 query.append(orderByFields[i]);
2375
2376 if ((i + 1) < orderByFields.length) {
2377 if (orderByComparator.isAscending() ^ previous) {
2378 query.append(ORDER_BY_ASC_HAS_NEXT);
2379 }
2380 else {
2381 query.append(ORDER_BY_DESC_HAS_NEXT);
2382 }
2383 }
2384 else {
2385 if (orderByComparator.isAscending() ^ previous) {
2386 query.append(ORDER_BY_ASC);
2387 }
2388 else {
2389 query.append(ORDER_BY_DESC);
2390 }
2391 }
2392 }
2393 }
2394
2395 String sql = query.toString();
2396
2397 Query q = session.createQuery(sql);
2398
2399 q.setFirstResult(0);
2400 q.setMaxResults(2);
2401
2402 QueryPos qPos = QueryPos.getInstance(q);
2403
2404 qPos.add(groupId);
2405
2406 qPos.add(roleId);
2407
2408 if (orderByComparator != null) {
2409 Object[] values = orderByComparator.getOrderByConditionValues(userGroupGroupRole);
2410
2411 for (Object value : values) {
2412 qPos.add(value);
2413 }
2414 }
2415
2416 List<UserGroupGroupRole> list = q.list();
2417
2418 if (list.size() == 2) {
2419 return list.get(1);
2420 }
2421 else {
2422 return null;
2423 }
2424 }
2425
2426
2432 public List<UserGroupGroupRole> findAll() throws SystemException {
2433 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2434 }
2435
2436
2448 public List<UserGroupGroupRole> findAll(int start, int end)
2449 throws SystemException {
2450 return findAll(start, end, null);
2451 }
2452
2453
2466 public List<UserGroupGroupRole> findAll(int start, int end,
2467 OrderByComparator orderByComparator) throws SystemException {
2468 FinderPath finderPath = null;
2469 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2470
2471 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2472 (orderByComparator == null)) {
2473 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2474 finderArgs = FINDER_ARGS_EMPTY;
2475 }
2476 else {
2477 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2478 finderArgs = new Object[] { start, end, orderByComparator };
2479 }
2480
2481 List<UserGroupGroupRole> list = (List<UserGroupGroupRole>)FinderCacheUtil.getResult(finderPath,
2482 finderArgs, this);
2483
2484 if (list == null) {
2485 StringBundler query = null;
2486 String sql = null;
2487
2488 if (orderByComparator != null) {
2489 query = new StringBundler(2 +
2490 (orderByComparator.getOrderByFields().length * 3));
2491
2492 query.append(_SQL_SELECT_USERGROUPGROUPROLE);
2493
2494 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2495 orderByComparator);
2496
2497 sql = query.toString();
2498 }
2499 else {
2500 sql = _SQL_SELECT_USERGROUPGROUPROLE;
2501 }
2502
2503 Session session = null;
2504
2505 try {
2506 session = openSession();
2507
2508 Query q = session.createQuery(sql);
2509
2510 if (orderByComparator == null) {
2511 list = (List<UserGroupGroupRole>)QueryUtil.list(q,
2512 getDialect(), start, end, false);
2513
2514 Collections.sort(list);
2515 }
2516 else {
2517 list = (List<UserGroupGroupRole>)QueryUtil.list(q,
2518 getDialect(), start, end);
2519 }
2520 }
2521 catch (Exception e) {
2522 throw processException(e);
2523 }
2524 finally {
2525 if (list == null) {
2526 FinderCacheUtil.removeResult(finderPath, finderArgs);
2527 }
2528 else {
2529 cacheResult(list);
2530
2531 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2532 }
2533
2534 closeSession(session);
2535 }
2536 }
2537
2538 return list;
2539 }
2540
2541
2547 public void removeByUserGroupId(long userGroupId) throws SystemException {
2548 for (UserGroupGroupRole userGroupGroupRole : findByUserGroupId(
2549 userGroupId)) {
2550 remove(userGroupGroupRole);
2551 }
2552 }
2553
2554
2560 public void removeByGroupId(long groupId) throws SystemException {
2561 for (UserGroupGroupRole userGroupGroupRole : findByGroupId(groupId)) {
2562 remove(userGroupGroupRole);
2563 }
2564 }
2565
2566
2572 public void removeByRoleId(long roleId) throws SystemException {
2573 for (UserGroupGroupRole userGroupGroupRole : findByRoleId(roleId)) {
2574 remove(userGroupGroupRole);
2575 }
2576 }
2577
2578
2585 public void removeByU_G(long userGroupId, long groupId)
2586 throws SystemException {
2587 for (UserGroupGroupRole userGroupGroupRole : findByU_G(userGroupId,
2588 groupId)) {
2589 remove(userGroupGroupRole);
2590 }
2591 }
2592
2593
2600 public void removeByG_R(long groupId, long roleId)
2601 throws SystemException {
2602 for (UserGroupGroupRole userGroupGroupRole : findByG_R(groupId, roleId)) {
2603 remove(userGroupGroupRole);
2604 }
2605 }
2606
2607
2612 public void removeAll() throws SystemException {
2613 for (UserGroupGroupRole userGroupGroupRole : findAll()) {
2614 remove(userGroupGroupRole);
2615 }
2616 }
2617
2618
2625 public int countByUserGroupId(long userGroupId) throws SystemException {
2626 Object[] finderArgs = new Object[] { userGroupId };
2627
2628 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERGROUPID,
2629 finderArgs, this);
2630
2631 if (count == null) {
2632 StringBundler query = new StringBundler(2);
2633
2634 query.append(_SQL_COUNT_USERGROUPGROUPROLE_WHERE);
2635
2636 query.append(_FINDER_COLUMN_USERGROUPID_USERGROUPID_2);
2637
2638 String sql = query.toString();
2639
2640 Session session = null;
2641
2642 try {
2643 session = openSession();
2644
2645 Query q = session.createQuery(sql);
2646
2647 QueryPos qPos = QueryPos.getInstance(q);
2648
2649 qPos.add(userGroupId);
2650
2651 count = (Long)q.uniqueResult();
2652 }
2653 catch (Exception e) {
2654 throw processException(e);
2655 }
2656 finally {
2657 if (count == null) {
2658 count = Long.valueOf(0);
2659 }
2660
2661 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERGROUPID,
2662 finderArgs, count);
2663
2664 closeSession(session);
2665 }
2666 }
2667
2668 return count.intValue();
2669 }
2670
2671
2678 public int countByGroupId(long groupId) throws SystemException {
2679 Object[] finderArgs = new Object[] { groupId };
2680
2681 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2682 finderArgs, this);
2683
2684 if (count == null) {
2685 StringBundler query = new StringBundler(2);
2686
2687 query.append(_SQL_COUNT_USERGROUPGROUPROLE_WHERE);
2688
2689 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2690
2691 String sql = query.toString();
2692
2693 Session session = null;
2694
2695 try {
2696 session = openSession();
2697
2698 Query q = session.createQuery(sql);
2699
2700 QueryPos qPos = QueryPos.getInstance(q);
2701
2702 qPos.add(groupId);
2703
2704 count = (Long)q.uniqueResult();
2705 }
2706 catch (Exception e) {
2707 throw processException(e);
2708 }
2709 finally {
2710 if (count == null) {
2711 count = Long.valueOf(0);
2712 }
2713
2714 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2715 finderArgs, count);
2716
2717 closeSession(session);
2718 }
2719 }
2720
2721 return count.intValue();
2722 }
2723
2724
2731 public int countByRoleId(long roleId) throws SystemException {
2732 Object[] finderArgs = new Object[] { roleId };
2733
2734 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ROLEID,
2735 finderArgs, this);
2736
2737 if (count == null) {
2738 StringBundler query = new StringBundler(2);
2739
2740 query.append(_SQL_COUNT_USERGROUPGROUPROLE_WHERE);
2741
2742 query.append(_FINDER_COLUMN_ROLEID_ROLEID_2);
2743
2744 String sql = query.toString();
2745
2746 Session session = null;
2747
2748 try {
2749 session = openSession();
2750
2751 Query q = session.createQuery(sql);
2752
2753 QueryPos qPos = QueryPos.getInstance(q);
2754
2755 qPos.add(roleId);
2756
2757 count = (Long)q.uniqueResult();
2758 }
2759 catch (Exception e) {
2760 throw processException(e);
2761 }
2762 finally {
2763 if (count == null) {
2764 count = Long.valueOf(0);
2765 }
2766
2767 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ROLEID,
2768 finderArgs, count);
2769
2770 closeSession(session);
2771 }
2772 }
2773
2774 return count.intValue();
2775 }
2776
2777
2785 public int countByU_G(long userGroupId, long groupId)
2786 throws SystemException {
2787 Object[] finderArgs = new Object[] { userGroupId, groupId };
2788
2789 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_G,
2790 finderArgs, this);
2791
2792 if (count == null) {
2793 StringBundler query = new StringBundler(3);
2794
2795 query.append(_SQL_COUNT_USERGROUPGROUPROLE_WHERE);
2796
2797 query.append(_FINDER_COLUMN_U_G_USERGROUPID_2);
2798
2799 query.append(_FINDER_COLUMN_U_G_GROUPID_2);
2800
2801 String sql = query.toString();
2802
2803 Session session = null;
2804
2805 try {
2806 session = openSession();
2807
2808 Query q = session.createQuery(sql);
2809
2810 QueryPos qPos = QueryPos.getInstance(q);
2811
2812 qPos.add(userGroupId);
2813
2814 qPos.add(groupId);
2815
2816 count = (Long)q.uniqueResult();
2817 }
2818 catch (Exception e) {
2819 throw processException(e);
2820 }
2821 finally {
2822 if (count == null) {
2823 count = Long.valueOf(0);
2824 }
2825
2826 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_G, finderArgs,
2827 count);
2828
2829 closeSession(session);
2830 }
2831 }
2832
2833 return count.intValue();
2834 }
2835
2836
2844 public int countByG_R(long groupId, long roleId) throws SystemException {
2845 Object[] finderArgs = new Object[] { groupId, roleId };
2846
2847 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_R,
2848 finderArgs, this);
2849
2850 if (count == null) {
2851 StringBundler query = new StringBundler(3);
2852
2853 query.append(_SQL_COUNT_USERGROUPGROUPROLE_WHERE);
2854
2855 query.append(_FINDER_COLUMN_G_R_GROUPID_2);
2856
2857 query.append(_FINDER_COLUMN_G_R_ROLEID_2);
2858
2859 String sql = query.toString();
2860
2861 Session session = null;
2862
2863 try {
2864 session = openSession();
2865
2866 Query q = session.createQuery(sql);
2867
2868 QueryPos qPos = QueryPos.getInstance(q);
2869
2870 qPos.add(groupId);
2871
2872 qPos.add(roleId);
2873
2874 count = (Long)q.uniqueResult();
2875 }
2876 catch (Exception e) {
2877 throw processException(e);
2878 }
2879 finally {
2880 if (count == null) {
2881 count = Long.valueOf(0);
2882 }
2883
2884 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_R, finderArgs,
2885 count);
2886
2887 closeSession(session);
2888 }
2889 }
2890
2891 return count.intValue();
2892 }
2893
2894
2900 public int countAll() throws SystemException {
2901 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2902 FINDER_ARGS_EMPTY, this);
2903
2904 if (count == null) {
2905 Session session = null;
2906
2907 try {
2908 session = openSession();
2909
2910 Query q = session.createQuery(_SQL_COUNT_USERGROUPGROUPROLE);
2911
2912 count = (Long)q.uniqueResult();
2913 }
2914 catch (Exception e) {
2915 throw processException(e);
2916 }
2917 finally {
2918 if (count == null) {
2919 count = Long.valueOf(0);
2920 }
2921
2922 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2923 FINDER_ARGS_EMPTY, count);
2924
2925 closeSession(session);
2926 }
2927 }
2928
2929 return count.intValue();
2930 }
2931
2932
2935 public void afterPropertiesSet() {
2936 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2937 com.liferay.portal.util.PropsUtil.get(
2938 "value.object.listener.com.liferay.portal.model.UserGroupGroupRole")));
2939
2940 if (listenerClassNames.length > 0) {
2941 try {
2942 List<ModelListener<UserGroupGroupRole>> listenersList = new ArrayList<ModelListener<UserGroupGroupRole>>();
2943
2944 for (String listenerClassName : listenerClassNames) {
2945 listenersList.add((ModelListener<UserGroupGroupRole>)InstanceFactory.newInstance(
2946 listenerClassName));
2947 }
2948
2949 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2950 }
2951 catch (Exception e) {
2952 _log.error(e);
2953 }
2954 }
2955 }
2956
2957 public void destroy() {
2958 EntityCacheUtil.removeCache(UserGroupGroupRoleImpl.class.getName());
2959 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2960 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2961 }
2962
2963 @BeanReference(type = AccountPersistence.class)
2964 protected AccountPersistence accountPersistence;
2965 @BeanReference(type = AddressPersistence.class)
2966 protected AddressPersistence addressPersistence;
2967 @BeanReference(type = BrowserTrackerPersistence.class)
2968 protected BrowserTrackerPersistence browserTrackerPersistence;
2969 @BeanReference(type = ClassNamePersistence.class)
2970 protected ClassNamePersistence classNamePersistence;
2971 @BeanReference(type = ClusterGroupPersistence.class)
2972 protected ClusterGroupPersistence clusterGroupPersistence;
2973 @BeanReference(type = CompanyPersistence.class)
2974 protected CompanyPersistence companyPersistence;
2975 @BeanReference(type = ContactPersistence.class)
2976 protected ContactPersistence contactPersistence;
2977 @BeanReference(type = CountryPersistence.class)
2978 protected CountryPersistence countryPersistence;
2979 @BeanReference(type = EmailAddressPersistence.class)
2980 protected EmailAddressPersistence emailAddressPersistence;
2981 @BeanReference(type = GroupPersistence.class)
2982 protected GroupPersistence groupPersistence;
2983 @BeanReference(type = ImagePersistence.class)
2984 protected ImagePersistence imagePersistence;
2985 @BeanReference(type = LayoutPersistence.class)
2986 protected LayoutPersistence layoutPersistence;
2987 @BeanReference(type = LayoutBranchPersistence.class)
2988 protected LayoutBranchPersistence layoutBranchPersistence;
2989 @BeanReference(type = LayoutPrototypePersistence.class)
2990 protected LayoutPrototypePersistence layoutPrototypePersistence;
2991 @BeanReference(type = LayoutRevisionPersistence.class)
2992 protected LayoutRevisionPersistence layoutRevisionPersistence;
2993 @BeanReference(type = LayoutSetPersistence.class)
2994 protected LayoutSetPersistence layoutSetPersistence;
2995 @BeanReference(type = LayoutSetBranchPersistence.class)
2996 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
2997 @BeanReference(type = LayoutSetPrototypePersistence.class)
2998 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2999 @BeanReference(type = ListTypePersistence.class)
3000 protected ListTypePersistence listTypePersistence;
3001 @BeanReference(type = LockPersistence.class)
3002 protected LockPersistence lockPersistence;
3003 @BeanReference(type = MembershipRequestPersistence.class)
3004 protected MembershipRequestPersistence membershipRequestPersistence;
3005 @BeanReference(type = OrganizationPersistence.class)
3006 protected OrganizationPersistence organizationPersistence;
3007 @BeanReference(type = OrgGroupPermissionPersistence.class)
3008 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
3009 @BeanReference(type = OrgGroupRolePersistence.class)
3010 protected OrgGroupRolePersistence orgGroupRolePersistence;
3011 @BeanReference(type = OrgLaborPersistence.class)
3012 protected OrgLaborPersistence orgLaborPersistence;
3013 @BeanReference(type = PasswordPolicyPersistence.class)
3014 protected PasswordPolicyPersistence passwordPolicyPersistence;
3015 @BeanReference(type = PasswordPolicyRelPersistence.class)
3016 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
3017 @BeanReference(type = PasswordTrackerPersistence.class)
3018 protected PasswordTrackerPersistence passwordTrackerPersistence;
3019 @BeanReference(type = PermissionPersistence.class)
3020 protected PermissionPersistence permissionPersistence;
3021 @BeanReference(type = PhonePersistence.class)
3022 protected PhonePersistence phonePersistence;
3023 @BeanReference(type = PluginSettingPersistence.class)
3024 protected PluginSettingPersistence pluginSettingPersistence;
3025 @BeanReference(type = PortalPreferencesPersistence.class)
3026 protected PortalPreferencesPersistence portalPreferencesPersistence;
3027 @BeanReference(type = PortletPersistence.class)
3028 protected PortletPersistence portletPersistence;
3029 @BeanReference(type = PortletItemPersistence.class)
3030 protected PortletItemPersistence portletItemPersistence;
3031 @BeanReference(type = PortletPreferencesPersistence.class)
3032 protected PortletPreferencesPersistence portletPreferencesPersistence;
3033 @BeanReference(type = RegionPersistence.class)
3034 protected RegionPersistence regionPersistence;
3035 @BeanReference(type = ReleasePersistence.class)
3036 protected ReleasePersistence releasePersistence;
3037 @BeanReference(type = RepositoryPersistence.class)
3038 protected RepositoryPersistence repositoryPersistence;
3039 @BeanReference(type = RepositoryEntryPersistence.class)
3040 protected RepositoryEntryPersistence repositoryEntryPersistence;
3041 @BeanReference(type = ResourcePersistence.class)
3042 protected ResourcePersistence resourcePersistence;
3043 @BeanReference(type = ResourceActionPersistence.class)
3044 protected ResourceActionPersistence resourceActionPersistence;
3045 @BeanReference(type = ResourceBlockPersistence.class)
3046 protected ResourceBlockPersistence resourceBlockPersistence;
3047 @BeanReference(type = ResourceBlockPermissionPersistence.class)
3048 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
3049 @BeanReference(type = ResourceCodePersistence.class)
3050 protected ResourceCodePersistence resourceCodePersistence;
3051 @BeanReference(type = ResourcePermissionPersistence.class)
3052 protected ResourcePermissionPersistence resourcePermissionPersistence;
3053 @BeanReference(type = ResourceTypePermissionPersistence.class)
3054 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
3055 @BeanReference(type = RolePersistence.class)
3056 protected RolePersistence rolePersistence;
3057 @BeanReference(type = ServiceComponentPersistence.class)
3058 protected ServiceComponentPersistence serviceComponentPersistence;
3059 @BeanReference(type = ShardPersistence.class)
3060 protected ShardPersistence shardPersistence;
3061 @BeanReference(type = SubscriptionPersistence.class)
3062 protected SubscriptionPersistence subscriptionPersistence;
3063 @BeanReference(type = TeamPersistence.class)
3064 protected TeamPersistence teamPersistence;
3065 @BeanReference(type = TicketPersistence.class)
3066 protected TicketPersistence ticketPersistence;
3067 @BeanReference(type = UserPersistence.class)
3068 protected UserPersistence userPersistence;
3069 @BeanReference(type = UserGroupPersistence.class)
3070 protected UserGroupPersistence userGroupPersistence;
3071 @BeanReference(type = UserGroupGroupRolePersistence.class)
3072 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
3073 @BeanReference(type = UserGroupRolePersistence.class)
3074 protected UserGroupRolePersistence userGroupRolePersistence;
3075 @BeanReference(type = UserIdMapperPersistence.class)
3076 protected UserIdMapperPersistence userIdMapperPersistence;
3077 @BeanReference(type = UserNotificationEventPersistence.class)
3078 protected UserNotificationEventPersistence userNotificationEventPersistence;
3079 @BeanReference(type = UserTrackerPersistence.class)
3080 protected UserTrackerPersistence userTrackerPersistence;
3081 @BeanReference(type = UserTrackerPathPersistence.class)
3082 protected UserTrackerPathPersistence userTrackerPathPersistence;
3083 @BeanReference(type = VirtualHostPersistence.class)
3084 protected VirtualHostPersistence virtualHostPersistence;
3085 @BeanReference(type = WebDAVPropsPersistence.class)
3086 protected WebDAVPropsPersistence webDAVPropsPersistence;
3087 @BeanReference(type = WebsitePersistence.class)
3088 protected WebsitePersistence websitePersistence;
3089 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
3090 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
3091 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
3092 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
3093 private static final String _SQL_SELECT_USERGROUPGROUPROLE = "SELECT userGroupGroupRole FROM UserGroupGroupRole userGroupGroupRole";
3094 private static final String _SQL_SELECT_USERGROUPGROUPROLE_WHERE = "SELECT userGroupGroupRole FROM UserGroupGroupRole userGroupGroupRole WHERE ";
3095 private static final String _SQL_COUNT_USERGROUPGROUPROLE = "SELECT COUNT(userGroupGroupRole) FROM UserGroupGroupRole userGroupGroupRole";
3096 private static final String _SQL_COUNT_USERGROUPGROUPROLE_WHERE = "SELECT COUNT(userGroupGroupRole) FROM UserGroupGroupRole userGroupGroupRole WHERE ";
3097 private static final String _FINDER_COLUMN_USERGROUPID_USERGROUPID_2 = "userGroupGroupRole.id.userGroupId = ?";
3098 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "userGroupGroupRole.id.groupId = ?";
3099 private static final String _FINDER_COLUMN_ROLEID_ROLEID_2 = "userGroupGroupRole.id.roleId = ?";
3100 private static final String _FINDER_COLUMN_U_G_USERGROUPID_2 = "userGroupGroupRole.id.userGroupId = ? AND ";
3101 private static final String _FINDER_COLUMN_U_G_GROUPID_2 = "userGroupGroupRole.id.groupId = ?";
3102 private static final String _FINDER_COLUMN_G_R_GROUPID_2 = "userGroupGroupRole.id.groupId = ? AND ";
3103 private static final String _FINDER_COLUMN_G_R_ROLEID_2 = "userGroupGroupRole.id.roleId = ?";
3104 private static final String _ORDER_BY_ENTITY_ALIAS = "userGroupGroupRole.";
3105 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserGroupGroupRole exists with the primary key ";
3106 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserGroupGroupRole exists with the key {";
3107 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3108 private static Log _log = LogFactoryUtil.getLog(UserGroupGroupRolePersistenceImpl.class);
3109 private static UserGroupGroupRole _nullUserGroupGroupRole = new UserGroupGroupRoleImpl() {
3110 @Override
3111 public Object clone() {
3112 return this;
3113 }
3114
3115 @Override
3116 public CacheModel<UserGroupGroupRole> toCacheModel() {
3117 return _nullUserGroupGroupRoleCacheModel;
3118 }
3119 };
3120
3121 private static CacheModel<UserGroupGroupRole> _nullUserGroupGroupRoleCacheModel =
3122 new CacheModel<UserGroupGroupRole>() {
3123 public UserGroupGroupRole toEntityModel() {
3124 return _nullUserGroupGroupRole;
3125 }
3126 };
3127 }