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