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
266 public UserGroupGroupRole create(UserGroupGroupRolePK userGroupGroupRolePK) {
267 UserGroupGroupRole userGroupGroupRole = new UserGroupGroupRoleImpl();
268
269 userGroupGroupRole.setNew(true);
270 userGroupGroupRole.setPrimaryKey(userGroupGroupRolePK);
271
272 return userGroupGroupRole;
273 }
274
275
283 @Override
284 public UserGroupGroupRole remove(Serializable primaryKey)
285 throws NoSuchModelException, SystemException {
286 return remove((UserGroupGroupRolePK)primaryKey);
287 }
288
289
297 public UserGroupGroupRole remove(UserGroupGroupRolePK userGroupGroupRolePK)
298 throws NoSuchUserGroupGroupRoleException, SystemException {
299 Session session = null;
300
301 try {
302 session = openSession();
303
304 UserGroupGroupRole userGroupGroupRole = (UserGroupGroupRole)session.get(UserGroupGroupRoleImpl.class,
305 userGroupGroupRolePK);
306
307 if (userGroupGroupRole == null) {
308 if (_log.isWarnEnabled()) {
309 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
310 userGroupGroupRolePK);
311 }
312
313 throw new NoSuchUserGroupGroupRoleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
314 userGroupGroupRolePK);
315 }
316
317 return userGroupGroupRolePersistence.remove(userGroupGroupRole);
318 }
319 catch (NoSuchUserGroupGroupRoleException nsee) {
320 throw nsee;
321 }
322 catch (Exception e) {
323 throw processException(e);
324 }
325 finally {
326 closeSession(session);
327 }
328 }
329
330
337 @Override
338 public UserGroupGroupRole remove(UserGroupGroupRole userGroupGroupRole)
339 throws SystemException {
340 return super.remove(userGroupGroupRole);
341 }
342
343 @Override
344 protected UserGroupGroupRole removeImpl(
345 UserGroupGroupRole userGroupGroupRole) throws SystemException {
346 userGroupGroupRole = toUnwrappedModel(userGroupGroupRole);
347
348 Session session = null;
349
350 try {
351 session = openSession();
352
353 BatchSessionUtil.delete(session, userGroupGroupRole);
354 }
355 catch (Exception e) {
356 throw processException(e);
357 }
358 finally {
359 closeSession(session);
360 }
361
362 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
363 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
364
365 EntityCacheUtil.removeResult(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
366 UserGroupGroupRoleImpl.class, userGroupGroupRole.getPrimaryKey());
367
368 return userGroupGroupRole;
369 }
370
371 @Override
372 public UserGroupGroupRole updateImpl(
373 com.liferay.portal.model.UserGroupGroupRole userGroupGroupRole,
374 boolean merge) throws SystemException {
375 userGroupGroupRole = toUnwrappedModel(userGroupGroupRole);
376
377 boolean isNew = userGroupGroupRole.isNew();
378
379 UserGroupGroupRoleModelImpl userGroupGroupRoleModelImpl = (UserGroupGroupRoleModelImpl)userGroupGroupRole;
380
381 Session session = null;
382
383 try {
384 session = openSession();
385
386 BatchSessionUtil.update(session, userGroupGroupRole, merge);
387
388 userGroupGroupRole.setNew(false);
389 }
390 catch (Exception e) {
391 throw processException(e);
392 }
393 finally {
394 closeSession(session);
395 }
396
397 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
398
399 if (isNew || !UserGroupGroupRoleModelImpl.COLUMN_BITMASK_ENABLED) {
400 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
401 }
402
403 else {
404 if ((userGroupGroupRoleModelImpl.getColumnBitmask() &
405 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERGROUPID.getColumnBitmask()) != 0) {
406 Object[] args = new Object[] {
407 Long.valueOf(userGroupGroupRoleModelImpl.getOriginalUserGroupId())
408 };
409
410 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERGROUPID,
411 args);
412 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERGROUPID,
413 args);
414
415 args = new Object[] {
416 Long.valueOf(userGroupGroupRoleModelImpl.getUserGroupId())
417 };
418
419 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERGROUPID,
420 args);
421 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERGROUPID,
422 args);
423 }
424
425 if ((userGroupGroupRoleModelImpl.getColumnBitmask() &
426 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
427 Object[] args = new Object[] {
428 Long.valueOf(userGroupGroupRoleModelImpl.getOriginalGroupId())
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 args = new Object[] {
436 Long.valueOf(userGroupGroupRoleModelImpl.getGroupId())
437 };
438
439 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
440 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
441 args);
442 }
443
444 if ((userGroupGroupRoleModelImpl.getColumnBitmask() &
445 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ROLEID.getColumnBitmask()) != 0) {
446 Object[] args = new Object[] {
447 Long.valueOf(userGroupGroupRoleModelImpl.getOriginalRoleId())
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 args = new Object[] {
455 Long.valueOf(userGroupGroupRoleModelImpl.getRoleId())
456 };
457
458 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ROLEID, args);
459 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ROLEID,
460 args);
461 }
462
463 if ((userGroupGroupRoleModelImpl.getColumnBitmask() &
464 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_G.getColumnBitmask()) != 0) {
465 Object[] args = new Object[] {
466 Long.valueOf(userGroupGroupRoleModelImpl.getOriginalUserGroupId()),
467 Long.valueOf(userGroupGroupRoleModelImpl.getOriginalGroupId())
468 };
469
470 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_G, args);
471 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_G,
472 args);
473
474 args = new Object[] {
475 Long.valueOf(userGroupGroupRoleModelImpl.getUserGroupId()),
476 Long.valueOf(userGroupGroupRoleModelImpl.getGroupId())
477 };
478
479 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_G, args);
480 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_G,
481 args);
482 }
483
484 if ((userGroupGroupRoleModelImpl.getColumnBitmask() &
485 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_R.getColumnBitmask()) != 0) {
486 Object[] args = new Object[] {
487 Long.valueOf(userGroupGroupRoleModelImpl.getOriginalGroupId()),
488 Long.valueOf(userGroupGroupRoleModelImpl.getOriginalRoleId())
489 };
490
491 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_R, args);
492 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_R,
493 args);
494
495 args = new Object[] {
496 Long.valueOf(userGroupGroupRoleModelImpl.getGroupId()),
497 Long.valueOf(userGroupGroupRoleModelImpl.getRoleId())
498 };
499
500 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_R, args);
501 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_R,
502 args);
503 }
504 }
505
506 EntityCacheUtil.putResult(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
507 UserGroupGroupRoleImpl.class, userGroupGroupRole.getPrimaryKey(),
508 userGroupGroupRole);
509
510 return userGroupGroupRole;
511 }
512
513 protected UserGroupGroupRole toUnwrappedModel(
514 UserGroupGroupRole userGroupGroupRole) {
515 if (userGroupGroupRole instanceof UserGroupGroupRoleImpl) {
516 return userGroupGroupRole;
517 }
518
519 UserGroupGroupRoleImpl userGroupGroupRoleImpl = new UserGroupGroupRoleImpl();
520
521 userGroupGroupRoleImpl.setNew(userGroupGroupRole.isNew());
522 userGroupGroupRoleImpl.setPrimaryKey(userGroupGroupRole.getPrimaryKey());
523
524 userGroupGroupRoleImpl.setUserGroupId(userGroupGroupRole.getUserGroupId());
525 userGroupGroupRoleImpl.setGroupId(userGroupGroupRole.getGroupId());
526 userGroupGroupRoleImpl.setRoleId(userGroupGroupRole.getRoleId());
527
528 return userGroupGroupRoleImpl;
529 }
530
531
539 @Override
540 public UserGroupGroupRole findByPrimaryKey(Serializable primaryKey)
541 throws NoSuchModelException, SystemException {
542 return findByPrimaryKey((UserGroupGroupRolePK)primaryKey);
543 }
544
545
553 public UserGroupGroupRole findByPrimaryKey(
554 UserGroupGroupRolePK userGroupGroupRolePK)
555 throws NoSuchUserGroupGroupRoleException, SystemException {
556 UserGroupGroupRole userGroupGroupRole = fetchByPrimaryKey(userGroupGroupRolePK);
557
558 if (userGroupGroupRole == null) {
559 if (_log.isWarnEnabled()) {
560 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
561 userGroupGroupRolePK);
562 }
563
564 throw new NoSuchUserGroupGroupRoleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
565 userGroupGroupRolePK);
566 }
567
568 return userGroupGroupRole;
569 }
570
571
578 @Override
579 public UserGroupGroupRole fetchByPrimaryKey(Serializable primaryKey)
580 throws SystemException {
581 return fetchByPrimaryKey((UserGroupGroupRolePK)primaryKey);
582 }
583
584
591 public UserGroupGroupRole fetchByPrimaryKey(
592 UserGroupGroupRolePK userGroupGroupRolePK) throws SystemException {
593 UserGroupGroupRole userGroupGroupRole = (UserGroupGroupRole)EntityCacheUtil.getResult(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
594 UserGroupGroupRoleImpl.class, userGroupGroupRolePK);
595
596 if (userGroupGroupRole == _nullUserGroupGroupRole) {
597 return null;
598 }
599
600 if (userGroupGroupRole == null) {
601 Session session = null;
602
603 boolean hasException = false;
604
605 try {
606 session = openSession();
607
608 userGroupGroupRole = (UserGroupGroupRole)session.get(UserGroupGroupRoleImpl.class,
609 userGroupGroupRolePK);
610 }
611 catch (Exception e) {
612 hasException = true;
613
614 throw processException(e);
615 }
616 finally {
617 if (userGroupGroupRole != null) {
618 cacheResult(userGroupGroupRole);
619 }
620 else if (!hasException) {
621 EntityCacheUtil.putResult(UserGroupGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
622 UserGroupGroupRoleImpl.class, userGroupGroupRolePK,
623 _nullUserGroupGroupRole);
624 }
625
626 closeSession(session);
627 }
628 }
629
630 return userGroupGroupRole;
631 }
632
633
640 public List<UserGroupGroupRole> findByUserGroupId(long userGroupId)
641 throws SystemException {
642 return findByUserGroupId(userGroupId, QueryUtil.ALL_POS,
643 QueryUtil.ALL_POS, null);
644 }
645
646
659 public List<UserGroupGroupRole> findByUserGroupId(long userGroupId,
660 int start, int end) throws SystemException {
661 return findByUserGroupId(userGroupId, start, end, null);
662 }
663
664
678 public List<UserGroupGroupRole> findByUserGroupId(long userGroupId,
679 int start, int end, OrderByComparator orderByComparator)
680 throws SystemException {
681 FinderPath finderPath = null;
682 Object[] finderArgs = null;
683
684 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
685 (orderByComparator == null)) {
686 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERGROUPID;
687 finderArgs = new Object[] { userGroupId };
688 }
689 else {
690 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERGROUPID;
691 finderArgs = new Object[] { userGroupId, start, end, orderByComparator };
692 }
693
694 List<UserGroupGroupRole> list = (List<UserGroupGroupRole>)FinderCacheUtil.getResult(finderPath,
695 finderArgs, this);
696
697 if (list == null) {
698 StringBundler query = null;
699
700 if (orderByComparator != null) {
701 query = new StringBundler(3 +
702 (orderByComparator.getOrderByFields().length * 3));
703 }
704 else {
705 query = new StringBundler(2);
706 }
707
708 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
709
710 query.append(_FINDER_COLUMN_USERGROUPID_USERGROUPID_2);
711
712 if (orderByComparator != null) {
713 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
714 orderByComparator);
715 }
716
717 String sql = query.toString();
718
719 Session session = null;
720
721 try {
722 session = openSession();
723
724 Query q = session.createQuery(sql);
725
726 QueryPos qPos = QueryPos.getInstance(q);
727
728 qPos.add(userGroupId);
729
730 list = (List<UserGroupGroupRole>)QueryUtil.list(q,
731 getDialect(), start, end);
732 }
733 catch (Exception e) {
734 throw processException(e);
735 }
736 finally {
737 if (list == null) {
738 FinderCacheUtil.removeResult(finderPath, finderArgs);
739 }
740 else {
741 cacheResult(list);
742
743 FinderCacheUtil.putResult(finderPath, finderArgs, list);
744 }
745
746 closeSession(session);
747 }
748 }
749
750 return list;
751 }
752
753
766 public UserGroupGroupRole findByUserGroupId_First(long userGroupId,
767 OrderByComparator orderByComparator)
768 throws NoSuchUserGroupGroupRoleException, SystemException {
769 List<UserGroupGroupRole> list = findByUserGroupId(userGroupId, 0, 1,
770 orderByComparator);
771
772 if (list.isEmpty()) {
773 StringBundler msg = new StringBundler(4);
774
775 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
776
777 msg.append("userGroupId=");
778 msg.append(userGroupId);
779
780 msg.append(StringPool.CLOSE_CURLY_BRACE);
781
782 throw new NoSuchUserGroupGroupRoleException(msg.toString());
783 }
784 else {
785 return list.get(0);
786 }
787 }
788
789
802 public UserGroupGroupRole findByUserGroupId_Last(long userGroupId,
803 OrderByComparator orderByComparator)
804 throws NoSuchUserGroupGroupRoleException, SystemException {
805 int count = countByUserGroupId(userGroupId);
806
807 List<UserGroupGroupRole> list = findByUserGroupId(userGroupId,
808 count - 1, count, orderByComparator);
809
810 if (list.isEmpty()) {
811 StringBundler msg = new StringBundler(4);
812
813 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
814
815 msg.append("userGroupId=");
816 msg.append(userGroupId);
817
818 msg.append(StringPool.CLOSE_CURLY_BRACE);
819
820 throw new NoSuchUserGroupGroupRoleException(msg.toString());
821 }
822 else {
823 return list.get(0);
824 }
825 }
826
827
841 public UserGroupGroupRole[] findByUserGroupId_PrevAndNext(
842 UserGroupGroupRolePK userGroupGroupRolePK, long userGroupId,
843 OrderByComparator orderByComparator)
844 throws NoSuchUserGroupGroupRoleException, SystemException {
845 UserGroupGroupRole userGroupGroupRole = findByPrimaryKey(userGroupGroupRolePK);
846
847 Session session = null;
848
849 try {
850 session = openSession();
851
852 UserGroupGroupRole[] array = new UserGroupGroupRoleImpl[3];
853
854 array[0] = getByUserGroupId_PrevAndNext(session,
855 userGroupGroupRole, userGroupId, orderByComparator, true);
856
857 array[1] = userGroupGroupRole;
858
859 array[2] = getByUserGroupId_PrevAndNext(session,
860 userGroupGroupRole, userGroupId, orderByComparator, false);
861
862 return array;
863 }
864 catch (Exception e) {
865 throw processException(e);
866 }
867 finally {
868 closeSession(session);
869 }
870 }
871
872 protected UserGroupGroupRole getByUserGroupId_PrevAndNext(Session session,
873 UserGroupGroupRole userGroupGroupRole, long userGroupId,
874 OrderByComparator orderByComparator, boolean previous) {
875 StringBundler query = null;
876
877 if (orderByComparator != null) {
878 query = new StringBundler(6 +
879 (orderByComparator.getOrderByFields().length * 6));
880 }
881 else {
882 query = new StringBundler(3);
883 }
884
885 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
886
887 query.append(_FINDER_COLUMN_USERGROUPID_USERGROUPID_2);
888
889 if (orderByComparator != null) {
890 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
891
892 if (orderByConditionFields.length > 0) {
893 query.append(WHERE_AND);
894 }
895
896 for (int i = 0; i < orderByConditionFields.length; i++) {
897 query.append(_ORDER_BY_ENTITY_ALIAS);
898 query.append(orderByConditionFields[i]);
899
900 if ((i + 1) < orderByConditionFields.length) {
901 if (orderByComparator.isAscending() ^ previous) {
902 query.append(WHERE_GREATER_THAN_HAS_NEXT);
903 }
904 else {
905 query.append(WHERE_LESSER_THAN_HAS_NEXT);
906 }
907 }
908 else {
909 if (orderByComparator.isAscending() ^ previous) {
910 query.append(WHERE_GREATER_THAN);
911 }
912 else {
913 query.append(WHERE_LESSER_THAN);
914 }
915 }
916 }
917
918 query.append(ORDER_BY_CLAUSE);
919
920 String[] orderByFields = orderByComparator.getOrderByFields();
921
922 for (int i = 0; i < orderByFields.length; i++) {
923 query.append(_ORDER_BY_ENTITY_ALIAS);
924 query.append(orderByFields[i]);
925
926 if ((i + 1) < orderByFields.length) {
927 if (orderByComparator.isAscending() ^ previous) {
928 query.append(ORDER_BY_ASC_HAS_NEXT);
929 }
930 else {
931 query.append(ORDER_BY_DESC_HAS_NEXT);
932 }
933 }
934 else {
935 if (orderByComparator.isAscending() ^ previous) {
936 query.append(ORDER_BY_ASC);
937 }
938 else {
939 query.append(ORDER_BY_DESC);
940 }
941 }
942 }
943 }
944
945 String sql = query.toString();
946
947 Query q = session.createQuery(sql);
948
949 q.setFirstResult(0);
950 q.setMaxResults(2);
951
952 QueryPos qPos = QueryPos.getInstance(q);
953
954 qPos.add(userGroupId);
955
956 if (orderByComparator != null) {
957 Object[] values = orderByComparator.getOrderByConditionValues(userGroupGroupRole);
958
959 for (Object value : values) {
960 qPos.add(value);
961 }
962 }
963
964 List<UserGroupGroupRole> list = q.list();
965
966 if (list.size() == 2) {
967 return list.get(1);
968 }
969 else {
970 return null;
971 }
972 }
973
974
981 public List<UserGroupGroupRole> findByGroupId(long groupId)
982 throws SystemException {
983 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
984 }
985
986
999 public List<UserGroupGroupRole> findByGroupId(long groupId, int start,
1000 int end) throws SystemException {
1001 return findByGroupId(groupId, start, end, null);
1002 }
1003
1004
1018 public List<UserGroupGroupRole> findByGroupId(long groupId, int start,
1019 int end, OrderByComparator orderByComparator) throws SystemException {
1020 FinderPath finderPath = null;
1021 Object[] finderArgs = null;
1022
1023 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1024 (orderByComparator == null)) {
1025 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1026 finderArgs = new Object[] { groupId };
1027 }
1028 else {
1029 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1030 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1031 }
1032
1033 List<UserGroupGroupRole> list = (List<UserGroupGroupRole>)FinderCacheUtil.getResult(finderPath,
1034 finderArgs, this);
1035
1036 if (list == null) {
1037 StringBundler query = null;
1038
1039 if (orderByComparator != null) {
1040 query = new StringBundler(3 +
1041 (orderByComparator.getOrderByFields().length * 3));
1042 }
1043 else {
1044 query = new StringBundler(2);
1045 }
1046
1047 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
1048
1049 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1050
1051 if (orderByComparator != null) {
1052 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1053 orderByComparator);
1054 }
1055
1056 String sql = query.toString();
1057
1058 Session session = null;
1059
1060 try {
1061 session = openSession();
1062
1063 Query q = session.createQuery(sql);
1064
1065 QueryPos qPos = QueryPos.getInstance(q);
1066
1067 qPos.add(groupId);
1068
1069 list = (List<UserGroupGroupRole>)QueryUtil.list(q,
1070 getDialect(), start, end);
1071 }
1072 catch (Exception e) {
1073 throw processException(e);
1074 }
1075 finally {
1076 if (list == null) {
1077 FinderCacheUtil.removeResult(finderPath, finderArgs);
1078 }
1079 else {
1080 cacheResult(list);
1081
1082 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1083 }
1084
1085 closeSession(session);
1086 }
1087 }
1088
1089 return list;
1090 }
1091
1092
1105 public UserGroupGroupRole findByGroupId_First(long groupId,
1106 OrderByComparator orderByComparator)
1107 throws NoSuchUserGroupGroupRoleException, SystemException {
1108 List<UserGroupGroupRole> list = findByGroupId(groupId, 0, 1,
1109 orderByComparator);
1110
1111 if (list.isEmpty()) {
1112 StringBundler msg = new StringBundler(4);
1113
1114 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1115
1116 msg.append("groupId=");
1117 msg.append(groupId);
1118
1119 msg.append(StringPool.CLOSE_CURLY_BRACE);
1120
1121 throw new NoSuchUserGroupGroupRoleException(msg.toString());
1122 }
1123 else {
1124 return list.get(0);
1125 }
1126 }
1127
1128
1141 public UserGroupGroupRole findByGroupId_Last(long groupId,
1142 OrderByComparator orderByComparator)
1143 throws NoSuchUserGroupGroupRoleException, SystemException {
1144 int count = countByGroupId(groupId);
1145
1146 List<UserGroupGroupRole> list = findByGroupId(groupId, count - 1,
1147 count, orderByComparator);
1148
1149 if (list.isEmpty()) {
1150 StringBundler msg = new StringBundler(4);
1151
1152 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1153
1154 msg.append("groupId=");
1155 msg.append(groupId);
1156
1157 msg.append(StringPool.CLOSE_CURLY_BRACE);
1158
1159 throw new NoSuchUserGroupGroupRoleException(msg.toString());
1160 }
1161 else {
1162 return list.get(0);
1163 }
1164 }
1165
1166
1180 public UserGroupGroupRole[] findByGroupId_PrevAndNext(
1181 UserGroupGroupRolePK userGroupGroupRolePK, long groupId,
1182 OrderByComparator orderByComparator)
1183 throws NoSuchUserGroupGroupRoleException, SystemException {
1184 UserGroupGroupRole userGroupGroupRole = findByPrimaryKey(userGroupGroupRolePK);
1185
1186 Session session = null;
1187
1188 try {
1189 session = openSession();
1190
1191 UserGroupGroupRole[] array = new UserGroupGroupRoleImpl[3];
1192
1193 array[0] = getByGroupId_PrevAndNext(session, userGroupGroupRole,
1194 groupId, orderByComparator, true);
1195
1196 array[1] = userGroupGroupRole;
1197
1198 array[2] = getByGroupId_PrevAndNext(session, userGroupGroupRole,
1199 groupId, orderByComparator, false);
1200
1201 return array;
1202 }
1203 catch (Exception e) {
1204 throw processException(e);
1205 }
1206 finally {
1207 closeSession(session);
1208 }
1209 }
1210
1211 protected UserGroupGroupRole getByGroupId_PrevAndNext(Session session,
1212 UserGroupGroupRole userGroupGroupRole, long groupId,
1213 OrderByComparator orderByComparator, boolean previous) {
1214 StringBundler query = null;
1215
1216 if (orderByComparator != null) {
1217 query = new StringBundler(6 +
1218 (orderByComparator.getOrderByFields().length * 6));
1219 }
1220 else {
1221 query = new StringBundler(3);
1222 }
1223
1224 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
1225
1226 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1227
1228 if (orderByComparator != null) {
1229 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1230
1231 if (orderByConditionFields.length > 0) {
1232 query.append(WHERE_AND);
1233 }
1234
1235 for (int i = 0; i < orderByConditionFields.length; i++) {
1236 query.append(_ORDER_BY_ENTITY_ALIAS);
1237 query.append(orderByConditionFields[i]);
1238
1239 if ((i + 1) < orderByConditionFields.length) {
1240 if (orderByComparator.isAscending() ^ previous) {
1241 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1242 }
1243 else {
1244 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1245 }
1246 }
1247 else {
1248 if (orderByComparator.isAscending() ^ previous) {
1249 query.append(WHERE_GREATER_THAN);
1250 }
1251 else {
1252 query.append(WHERE_LESSER_THAN);
1253 }
1254 }
1255 }
1256
1257 query.append(ORDER_BY_CLAUSE);
1258
1259 String[] orderByFields = orderByComparator.getOrderByFields();
1260
1261 for (int i = 0; i < orderByFields.length; i++) {
1262 query.append(_ORDER_BY_ENTITY_ALIAS);
1263 query.append(orderByFields[i]);
1264
1265 if ((i + 1) < orderByFields.length) {
1266 if (orderByComparator.isAscending() ^ previous) {
1267 query.append(ORDER_BY_ASC_HAS_NEXT);
1268 }
1269 else {
1270 query.append(ORDER_BY_DESC_HAS_NEXT);
1271 }
1272 }
1273 else {
1274 if (orderByComparator.isAscending() ^ previous) {
1275 query.append(ORDER_BY_ASC);
1276 }
1277 else {
1278 query.append(ORDER_BY_DESC);
1279 }
1280 }
1281 }
1282 }
1283
1284 String sql = query.toString();
1285
1286 Query q = session.createQuery(sql);
1287
1288 q.setFirstResult(0);
1289 q.setMaxResults(2);
1290
1291 QueryPos qPos = QueryPos.getInstance(q);
1292
1293 qPos.add(groupId);
1294
1295 if (orderByComparator != null) {
1296 Object[] values = orderByComparator.getOrderByConditionValues(userGroupGroupRole);
1297
1298 for (Object value : values) {
1299 qPos.add(value);
1300 }
1301 }
1302
1303 List<UserGroupGroupRole> list = q.list();
1304
1305 if (list.size() == 2) {
1306 return list.get(1);
1307 }
1308 else {
1309 return null;
1310 }
1311 }
1312
1313
1320 public List<UserGroupGroupRole> findByRoleId(long roleId)
1321 throws SystemException {
1322 return findByRoleId(roleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1323 }
1324
1325
1338 public List<UserGroupGroupRole> findByRoleId(long roleId, int start, int end)
1339 throws SystemException {
1340 return findByRoleId(roleId, start, end, null);
1341 }
1342
1343
1357 public List<UserGroupGroupRole> findByRoleId(long roleId, int start,
1358 int end, OrderByComparator orderByComparator) throws SystemException {
1359 FinderPath finderPath = null;
1360 Object[] finderArgs = null;
1361
1362 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1363 (orderByComparator == null)) {
1364 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ROLEID;
1365 finderArgs = new Object[] { roleId };
1366 }
1367 else {
1368 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_ROLEID;
1369 finderArgs = new Object[] { roleId, start, end, orderByComparator };
1370 }
1371
1372 List<UserGroupGroupRole> list = (List<UserGroupGroupRole>)FinderCacheUtil.getResult(finderPath,
1373 finderArgs, this);
1374
1375 if (list == null) {
1376 StringBundler query = null;
1377
1378 if (orderByComparator != null) {
1379 query = new StringBundler(3 +
1380 (orderByComparator.getOrderByFields().length * 3));
1381 }
1382 else {
1383 query = new StringBundler(2);
1384 }
1385
1386 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
1387
1388 query.append(_FINDER_COLUMN_ROLEID_ROLEID_2);
1389
1390 if (orderByComparator != null) {
1391 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1392 orderByComparator);
1393 }
1394
1395 String sql = query.toString();
1396
1397 Session session = null;
1398
1399 try {
1400 session = openSession();
1401
1402 Query q = session.createQuery(sql);
1403
1404 QueryPos qPos = QueryPos.getInstance(q);
1405
1406 qPos.add(roleId);
1407
1408 list = (List<UserGroupGroupRole>)QueryUtil.list(q,
1409 getDialect(), start, end);
1410 }
1411 catch (Exception e) {
1412 throw processException(e);
1413 }
1414 finally {
1415 if (list == null) {
1416 FinderCacheUtil.removeResult(finderPath, finderArgs);
1417 }
1418 else {
1419 cacheResult(list);
1420
1421 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1422 }
1423
1424 closeSession(session);
1425 }
1426 }
1427
1428 return list;
1429 }
1430
1431
1444 public UserGroupGroupRole findByRoleId_First(long roleId,
1445 OrderByComparator orderByComparator)
1446 throws NoSuchUserGroupGroupRoleException, SystemException {
1447 List<UserGroupGroupRole> list = findByRoleId(roleId, 0, 1,
1448 orderByComparator);
1449
1450 if (list.isEmpty()) {
1451 StringBundler msg = new StringBundler(4);
1452
1453 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1454
1455 msg.append("roleId=");
1456 msg.append(roleId);
1457
1458 msg.append(StringPool.CLOSE_CURLY_BRACE);
1459
1460 throw new NoSuchUserGroupGroupRoleException(msg.toString());
1461 }
1462 else {
1463 return list.get(0);
1464 }
1465 }
1466
1467
1480 public UserGroupGroupRole findByRoleId_Last(long roleId,
1481 OrderByComparator orderByComparator)
1482 throws NoSuchUserGroupGroupRoleException, SystemException {
1483 int count = countByRoleId(roleId);
1484
1485 List<UserGroupGroupRole> list = findByRoleId(roleId, count - 1, count,
1486 orderByComparator);
1487
1488 if (list.isEmpty()) {
1489 StringBundler msg = new StringBundler(4);
1490
1491 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1492
1493 msg.append("roleId=");
1494 msg.append(roleId);
1495
1496 msg.append(StringPool.CLOSE_CURLY_BRACE);
1497
1498 throw new NoSuchUserGroupGroupRoleException(msg.toString());
1499 }
1500 else {
1501 return list.get(0);
1502 }
1503 }
1504
1505
1519 public UserGroupGroupRole[] findByRoleId_PrevAndNext(
1520 UserGroupGroupRolePK userGroupGroupRolePK, long roleId,
1521 OrderByComparator orderByComparator)
1522 throws NoSuchUserGroupGroupRoleException, SystemException {
1523 UserGroupGroupRole userGroupGroupRole = findByPrimaryKey(userGroupGroupRolePK);
1524
1525 Session session = null;
1526
1527 try {
1528 session = openSession();
1529
1530 UserGroupGroupRole[] array = new UserGroupGroupRoleImpl[3];
1531
1532 array[0] = getByRoleId_PrevAndNext(session, userGroupGroupRole,
1533 roleId, orderByComparator, true);
1534
1535 array[1] = userGroupGroupRole;
1536
1537 array[2] = getByRoleId_PrevAndNext(session, userGroupGroupRole,
1538 roleId, orderByComparator, false);
1539
1540 return array;
1541 }
1542 catch (Exception e) {
1543 throw processException(e);
1544 }
1545 finally {
1546 closeSession(session);
1547 }
1548 }
1549
1550 protected UserGroupGroupRole getByRoleId_PrevAndNext(Session session,
1551 UserGroupGroupRole userGroupGroupRole, long roleId,
1552 OrderByComparator orderByComparator, boolean previous) {
1553 StringBundler query = null;
1554
1555 if (orderByComparator != null) {
1556 query = new StringBundler(6 +
1557 (orderByComparator.getOrderByFields().length * 6));
1558 }
1559 else {
1560 query = new StringBundler(3);
1561 }
1562
1563 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
1564
1565 query.append(_FINDER_COLUMN_ROLEID_ROLEID_2);
1566
1567 if (orderByComparator != null) {
1568 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1569
1570 if (orderByConditionFields.length > 0) {
1571 query.append(WHERE_AND);
1572 }
1573
1574 for (int i = 0; i < orderByConditionFields.length; i++) {
1575 query.append(_ORDER_BY_ENTITY_ALIAS);
1576 query.append(orderByConditionFields[i]);
1577
1578 if ((i + 1) < orderByConditionFields.length) {
1579 if (orderByComparator.isAscending() ^ previous) {
1580 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1581 }
1582 else {
1583 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1584 }
1585 }
1586 else {
1587 if (orderByComparator.isAscending() ^ previous) {
1588 query.append(WHERE_GREATER_THAN);
1589 }
1590 else {
1591 query.append(WHERE_LESSER_THAN);
1592 }
1593 }
1594 }
1595
1596 query.append(ORDER_BY_CLAUSE);
1597
1598 String[] orderByFields = orderByComparator.getOrderByFields();
1599
1600 for (int i = 0; i < orderByFields.length; i++) {
1601 query.append(_ORDER_BY_ENTITY_ALIAS);
1602 query.append(orderByFields[i]);
1603
1604 if ((i + 1) < orderByFields.length) {
1605 if (orderByComparator.isAscending() ^ previous) {
1606 query.append(ORDER_BY_ASC_HAS_NEXT);
1607 }
1608 else {
1609 query.append(ORDER_BY_DESC_HAS_NEXT);
1610 }
1611 }
1612 else {
1613 if (orderByComparator.isAscending() ^ previous) {
1614 query.append(ORDER_BY_ASC);
1615 }
1616 else {
1617 query.append(ORDER_BY_DESC);
1618 }
1619 }
1620 }
1621 }
1622
1623 String sql = query.toString();
1624
1625 Query q = session.createQuery(sql);
1626
1627 q.setFirstResult(0);
1628 q.setMaxResults(2);
1629
1630 QueryPos qPos = QueryPos.getInstance(q);
1631
1632 qPos.add(roleId);
1633
1634 if (orderByComparator != null) {
1635 Object[] values = orderByComparator.getOrderByConditionValues(userGroupGroupRole);
1636
1637 for (Object value : values) {
1638 qPos.add(value);
1639 }
1640 }
1641
1642 List<UserGroupGroupRole> list = q.list();
1643
1644 if (list.size() == 2) {
1645 return list.get(1);
1646 }
1647 else {
1648 return null;
1649 }
1650 }
1651
1652
1660 public List<UserGroupGroupRole> findByU_G(long userGroupId, long groupId)
1661 throws SystemException {
1662 return findByU_G(userGroupId, groupId, QueryUtil.ALL_POS,
1663 QueryUtil.ALL_POS, null);
1664 }
1665
1666
1680 public List<UserGroupGroupRole> findByU_G(long userGroupId, long groupId,
1681 int start, int end) throws SystemException {
1682 return findByU_G(userGroupId, groupId, start, end, null);
1683 }
1684
1685
1700 public List<UserGroupGroupRole> findByU_G(long userGroupId, long groupId,
1701 int start, int end, OrderByComparator orderByComparator)
1702 throws SystemException {
1703 FinderPath finderPath = null;
1704 Object[] finderArgs = null;
1705
1706 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1707 (orderByComparator == null)) {
1708 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_G;
1709 finderArgs = new Object[] { userGroupId, groupId };
1710 }
1711 else {
1712 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_G;
1713 finderArgs = new Object[] {
1714 userGroupId, groupId,
1715
1716 start, end, orderByComparator
1717 };
1718 }
1719
1720 List<UserGroupGroupRole> list = (List<UserGroupGroupRole>)FinderCacheUtil.getResult(finderPath,
1721 finderArgs, this);
1722
1723 if (list == null) {
1724 StringBundler query = null;
1725
1726 if (orderByComparator != null) {
1727 query = new StringBundler(4 +
1728 (orderByComparator.getOrderByFields().length * 3));
1729 }
1730 else {
1731 query = new StringBundler(3);
1732 }
1733
1734 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
1735
1736 query.append(_FINDER_COLUMN_U_G_USERGROUPID_2);
1737
1738 query.append(_FINDER_COLUMN_U_G_GROUPID_2);
1739
1740 if (orderByComparator != null) {
1741 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1742 orderByComparator);
1743 }
1744
1745 String sql = query.toString();
1746
1747 Session session = null;
1748
1749 try {
1750 session = openSession();
1751
1752 Query q = session.createQuery(sql);
1753
1754 QueryPos qPos = QueryPos.getInstance(q);
1755
1756 qPos.add(userGroupId);
1757
1758 qPos.add(groupId);
1759
1760 list = (List<UserGroupGroupRole>)QueryUtil.list(q,
1761 getDialect(), start, end);
1762 }
1763 catch (Exception e) {
1764 throw processException(e);
1765 }
1766 finally {
1767 if (list == null) {
1768 FinderCacheUtil.removeResult(finderPath, finderArgs);
1769 }
1770 else {
1771 cacheResult(list);
1772
1773 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1774 }
1775
1776 closeSession(session);
1777 }
1778 }
1779
1780 return list;
1781 }
1782
1783
1797 public UserGroupGroupRole findByU_G_First(long userGroupId, long groupId,
1798 OrderByComparator orderByComparator)
1799 throws NoSuchUserGroupGroupRoleException, SystemException {
1800 List<UserGroupGroupRole> list = findByU_G(userGroupId, groupId, 0, 1,
1801 orderByComparator);
1802
1803 if (list.isEmpty()) {
1804 StringBundler msg = new StringBundler(6);
1805
1806 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1807
1808 msg.append("userGroupId=");
1809 msg.append(userGroupId);
1810
1811 msg.append(", groupId=");
1812 msg.append(groupId);
1813
1814 msg.append(StringPool.CLOSE_CURLY_BRACE);
1815
1816 throw new NoSuchUserGroupGroupRoleException(msg.toString());
1817 }
1818 else {
1819 return list.get(0);
1820 }
1821 }
1822
1823
1837 public UserGroupGroupRole findByU_G_Last(long userGroupId, long groupId,
1838 OrderByComparator orderByComparator)
1839 throws NoSuchUserGroupGroupRoleException, SystemException {
1840 int count = countByU_G(userGroupId, groupId);
1841
1842 List<UserGroupGroupRole> list = findByU_G(userGroupId, groupId,
1843 count - 1, count, orderByComparator);
1844
1845 if (list.isEmpty()) {
1846 StringBundler msg = new StringBundler(6);
1847
1848 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1849
1850 msg.append("userGroupId=");
1851 msg.append(userGroupId);
1852
1853 msg.append(", groupId=");
1854 msg.append(groupId);
1855
1856 msg.append(StringPool.CLOSE_CURLY_BRACE);
1857
1858 throw new NoSuchUserGroupGroupRoleException(msg.toString());
1859 }
1860 else {
1861 return list.get(0);
1862 }
1863 }
1864
1865
1880 public UserGroupGroupRole[] findByU_G_PrevAndNext(
1881 UserGroupGroupRolePK userGroupGroupRolePK, long userGroupId,
1882 long groupId, OrderByComparator orderByComparator)
1883 throws NoSuchUserGroupGroupRoleException, SystemException {
1884 UserGroupGroupRole userGroupGroupRole = findByPrimaryKey(userGroupGroupRolePK);
1885
1886 Session session = null;
1887
1888 try {
1889 session = openSession();
1890
1891 UserGroupGroupRole[] array = new UserGroupGroupRoleImpl[3];
1892
1893 array[0] = getByU_G_PrevAndNext(session, userGroupGroupRole,
1894 userGroupId, groupId, orderByComparator, true);
1895
1896 array[1] = userGroupGroupRole;
1897
1898 array[2] = getByU_G_PrevAndNext(session, userGroupGroupRole,
1899 userGroupId, groupId, orderByComparator, false);
1900
1901 return array;
1902 }
1903 catch (Exception e) {
1904 throw processException(e);
1905 }
1906 finally {
1907 closeSession(session);
1908 }
1909 }
1910
1911 protected UserGroupGroupRole getByU_G_PrevAndNext(Session session,
1912 UserGroupGroupRole userGroupGroupRole, long userGroupId, long groupId,
1913 OrderByComparator orderByComparator, boolean previous) {
1914 StringBundler query = null;
1915
1916 if (orderByComparator != null) {
1917 query = new StringBundler(6 +
1918 (orderByComparator.getOrderByFields().length * 6));
1919 }
1920 else {
1921 query = new StringBundler(3);
1922 }
1923
1924 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
1925
1926 query.append(_FINDER_COLUMN_U_G_USERGROUPID_2);
1927
1928 query.append(_FINDER_COLUMN_U_G_GROUPID_2);
1929
1930 if (orderByComparator != null) {
1931 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1932
1933 if (orderByConditionFields.length > 0) {
1934 query.append(WHERE_AND);
1935 }
1936
1937 for (int i = 0; i < orderByConditionFields.length; i++) {
1938 query.append(_ORDER_BY_ENTITY_ALIAS);
1939 query.append(orderByConditionFields[i]);
1940
1941 if ((i + 1) < orderByConditionFields.length) {
1942 if (orderByComparator.isAscending() ^ previous) {
1943 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1944 }
1945 else {
1946 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1947 }
1948 }
1949 else {
1950 if (orderByComparator.isAscending() ^ previous) {
1951 query.append(WHERE_GREATER_THAN);
1952 }
1953 else {
1954 query.append(WHERE_LESSER_THAN);
1955 }
1956 }
1957 }
1958
1959 query.append(ORDER_BY_CLAUSE);
1960
1961 String[] orderByFields = orderByComparator.getOrderByFields();
1962
1963 for (int i = 0; i < orderByFields.length; i++) {
1964 query.append(_ORDER_BY_ENTITY_ALIAS);
1965 query.append(orderByFields[i]);
1966
1967 if ((i + 1) < orderByFields.length) {
1968 if (orderByComparator.isAscending() ^ previous) {
1969 query.append(ORDER_BY_ASC_HAS_NEXT);
1970 }
1971 else {
1972 query.append(ORDER_BY_DESC_HAS_NEXT);
1973 }
1974 }
1975 else {
1976 if (orderByComparator.isAscending() ^ previous) {
1977 query.append(ORDER_BY_ASC);
1978 }
1979 else {
1980 query.append(ORDER_BY_DESC);
1981 }
1982 }
1983 }
1984 }
1985
1986 String sql = query.toString();
1987
1988 Query q = session.createQuery(sql);
1989
1990 q.setFirstResult(0);
1991 q.setMaxResults(2);
1992
1993 QueryPos qPos = QueryPos.getInstance(q);
1994
1995 qPos.add(userGroupId);
1996
1997 qPos.add(groupId);
1998
1999 if (orderByComparator != null) {
2000 Object[] values = orderByComparator.getOrderByConditionValues(userGroupGroupRole);
2001
2002 for (Object value : values) {
2003 qPos.add(value);
2004 }
2005 }
2006
2007 List<UserGroupGroupRole> list = q.list();
2008
2009 if (list.size() == 2) {
2010 return list.get(1);
2011 }
2012 else {
2013 return null;
2014 }
2015 }
2016
2017
2025 public List<UserGroupGroupRole> findByG_R(long groupId, long roleId)
2026 throws SystemException {
2027 return findByG_R(groupId, roleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2028 null);
2029 }
2030
2031
2045 public List<UserGroupGroupRole> findByG_R(long groupId, long roleId,
2046 int start, int end) throws SystemException {
2047 return findByG_R(groupId, roleId, start, end, null);
2048 }
2049
2050
2065 public List<UserGroupGroupRole> findByG_R(long groupId, long roleId,
2066 int start, int end, OrderByComparator orderByComparator)
2067 throws SystemException {
2068 FinderPath finderPath = null;
2069 Object[] finderArgs = null;
2070
2071 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2072 (orderByComparator == null)) {
2073 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_R;
2074 finderArgs = new Object[] { groupId, roleId };
2075 }
2076 else {
2077 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_R;
2078 finderArgs = new Object[] {
2079 groupId, roleId,
2080
2081 start, end, orderByComparator
2082 };
2083 }
2084
2085 List<UserGroupGroupRole> list = (List<UserGroupGroupRole>)FinderCacheUtil.getResult(finderPath,
2086 finderArgs, this);
2087
2088 if (list == null) {
2089 StringBundler query = null;
2090
2091 if (orderByComparator != null) {
2092 query = new StringBundler(4 +
2093 (orderByComparator.getOrderByFields().length * 3));
2094 }
2095 else {
2096 query = new StringBundler(3);
2097 }
2098
2099 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
2100
2101 query.append(_FINDER_COLUMN_G_R_GROUPID_2);
2102
2103 query.append(_FINDER_COLUMN_G_R_ROLEID_2);
2104
2105 if (orderByComparator != null) {
2106 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2107 orderByComparator);
2108 }
2109
2110 String sql = query.toString();
2111
2112 Session session = null;
2113
2114 try {
2115 session = openSession();
2116
2117 Query q = session.createQuery(sql);
2118
2119 QueryPos qPos = QueryPos.getInstance(q);
2120
2121 qPos.add(groupId);
2122
2123 qPos.add(roleId);
2124
2125 list = (List<UserGroupGroupRole>)QueryUtil.list(q,
2126 getDialect(), start, end);
2127 }
2128 catch (Exception e) {
2129 throw processException(e);
2130 }
2131 finally {
2132 if (list == null) {
2133 FinderCacheUtil.removeResult(finderPath, finderArgs);
2134 }
2135 else {
2136 cacheResult(list);
2137
2138 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2139 }
2140
2141 closeSession(session);
2142 }
2143 }
2144
2145 return list;
2146 }
2147
2148
2162 public UserGroupGroupRole findByG_R_First(long groupId, long roleId,
2163 OrderByComparator orderByComparator)
2164 throws NoSuchUserGroupGroupRoleException, SystemException {
2165 List<UserGroupGroupRole> list = findByG_R(groupId, roleId, 0, 1,
2166 orderByComparator);
2167
2168 if (list.isEmpty()) {
2169 StringBundler msg = new StringBundler(6);
2170
2171 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2172
2173 msg.append("groupId=");
2174 msg.append(groupId);
2175
2176 msg.append(", roleId=");
2177 msg.append(roleId);
2178
2179 msg.append(StringPool.CLOSE_CURLY_BRACE);
2180
2181 throw new NoSuchUserGroupGroupRoleException(msg.toString());
2182 }
2183 else {
2184 return list.get(0);
2185 }
2186 }
2187
2188
2202 public UserGroupGroupRole findByG_R_Last(long groupId, long roleId,
2203 OrderByComparator orderByComparator)
2204 throws NoSuchUserGroupGroupRoleException, SystemException {
2205 int count = countByG_R(groupId, roleId);
2206
2207 List<UserGroupGroupRole> list = findByG_R(groupId, roleId, count - 1,
2208 count, orderByComparator);
2209
2210 if (list.isEmpty()) {
2211 StringBundler msg = new StringBundler(6);
2212
2213 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2214
2215 msg.append("groupId=");
2216 msg.append(groupId);
2217
2218 msg.append(", roleId=");
2219 msg.append(roleId);
2220
2221 msg.append(StringPool.CLOSE_CURLY_BRACE);
2222
2223 throw new NoSuchUserGroupGroupRoleException(msg.toString());
2224 }
2225 else {
2226 return list.get(0);
2227 }
2228 }
2229
2230
2245 public UserGroupGroupRole[] findByG_R_PrevAndNext(
2246 UserGroupGroupRolePK userGroupGroupRolePK, long groupId, long roleId,
2247 OrderByComparator orderByComparator)
2248 throws NoSuchUserGroupGroupRoleException, SystemException {
2249 UserGroupGroupRole userGroupGroupRole = findByPrimaryKey(userGroupGroupRolePK);
2250
2251 Session session = null;
2252
2253 try {
2254 session = openSession();
2255
2256 UserGroupGroupRole[] array = new UserGroupGroupRoleImpl[3];
2257
2258 array[0] = getByG_R_PrevAndNext(session, userGroupGroupRole,
2259 groupId, roleId, orderByComparator, true);
2260
2261 array[1] = userGroupGroupRole;
2262
2263 array[2] = getByG_R_PrevAndNext(session, userGroupGroupRole,
2264 groupId, roleId, orderByComparator, false);
2265
2266 return array;
2267 }
2268 catch (Exception e) {
2269 throw processException(e);
2270 }
2271 finally {
2272 closeSession(session);
2273 }
2274 }
2275
2276 protected UserGroupGroupRole getByG_R_PrevAndNext(Session session,
2277 UserGroupGroupRole userGroupGroupRole, long groupId, long roleId,
2278 OrderByComparator orderByComparator, boolean previous) {
2279 StringBundler query = null;
2280
2281 if (orderByComparator != null) {
2282 query = new StringBundler(6 +
2283 (orderByComparator.getOrderByFields().length * 6));
2284 }
2285 else {
2286 query = new StringBundler(3);
2287 }
2288
2289 query.append(_SQL_SELECT_USERGROUPGROUPROLE_WHERE);
2290
2291 query.append(_FINDER_COLUMN_G_R_GROUPID_2);
2292
2293 query.append(_FINDER_COLUMN_G_R_ROLEID_2);
2294
2295 if (orderByComparator != null) {
2296 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2297
2298 if (orderByConditionFields.length > 0) {
2299 query.append(WHERE_AND);
2300 }
2301
2302 for (int i = 0; i < orderByConditionFields.length; i++) {
2303 query.append(_ORDER_BY_ENTITY_ALIAS);
2304 query.append(orderByConditionFields[i]);
2305
2306 if ((i + 1) < orderByConditionFields.length) {
2307 if (orderByComparator.isAscending() ^ previous) {
2308 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2309 }
2310 else {
2311 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2312 }
2313 }
2314 else {
2315 if (orderByComparator.isAscending() ^ previous) {
2316 query.append(WHERE_GREATER_THAN);
2317 }
2318 else {
2319 query.append(WHERE_LESSER_THAN);
2320 }
2321 }
2322 }
2323
2324 query.append(ORDER_BY_CLAUSE);
2325
2326 String[] orderByFields = orderByComparator.getOrderByFields();
2327
2328 for (int i = 0; i < orderByFields.length; i++) {
2329 query.append(_ORDER_BY_ENTITY_ALIAS);
2330 query.append(orderByFields[i]);
2331
2332 if ((i + 1) < orderByFields.length) {
2333 if (orderByComparator.isAscending() ^ previous) {
2334 query.append(ORDER_BY_ASC_HAS_NEXT);
2335 }
2336 else {
2337 query.append(ORDER_BY_DESC_HAS_NEXT);
2338 }
2339 }
2340 else {
2341 if (orderByComparator.isAscending() ^ previous) {
2342 query.append(ORDER_BY_ASC);
2343 }
2344 else {
2345 query.append(ORDER_BY_DESC);
2346 }
2347 }
2348 }
2349 }
2350
2351 String sql = query.toString();
2352
2353 Query q = session.createQuery(sql);
2354
2355 q.setFirstResult(0);
2356 q.setMaxResults(2);
2357
2358 QueryPos qPos = QueryPos.getInstance(q);
2359
2360 qPos.add(groupId);
2361
2362 qPos.add(roleId);
2363
2364 if (orderByComparator != null) {
2365 Object[] values = orderByComparator.getOrderByConditionValues(userGroupGroupRole);
2366
2367 for (Object value : values) {
2368 qPos.add(value);
2369 }
2370 }
2371
2372 List<UserGroupGroupRole> list = q.list();
2373
2374 if (list.size() == 2) {
2375 return list.get(1);
2376 }
2377 else {
2378 return null;
2379 }
2380 }
2381
2382
2388 public List<UserGroupGroupRole> findAll() throws SystemException {
2389 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2390 }
2391
2392
2404 public List<UserGroupGroupRole> findAll(int start, int end)
2405 throws SystemException {
2406 return findAll(start, end, null);
2407 }
2408
2409
2422 public List<UserGroupGroupRole> findAll(int start, int end,
2423 OrderByComparator orderByComparator) throws SystemException {
2424 FinderPath finderPath = null;
2425 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2426
2427 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2428 (orderByComparator == null)) {
2429 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2430 finderArgs = FINDER_ARGS_EMPTY;
2431 }
2432 else {
2433 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2434 finderArgs = new Object[] { start, end, orderByComparator };
2435 }
2436
2437 List<UserGroupGroupRole> list = (List<UserGroupGroupRole>)FinderCacheUtil.getResult(finderPath,
2438 finderArgs, this);
2439
2440 if (list == null) {
2441 StringBundler query = null;
2442 String sql = null;
2443
2444 if (orderByComparator != null) {
2445 query = new StringBundler(2 +
2446 (orderByComparator.getOrderByFields().length * 3));
2447
2448 query.append(_SQL_SELECT_USERGROUPGROUPROLE);
2449
2450 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2451 orderByComparator);
2452
2453 sql = query.toString();
2454 }
2455 else {
2456 sql = _SQL_SELECT_USERGROUPGROUPROLE;
2457 }
2458
2459 Session session = null;
2460
2461 try {
2462 session = openSession();
2463
2464 Query q = session.createQuery(sql);
2465
2466 if (orderByComparator == null) {
2467 list = (List<UserGroupGroupRole>)QueryUtil.list(q,
2468 getDialect(), start, end, false);
2469
2470 Collections.sort(list);
2471 }
2472 else {
2473 list = (List<UserGroupGroupRole>)QueryUtil.list(q,
2474 getDialect(), start, end);
2475 }
2476 }
2477 catch (Exception e) {
2478 throw processException(e);
2479 }
2480 finally {
2481 if (list == null) {
2482 FinderCacheUtil.removeResult(finderPath, finderArgs);
2483 }
2484 else {
2485 cacheResult(list);
2486
2487 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2488 }
2489
2490 closeSession(session);
2491 }
2492 }
2493
2494 return list;
2495 }
2496
2497
2503 public void removeByUserGroupId(long userGroupId) throws SystemException {
2504 for (UserGroupGroupRole userGroupGroupRole : findByUserGroupId(
2505 userGroupId)) {
2506 userGroupGroupRolePersistence.remove(userGroupGroupRole);
2507 }
2508 }
2509
2510
2516 public void removeByGroupId(long groupId) throws SystemException {
2517 for (UserGroupGroupRole userGroupGroupRole : findByGroupId(groupId)) {
2518 userGroupGroupRolePersistence.remove(userGroupGroupRole);
2519 }
2520 }
2521
2522
2528 public void removeByRoleId(long roleId) throws SystemException {
2529 for (UserGroupGroupRole userGroupGroupRole : findByRoleId(roleId)) {
2530 userGroupGroupRolePersistence.remove(userGroupGroupRole);
2531 }
2532 }
2533
2534
2541 public void removeByU_G(long userGroupId, long groupId)
2542 throws SystemException {
2543 for (UserGroupGroupRole userGroupGroupRole : findByU_G(userGroupId,
2544 groupId)) {
2545 userGroupGroupRolePersistence.remove(userGroupGroupRole);
2546 }
2547 }
2548
2549
2556 public void removeByG_R(long groupId, long roleId)
2557 throws SystemException {
2558 for (UserGroupGroupRole userGroupGroupRole : findByG_R(groupId, roleId)) {
2559 userGroupGroupRolePersistence.remove(userGroupGroupRole);
2560 }
2561 }
2562
2563
2568 public void removeAll() throws SystemException {
2569 for (UserGroupGroupRole userGroupGroupRole : findAll()) {
2570 userGroupGroupRolePersistence.remove(userGroupGroupRole);
2571 }
2572 }
2573
2574
2581 public int countByUserGroupId(long userGroupId) throws SystemException {
2582 Object[] finderArgs = new Object[] { userGroupId };
2583
2584 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERGROUPID,
2585 finderArgs, this);
2586
2587 if (count == null) {
2588 StringBundler query = new StringBundler(2);
2589
2590 query.append(_SQL_COUNT_USERGROUPGROUPROLE_WHERE);
2591
2592 query.append(_FINDER_COLUMN_USERGROUPID_USERGROUPID_2);
2593
2594 String sql = query.toString();
2595
2596 Session session = null;
2597
2598 try {
2599 session = openSession();
2600
2601 Query q = session.createQuery(sql);
2602
2603 QueryPos qPos = QueryPos.getInstance(q);
2604
2605 qPos.add(userGroupId);
2606
2607 count = (Long)q.uniqueResult();
2608 }
2609 catch (Exception e) {
2610 throw processException(e);
2611 }
2612 finally {
2613 if (count == null) {
2614 count = Long.valueOf(0);
2615 }
2616
2617 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERGROUPID,
2618 finderArgs, count);
2619
2620 closeSession(session);
2621 }
2622 }
2623
2624 return count.intValue();
2625 }
2626
2627
2634 public int countByGroupId(long groupId) throws SystemException {
2635 Object[] finderArgs = new Object[] { groupId };
2636
2637 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2638 finderArgs, this);
2639
2640 if (count == null) {
2641 StringBundler query = new StringBundler(2);
2642
2643 query.append(_SQL_COUNT_USERGROUPGROUPROLE_WHERE);
2644
2645 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2646
2647 String sql = query.toString();
2648
2649 Session session = null;
2650
2651 try {
2652 session = openSession();
2653
2654 Query q = session.createQuery(sql);
2655
2656 QueryPos qPos = QueryPos.getInstance(q);
2657
2658 qPos.add(groupId);
2659
2660 count = (Long)q.uniqueResult();
2661 }
2662 catch (Exception e) {
2663 throw processException(e);
2664 }
2665 finally {
2666 if (count == null) {
2667 count = Long.valueOf(0);
2668 }
2669
2670 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2671 finderArgs, count);
2672
2673 closeSession(session);
2674 }
2675 }
2676
2677 return count.intValue();
2678 }
2679
2680
2687 public int countByRoleId(long roleId) throws SystemException {
2688 Object[] finderArgs = new Object[] { roleId };
2689
2690 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ROLEID,
2691 finderArgs, this);
2692
2693 if (count == null) {
2694 StringBundler query = new StringBundler(2);
2695
2696 query.append(_SQL_COUNT_USERGROUPGROUPROLE_WHERE);
2697
2698 query.append(_FINDER_COLUMN_ROLEID_ROLEID_2);
2699
2700 String sql = query.toString();
2701
2702 Session session = null;
2703
2704 try {
2705 session = openSession();
2706
2707 Query q = session.createQuery(sql);
2708
2709 QueryPos qPos = QueryPos.getInstance(q);
2710
2711 qPos.add(roleId);
2712
2713 count = (Long)q.uniqueResult();
2714 }
2715 catch (Exception e) {
2716 throw processException(e);
2717 }
2718 finally {
2719 if (count == null) {
2720 count = Long.valueOf(0);
2721 }
2722
2723 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ROLEID,
2724 finderArgs, count);
2725
2726 closeSession(session);
2727 }
2728 }
2729
2730 return count.intValue();
2731 }
2732
2733
2741 public int countByU_G(long userGroupId, long groupId)
2742 throws SystemException {
2743 Object[] finderArgs = new Object[] { userGroupId, groupId };
2744
2745 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_G,
2746 finderArgs, this);
2747
2748 if (count == null) {
2749 StringBundler query = new StringBundler(3);
2750
2751 query.append(_SQL_COUNT_USERGROUPGROUPROLE_WHERE);
2752
2753 query.append(_FINDER_COLUMN_U_G_USERGROUPID_2);
2754
2755 query.append(_FINDER_COLUMN_U_G_GROUPID_2);
2756
2757 String sql = query.toString();
2758
2759 Session session = null;
2760
2761 try {
2762 session = openSession();
2763
2764 Query q = session.createQuery(sql);
2765
2766 QueryPos qPos = QueryPos.getInstance(q);
2767
2768 qPos.add(userGroupId);
2769
2770 qPos.add(groupId);
2771
2772 count = (Long)q.uniqueResult();
2773 }
2774 catch (Exception e) {
2775 throw processException(e);
2776 }
2777 finally {
2778 if (count == null) {
2779 count = Long.valueOf(0);
2780 }
2781
2782 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_G, finderArgs,
2783 count);
2784
2785 closeSession(session);
2786 }
2787 }
2788
2789 return count.intValue();
2790 }
2791
2792
2800 public int countByG_R(long groupId, long roleId) throws SystemException {
2801 Object[] finderArgs = new Object[] { groupId, roleId };
2802
2803 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_R,
2804 finderArgs, this);
2805
2806 if (count == null) {
2807 StringBundler query = new StringBundler(3);
2808
2809 query.append(_SQL_COUNT_USERGROUPGROUPROLE_WHERE);
2810
2811 query.append(_FINDER_COLUMN_G_R_GROUPID_2);
2812
2813 query.append(_FINDER_COLUMN_G_R_ROLEID_2);
2814
2815 String sql = query.toString();
2816
2817 Session session = null;
2818
2819 try {
2820 session = openSession();
2821
2822 Query q = session.createQuery(sql);
2823
2824 QueryPos qPos = QueryPos.getInstance(q);
2825
2826 qPos.add(groupId);
2827
2828 qPos.add(roleId);
2829
2830 count = (Long)q.uniqueResult();
2831 }
2832 catch (Exception e) {
2833 throw processException(e);
2834 }
2835 finally {
2836 if (count == null) {
2837 count = Long.valueOf(0);
2838 }
2839
2840 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_R, finderArgs,
2841 count);
2842
2843 closeSession(session);
2844 }
2845 }
2846
2847 return count.intValue();
2848 }
2849
2850
2856 public int countAll() throws SystemException {
2857 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2858 FINDER_ARGS_EMPTY, this);
2859
2860 if (count == null) {
2861 Session session = null;
2862
2863 try {
2864 session = openSession();
2865
2866 Query q = session.createQuery(_SQL_COUNT_USERGROUPGROUPROLE);
2867
2868 count = (Long)q.uniqueResult();
2869 }
2870 catch (Exception e) {
2871 throw processException(e);
2872 }
2873 finally {
2874 if (count == null) {
2875 count = Long.valueOf(0);
2876 }
2877
2878 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2879 FINDER_ARGS_EMPTY, count);
2880
2881 closeSession(session);
2882 }
2883 }
2884
2885 return count.intValue();
2886 }
2887
2888
2891 public void afterPropertiesSet() {
2892 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2893 com.liferay.portal.util.PropsUtil.get(
2894 "value.object.listener.com.liferay.portal.model.UserGroupGroupRole")));
2895
2896 if (listenerClassNames.length > 0) {
2897 try {
2898 List<ModelListener<UserGroupGroupRole>> listenersList = new ArrayList<ModelListener<UserGroupGroupRole>>();
2899
2900 for (String listenerClassName : listenerClassNames) {
2901 listenersList.add((ModelListener<UserGroupGroupRole>)InstanceFactory.newInstance(
2902 listenerClassName));
2903 }
2904
2905 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2906 }
2907 catch (Exception e) {
2908 _log.error(e);
2909 }
2910 }
2911 }
2912
2913 public void destroy() {
2914 EntityCacheUtil.removeCache(UserGroupGroupRoleImpl.class.getName());
2915 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2916 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2917 }
2918
2919 @BeanReference(type = AccountPersistence.class)
2920 protected AccountPersistence accountPersistence;
2921 @BeanReference(type = AddressPersistence.class)
2922 protected AddressPersistence addressPersistence;
2923 @BeanReference(type = BrowserTrackerPersistence.class)
2924 protected BrowserTrackerPersistence browserTrackerPersistence;
2925 @BeanReference(type = ClassNamePersistence.class)
2926 protected ClassNamePersistence classNamePersistence;
2927 @BeanReference(type = ClusterGroupPersistence.class)
2928 protected ClusterGroupPersistence clusterGroupPersistence;
2929 @BeanReference(type = CompanyPersistence.class)
2930 protected CompanyPersistence companyPersistence;
2931 @BeanReference(type = ContactPersistence.class)
2932 protected ContactPersistence contactPersistence;
2933 @BeanReference(type = CountryPersistence.class)
2934 protected CountryPersistence countryPersistence;
2935 @BeanReference(type = EmailAddressPersistence.class)
2936 protected EmailAddressPersistence emailAddressPersistence;
2937 @BeanReference(type = GroupPersistence.class)
2938 protected GroupPersistence groupPersistence;
2939 @BeanReference(type = ImagePersistence.class)
2940 protected ImagePersistence imagePersistence;
2941 @BeanReference(type = LayoutPersistence.class)
2942 protected LayoutPersistence layoutPersistence;
2943 @BeanReference(type = LayoutBranchPersistence.class)
2944 protected LayoutBranchPersistence layoutBranchPersistence;
2945 @BeanReference(type = LayoutPrototypePersistence.class)
2946 protected LayoutPrototypePersistence layoutPrototypePersistence;
2947 @BeanReference(type = LayoutRevisionPersistence.class)
2948 protected LayoutRevisionPersistence layoutRevisionPersistence;
2949 @BeanReference(type = LayoutSetPersistence.class)
2950 protected LayoutSetPersistence layoutSetPersistence;
2951 @BeanReference(type = LayoutSetBranchPersistence.class)
2952 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
2953 @BeanReference(type = LayoutSetPrototypePersistence.class)
2954 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2955 @BeanReference(type = ListTypePersistence.class)
2956 protected ListTypePersistence listTypePersistence;
2957 @BeanReference(type = LockPersistence.class)
2958 protected LockPersistence lockPersistence;
2959 @BeanReference(type = MembershipRequestPersistence.class)
2960 protected MembershipRequestPersistence membershipRequestPersistence;
2961 @BeanReference(type = OrganizationPersistence.class)
2962 protected OrganizationPersistence organizationPersistence;
2963 @BeanReference(type = OrgGroupPermissionPersistence.class)
2964 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
2965 @BeanReference(type = OrgGroupRolePersistence.class)
2966 protected OrgGroupRolePersistence orgGroupRolePersistence;
2967 @BeanReference(type = OrgLaborPersistence.class)
2968 protected OrgLaborPersistence orgLaborPersistence;
2969 @BeanReference(type = PasswordPolicyPersistence.class)
2970 protected PasswordPolicyPersistence passwordPolicyPersistence;
2971 @BeanReference(type = PasswordPolicyRelPersistence.class)
2972 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2973 @BeanReference(type = PasswordTrackerPersistence.class)
2974 protected PasswordTrackerPersistence passwordTrackerPersistence;
2975 @BeanReference(type = PermissionPersistence.class)
2976 protected PermissionPersistence permissionPersistence;
2977 @BeanReference(type = PhonePersistence.class)
2978 protected PhonePersistence phonePersistence;
2979 @BeanReference(type = PluginSettingPersistence.class)
2980 protected PluginSettingPersistence pluginSettingPersistence;
2981 @BeanReference(type = PortalPreferencesPersistence.class)
2982 protected PortalPreferencesPersistence portalPreferencesPersistence;
2983 @BeanReference(type = PortletPersistence.class)
2984 protected PortletPersistence portletPersistence;
2985 @BeanReference(type = PortletItemPersistence.class)
2986 protected PortletItemPersistence portletItemPersistence;
2987 @BeanReference(type = PortletPreferencesPersistence.class)
2988 protected PortletPreferencesPersistence portletPreferencesPersistence;
2989 @BeanReference(type = RegionPersistence.class)
2990 protected RegionPersistence regionPersistence;
2991 @BeanReference(type = ReleasePersistence.class)
2992 protected ReleasePersistence releasePersistence;
2993 @BeanReference(type = RepositoryPersistence.class)
2994 protected RepositoryPersistence repositoryPersistence;
2995 @BeanReference(type = RepositoryEntryPersistence.class)
2996 protected RepositoryEntryPersistence repositoryEntryPersistence;
2997 @BeanReference(type = ResourcePersistence.class)
2998 protected ResourcePersistence resourcePersistence;
2999 @BeanReference(type = ResourceActionPersistence.class)
3000 protected ResourceActionPersistence resourceActionPersistence;
3001 @BeanReference(type = ResourceBlockPersistence.class)
3002 protected ResourceBlockPersistence resourceBlockPersistence;
3003 @BeanReference(type = ResourceBlockPermissionPersistence.class)
3004 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
3005 @BeanReference(type = ResourceCodePersistence.class)
3006 protected ResourceCodePersistence resourceCodePersistence;
3007 @BeanReference(type = ResourcePermissionPersistence.class)
3008 protected ResourcePermissionPersistence resourcePermissionPersistence;
3009 @BeanReference(type = ResourceTypePermissionPersistence.class)
3010 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
3011 @BeanReference(type = RolePersistence.class)
3012 protected RolePersistence rolePersistence;
3013 @BeanReference(type = ServiceComponentPersistence.class)
3014 protected ServiceComponentPersistence serviceComponentPersistence;
3015 @BeanReference(type = ShardPersistence.class)
3016 protected ShardPersistence shardPersistence;
3017 @BeanReference(type = SubscriptionPersistence.class)
3018 protected SubscriptionPersistence subscriptionPersistence;
3019 @BeanReference(type = TeamPersistence.class)
3020 protected TeamPersistence teamPersistence;
3021 @BeanReference(type = TicketPersistence.class)
3022 protected TicketPersistence ticketPersistence;
3023 @BeanReference(type = UserPersistence.class)
3024 protected UserPersistence userPersistence;
3025 @BeanReference(type = UserGroupPersistence.class)
3026 protected UserGroupPersistence userGroupPersistence;
3027 @BeanReference(type = UserGroupGroupRolePersistence.class)
3028 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
3029 @BeanReference(type = UserGroupRolePersistence.class)
3030 protected UserGroupRolePersistence userGroupRolePersistence;
3031 @BeanReference(type = UserIdMapperPersistence.class)
3032 protected UserIdMapperPersistence userIdMapperPersistence;
3033 @BeanReference(type = UserNotificationEventPersistence.class)
3034 protected UserNotificationEventPersistence userNotificationEventPersistence;
3035 @BeanReference(type = UserTrackerPersistence.class)
3036 protected UserTrackerPersistence userTrackerPersistence;
3037 @BeanReference(type = UserTrackerPathPersistence.class)
3038 protected UserTrackerPathPersistence userTrackerPathPersistence;
3039 @BeanReference(type = VirtualHostPersistence.class)
3040 protected VirtualHostPersistence virtualHostPersistence;
3041 @BeanReference(type = WebDAVPropsPersistence.class)
3042 protected WebDAVPropsPersistence webDAVPropsPersistence;
3043 @BeanReference(type = WebsitePersistence.class)
3044 protected WebsitePersistence websitePersistence;
3045 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
3046 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
3047 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
3048 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
3049 private static final String _SQL_SELECT_USERGROUPGROUPROLE = "SELECT userGroupGroupRole FROM UserGroupGroupRole userGroupGroupRole";
3050 private static final String _SQL_SELECT_USERGROUPGROUPROLE_WHERE = "SELECT userGroupGroupRole FROM UserGroupGroupRole userGroupGroupRole WHERE ";
3051 private static final String _SQL_COUNT_USERGROUPGROUPROLE = "SELECT COUNT(userGroupGroupRole) FROM UserGroupGroupRole userGroupGroupRole";
3052 private static final String _SQL_COUNT_USERGROUPGROUPROLE_WHERE = "SELECT COUNT(userGroupGroupRole) FROM UserGroupGroupRole userGroupGroupRole WHERE ";
3053 private static final String _FINDER_COLUMN_USERGROUPID_USERGROUPID_2 = "userGroupGroupRole.id.userGroupId = ?";
3054 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "userGroupGroupRole.id.groupId = ?";
3055 private static final String _FINDER_COLUMN_ROLEID_ROLEID_2 = "userGroupGroupRole.id.roleId = ?";
3056 private static final String _FINDER_COLUMN_U_G_USERGROUPID_2 = "userGroupGroupRole.id.userGroupId = ? AND ";
3057 private static final String _FINDER_COLUMN_U_G_GROUPID_2 = "userGroupGroupRole.id.groupId = ?";
3058 private static final String _FINDER_COLUMN_G_R_GROUPID_2 = "userGroupGroupRole.id.groupId = ? AND ";
3059 private static final String _FINDER_COLUMN_G_R_ROLEID_2 = "userGroupGroupRole.id.roleId = ?";
3060 private static final String _ORDER_BY_ENTITY_ALIAS = "userGroupGroupRole.";
3061 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserGroupGroupRole exists with the primary key ";
3062 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserGroupGroupRole exists with the key {";
3063 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3064 private static Log _log = LogFactoryUtil.getLog(UserGroupGroupRolePersistenceImpl.class);
3065 private static UserGroupGroupRole _nullUserGroupGroupRole = new UserGroupGroupRoleImpl() {
3066 @Override
3067 public Object clone() {
3068 return this;
3069 }
3070
3071 @Override
3072 public CacheModel<UserGroupGroupRole> toCacheModel() {
3073 return _nullUserGroupGroupRoleCacheModel;
3074 }
3075 };
3076
3077 private static CacheModel<UserGroupGroupRole> _nullUserGroupGroupRoleCacheModel =
3078 new CacheModel<UserGroupGroupRole>() {
3079 public UserGroupGroupRole toEntityModel() {
3080 return _nullUserGroupGroupRole;
3081 }
3082 };
3083 }