1
22
23 package com.liferay.portal.service.persistence;
24
25 import com.liferay.portal.NoSuchOrgGroupRoleException;
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.OrgGroupRole;
36 import com.liferay.portal.model.impl.OrgGroupRoleImpl;
37 import com.liferay.portal.model.impl.OrgGroupRoleModelImpl;
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 OrgGroupRolePersistenceImpl extends BasePersistence
61 implements OrgGroupRolePersistence {
62 public OrgGroupRole create(OrgGroupRolePK orgGroupRolePK) {
63 OrgGroupRole orgGroupRole = new OrgGroupRoleImpl();
64
65 orgGroupRole.setNew(true);
66 orgGroupRole.setPrimaryKey(orgGroupRolePK);
67
68 return orgGroupRole;
69 }
70
71 public OrgGroupRole remove(OrgGroupRolePK orgGroupRolePK)
72 throws NoSuchOrgGroupRoleException, SystemException {
73 Session session = null;
74
75 try {
76 session = openSession();
77
78 OrgGroupRole orgGroupRole = (OrgGroupRole)session.get(OrgGroupRoleImpl.class,
79 orgGroupRolePK);
80
81 if (orgGroupRole == null) {
82 if (_log.isWarnEnabled()) {
83 _log.warn("No OrgGroupRole exists with the primary key " +
84 orgGroupRolePK);
85 }
86
87 throw new NoSuchOrgGroupRoleException(
88 "No OrgGroupRole exists with the primary key " +
89 orgGroupRolePK);
90 }
91
92 return remove(orgGroupRole);
93 }
94 catch (NoSuchOrgGroupRoleException 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 OrgGroupRole remove(OrgGroupRole orgGroupRole)
106 throws SystemException {
107 ModelListener listener = _getListener();
108
109 if (listener != null) {
110 listener.onBeforeRemove(orgGroupRole);
111 }
112
113 orgGroupRole = removeImpl(orgGroupRole);
114
115 if (listener != null) {
116 listener.onAfterRemove(orgGroupRole);
117 }
118
119 return orgGroupRole;
120 }
121
122 protected OrgGroupRole removeImpl(OrgGroupRole orgGroupRole)
123 throws SystemException {
124 Session session = null;
125
126 try {
127 session = openSession();
128
129 session.delete(orgGroupRole);
130
131 session.flush();
132
133 return orgGroupRole;
134 }
135 catch (Exception e) {
136 throw HibernateUtil.processException(e);
137 }
138 finally {
139 closeSession(session);
140
141 FinderCache.clearCache(OrgGroupRole.class.getName());
142 }
143 }
144
145 public OrgGroupRole update(OrgGroupRole orgGroupRole)
146 throws SystemException {
147 return update(orgGroupRole, false);
148 }
149
150 public OrgGroupRole update(OrgGroupRole orgGroupRole, boolean merge)
151 throws SystemException {
152 ModelListener listener = _getListener();
153
154 boolean isNew = orgGroupRole.isNew();
155
156 if (listener != null) {
157 if (isNew) {
158 listener.onBeforeCreate(orgGroupRole);
159 }
160 else {
161 listener.onBeforeUpdate(orgGroupRole);
162 }
163 }
164
165 orgGroupRole = updateImpl(orgGroupRole, merge);
166
167 if (listener != null) {
168 if (isNew) {
169 listener.onAfterCreate(orgGroupRole);
170 }
171 else {
172 listener.onAfterUpdate(orgGroupRole);
173 }
174 }
175
176 return orgGroupRole;
177 }
178
179 public OrgGroupRole updateImpl(
180 com.liferay.portal.model.OrgGroupRole orgGroupRole, boolean merge)
181 throws SystemException {
182 Session session = null;
183
184 try {
185 session = openSession();
186
187 if (merge) {
188 session.merge(orgGroupRole);
189 }
190 else {
191 if (orgGroupRole.isNew()) {
192 session.save(orgGroupRole);
193 }
194 }
195
196 session.flush();
197
198 orgGroupRole.setNew(false);
199
200 return orgGroupRole;
201 }
202 catch (Exception e) {
203 throw HibernateUtil.processException(e);
204 }
205 finally {
206 closeSession(session);
207
208 FinderCache.clearCache(OrgGroupRole.class.getName());
209 }
210 }
211
212 public OrgGroupRole findByPrimaryKey(OrgGroupRolePK orgGroupRolePK)
213 throws NoSuchOrgGroupRoleException, SystemException {
214 OrgGroupRole orgGroupRole = fetchByPrimaryKey(orgGroupRolePK);
215
216 if (orgGroupRole == null) {
217 if (_log.isWarnEnabled()) {
218 _log.warn("No OrgGroupRole exists with the primary key " +
219 orgGroupRolePK);
220 }
221
222 throw new NoSuchOrgGroupRoleException(
223 "No OrgGroupRole exists with the primary key " +
224 orgGroupRolePK);
225 }
226
227 return orgGroupRole;
228 }
229
230 public OrgGroupRole fetchByPrimaryKey(OrgGroupRolePK orgGroupRolePK)
231 throws SystemException {
232 Session session = null;
233
234 try {
235 session = openSession();
236
237 return (OrgGroupRole)session.get(OrgGroupRoleImpl.class,
238 orgGroupRolePK);
239 }
240 catch (Exception e) {
241 throw HibernateUtil.processException(e);
242 }
243 finally {
244 closeSession(session);
245 }
246 }
247
248 public List findByGroupId(long groupId) throws SystemException {
249 boolean finderClassNameCacheEnabled = OrgGroupRoleModelImpl.CACHE_ENABLED;
250 String finderClassName = OrgGroupRole.class.getName();
251 String finderMethodName = "findByGroupId";
252 String[] finderParams = new String[] { Long.class.getName() };
253 Object[] finderArgs = new Object[] { new Long(groupId) };
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.OrgGroupRole WHERE ");
272
273 query.append("groupId = ?");
274
275 query.append(" ");
276
277 Query q = session.createQuery(query.toString());
278
279 int queryPos = 0;
280
281 q.setLong(queryPos++, groupId);
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 findByGroupId(long groupId, int begin, int end)
304 throws SystemException {
305 return findByGroupId(groupId, begin, end, null);
306 }
307
308 public List findByGroupId(long groupId, int begin, int end,
309 OrderByComparator obc) throws SystemException {
310 boolean finderClassNameCacheEnabled = OrgGroupRoleModelImpl.CACHE_ENABLED;
311 String finderClassName = OrgGroupRole.class.getName();
312 String finderMethodName = "findByGroupId";
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(groupId),
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.OrgGroupRole WHERE ");
342
343 query.append("groupId = ?");
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++, groupId);
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 OrgGroupRole findByGroupId_First(long groupId, OrderByComparator obc)
379 throws NoSuchOrgGroupRoleException, SystemException {
380 List list = findByGroupId(groupId, 0, 1, obc);
381
382 if (list.size() == 0) {
383 StringMaker msg = new StringMaker();
384
385 msg.append("No OrgGroupRole exists with the key {");
386
387 msg.append("groupId=" + groupId);
388
389 msg.append(StringPool.CLOSE_CURLY_BRACE);
390
391 throw new NoSuchOrgGroupRoleException(msg.toString());
392 }
393 else {
394 return (OrgGroupRole)list.get(0);
395 }
396 }
397
398 public OrgGroupRole findByGroupId_Last(long groupId, OrderByComparator obc)
399 throws NoSuchOrgGroupRoleException, SystemException {
400 int count = countByGroupId(groupId);
401
402 List list = findByGroupId(groupId, count - 1, count, obc);
403
404 if (list.size() == 0) {
405 StringMaker msg = new StringMaker();
406
407 msg.append("No OrgGroupRole exists with the key {");
408
409 msg.append("groupId=" + groupId);
410
411 msg.append(StringPool.CLOSE_CURLY_BRACE);
412
413 throw new NoSuchOrgGroupRoleException(msg.toString());
414 }
415 else {
416 return (OrgGroupRole)list.get(0);
417 }
418 }
419
420 public OrgGroupRole[] findByGroupId_PrevAndNext(
421 OrgGroupRolePK orgGroupRolePK, long groupId, OrderByComparator obc)
422 throws NoSuchOrgGroupRoleException, SystemException {
423 OrgGroupRole orgGroupRole = findByPrimaryKey(orgGroupRolePK);
424
425 int count = countByGroupId(groupId);
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.OrgGroupRole WHERE ");
435
436 query.append("groupId = ?");
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++, groupId);
450
451 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
452 orgGroupRole);
453
454 OrgGroupRole[] array = new OrgGroupRoleImpl[3];
455
456 array[0] = (OrgGroupRole)objArray[0];
457 array[1] = (OrgGroupRole)objArray[1];
458 array[2] = (OrgGroupRole)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 findByRoleId(long roleId) throws SystemException {
471 boolean finderClassNameCacheEnabled = OrgGroupRoleModelImpl.CACHE_ENABLED;
472 String finderClassName = OrgGroupRole.class.getName();
473 String finderMethodName = "findByRoleId";
474 String[] finderParams = new String[] { Long.class.getName() };
475 Object[] finderArgs = new Object[] { new Long(roleId) };
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.OrgGroupRole WHERE ");
494
495 query.append("roleId = ?");
496
497 query.append(" ");
498
499 Query q = session.createQuery(query.toString());
500
501 int queryPos = 0;
502
503 q.setLong(queryPos++, roleId);
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 findByRoleId(long roleId, int begin, int end)
526 throws SystemException {
527 return findByRoleId(roleId, begin, end, null);
528 }
529
530 public List findByRoleId(long roleId, int begin, int end,
531 OrderByComparator obc) throws SystemException {
532 boolean finderClassNameCacheEnabled = OrgGroupRoleModelImpl.CACHE_ENABLED;
533 String finderClassName = OrgGroupRole.class.getName();
534 String finderMethodName = "findByRoleId";
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(roleId),
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.OrgGroupRole WHERE ");
564
565 query.append("roleId = ?");
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++, roleId);
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 OrgGroupRole findByRoleId_First(long roleId, OrderByComparator obc)
601 throws NoSuchOrgGroupRoleException, SystemException {
602 List list = findByRoleId(roleId, 0, 1, obc);
603
604 if (list.size() == 0) {
605 StringMaker msg = new StringMaker();
606
607 msg.append("No OrgGroupRole exists with the key {");
608
609 msg.append("roleId=" + roleId);
610
611 msg.append(StringPool.CLOSE_CURLY_BRACE);
612
613 throw new NoSuchOrgGroupRoleException(msg.toString());
614 }
615 else {
616 return (OrgGroupRole)list.get(0);
617 }
618 }
619
620 public OrgGroupRole findByRoleId_Last(long roleId, OrderByComparator obc)
621 throws NoSuchOrgGroupRoleException, SystemException {
622 int count = countByRoleId(roleId);
623
624 List list = findByRoleId(roleId, count - 1, count, obc);
625
626 if (list.size() == 0) {
627 StringMaker msg = new StringMaker();
628
629 msg.append("No OrgGroupRole exists with the key {");
630
631 msg.append("roleId=" + roleId);
632
633 msg.append(StringPool.CLOSE_CURLY_BRACE);
634
635 throw new NoSuchOrgGroupRoleException(msg.toString());
636 }
637 else {
638 return (OrgGroupRole)list.get(0);
639 }
640 }
641
642 public OrgGroupRole[] findByRoleId_PrevAndNext(
643 OrgGroupRolePK orgGroupRolePK, long roleId, OrderByComparator obc)
644 throws NoSuchOrgGroupRoleException, SystemException {
645 OrgGroupRole orgGroupRole = findByPrimaryKey(orgGroupRolePK);
646
647 int count = countByRoleId(roleId);
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.OrgGroupRole WHERE ");
657
658 query.append("roleId = ?");
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++, roleId);
672
673 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
674 orgGroupRole);
675
676 OrgGroupRole[] array = new OrgGroupRoleImpl[3];
677
678 array[0] = (OrgGroupRole)objArray[0];
679 array[1] = (OrgGroupRole)objArray[1];
680 array[2] = (OrgGroupRole)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 findWithDynamicQuery(DynamicQueryInitializer queryInitializer)
693 throws SystemException {
694 Session session = null;
695
696 try {
697 session = openSession();
698
699 DynamicQuery query = queryInitializer.initialize(session);
700
701 return query.list();
702 }
703 catch (Exception e) {
704 throw HibernateUtil.processException(e);
705 }
706 finally {
707 closeSession(session);
708 }
709 }
710
711 public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer,
712 int begin, int end) throws SystemException {
713 Session session = null;
714
715 try {
716 session = openSession();
717
718 DynamicQuery query = queryInitializer.initialize(session);
719
720 query.setLimit(begin, end);
721
722 return query.list();
723 }
724 catch (Exception e) {
725 throw HibernateUtil.processException(e);
726 }
727 finally {
728 closeSession(session);
729 }
730 }
731
732 public List findAll() throws SystemException {
733 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
734 }
735
736 public List findAll(int begin, int end) throws SystemException {
737 return findAll(begin, end, null);
738 }
739
740 public List findAll(int begin, int end, OrderByComparator obc)
741 throws SystemException {
742 boolean finderClassNameCacheEnabled = OrgGroupRoleModelImpl.CACHE_ENABLED;
743 String finderClassName = OrgGroupRole.class.getName();
744 String finderMethodName = "findAll";
745 String[] finderParams = new String[] {
746 "java.lang.Integer", "java.lang.Integer",
747 "com.liferay.portal.kernel.util.OrderByComparator"
748 };
749 Object[] finderArgs = new Object[] {
750 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
751 };
752
753 Object result = null;
754
755 if (finderClassNameCacheEnabled) {
756 result = FinderCache.getResult(finderClassName, finderMethodName,
757 finderParams, finderArgs, getSessionFactory());
758 }
759
760 if (result == null) {
761 Session session = null;
762
763 try {
764 session = openSession();
765
766 StringMaker query = new StringMaker();
767
768 query.append("FROM com.liferay.portal.model.OrgGroupRole ");
769
770 if (obc != null) {
771 query.append("ORDER BY ");
772 query.append(obc.getOrderBy());
773 }
774
775 Query q = session.createQuery(query.toString());
776
777 List list = QueryUtil.list(q, getDialect(), begin, end);
778
779 if (obc == null) {
780 Collections.sort(list);
781 }
782
783 FinderCache.putResult(finderClassNameCacheEnabled,
784 finderClassName, finderMethodName, finderParams,
785 finderArgs, list);
786
787 return list;
788 }
789 catch (Exception e) {
790 throw HibernateUtil.processException(e);
791 }
792 finally {
793 closeSession(session);
794 }
795 }
796 else {
797 return (List)result;
798 }
799 }
800
801 public void removeByGroupId(long groupId) throws SystemException {
802 Iterator itr = findByGroupId(groupId).iterator();
803
804 while (itr.hasNext()) {
805 OrgGroupRole orgGroupRole = (OrgGroupRole)itr.next();
806
807 remove(orgGroupRole);
808 }
809 }
810
811 public void removeByRoleId(long roleId) throws SystemException {
812 Iterator itr = findByRoleId(roleId).iterator();
813
814 while (itr.hasNext()) {
815 OrgGroupRole orgGroupRole = (OrgGroupRole)itr.next();
816
817 remove(orgGroupRole);
818 }
819 }
820
821 public void removeAll() throws SystemException {
822 Iterator itr = findAll().iterator();
823
824 while (itr.hasNext()) {
825 remove((OrgGroupRole)itr.next());
826 }
827 }
828
829 public int countByGroupId(long groupId) throws SystemException {
830 boolean finderClassNameCacheEnabled = OrgGroupRoleModelImpl.CACHE_ENABLED;
831 String finderClassName = OrgGroupRole.class.getName();
832 String finderMethodName = "countByGroupId";
833 String[] finderParams = new String[] { Long.class.getName() };
834 Object[] finderArgs = new Object[] { new Long(groupId) };
835
836 Object result = null;
837
838 if (finderClassNameCacheEnabled) {
839 result = FinderCache.getResult(finderClassName, finderMethodName,
840 finderParams, finderArgs, getSessionFactory());
841 }
842
843 if (result == null) {
844 Session session = null;
845
846 try {
847 session = openSession();
848
849 StringMaker query = new StringMaker();
850
851 query.append("SELECT COUNT(*) ");
852 query.append(
853 "FROM com.liferay.portal.model.OrgGroupRole WHERE ");
854
855 query.append("groupId = ?");
856
857 query.append(" ");
858
859 Query q = session.createQuery(query.toString());
860
861 int queryPos = 0;
862
863 q.setLong(queryPos++, groupId);
864
865 Long count = null;
866
867 Iterator itr = q.list().iterator();
868
869 if (itr.hasNext()) {
870 count = (Long)itr.next();
871 }
872
873 if (count == null) {
874 count = new Long(0);
875 }
876
877 FinderCache.putResult(finderClassNameCacheEnabled,
878 finderClassName, finderMethodName, finderParams,
879 finderArgs, count);
880
881 return count.intValue();
882 }
883 catch (Exception e) {
884 throw HibernateUtil.processException(e);
885 }
886 finally {
887 closeSession(session);
888 }
889 }
890 else {
891 return ((Long)result).intValue();
892 }
893 }
894
895 public int countByRoleId(long roleId) throws SystemException {
896 boolean finderClassNameCacheEnabled = OrgGroupRoleModelImpl.CACHE_ENABLED;
897 String finderClassName = OrgGroupRole.class.getName();
898 String finderMethodName = "countByRoleId";
899 String[] finderParams = new String[] { Long.class.getName() };
900 Object[] finderArgs = new Object[] { new Long(roleId) };
901
902 Object result = null;
903
904 if (finderClassNameCacheEnabled) {
905 result = FinderCache.getResult(finderClassName, finderMethodName,
906 finderParams, finderArgs, getSessionFactory());
907 }
908
909 if (result == null) {
910 Session session = null;
911
912 try {
913 session = openSession();
914
915 StringMaker query = new StringMaker();
916
917 query.append("SELECT COUNT(*) ");
918 query.append(
919 "FROM com.liferay.portal.model.OrgGroupRole WHERE ");
920
921 query.append("roleId = ?");
922
923 query.append(" ");
924
925 Query q = session.createQuery(query.toString());
926
927 int queryPos = 0;
928
929 q.setLong(queryPos++, roleId);
930
931 Long count = null;
932
933 Iterator itr = q.list().iterator();
934
935 if (itr.hasNext()) {
936 count = (Long)itr.next();
937 }
938
939 if (count == null) {
940 count = new Long(0);
941 }
942
943 FinderCache.putResult(finderClassNameCacheEnabled,
944 finderClassName, finderMethodName, finderParams,
945 finderArgs, count);
946
947 return count.intValue();
948 }
949 catch (Exception e) {
950 throw HibernateUtil.processException(e);
951 }
952 finally {
953 closeSession(session);
954 }
955 }
956 else {
957 return ((Long)result).intValue();
958 }
959 }
960
961 public int countAll() throws SystemException {
962 boolean finderClassNameCacheEnabled = OrgGroupRoleModelImpl.CACHE_ENABLED;
963 String finderClassName = OrgGroupRole.class.getName();
964 String finderMethodName = "countAll";
965 String[] finderParams = new String[] { };
966 Object[] finderArgs = new Object[] { };
967
968 Object result = null;
969
970 if (finderClassNameCacheEnabled) {
971 result = FinderCache.getResult(finderClassName, finderMethodName,
972 finderParams, finderArgs, getSessionFactory());
973 }
974
975 if (result == null) {
976 Session session = null;
977
978 try {
979 session = openSession();
980
981 Query q = session.createQuery(
982 "SELECT COUNT(*) FROM com.liferay.portal.model.OrgGroupRole");
983
984 Long count = null;
985
986 Iterator itr = q.list().iterator();
987
988 if (itr.hasNext()) {
989 count = (Long)itr.next();
990 }
991
992 if (count == null) {
993 count = new Long(0);
994 }
995
996 FinderCache.putResult(finderClassNameCacheEnabled,
997 finderClassName, finderMethodName, finderParams,
998 finderArgs, count);
999
1000 return count.intValue();
1001 }
1002 catch (Exception e) {
1003 throw HibernateUtil.processException(e);
1004 }
1005 finally {
1006 closeSession(session);
1007 }
1008 }
1009 else {
1010 return ((Long)result).intValue();
1011 }
1012 }
1013
1014 protected void initDao() {
1015 }
1016
1017 private static ModelListener _getListener() {
1018 if (Validator.isNotNull(_LISTENER)) {
1019 try {
1020 return (ModelListener)Class.forName(_LISTENER).newInstance();
1021 }
1022 catch (Exception e) {
1023 _log.error(e);
1024 }
1025 }
1026
1027 return null;
1028 }
1029
1030 private static final String _LISTENER = GetterUtil.getString(PropsUtil.get(
1031 "value.object.listener.com.liferay.portal.model.OrgGroupRole"));
1032 private static Log _log = LogFactory.getLog(OrgGroupRolePersistenceImpl.class);
1033}