1
14
15 package com.liferay.portal.service.persistence;
16
17 import com.liferay.portal.NoSuchModelException;
18 import com.liferay.portal.NoSuchUserGroupRoleException;
19 import com.liferay.portal.kernel.annotation.BeanReference;
20 import com.liferay.portal.kernel.cache.CacheRegistry;
21 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
22 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
23 import com.liferay.portal.kernel.dao.orm.FinderPath;
24 import com.liferay.portal.kernel.dao.orm.Query;
25 import com.liferay.portal.kernel.dao.orm.QueryPos;
26 import com.liferay.portal.kernel.dao.orm.QueryUtil;
27 import com.liferay.portal.kernel.dao.orm.Session;
28 import com.liferay.portal.kernel.exception.SystemException;
29 import com.liferay.portal.kernel.log.Log;
30 import com.liferay.portal.kernel.log.LogFactoryUtil;
31 import com.liferay.portal.kernel.util.GetterUtil;
32 import com.liferay.portal.kernel.util.OrderByComparator;
33 import com.liferay.portal.kernel.util.StringBundler;
34 import com.liferay.portal.kernel.util.StringPool;
35 import com.liferay.portal.kernel.util.StringUtil;
36 import com.liferay.portal.model.ModelListener;
37 import com.liferay.portal.model.UserGroupRole;
38 import com.liferay.portal.model.impl.UserGroupRoleImpl;
39 import com.liferay.portal.model.impl.UserGroupRoleModelImpl;
40 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
41
42 import java.io.Serializable;
43
44 import java.util.ArrayList;
45 import java.util.Collections;
46 import java.util.List;
47
48
61 public class UserGroupRolePersistenceImpl extends BasePersistenceImpl<UserGroupRole>
62 implements UserGroupRolePersistence {
63 public static final String FINDER_CLASS_NAME_ENTITY = UserGroupRoleImpl.class.getName();
64 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
65 ".List";
66 public static final FinderPath FINDER_PATH_FIND_BY_USERID = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
67 UserGroupRoleModelImpl.FINDER_CACHE_ENABLED,
68 FINDER_CLASS_NAME_LIST, "findByUserId",
69 new String[] { Long.class.getName() });
70 public static final FinderPath FINDER_PATH_FIND_BY_OBC_USERID = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
71 UserGroupRoleModelImpl.FINDER_CACHE_ENABLED,
72 FINDER_CLASS_NAME_LIST, "findByUserId",
73 new String[] {
74 Long.class.getName(),
75
76 "java.lang.Integer", "java.lang.Integer",
77 "com.liferay.portal.kernel.util.OrderByComparator"
78 });
79 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
80 UserGroupRoleModelImpl.FINDER_CACHE_ENABLED,
81 FINDER_CLASS_NAME_LIST, "countByUserId",
82 new String[] { Long.class.getName() });
83 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
84 UserGroupRoleModelImpl.FINDER_CACHE_ENABLED,
85 FINDER_CLASS_NAME_LIST, "findByGroupId",
86 new String[] { Long.class.getName() });
87 public static final FinderPath FINDER_PATH_FIND_BY_OBC_GROUPID = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
88 UserGroupRoleModelImpl.FINDER_CACHE_ENABLED,
89 FINDER_CLASS_NAME_LIST, "findByGroupId",
90 new String[] {
91 Long.class.getName(),
92
93 "java.lang.Integer", "java.lang.Integer",
94 "com.liferay.portal.kernel.util.OrderByComparator"
95 });
96 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
97 UserGroupRoleModelImpl.FINDER_CACHE_ENABLED,
98 FINDER_CLASS_NAME_LIST, "countByGroupId",
99 new String[] { Long.class.getName() });
100 public static final FinderPath FINDER_PATH_FIND_BY_ROLEID = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
101 UserGroupRoleModelImpl.FINDER_CACHE_ENABLED,
102 FINDER_CLASS_NAME_LIST, "findByRoleId",
103 new String[] { Long.class.getName() });
104 public static final FinderPath FINDER_PATH_FIND_BY_OBC_ROLEID = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
105 UserGroupRoleModelImpl.FINDER_CACHE_ENABLED,
106 FINDER_CLASS_NAME_LIST, "findByRoleId",
107 new String[] {
108 Long.class.getName(),
109
110 "java.lang.Integer", "java.lang.Integer",
111 "com.liferay.portal.kernel.util.OrderByComparator"
112 });
113 public static final FinderPath FINDER_PATH_COUNT_BY_ROLEID = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
114 UserGroupRoleModelImpl.FINDER_CACHE_ENABLED,
115 FINDER_CLASS_NAME_LIST, "countByRoleId",
116 new String[] { Long.class.getName() });
117 public static final FinderPath FINDER_PATH_FIND_BY_U_G = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
118 UserGroupRoleModelImpl.FINDER_CACHE_ENABLED,
119 FINDER_CLASS_NAME_LIST, "findByU_G",
120 new String[] { Long.class.getName(), Long.class.getName() });
121 public static final FinderPath FINDER_PATH_FIND_BY_OBC_U_G = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
122 UserGroupRoleModelImpl.FINDER_CACHE_ENABLED,
123 FINDER_CLASS_NAME_LIST, "findByU_G",
124 new String[] {
125 Long.class.getName(), Long.class.getName(),
126
127 "java.lang.Integer", "java.lang.Integer",
128 "com.liferay.portal.kernel.util.OrderByComparator"
129 });
130 public static final FinderPath FINDER_PATH_COUNT_BY_U_G = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
131 UserGroupRoleModelImpl.FINDER_CACHE_ENABLED,
132 FINDER_CLASS_NAME_LIST, "countByU_G",
133 new String[] { Long.class.getName(), Long.class.getName() });
134 public static final FinderPath FINDER_PATH_FIND_BY_G_R = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
135 UserGroupRoleModelImpl.FINDER_CACHE_ENABLED,
136 FINDER_CLASS_NAME_LIST, "findByG_R",
137 new String[] { Long.class.getName(), Long.class.getName() });
138 public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_R = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
139 UserGroupRoleModelImpl.FINDER_CACHE_ENABLED,
140 FINDER_CLASS_NAME_LIST, "findByG_R",
141 new String[] {
142 Long.class.getName(), Long.class.getName(),
143
144 "java.lang.Integer", "java.lang.Integer",
145 "com.liferay.portal.kernel.util.OrderByComparator"
146 });
147 public static final FinderPath FINDER_PATH_COUNT_BY_G_R = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
148 UserGroupRoleModelImpl.FINDER_CACHE_ENABLED,
149 FINDER_CLASS_NAME_LIST, "countByG_R",
150 new String[] { Long.class.getName(), Long.class.getName() });
151 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
152 UserGroupRoleModelImpl.FINDER_CACHE_ENABLED,
153 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
154 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
155 UserGroupRoleModelImpl.FINDER_CACHE_ENABLED,
156 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
157
158 public void cacheResult(UserGroupRole userGroupRole) {
159 EntityCacheUtil.putResult(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
160 UserGroupRoleImpl.class, userGroupRole.getPrimaryKey(),
161 userGroupRole);
162 }
163
164 public void cacheResult(List<UserGroupRole> userGroupRoles) {
165 for (UserGroupRole userGroupRole : userGroupRoles) {
166 if (EntityCacheUtil.getResult(
167 UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
168 UserGroupRoleImpl.class, userGroupRole.getPrimaryKey(),
169 this) == null) {
170 cacheResult(userGroupRole);
171 }
172 }
173 }
174
175 public void clearCache() {
176 CacheRegistry.clear(UserGroupRoleImpl.class.getName());
177 EntityCacheUtil.clearCache(UserGroupRoleImpl.class.getName());
178 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
179 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
180 }
181
182 public UserGroupRole create(UserGroupRolePK userGroupRolePK) {
183 UserGroupRole userGroupRole = new UserGroupRoleImpl();
184
185 userGroupRole.setNew(true);
186 userGroupRole.setPrimaryKey(userGroupRolePK);
187
188 return userGroupRole;
189 }
190
191 public UserGroupRole remove(Serializable primaryKey)
192 throws NoSuchModelException, SystemException {
193 return remove((UserGroupRolePK)primaryKey);
194 }
195
196 public UserGroupRole remove(UserGroupRolePK userGroupRolePK)
197 throws NoSuchUserGroupRoleException, SystemException {
198 Session session = null;
199
200 try {
201 session = openSession();
202
203 UserGroupRole userGroupRole = (UserGroupRole)session.get(UserGroupRoleImpl.class,
204 userGroupRolePK);
205
206 if (userGroupRole == null) {
207 if (_log.isWarnEnabled()) {
208 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
209 userGroupRolePK);
210 }
211
212 throw new NoSuchUserGroupRoleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
213 userGroupRolePK);
214 }
215
216 return remove(userGroupRole);
217 }
218 catch (NoSuchUserGroupRoleException nsee) {
219 throw nsee;
220 }
221 catch (Exception e) {
222 throw processException(e);
223 }
224 finally {
225 closeSession(session);
226 }
227 }
228
229 public UserGroupRole remove(UserGroupRole userGroupRole)
230 throws SystemException {
231 for (ModelListener<UserGroupRole> listener : listeners) {
232 listener.onBeforeRemove(userGroupRole);
233 }
234
235 userGroupRole = removeImpl(userGroupRole);
236
237 for (ModelListener<UserGroupRole> listener : listeners) {
238 listener.onAfterRemove(userGroupRole);
239 }
240
241 return userGroupRole;
242 }
243
244 protected UserGroupRole removeImpl(UserGroupRole userGroupRole)
245 throws SystemException {
246 userGroupRole = toUnwrappedModel(userGroupRole);
247
248 Session session = null;
249
250 try {
251 session = openSession();
252
253 if (userGroupRole.isCachedModel() || BatchSessionUtil.isEnabled()) {
254 Object staleObject = session.get(UserGroupRoleImpl.class,
255 userGroupRole.getPrimaryKeyObj());
256
257 if (staleObject != null) {
258 session.evict(staleObject);
259 }
260 }
261
262 session.delete(userGroupRole);
263
264 session.flush();
265 }
266 catch (Exception e) {
267 throw processException(e);
268 }
269 finally {
270 closeSession(session);
271 }
272
273 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
274
275 EntityCacheUtil.removeResult(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
276 UserGroupRoleImpl.class, userGroupRole.getPrimaryKey());
277
278 return userGroupRole;
279 }
280
281 public UserGroupRole updateImpl(
282 com.liferay.portal.model.UserGroupRole userGroupRole, boolean merge)
283 throws SystemException {
284 userGroupRole = toUnwrappedModel(userGroupRole);
285
286 Session session = null;
287
288 try {
289 session = openSession();
290
291 BatchSessionUtil.update(session, userGroupRole, merge);
292
293 userGroupRole.setNew(false);
294 }
295 catch (Exception e) {
296 throw processException(e);
297 }
298 finally {
299 closeSession(session);
300 }
301
302 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
303
304 EntityCacheUtil.putResult(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
305 UserGroupRoleImpl.class, userGroupRole.getPrimaryKey(),
306 userGroupRole);
307
308 return userGroupRole;
309 }
310
311 protected UserGroupRole toUnwrappedModel(UserGroupRole userGroupRole) {
312 if (userGroupRole instanceof UserGroupRoleImpl) {
313 return userGroupRole;
314 }
315
316 UserGroupRoleImpl userGroupRoleImpl = new UserGroupRoleImpl();
317
318 userGroupRoleImpl.setNew(userGroupRole.isNew());
319 userGroupRoleImpl.setPrimaryKey(userGroupRole.getPrimaryKey());
320
321 userGroupRoleImpl.setUserId(userGroupRole.getUserId());
322 userGroupRoleImpl.setGroupId(userGroupRole.getGroupId());
323 userGroupRoleImpl.setRoleId(userGroupRole.getRoleId());
324
325 return userGroupRoleImpl;
326 }
327
328 public UserGroupRole findByPrimaryKey(Serializable primaryKey)
329 throws NoSuchModelException, SystemException {
330 return findByPrimaryKey((UserGroupRolePK)primaryKey);
331 }
332
333 public UserGroupRole findByPrimaryKey(UserGroupRolePK userGroupRolePK)
334 throws NoSuchUserGroupRoleException, SystemException {
335 UserGroupRole userGroupRole = fetchByPrimaryKey(userGroupRolePK);
336
337 if (userGroupRole == null) {
338 if (_log.isWarnEnabled()) {
339 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + userGroupRolePK);
340 }
341
342 throw new NoSuchUserGroupRoleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
343 userGroupRolePK);
344 }
345
346 return userGroupRole;
347 }
348
349 public UserGroupRole fetchByPrimaryKey(Serializable primaryKey)
350 throws SystemException {
351 return fetchByPrimaryKey((UserGroupRolePK)primaryKey);
352 }
353
354 public UserGroupRole fetchByPrimaryKey(UserGroupRolePK userGroupRolePK)
355 throws SystemException {
356 UserGroupRole userGroupRole = (UserGroupRole)EntityCacheUtil.getResult(UserGroupRoleModelImpl.ENTITY_CACHE_ENABLED,
357 UserGroupRoleImpl.class, userGroupRolePK, this);
358
359 if (userGroupRole == null) {
360 Session session = null;
361
362 try {
363 session = openSession();
364
365 userGroupRole = (UserGroupRole)session.get(UserGroupRoleImpl.class,
366 userGroupRolePK);
367 }
368 catch (Exception e) {
369 throw processException(e);
370 }
371 finally {
372 if (userGroupRole != null) {
373 cacheResult(userGroupRole);
374 }
375
376 closeSession(session);
377 }
378 }
379
380 return userGroupRole;
381 }
382
383 public List<UserGroupRole> findByUserId(long userId)
384 throws SystemException {
385 Object[] finderArgs = new Object[] { new Long(userId) };
386
387 List<UserGroupRole> list = (List<UserGroupRole>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_USERID,
388 finderArgs, this);
389
390 if (list == null) {
391 Session session = null;
392
393 try {
394 session = openSession();
395
396 StringBundler query = new StringBundler(2);
397
398 query.append(_SQL_SELECT_USERGROUPROLE_WHERE);
399
400 query.append(_FINDER_COLUMN_USERID_USERID_2);
401
402 String sql = query.toString();
403
404 Query q = session.createQuery(sql);
405
406 QueryPos qPos = QueryPos.getInstance(q);
407
408 qPos.add(userId);
409
410 list = q.list();
411 }
412 catch (Exception e) {
413 throw processException(e);
414 }
415 finally {
416 if (list == null) {
417 list = new ArrayList<UserGroupRole>();
418 }
419
420 cacheResult(list);
421
422 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_USERID,
423 finderArgs, list);
424
425 closeSession(session);
426 }
427 }
428
429 return list;
430 }
431
432 public List<UserGroupRole> findByUserId(long userId, int start, int end)
433 throws SystemException {
434 return findByUserId(userId, start, end, null);
435 }
436
437 public List<UserGroupRole> findByUserId(long userId, int start, int end,
438 OrderByComparator orderByComparator) throws SystemException {
439 Object[] finderArgs = new Object[] {
440 new Long(userId),
441
442 String.valueOf(start), String.valueOf(end),
443 String.valueOf(orderByComparator)
444 };
445
446 List<UserGroupRole> list = (List<UserGroupRole>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_USERID,
447 finderArgs, this);
448
449 if (list == null) {
450 Session session = null;
451
452 try {
453 session = openSession();
454
455 StringBundler query = null;
456
457 if (orderByComparator != null) {
458 query = new StringBundler(3 +
459 (orderByComparator.getOrderByFields().length * 3));
460 }
461 else {
462 query = new StringBundler(2);
463 }
464
465 query.append(_SQL_SELECT_USERGROUPROLE_WHERE);
466
467 query.append(_FINDER_COLUMN_USERID_USERID_2);
468
469 if (orderByComparator != null) {
470 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
471 orderByComparator);
472 }
473
474 String sql = query.toString();
475
476 Query q = session.createQuery(sql);
477
478 QueryPos qPos = QueryPos.getInstance(q);
479
480 qPos.add(userId);
481
482 list = (List<UserGroupRole>)QueryUtil.list(q, getDialect(),
483 start, end);
484 }
485 catch (Exception e) {
486 throw processException(e);
487 }
488 finally {
489 if (list == null) {
490 list = new ArrayList<UserGroupRole>();
491 }
492
493 cacheResult(list);
494
495 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_USERID,
496 finderArgs, list);
497
498 closeSession(session);
499 }
500 }
501
502 return list;
503 }
504
505 public UserGroupRole findByUserId_First(long userId,
506 OrderByComparator orderByComparator)
507 throws NoSuchUserGroupRoleException, SystemException {
508 List<UserGroupRole> list = findByUserId(userId, 0, 1, orderByComparator);
509
510 if (list.isEmpty()) {
511 StringBundler msg = new StringBundler(4);
512
513 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
514
515 msg.append("userId=");
516 msg.append(userId);
517
518 msg.append(StringPool.CLOSE_CURLY_BRACE);
519
520 throw new NoSuchUserGroupRoleException(msg.toString());
521 }
522 else {
523 return list.get(0);
524 }
525 }
526
527 public UserGroupRole findByUserId_Last(long userId,
528 OrderByComparator orderByComparator)
529 throws NoSuchUserGroupRoleException, SystemException {
530 int count = countByUserId(userId);
531
532 List<UserGroupRole> list = findByUserId(userId, count - 1, count,
533 orderByComparator);
534
535 if (list.isEmpty()) {
536 StringBundler msg = new StringBundler(4);
537
538 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
539
540 msg.append("userId=");
541 msg.append(userId);
542
543 msg.append(StringPool.CLOSE_CURLY_BRACE);
544
545 throw new NoSuchUserGroupRoleException(msg.toString());
546 }
547 else {
548 return list.get(0);
549 }
550 }
551
552 public UserGroupRole[] findByUserId_PrevAndNext(
553 UserGroupRolePK userGroupRolePK, long userId,
554 OrderByComparator orderByComparator)
555 throws NoSuchUserGroupRoleException, SystemException {
556 UserGroupRole userGroupRole = findByPrimaryKey(userGroupRolePK);
557
558 int count = countByUserId(userId);
559
560 Session session = null;
561
562 try {
563 session = openSession();
564
565 StringBundler query = null;
566
567 if (orderByComparator != null) {
568 query = new StringBundler(3 +
569 (orderByComparator.getOrderByFields().length * 3));
570 }
571 else {
572 query = new StringBundler(2);
573 }
574
575 query.append(_SQL_SELECT_USERGROUPROLE_WHERE);
576
577 query.append(_FINDER_COLUMN_USERID_USERID_2);
578
579 if (orderByComparator != null) {
580 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
581 orderByComparator);
582 }
583
584 String sql = query.toString();
585
586 Query q = session.createQuery(sql);
587
588 QueryPos qPos = QueryPos.getInstance(q);
589
590 qPos.add(userId);
591
592 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
593 orderByComparator, userGroupRole);
594
595 UserGroupRole[] array = new UserGroupRoleImpl[3];
596
597 array[0] = (UserGroupRole)objArray[0];
598 array[1] = (UserGroupRole)objArray[1];
599 array[2] = (UserGroupRole)objArray[2];
600
601 return array;
602 }
603 catch (Exception e) {
604 throw processException(e);
605 }
606 finally {
607 closeSession(session);
608 }
609 }
610
611 public List<UserGroupRole> findByGroupId(long groupId)
612 throws SystemException {
613 Object[] finderArgs = new Object[] { new Long(groupId) };
614
615 List<UserGroupRole> list = (List<UserGroupRole>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
616 finderArgs, this);
617
618 if (list == null) {
619 Session session = null;
620
621 try {
622 session = openSession();
623
624 StringBundler query = new StringBundler(2);
625
626 query.append(_SQL_SELECT_USERGROUPROLE_WHERE);
627
628 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
629
630 String sql = query.toString();
631
632 Query q = session.createQuery(sql);
633
634 QueryPos qPos = QueryPos.getInstance(q);
635
636 qPos.add(groupId);
637
638 list = q.list();
639 }
640 catch (Exception e) {
641 throw processException(e);
642 }
643 finally {
644 if (list == null) {
645 list = new ArrayList<UserGroupRole>();
646 }
647
648 cacheResult(list);
649
650 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
651 finderArgs, list);
652
653 closeSession(session);
654 }
655 }
656
657 return list;
658 }
659
660 public List<UserGroupRole> findByGroupId(long groupId, int start, int end)
661 throws SystemException {
662 return findByGroupId(groupId, start, end, null);
663 }
664
665 public List<UserGroupRole> findByGroupId(long groupId, int start, int end,
666 OrderByComparator orderByComparator) throws SystemException {
667 Object[] finderArgs = new Object[] {
668 new Long(groupId),
669
670 String.valueOf(start), String.valueOf(end),
671 String.valueOf(orderByComparator)
672 };
673
674 List<UserGroupRole> list = (List<UserGroupRole>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
675 finderArgs, this);
676
677 if (list == null) {
678 Session session = null;
679
680 try {
681 session = openSession();
682
683 StringBundler query = null;
684
685 if (orderByComparator != null) {
686 query = new StringBundler(3 +
687 (orderByComparator.getOrderByFields().length * 3));
688 }
689 else {
690 query = new StringBundler(2);
691 }
692
693 query.append(_SQL_SELECT_USERGROUPROLE_WHERE);
694
695 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
696
697 if (orderByComparator != null) {
698 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
699 orderByComparator);
700 }
701
702 String sql = query.toString();
703
704 Query q = session.createQuery(sql);
705
706 QueryPos qPos = QueryPos.getInstance(q);
707
708 qPos.add(groupId);
709
710 list = (List<UserGroupRole>)QueryUtil.list(q, getDialect(),
711 start, end);
712 }
713 catch (Exception e) {
714 throw processException(e);
715 }
716 finally {
717 if (list == null) {
718 list = new ArrayList<UserGroupRole>();
719 }
720
721 cacheResult(list);
722
723 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
724 finderArgs, list);
725
726 closeSession(session);
727 }
728 }
729
730 return list;
731 }
732
733 public UserGroupRole findByGroupId_First(long groupId,
734 OrderByComparator orderByComparator)
735 throws NoSuchUserGroupRoleException, SystemException {
736 List<UserGroupRole> list = findByGroupId(groupId, 0, 1,
737 orderByComparator);
738
739 if (list.isEmpty()) {
740 StringBundler msg = new StringBundler(4);
741
742 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
743
744 msg.append("groupId=");
745 msg.append(groupId);
746
747 msg.append(StringPool.CLOSE_CURLY_BRACE);
748
749 throw new NoSuchUserGroupRoleException(msg.toString());
750 }
751 else {
752 return list.get(0);
753 }
754 }
755
756 public UserGroupRole findByGroupId_Last(long groupId,
757 OrderByComparator orderByComparator)
758 throws NoSuchUserGroupRoleException, SystemException {
759 int count = countByGroupId(groupId);
760
761 List<UserGroupRole> list = findByGroupId(groupId, count - 1, count,
762 orderByComparator);
763
764 if (list.isEmpty()) {
765 StringBundler msg = new StringBundler(4);
766
767 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
768
769 msg.append("groupId=");
770 msg.append(groupId);
771
772 msg.append(StringPool.CLOSE_CURLY_BRACE);
773
774 throw new NoSuchUserGroupRoleException(msg.toString());
775 }
776 else {
777 return list.get(0);
778 }
779 }
780
781 public UserGroupRole[] findByGroupId_PrevAndNext(
782 UserGroupRolePK userGroupRolePK, long groupId,
783 OrderByComparator orderByComparator)
784 throws NoSuchUserGroupRoleException, SystemException {
785 UserGroupRole userGroupRole = findByPrimaryKey(userGroupRolePK);
786
787 int count = countByGroupId(groupId);
788
789 Session session = null;
790
791 try {
792 session = openSession();
793
794 StringBundler query = null;
795
796 if (orderByComparator != null) {
797 query = new StringBundler(3 +
798 (orderByComparator.getOrderByFields().length * 3));
799 }
800 else {
801 query = new StringBundler(2);
802 }
803
804 query.append(_SQL_SELECT_USERGROUPROLE_WHERE);
805
806 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
807
808 if (orderByComparator != null) {
809 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
810 orderByComparator);
811 }
812
813 String sql = query.toString();
814
815 Query q = session.createQuery(sql);
816
817 QueryPos qPos = QueryPos.getInstance(q);
818
819 qPos.add(groupId);
820
821 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
822 orderByComparator, userGroupRole);
823
824 UserGroupRole[] array = new UserGroupRoleImpl[3];
825
826 array[0] = (UserGroupRole)objArray[0];
827 array[1] = (UserGroupRole)objArray[1];
828 array[2] = (UserGroupRole)objArray[2];
829
830 return array;
831 }
832 catch (Exception e) {
833 throw processException(e);
834 }
835 finally {
836 closeSession(session);
837 }
838 }
839
840 public List<UserGroupRole> findByRoleId(long roleId)
841 throws SystemException {
842 Object[] finderArgs = new Object[] { new Long(roleId) };
843
844 List<UserGroupRole> list = (List<UserGroupRole>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_ROLEID,
845 finderArgs, this);
846
847 if (list == null) {
848 Session session = null;
849
850 try {
851 session = openSession();
852
853 StringBundler query = new StringBundler(2);
854
855 query.append(_SQL_SELECT_USERGROUPROLE_WHERE);
856
857 query.append(_FINDER_COLUMN_ROLEID_ROLEID_2);
858
859 String sql = query.toString();
860
861 Query q = session.createQuery(sql);
862
863 QueryPos qPos = QueryPos.getInstance(q);
864
865 qPos.add(roleId);
866
867 list = q.list();
868 }
869 catch (Exception e) {
870 throw processException(e);
871 }
872 finally {
873 if (list == null) {
874 list = new ArrayList<UserGroupRole>();
875 }
876
877 cacheResult(list);
878
879 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_ROLEID,
880 finderArgs, list);
881
882 closeSession(session);
883 }
884 }
885
886 return list;
887 }
888
889 public List<UserGroupRole> findByRoleId(long roleId, int start, int end)
890 throws SystemException {
891 return findByRoleId(roleId, start, end, null);
892 }
893
894 public List<UserGroupRole> findByRoleId(long roleId, int start, int end,
895 OrderByComparator orderByComparator) throws SystemException {
896 Object[] finderArgs = new Object[] {
897 new Long(roleId),
898
899 String.valueOf(start), String.valueOf(end),
900 String.valueOf(orderByComparator)
901 };
902
903 List<UserGroupRole> list = (List<UserGroupRole>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_ROLEID,
904 finderArgs, this);
905
906 if (list == null) {
907 Session session = null;
908
909 try {
910 session = openSession();
911
912 StringBundler query = null;
913
914 if (orderByComparator != null) {
915 query = new StringBundler(3 +
916 (orderByComparator.getOrderByFields().length * 3));
917 }
918 else {
919 query = new StringBundler(2);
920 }
921
922 query.append(_SQL_SELECT_USERGROUPROLE_WHERE);
923
924 query.append(_FINDER_COLUMN_ROLEID_ROLEID_2);
925
926 if (orderByComparator != null) {
927 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
928 orderByComparator);
929 }
930
931 String sql = query.toString();
932
933 Query q = session.createQuery(sql);
934
935 QueryPos qPos = QueryPos.getInstance(q);
936
937 qPos.add(roleId);
938
939 list = (List<UserGroupRole>)QueryUtil.list(q, getDialect(),
940 start, end);
941 }
942 catch (Exception e) {
943 throw processException(e);
944 }
945 finally {
946 if (list == null) {
947 list = new ArrayList<UserGroupRole>();
948 }
949
950 cacheResult(list);
951
952 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_ROLEID,
953 finderArgs, list);
954
955 closeSession(session);
956 }
957 }
958
959 return list;
960 }
961
962 public UserGroupRole findByRoleId_First(long roleId,
963 OrderByComparator orderByComparator)
964 throws NoSuchUserGroupRoleException, SystemException {
965 List<UserGroupRole> list = findByRoleId(roleId, 0, 1, orderByComparator);
966
967 if (list.isEmpty()) {
968 StringBundler msg = new StringBundler(4);
969
970 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
971
972 msg.append("roleId=");
973 msg.append(roleId);
974
975 msg.append(StringPool.CLOSE_CURLY_BRACE);
976
977 throw new NoSuchUserGroupRoleException(msg.toString());
978 }
979 else {
980 return list.get(0);
981 }
982 }
983
984 public UserGroupRole findByRoleId_Last(long roleId,
985 OrderByComparator orderByComparator)
986 throws NoSuchUserGroupRoleException, SystemException {
987 int count = countByRoleId(roleId);
988
989 List<UserGroupRole> list = findByRoleId(roleId, count - 1, count,
990 orderByComparator);
991
992 if (list.isEmpty()) {
993 StringBundler msg = new StringBundler(4);
994
995 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
996
997 msg.append("roleId=");
998 msg.append(roleId);
999
1000 msg.append(StringPool.CLOSE_CURLY_BRACE);
1001
1002 throw new NoSuchUserGroupRoleException(msg.toString());
1003 }
1004 else {
1005 return list.get(0);
1006 }
1007 }
1008
1009 public UserGroupRole[] findByRoleId_PrevAndNext(
1010 UserGroupRolePK userGroupRolePK, long roleId,
1011 OrderByComparator orderByComparator)
1012 throws NoSuchUserGroupRoleException, SystemException {
1013 UserGroupRole userGroupRole = findByPrimaryKey(userGroupRolePK);
1014
1015 int count = countByRoleId(roleId);
1016
1017 Session session = null;
1018
1019 try {
1020 session = openSession();
1021
1022 StringBundler query = null;
1023
1024 if (orderByComparator != null) {
1025 query = new StringBundler(3 +
1026 (orderByComparator.getOrderByFields().length * 3));
1027 }
1028 else {
1029 query = new StringBundler(2);
1030 }
1031
1032 query.append(_SQL_SELECT_USERGROUPROLE_WHERE);
1033
1034 query.append(_FINDER_COLUMN_ROLEID_ROLEID_2);
1035
1036 if (orderByComparator != null) {
1037 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1038 orderByComparator);
1039 }
1040
1041 String sql = query.toString();
1042
1043 Query q = session.createQuery(sql);
1044
1045 QueryPos qPos = QueryPos.getInstance(q);
1046
1047 qPos.add(roleId);
1048
1049 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
1050 orderByComparator, userGroupRole);
1051
1052 UserGroupRole[] array = new UserGroupRoleImpl[3];
1053
1054 array[0] = (UserGroupRole)objArray[0];
1055 array[1] = (UserGroupRole)objArray[1];
1056 array[2] = (UserGroupRole)objArray[2];
1057
1058 return array;
1059 }
1060 catch (Exception e) {
1061 throw processException(e);
1062 }
1063 finally {
1064 closeSession(session);
1065 }
1066 }
1067
1068 public List<UserGroupRole> findByU_G(long userId, long groupId)
1069 throws SystemException {
1070 Object[] finderArgs = new Object[] { new Long(userId), new Long(groupId) };
1071
1072 List<UserGroupRole> list = (List<UserGroupRole>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_U_G,
1073 finderArgs, this);
1074
1075 if (list == null) {
1076 Session session = null;
1077
1078 try {
1079 session = openSession();
1080
1081 StringBundler query = new StringBundler(3);
1082
1083 query.append(_SQL_SELECT_USERGROUPROLE_WHERE);
1084
1085 query.append(_FINDER_COLUMN_U_G_USERID_2);
1086
1087 query.append(_FINDER_COLUMN_U_G_GROUPID_2);
1088
1089 String sql = query.toString();
1090
1091 Query q = session.createQuery(sql);
1092
1093 QueryPos qPos = QueryPos.getInstance(q);
1094
1095 qPos.add(userId);
1096
1097 qPos.add(groupId);
1098
1099 list = q.list();
1100 }
1101 catch (Exception e) {
1102 throw processException(e);
1103 }
1104 finally {
1105 if (list == null) {
1106 list = new ArrayList<UserGroupRole>();
1107 }
1108
1109 cacheResult(list);
1110
1111 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_U_G, finderArgs,
1112 list);
1113
1114 closeSession(session);
1115 }
1116 }
1117
1118 return list;
1119 }
1120
1121 public List<UserGroupRole> findByU_G(long userId, long groupId, int start,
1122 int end) throws SystemException {
1123 return findByU_G(userId, groupId, start, end, null);
1124 }
1125
1126 public List<UserGroupRole> findByU_G(long userId, long groupId, int start,
1127 int end, OrderByComparator orderByComparator) throws SystemException {
1128 Object[] finderArgs = new Object[] {
1129 new Long(userId), new Long(groupId),
1130
1131 String.valueOf(start), String.valueOf(end),
1132 String.valueOf(orderByComparator)
1133 };
1134
1135 List<UserGroupRole> list = (List<UserGroupRole>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_U_G,
1136 finderArgs, this);
1137
1138 if (list == null) {
1139 Session session = null;
1140
1141 try {
1142 session = openSession();
1143
1144 StringBundler query = null;
1145
1146 if (orderByComparator != null) {
1147 query = new StringBundler(4 +
1148 (orderByComparator.getOrderByFields().length * 3));
1149 }
1150 else {
1151 query = new StringBundler(3);
1152 }
1153
1154 query.append(_SQL_SELECT_USERGROUPROLE_WHERE);
1155
1156 query.append(_FINDER_COLUMN_U_G_USERID_2);
1157
1158 query.append(_FINDER_COLUMN_U_G_GROUPID_2);
1159
1160 if (orderByComparator != null) {
1161 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1162 orderByComparator);
1163 }
1164
1165 String sql = query.toString();
1166
1167 Query q = session.createQuery(sql);
1168
1169 QueryPos qPos = QueryPos.getInstance(q);
1170
1171 qPos.add(userId);
1172
1173 qPos.add(groupId);
1174
1175 list = (List<UserGroupRole>)QueryUtil.list(q, getDialect(),
1176 start, end);
1177 }
1178 catch (Exception e) {
1179 throw processException(e);
1180 }
1181 finally {
1182 if (list == null) {
1183 list = new ArrayList<UserGroupRole>();
1184 }
1185
1186 cacheResult(list);
1187
1188 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_U_G,
1189 finderArgs, list);
1190
1191 closeSession(session);
1192 }
1193 }
1194
1195 return list;
1196 }
1197
1198 public UserGroupRole findByU_G_First(long userId, long groupId,
1199 OrderByComparator orderByComparator)
1200 throws NoSuchUserGroupRoleException, SystemException {
1201 List<UserGroupRole> list = findByU_G(userId, groupId, 0, 1,
1202 orderByComparator);
1203
1204 if (list.isEmpty()) {
1205 StringBundler msg = new StringBundler(6);
1206
1207 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1208
1209 msg.append("userId=");
1210 msg.append(userId);
1211
1212 msg.append(", groupId=");
1213 msg.append(groupId);
1214
1215 msg.append(StringPool.CLOSE_CURLY_BRACE);
1216
1217 throw new NoSuchUserGroupRoleException(msg.toString());
1218 }
1219 else {
1220 return list.get(0);
1221 }
1222 }
1223
1224 public UserGroupRole findByU_G_Last(long userId, long groupId,
1225 OrderByComparator orderByComparator)
1226 throws NoSuchUserGroupRoleException, SystemException {
1227 int count = countByU_G(userId, groupId);
1228
1229 List<UserGroupRole> list = findByU_G(userId, groupId, count - 1, count,
1230 orderByComparator);
1231
1232 if (list.isEmpty()) {
1233 StringBundler msg = new StringBundler(6);
1234
1235 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1236
1237 msg.append("userId=");
1238 msg.append(userId);
1239
1240 msg.append(", groupId=");
1241 msg.append(groupId);
1242
1243 msg.append(StringPool.CLOSE_CURLY_BRACE);
1244
1245 throw new NoSuchUserGroupRoleException(msg.toString());
1246 }
1247 else {
1248 return list.get(0);
1249 }
1250 }
1251
1252 public UserGroupRole[] findByU_G_PrevAndNext(
1253 UserGroupRolePK userGroupRolePK, long userId, long groupId,
1254 OrderByComparator orderByComparator)
1255 throws NoSuchUserGroupRoleException, SystemException {
1256 UserGroupRole userGroupRole = findByPrimaryKey(userGroupRolePK);
1257
1258 int count = countByU_G(userId, groupId);
1259
1260 Session session = null;
1261
1262 try {
1263 session = openSession();
1264
1265 StringBundler query = null;
1266
1267 if (orderByComparator != null) {
1268 query = new StringBundler(4 +
1269 (orderByComparator.getOrderByFields().length * 3));
1270 }
1271 else {
1272 query = new StringBundler(3);
1273 }
1274
1275 query.append(_SQL_SELECT_USERGROUPROLE_WHERE);
1276
1277 query.append(_FINDER_COLUMN_U_G_USERID_2);
1278
1279 query.append(_FINDER_COLUMN_U_G_GROUPID_2);
1280
1281 if (orderByComparator != null) {
1282 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1283 orderByComparator);
1284 }
1285
1286 String sql = query.toString();
1287
1288 Query q = session.createQuery(sql);
1289
1290 QueryPos qPos = QueryPos.getInstance(q);
1291
1292 qPos.add(userId);
1293
1294 qPos.add(groupId);
1295
1296 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
1297 orderByComparator, userGroupRole);
1298
1299 UserGroupRole[] array = new UserGroupRoleImpl[3];
1300
1301 array[0] = (UserGroupRole)objArray[0];
1302 array[1] = (UserGroupRole)objArray[1];
1303 array[2] = (UserGroupRole)objArray[2];
1304
1305 return array;
1306 }
1307 catch (Exception e) {
1308 throw processException(e);
1309 }
1310 finally {
1311 closeSession(session);
1312 }
1313 }
1314
1315 public List<UserGroupRole> findByG_R(long groupId, long roleId)
1316 throws SystemException {
1317 Object[] finderArgs = new Object[] { new Long(groupId), new Long(roleId) };
1318
1319 List<UserGroupRole> list = (List<UserGroupRole>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_R,
1320 finderArgs, this);
1321
1322 if (list == null) {
1323 Session session = null;
1324
1325 try {
1326 session = openSession();
1327
1328 StringBundler query = new StringBundler(3);
1329
1330 query.append(_SQL_SELECT_USERGROUPROLE_WHERE);
1331
1332 query.append(_FINDER_COLUMN_G_R_GROUPID_2);
1333
1334 query.append(_FINDER_COLUMN_G_R_ROLEID_2);
1335
1336 String sql = query.toString();
1337
1338 Query q = session.createQuery(sql);
1339
1340 QueryPos qPos = QueryPos.getInstance(q);
1341
1342 qPos.add(groupId);
1343
1344 qPos.add(roleId);
1345
1346 list = q.list();
1347 }
1348 catch (Exception e) {
1349 throw processException(e);
1350 }
1351 finally {
1352 if (list == null) {
1353 list = new ArrayList<UserGroupRole>();
1354 }
1355
1356 cacheResult(list);
1357
1358 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_R, finderArgs,
1359 list);
1360
1361 closeSession(session);
1362 }
1363 }
1364
1365 return list;
1366 }
1367
1368 public List<UserGroupRole> findByG_R(long groupId, long roleId, int start,
1369 int end) throws SystemException {
1370 return findByG_R(groupId, roleId, start, end, null);
1371 }
1372
1373 public List<UserGroupRole> findByG_R(long groupId, long roleId, int start,
1374 int end, OrderByComparator orderByComparator) throws SystemException {
1375 Object[] finderArgs = new Object[] {
1376 new Long(groupId), new Long(roleId),
1377
1378 String.valueOf(start), String.valueOf(end),
1379 String.valueOf(orderByComparator)
1380 };
1381
1382 List<UserGroupRole> list = (List<UserGroupRole>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_R,
1383 finderArgs, this);
1384
1385 if (list == null) {
1386 Session session = null;
1387
1388 try {
1389 session = openSession();
1390
1391 StringBundler query = null;
1392
1393 if (orderByComparator != null) {
1394 query = new StringBundler(4 +
1395 (orderByComparator.getOrderByFields().length * 3));
1396 }
1397 else {
1398 query = new StringBundler(3);
1399 }
1400
1401 query.append(_SQL_SELECT_USERGROUPROLE_WHERE);
1402
1403 query.append(_FINDER_COLUMN_G_R_GROUPID_2);
1404
1405 query.append(_FINDER_COLUMN_G_R_ROLEID_2);
1406
1407 if (orderByComparator != null) {
1408 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1409 orderByComparator);
1410 }
1411
1412 String sql = query.toString();
1413
1414 Query q = session.createQuery(sql);
1415
1416 QueryPos qPos = QueryPos.getInstance(q);
1417
1418 qPos.add(groupId);
1419
1420 qPos.add(roleId);
1421
1422 list = (List<UserGroupRole>)QueryUtil.list(q, getDialect(),
1423 start, end);
1424 }
1425 catch (Exception e) {
1426 throw processException(e);
1427 }
1428 finally {
1429 if (list == null) {
1430 list = new ArrayList<UserGroupRole>();
1431 }
1432
1433 cacheResult(list);
1434
1435 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_R,
1436 finderArgs, list);
1437
1438 closeSession(session);
1439 }
1440 }
1441
1442 return list;
1443 }
1444
1445 public UserGroupRole findByG_R_First(long groupId, long roleId,
1446 OrderByComparator orderByComparator)
1447 throws NoSuchUserGroupRoleException, SystemException {
1448 List<UserGroupRole> list = findByG_R(groupId, roleId, 0, 1,
1449 orderByComparator);
1450
1451 if (list.isEmpty()) {
1452 StringBundler msg = new StringBundler(6);
1453
1454 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1455
1456 msg.append("groupId=");
1457 msg.append(groupId);
1458
1459 msg.append(", roleId=");
1460 msg.append(roleId);
1461
1462 msg.append(StringPool.CLOSE_CURLY_BRACE);
1463
1464 throw new NoSuchUserGroupRoleException(msg.toString());
1465 }
1466 else {
1467 return list.get(0);
1468 }
1469 }
1470
1471 public UserGroupRole findByG_R_Last(long groupId, long roleId,
1472 OrderByComparator orderByComparator)
1473 throws NoSuchUserGroupRoleException, SystemException {
1474 int count = countByG_R(groupId, roleId);
1475
1476 List<UserGroupRole> list = findByG_R(groupId, roleId, count - 1, count,
1477 orderByComparator);
1478
1479 if (list.isEmpty()) {
1480 StringBundler msg = new StringBundler(6);
1481
1482 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1483
1484 msg.append("groupId=");
1485 msg.append(groupId);
1486
1487 msg.append(", roleId=");
1488 msg.append(roleId);
1489
1490 msg.append(StringPool.CLOSE_CURLY_BRACE);
1491
1492 throw new NoSuchUserGroupRoleException(msg.toString());
1493 }
1494 else {
1495 return list.get(0);
1496 }
1497 }
1498
1499 public UserGroupRole[] findByG_R_PrevAndNext(
1500 UserGroupRolePK userGroupRolePK, long groupId, long roleId,
1501 OrderByComparator orderByComparator)
1502 throws NoSuchUserGroupRoleException, SystemException {
1503 UserGroupRole userGroupRole = findByPrimaryKey(userGroupRolePK);
1504
1505 int count = countByG_R(groupId, roleId);
1506
1507 Session session = null;
1508
1509 try {
1510 session = openSession();
1511
1512 StringBundler query = null;
1513
1514 if (orderByComparator != null) {
1515 query = new StringBundler(4 +
1516 (orderByComparator.getOrderByFields().length * 3));
1517 }
1518 else {
1519 query = new StringBundler(3);
1520 }
1521
1522 query.append(_SQL_SELECT_USERGROUPROLE_WHERE);
1523
1524 query.append(_FINDER_COLUMN_G_R_GROUPID_2);
1525
1526 query.append(_FINDER_COLUMN_G_R_ROLEID_2);
1527
1528 if (orderByComparator != null) {
1529 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1530 orderByComparator);
1531 }
1532
1533 String sql = query.toString();
1534
1535 Query q = session.createQuery(sql);
1536
1537 QueryPos qPos = QueryPos.getInstance(q);
1538
1539 qPos.add(groupId);
1540
1541 qPos.add(roleId);
1542
1543 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
1544 orderByComparator, userGroupRole);
1545
1546 UserGroupRole[] array = new UserGroupRoleImpl[3];
1547
1548 array[0] = (UserGroupRole)objArray[0];
1549 array[1] = (UserGroupRole)objArray[1];
1550 array[2] = (UserGroupRole)objArray[2];
1551
1552 return array;
1553 }
1554 catch (Exception e) {
1555 throw processException(e);
1556 }
1557 finally {
1558 closeSession(session);
1559 }
1560 }
1561
1562 public List<UserGroupRole> findAll() throws SystemException {
1563 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1564 }
1565
1566 public List<UserGroupRole> findAll(int start, int end)
1567 throws SystemException {
1568 return findAll(start, end, null);
1569 }
1570
1571 public List<UserGroupRole> findAll(int start, int end,
1572 OrderByComparator orderByComparator) throws SystemException {
1573 Object[] finderArgs = new Object[] {
1574 String.valueOf(start), String.valueOf(end),
1575 String.valueOf(orderByComparator)
1576 };
1577
1578 List<UserGroupRole> list = (List<UserGroupRole>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1579 finderArgs, this);
1580
1581 if (list == null) {
1582 Session session = null;
1583
1584 try {
1585 session = openSession();
1586
1587 StringBundler query = null;
1588 String sql = null;
1589
1590 if (orderByComparator != null) {
1591 query = new StringBundler(2 +
1592 (orderByComparator.getOrderByFields().length * 3));
1593
1594 query.append(_SQL_SELECT_USERGROUPROLE);
1595
1596 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1597 orderByComparator);
1598
1599 sql = query.toString();
1600 }
1601
1602 sql = _SQL_SELECT_USERGROUPROLE;
1603
1604 Query q = session.createQuery(sql);
1605
1606 if (orderByComparator == null) {
1607 list = (List<UserGroupRole>)QueryUtil.list(q, getDialect(),
1608 start, end, false);
1609
1610 Collections.sort(list);
1611 }
1612 else {
1613 list = (List<UserGroupRole>)QueryUtil.list(q, getDialect(),
1614 start, end);
1615 }
1616 }
1617 catch (Exception e) {
1618 throw processException(e);
1619 }
1620 finally {
1621 if (list == null) {
1622 list = new ArrayList<UserGroupRole>();
1623 }
1624
1625 cacheResult(list);
1626
1627 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1628
1629 closeSession(session);
1630 }
1631 }
1632
1633 return list;
1634 }
1635
1636 public void removeByUserId(long userId) throws SystemException {
1637 for (UserGroupRole userGroupRole : findByUserId(userId)) {
1638 remove(userGroupRole);
1639 }
1640 }
1641
1642 public void removeByGroupId(long groupId) throws SystemException {
1643 for (UserGroupRole userGroupRole : findByGroupId(groupId)) {
1644 remove(userGroupRole);
1645 }
1646 }
1647
1648 public void removeByRoleId(long roleId) throws SystemException {
1649 for (UserGroupRole userGroupRole : findByRoleId(roleId)) {
1650 remove(userGroupRole);
1651 }
1652 }
1653
1654 public void removeByU_G(long userId, long groupId)
1655 throws SystemException {
1656 for (UserGroupRole userGroupRole : findByU_G(userId, groupId)) {
1657 remove(userGroupRole);
1658 }
1659 }
1660
1661 public void removeByG_R(long groupId, long roleId)
1662 throws SystemException {
1663 for (UserGroupRole userGroupRole : findByG_R(groupId, roleId)) {
1664 remove(userGroupRole);
1665 }
1666 }
1667
1668 public void removeAll() throws SystemException {
1669 for (UserGroupRole userGroupRole : findAll()) {
1670 remove(userGroupRole);
1671 }
1672 }
1673
1674 public int countByUserId(long userId) throws SystemException {
1675 Object[] finderArgs = new Object[] { new Long(userId) };
1676
1677 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
1678 finderArgs, this);
1679
1680 if (count == null) {
1681 Session session = null;
1682
1683 try {
1684 session = openSession();
1685
1686 StringBundler query = new StringBundler(2);
1687
1688 query.append(_SQL_COUNT_USERGROUPROLE_WHERE);
1689
1690 query.append(_FINDER_COLUMN_USERID_USERID_2);
1691
1692 String sql = query.toString();
1693
1694 Query q = session.createQuery(sql);
1695
1696 QueryPos qPos = QueryPos.getInstance(q);
1697
1698 qPos.add(userId);
1699
1700 count = (Long)q.uniqueResult();
1701 }
1702 catch (Exception e) {
1703 throw processException(e);
1704 }
1705 finally {
1706 if (count == null) {
1707 count = Long.valueOf(0);
1708 }
1709
1710 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
1711 finderArgs, count);
1712
1713 closeSession(session);
1714 }
1715 }
1716
1717 return count.intValue();
1718 }
1719
1720 public int countByGroupId(long groupId) throws SystemException {
1721 Object[] finderArgs = new Object[] { new Long(groupId) };
1722
1723 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1724 finderArgs, this);
1725
1726 if (count == null) {
1727 Session session = null;
1728
1729 try {
1730 session = openSession();
1731
1732 StringBundler query = new StringBundler(2);
1733
1734 query.append(_SQL_COUNT_USERGROUPROLE_WHERE);
1735
1736 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1737
1738 String sql = query.toString();
1739
1740 Query q = session.createQuery(sql);
1741
1742 QueryPos qPos = QueryPos.getInstance(q);
1743
1744 qPos.add(groupId);
1745
1746 count = (Long)q.uniqueResult();
1747 }
1748 catch (Exception e) {
1749 throw processException(e);
1750 }
1751 finally {
1752 if (count == null) {
1753 count = Long.valueOf(0);
1754 }
1755
1756 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1757 finderArgs, count);
1758
1759 closeSession(session);
1760 }
1761 }
1762
1763 return count.intValue();
1764 }
1765
1766 public int countByRoleId(long roleId) throws SystemException {
1767 Object[] finderArgs = new Object[] { new Long(roleId) };
1768
1769 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ROLEID,
1770 finderArgs, this);
1771
1772 if (count == null) {
1773 Session session = null;
1774
1775 try {
1776 session = openSession();
1777
1778 StringBundler query = new StringBundler(2);
1779
1780 query.append(_SQL_COUNT_USERGROUPROLE_WHERE);
1781
1782 query.append(_FINDER_COLUMN_ROLEID_ROLEID_2);
1783
1784 String sql = query.toString();
1785
1786 Query q = session.createQuery(sql);
1787
1788 QueryPos qPos = QueryPos.getInstance(q);
1789
1790 qPos.add(roleId);
1791
1792 count = (Long)q.uniqueResult();
1793 }
1794 catch (Exception e) {
1795 throw processException(e);
1796 }
1797 finally {
1798 if (count == null) {
1799 count = Long.valueOf(0);
1800 }
1801
1802 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ROLEID,
1803 finderArgs, count);
1804
1805 closeSession(session);
1806 }
1807 }
1808
1809 return count.intValue();
1810 }
1811
1812 public int countByU_G(long userId, long groupId) throws SystemException {
1813 Object[] finderArgs = new Object[] { new Long(userId), new Long(groupId) };
1814
1815 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_G,
1816 finderArgs, this);
1817
1818 if (count == null) {
1819 Session session = null;
1820
1821 try {
1822 session = openSession();
1823
1824 StringBundler query = new StringBundler(3);
1825
1826 query.append(_SQL_COUNT_USERGROUPROLE_WHERE);
1827
1828 query.append(_FINDER_COLUMN_U_G_USERID_2);
1829
1830 query.append(_FINDER_COLUMN_U_G_GROUPID_2);
1831
1832 String sql = query.toString();
1833
1834 Query q = session.createQuery(sql);
1835
1836 QueryPos qPos = QueryPos.getInstance(q);
1837
1838 qPos.add(userId);
1839
1840 qPos.add(groupId);
1841
1842 count = (Long)q.uniqueResult();
1843 }
1844 catch (Exception e) {
1845 throw processException(e);
1846 }
1847 finally {
1848 if (count == null) {
1849 count = Long.valueOf(0);
1850 }
1851
1852 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_G, finderArgs,
1853 count);
1854
1855 closeSession(session);
1856 }
1857 }
1858
1859 return count.intValue();
1860 }
1861
1862 public int countByG_R(long groupId, long roleId) throws SystemException {
1863 Object[] finderArgs = new Object[] { new Long(groupId), new Long(roleId) };
1864
1865 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_R,
1866 finderArgs, this);
1867
1868 if (count == null) {
1869 Session session = null;
1870
1871 try {
1872 session = openSession();
1873
1874 StringBundler query = new StringBundler(3);
1875
1876 query.append(_SQL_COUNT_USERGROUPROLE_WHERE);
1877
1878 query.append(_FINDER_COLUMN_G_R_GROUPID_2);
1879
1880 query.append(_FINDER_COLUMN_G_R_ROLEID_2);
1881
1882 String sql = query.toString();
1883
1884 Query q = session.createQuery(sql);
1885
1886 QueryPos qPos = QueryPos.getInstance(q);
1887
1888 qPos.add(groupId);
1889
1890 qPos.add(roleId);
1891
1892 count = (Long)q.uniqueResult();
1893 }
1894 catch (Exception e) {
1895 throw processException(e);
1896 }
1897 finally {
1898 if (count == null) {
1899 count = Long.valueOf(0);
1900 }
1901
1902 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_R, finderArgs,
1903 count);
1904
1905 closeSession(session);
1906 }
1907 }
1908
1909 return count.intValue();
1910 }
1911
1912 public int countAll() throws SystemException {
1913 Object[] finderArgs = new Object[0];
1914
1915 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1916 finderArgs, this);
1917
1918 if (count == null) {
1919 Session session = null;
1920
1921 try {
1922 session = openSession();
1923
1924 Query q = session.createQuery(_SQL_COUNT_USERGROUPROLE);
1925
1926 count = (Long)q.uniqueResult();
1927 }
1928 catch (Exception e) {
1929 throw processException(e);
1930 }
1931 finally {
1932 if (count == null) {
1933 count = Long.valueOf(0);
1934 }
1935
1936 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1937 count);
1938
1939 closeSession(session);
1940 }
1941 }
1942
1943 return count.intValue();
1944 }
1945
1946 public void afterPropertiesSet() {
1947 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1948 com.liferay.portal.util.PropsUtil.get(
1949 "value.object.listener.com.liferay.portal.model.UserGroupRole")));
1950
1951 if (listenerClassNames.length > 0) {
1952 try {
1953 List<ModelListener<UserGroupRole>> listenersList = new ArrayList<ModelListener<UserGroupRole>>();
1954
1955 for (String listenerClassName : listenerClassNames) {
1956 listenersList.add((ModelListener<UserGroupRole>)Class.forName(
1957 listenerClassName).newInstance());
1958 }
1959
1960 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1961 }
1962 catch (Exception e) {
1963 _log.error(e);
1964 }
1965 }
1966 }
1967
1968 @BeanReference(type = AccountPersistence.class)
1969 protected AccountPersistence accountPersistence;
1970 @BeanReference(type = AddressPersistence.class)
1971 protected AddressPersistence addressPersistence;
1972 @BeanReference(type = BrowserTrackerPersistence.class)
1973 protected BrowserTrackerPersistence browserTrackerPersistence;
1974 @BeanReference(type = ClassNamePersistence.class)
1975 protected ClassNamePersistence classNamePersistence;
1976 @BeanReference(type = CompanyPersistence.class)
1977 protected CompanyPersistence companyPersistence;
1978 @BeanReference(type = ContactPersistence.class)
1979 protected ContactPersistence contactPersistence;
1980 @BeanReference(type = CountryPersistence.class)
1981 protected CountryPersistence countryPersistence;
1982 @BeanReference(type = EmailAddressPersistence.class)
1983 protected EmailAddressPersistence emailAddressPersistence;
1984 @BeanReference(type = GroupPersistence.class)
1985 protected GroupPersistence groupPersistence;
1986 @BeanReference(type = ImagePersistence.class)
1987 protected ImagePersistence imagePersistence;
1988 @BeanReference(type = LayoutPersistence.class)
1989 protected LayoutPersistence layoutPersistence;
1990 @BeanReference(type = LayoutPrototypePersistence.class)
1991 protected LayoutPrototypePersistence layoutPrototypePersistence;
1992 @BeanReference(type = LayoutSetPersistence.class)
1993 protected LayoutSetPersistence layoutSetPersistence;
1994 @BeanReference(type = LayoutSetPrototypePersistence.class)
1995 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1996 @BeanReference(type = ListTypePersistence.class)
1997 protected ListTypePersistence listTypePersistence;
1998 @BeanReference(type = LockPersistence.class)
1999 protected LockPersistence lockPersistence;
2000 @BeanReference(type = MembershipRequestPersistence.class)
2001 protected MembershipRequestPersistence membershipRequestPersistence;
2002 @BeanReference(type = OrganizationPersistence.class)
2003 protected OrganizationPersistence organizationPersistence;
2004 @BeanReference(type = OrgGroupPermissionPersistence.class)
2005 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
2006 @BeanReference(type = OrgGroupRolePersistence.class)
2007 protected OrgGroupRolePersistence orgGroupRolePersistence;
2008 @BeanReference(type = OrgLaborPersistence.class)
2009 protected OrgLaborPersistence orgLaborPersistence;
2010 @BeanReference(type = PasswordPolicyPersistence.class)
2011 protected PasswordPolicyPersistence passwordPolicyPersistence;
2012 @BeanReference(type = PasswordPolicyRelPersistence.class)
2013 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2014 @BeanReference(type = PasswordTrackerPersistence.class)
2015 protected PasswordTrackerPersistence passwordTrackerPersistence;
2016 @BeanReference(type = PermissionPersistence.class)
2017 protected PermissionPersistence permissionPersistence;
2018 @BeanReference(type = PhonePersistence.class)
2019 protected PhonePersistence phonePersistence;
2020 @BeanReference(type = PluginSettingPersistence.class)
2021 protected PluginSettingPersistence pluginSettingPersistence;
2022 @BeanReference(type = PortletPersistence.class)
2023 protected PortletPersistence portletPersistence;
2024 @BeanReference(type = PortletItemPersistence.class)
2025 protected PortletItemPersistence portletItemPersistence;
2026 @BeanReference(type = PortletPreferencesPersistence.class)
2027 protected PortletPreferencesPersistence portletPreferencesPersistence;
2028 @BeanReference(type = RegionPersistence.class)
2029 protected RegionPersistence regionPersistence;
2030 @BeanReference(type = ReleasePersistence.class)
2031 protected ReleasePersistence releasePersistence;
2032 @BeanReference(type = ResourcePersistence.class)
2033 protected ResourcePersistence resourcePersistence;
2034 @BeanReference(type = ResourceActionPersistence.class)
2035 protected ResourceActionPersistence resourceActionPersistence;
2036 @BeanReference(type = ResourceCodePersistence.class)
2037 protected ResourceCodePersistence resourceCodePersistence;
2038 @BeanReference(type = ResourcePermissionPersistence.class)
2039 protected ResourcePermissionPersistence resourcePermissionPersistence;
2040 @BeanReference(type = RolePersistence.class)
2041 protected RolePersistence rolePersistence;
2042 @BeanReference(type = ServiceComponentPersistence.class)
2043 protected ServiceComponentPersistence serviceComponentPersistence;
2044 @BeanReference(type = ShardPersistence.class)
2045 protected ShardPersistence shardPersistence;
2046 @BeanReference(type = SubscriptionPersistence.class)
2047 protected SubscriptionPersistence subscriptionPersistence;
2048 @BeanReference(type = TeamPersistence.class)
2049 protected TeamPersistence teamPersistence;
2050 @BeanReference(type = UserPersistence.class)
2051 protected UserPersistence userPersistence;
2052 @BeanReference(type = UserGroupPersistence.class)
2053 protected UserGroupPersistence userGroupPersistence;
2054 @BeanReference(type = UserGroupGroupRolePersistence.class)
2055 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2056 @BeanReference(type = UserGroupRolePersistence.class)
2057 protected UserGroupRolePersistence userGroupRolePersistence;
2058 @BeanReference(type = UserIdMapperPersistence.class)
2059 protected UserIdMapperPersistence userIdMapperPersistence;
2060 @BeanReference(type = UserTrackerPersistence.class)
2061 protected UserTrackerPersistence userTrackerPersistence;
2062 @BeanReference(type = UserTrackerPathPersistence.class)
2063 protected UserTrackerPathPersistence userTrackerPathPersistence;
2064 @BeanReference(type = WebDAVPropsPersistence.class)
2065 protected WebDAVPropsPersistence webDAVPropsPersistence;
2066 @BeanReference(type = WebsitePersistence.class)
2067 protected WebsitePersistence websitePersistence;
2068 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2069 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2070 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2071 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2072 private static final String _SQL_SELECT_USERGROUPROLE = "SELECT userGroupRole FROM UserGroupRole userGroupRole";
2073 private static final String _SQL_SELECT_USERGROUPROLE_WHERE = "SELECT userGroupRole FROM UserGroupRole userGroupRole WHERE ";
2074 private static final String _SQL_COUNT_USERGROUPROLE = "SELECT COUNT(userGroupRole) FROM UserGroupRole userGroupRole";
2075 private static final String _SQL_COUNT_USERGROUPROLE_WHERE = "SELECT COUNT(userGroupRole) FROM UserGroupRole userGroupRole WHERE ";
2076 private static final String _FINDER_COLUMN_USERID_USERID_2 = "userGroupRole.id.userId = ?";
2077 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "userGroupRole.id.groupId = ?";
2078 private static final String _FINDER_COLUMN_ROLEID_ROLEID_2 = "userGroupRole.id.roleId = ?";
2079 private static final String _FINDER_COLUMN_U_G_USERID_2 = "userGroupRole.id.userId = ? AND ";
2080 private static final String _FINDER_COLUMN_U_G_GROUPID_2 = "userGroupRole.id.groupId = ?";
2081 private static final String _FINDER_COLUMN_G_R_GROUPID_2 = "userGroupRole.id.groupId = ? AND ";
2082 private static final String _FINDER_COLUMN_G_R_ROLEID_2 = "userGroupRole.id.roleId = ?";
2083 private static final String _ORDER_BY_ENTITY_ALIAS = "userGroupRole.";
2084 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserGroupRole exists with the primary key ";
2085 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserGroupRole exists with the key {";
2086 private static Log _log = LogFactoryUtil.getLog(UserGroupRolePersistenceImpl.class);
2087}