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.annotation.BeanReference;
28 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
29 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
30 import com.liferay.portal.kernel.dao.orm.Query;
31 import com.liferay.portal.kernel.dao.orm.QueryPos;
32 import com.liferay.portal.kernel.dao.orm.QueryUtil;
33 import com.liferay.portal.kernel.dao.orm.Session;
34 import com.liferay.portal.kernel.log.Log;
35 import com.liferay.portal.kernel.log.LogFactoryUtil;
36 import com.liferay.portal.kernel.util.GetterUtil;
37 import com.liferay.portal.kernel.util.OrderByComparator;
38 import com.liferay.portal.kernel.util.StringPool;
39 import com.liferay.portal.kernel.util.StringUtil;
40 import com.liferay.portal.model.ModelListener;
41 import com.liferay.portal.model.OrgGroupRole;
42 import com.liferay.portal.model.impl.OrgGroupRoleImpl;
43 import com.liferay.portal.model.impl.OrgGroupRoleModelImpl;
44 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
45
46 import java.util.ArrayList;
47 import java.util.Collections;
48 import java.util.Iterator;
49 import java.util.List;
50
51
57 public class OrgGroupRolePersistenceImpl extends BasePersistenceImpl
58 implements OrgGroupRolePersistence {
59 public OrgGroupRole create(OrgGroupRolePK orgGroupRolePK) {
60 OrgGroupRole orgGroupRole = new OrgGroupRoleImpl();
61
62 orgGroupRole.setNew(true);
63 orgGroupRole.setPrimaryKey(orgGroupRolePK);
64
65 return orgGroupRole;
66 }
67
68 public OrgGroupRole remove(OrgGroupRolePK orgGroupRolePK)
69 throws NoSuchOrgGroupRoleException, SystemException {
70 Session session = null;
71
72 try {
73 session = openSession();
74
75 OrgGroupRole orgGroupRole = (OrgGroupRole)session.get(OrgGroupRoleImpl.class,
76 orgGroupRolePK);
77
78 if (orgGroupRole == null) {
79 if (_log.isWarnEnabled()) {
80 _log.warn("No OrgGroupRole exists with the primary key " +
81 orgGroupRolePK);
82 }
83
84 throw new NoSuchOrgGroupRoleException(
85 "No OrgGroupRole exists with the primary key " +
86 orgGroupRolePK);
87 }
88
89 return remove(orgGroupRole);
90 }
91 catch (NoSuchOrgGroupRoleException nsee) {
92 throw nsee;
93 }
94 catch (Exception e) {
95 throw processException(e);
96 }
97 finally {
98 closeSession(session);
99 }
100 }
101
102 public OrgGroupRole remove(OrgGroupRole orgGroupRole)
103 throws SystemException {
104 for (ModelListener listener : listeners) {
105 listener.onBeforeRemove(orgGroupRole);
106 }
107
108 orgGroupRole = removeImpl(orgGroupRole);
109
110 for (ModelListener listener : listeners) {
111 listener.onAfterRemove(orgGroupRole);
112 }
113
114 return orgGroupRole;
115 }
116
117 protected OrgGroupRole removeImpl(OrgGroupRole orgGroupRole)
118 throws SystemException {
119 Session session = null;
120
121 try {
122 session = openSession();
123
124 if (BatchSessionUtil.isEnabled()) {
125 Object staleObject = session.get(OrgGroupRoleImpl.class,
126 orgGroupRole.getPrimaryKeyObj());
127
128 if (staleObject != null) {
129 session.evict(staleObject);
130 }
131 }
132
133 session.delete(orgGroupRole);
134
135 session.flush();
136
137 return orgGroupRole;
138 }
139 catch (Exception e) {
140 throw processException(e);
141 }
142 finally {
143 closeSession(session);
144
145 FinderCacheUtil.clearCache(OrgGroupRole.class.getName());
146 }
147 }
148
149
152 public OrgGroupRole update(OrgGroupRole orgGroupRole)
153 throws SystemException {
154 if (_log.isWarnEnabled()) {
155 _log.warn(
156 "Using the deprecated update(OrgGroupRole orgGroupRole) method. Use update(OrgGroupRole orgGroupRole, boolean merge) instead.");
157 }
158
159 return update(orgGroupRole, false);
160 }
161
162
175 public OrgGroupRole update(OrgGroupRole orgGroupRole, boolean merge)
176 throws SystemException {
177 boolean isNew = orgGroupRole.isNew();
178
179 for (ModelListener listener : listeners) {
180 if (isNew) {
181 listener.onBeforeCreate(orgGroupRole);
182 }
183 else {
184 listener.onBeforeUpdate(orgGroupRole);
185 }
186 }
187
188 orgGroupRole = updateImpl(orgGroupRole, merge);
189
190 for (ModelListener listener : listeners) {
191 if (isNew) {
192 listener.onAfterCreate(orgGroupRole);
193 }
194 else {
195 listener.onAfterUpdate(orgGroupRole);
196 }
197 }
198
199 return orgGroupRole;
200 }
201
202 public OrgGroupRole updateImpl(
203 com.liferay.portal.model.OrgGroupRole orgGroupRole, boolean merge)
204 throws SystemException {
205 Session session = null;
206
207 try {
208 session = openSession();
209
210 BatchSessionUtil.update(session, orgGroupRole, merge);
211
212 orgGroupRole.setNew(false);
213
214 return orgGroupRole;
215 }
216 catch (Exception e) {
217 throw processException(e);
218 }
219 finally {
220 closeSession(session);
221
222 FinderCacheUtil.clearCache(OrgGroupRole.class.getName());
223 }
224 }
225
226 public OrgGroupRole findByPrimaryKey(OrgGroupRolePK orgGroupRolePK)
227 throws NoSuchOrgGroupRoleException, SystemException {
228 OrgGroupRole orgGroupRole = fetchByPrimaryKey(orgGroupRolePK);
229
230 if (orgGroupRole == null) {
231 if (_log.isWarnEnabled()) {
232 _log.warn("No OrgGroupRole exists with the primary key " +
233 orgGroupRolePK);
234 }
235
236 throw new NoSuchOrgGroupRoleException(
237 "No OrgGroupRole exists with the primary key " +
238 orgGroupRolePK);
239 }
240
241 return orgGroupRole;
242 }
243
244 public OrgGroupRole fetchByPrimaryKey(OrgGroupRolePK orgGroupRolePK)
245 throws SystemException {
246 Session session = null;
247
248 try {
249 session = openSession();
250
251 return (OrgGroupRole)session.get(OrgGroupRoleImpl.class,
252 orgGroupRolePK);
253 }
254 catch (Exception e) {
255 throw processException(e);
256 }
257 finally {
258 closeSession(session);
259 }
260 }
261
262 public List<OrgGroupRole> findByGroupId(long groupId)
263 throws SystemException {
264 boolean finderClassNameCacheEnabled = OrgGroupRoleModelImpl.CACHE_ENABLED;
265 String finderClassName = OrgGroupRole.class.getName();
266 String finderMethodName = "findByGroupId";
267 String[] finderParams = new String[] { Long.class.getName() };
268 Object[] finderArgs = new Object[] { new Long(groupId) };
269
270 Object result = null;
271
272 if (finderClassNameCacheEnabled) {
273 result = FinderCacheUtil.getResult(finderClassName,
274 finderMethodName, finderParams, finderArgs, this);
275 }
276
277 if (result == null) {
278 Session session = null;
279
280 try {
281 session = openSession();
282
283 StringBuilder query = new StringBuilder();
284
285 query.append(
286 "FROM com.liferay.portal.model.OrgGroupRole WHERE ");
287
288 query.append("groupId = ?");
289
290 query.append(" ");
291
292 Query q = session.createQuery(query.toString());
293
294 QueryPos qPos = QueryPos.getInstance(q);
295
296 qPos.add(groupId);
297
298 List<OrgGroupRole> list = q.list();
299
300 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
301 finderClassName, finderMethodName, finderParams,
302 finderArgs, list);
303
304 return list;
305 }
306 catch (Exception e) {
307 throw processException(e);
308 }
309 finally {
310 closeSession(session);
311 }
312 }
313 else {
314 return (List<OrgGroupRole>)result;
315 }
316 }
317
318 public List<OrgGroupRole> findByGroupId(long groupId, int start, int end)
319 throws SystemException {
320 return findByGroupId(groupId, start, end, null);
321 }
322
323 public List<OrgGroupRole> findByGroupId(long groupId, int start, int end,
324 OrderByComparator obc) throws SystemException {
325 boolean finderClassNameCacheEnabled = OrgGroupRoleModelImpl.CACHE_ENABLED;
326 String finderClassName = OrgGroupRole.class.getName();
327 String finderMethodName = "findByGroupId";
328 String[] finderParams = new String[] {
329 Long.class.getName(),
330
331 "java.lang.Integer", "java.lang.Integer",
332 "com.liferay.portal.kernel.util.OrderByComparator"
333 };
334 Object[] finderArgs = new Object[] {
335 new Long(groupId),
336
337 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
338 };
339
340 Object result = null;
341
342 if (finderClassNameCacheEnabled) {
343 result = FinderCacheUtil.getResult(finderClassName,
344 finderMethodName, finderParams, finderArgs, this);
345 }
346
347 if (result == null) {
348 Session session = null;
349
350 try {
351 session = openSession();
352
353 StringBuilder query = new StringBuilder();
354
355 query.append(
356 "FROM com.liferay.portal.model.OrgGroupRole WHERE ");
357
358 query.append("groupId = ?");
359
360 query.append(" ");
361
362 if (obc != null) {
363 query.append("ORDER BY ");
364 query.append(obc.getOrderBy());
365 }
366
367 Query q = session.createQuery(query.toString());
368
369 QueryPos qPos = QueryPos.getInstance(q);
370
371 qPos.add(groupId);
372
373 List<OrgGroupRole> list = (List<OrgGroupRole>)QueryUtil.list(q,
374 getDialect(), start, end);
375
376 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
377 finderClassName, finderMethodName, finderParams,
378 finderArgs, list);
379
380 return list;
381 }
382 catch (Exception e) {
383 throw processException(e);
384 }
385 finally {
386 closeSession(session);
387 }
388 }
389 else {
390 return (List<OrgGroupRole>)result;
391 }
392 }
393
394 public OrgGroupRole findByGroupId_First(long groupId, OrderByComparator obc)
395 throws NoSuchOrgGroupRoleException, SystemException {
396 List<OrgGroupRole> list = findByGroupId(groupId, 0, 1, obc);
397
398 if (list.size() == 0) {
399 StringBuilder msg = new StringBuilder();
400
401 msg.append("No OrgGroupRole exists with the key {");
402
403 msg.append("groupId=" + groupId);
404
405 msg.append(StringPool.CLOSE_CURLY_BRACE);
406
407 throw new NoSuchOrgGroupRoleException(msg.toString());
408 }
409 else {
410 return list.get(0);
411 }
412 }
413
414 public OrgGroupRole findByGroupId_Last(long groupId, OrderByComparator obc)
415 throws NoSuchOrgGroupRoleException, SystemException {
416 int count = countByGroupId(groupId);
417
418 List<OrgGroupRole> list = findByGroupId(groupId, count - 1, count, obc);
419
420 if (list.size() == 0) {
421 StringBuilder msg = new StringBuilder();
422
423 msg.append("No OrgGroupRole exists with the key {");
424
425 msg.append("groupId=" + groupId);
426
427 msg.append(StringPool.CLOSE_CURLY_BRACE);
428
429 throw new NoSuchOrgGroupRoleException(msg.toString());
430 }
431 else {
432 return list.get(0);
433 }
434 }
435
436 public OrgGroupRole[] findByGroupId_PrevAndNext(
437 OrgGroupRolePK orgGroupRolePK, long groupId, OrderByComparator obc)
438 throws NoSuchOrgGroupRoleException, SystemException {
439 OrgGroupRole orgGroupRole = findByPrimaryKey(orgGroupRolePK);
440
441 int count = countByGroupId(groupId);
442
443 Session session = null;
444
445 try {
446 session = openSession();
447
448 StringBuilder query = new StringBuilder();
449
450 query.append("FROM com.liferay.portal.model.OrgGroupRole WHERE ");
451
452 query.append("groupId = ?");
453
454 query.append(" ");
455
456 if (obc != null) {
457 query.append("ORDER BY ");
458 query.append(obc.getOrderBy());
459 }
460
461 Query q = session.createQuery(query.toString());
462
463 QueryPos qPos = QueryPos.getInstance(q);
464
465 qPos.add(groupId);
466
467 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
468 orgGroupRole);
469
470 OrgGroupRole[] array = new OrgGroupRoleImpl[3];
471
472 array[0] = (OrgGroupRole)objArray[0];
473 array[1] = (OrgGroupRole)objArray[1];
474 array[2] = (OrgGroupRole)objArray[2];
475
476 return array;
477 }
478 catch (Exception e) {
479 throw processException(e);
480 }
481 finally {
482 closeSession(session);
483 }
484 }
485
486 public List<OrgGroupRole> findByRoleId(long roleId)
487 throws SystemException {
488 boolean finderClassNameCacheEnabled = OrgGroupRoleModelImpl.CACHE_ENABLED;
489 String finderClassName = OrgGroupRole.class.getName();
490 String finderMethodName = "findByRoleId";
491 String[] finderParams = new String[] { Long.class.getName() };
492 Object[] finderArgs = new Object[] { new Long(roleId) };
493
494 Object result = null;
495
496 if (finderClassNameCacheEnabled) {
497 result = FinderCacheUtil.getResult(finderClassName,
498 finderMethodName, finderParams, finderArgs, this);
499 }
500
501 if (result == null) {
502 Session session = null;
503
504 try {
505 session = openSession();
506
507 StringBuilder query = new StringBuilder();
508
509 query.append(
510 "FROM com.liferay.portal.model.OrgGroupRole WHERE ");
511
512 query.append("roleId = ?");
513
514 query.append(" ");
515
516 Query q = session.createQuery(query.toString());
517
518 QueryPos qPos = QueryPos.getInstance(q);
519
520 qPos.add(roleId);
521
522 List<OrgGroupRole> list = q.list();
523
524 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
525 finderClassName, finderMethodName, finderParams,
526 finderArgs, list);
527
528 return list;
529 }
530 catch (Exception e) {
531 throw processException(e);
532 }
533 finally {
534 closeSession(session);
535 }
536 }
537 else {
538 return (List<OrgGroupRole>)result;
539 }
540 }
541
542 public List<OrgGroupRole> findByRoleId(long roleId, int start, int end)
543 throws SystemException {
544 return findByRoleId(roleId, start, end, null);
545 }
546
547 public List<OrgGroupRole> findByRoleId(long roleId, int start, int end,
548 OrderByComparator obc) throws SystemException {
549 boolean finderClassNameCacheEnabled = OrgGroupRoleModelImpl.CACHE_ENABLED;
550 String finderClassName = OrgGroupRole.class.getName();
551 String finderMethodName = "findByRoleId";
552 String[] finderParams = new String[] {
553 Long.class.getName(),
554
555 "java.lang.Integer", "java.lang.Integer",
556 "com.liferay.portal.kernel.util.OrderByComparator"
557 };
558 Object[] finderArgs = new Object[] {
559 new Long(roleId),
560
561 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
562 };
563
564 Object result = null;
565
566 if (finderClassNameCacheEnabled) {
567 result = FinderCacheUtil.getResult(finderClassName,
568 finderMethodName, finderParams, finderArgs, this);
569 }
570
571 if (result == null) {
572 Session session = null;
573
574 try {
575 session = openSession();
576
577 StringBuilder query = new StringBuilder();
578
579 query.append(
580 "FROM com.liferay.portal.model.OrgGroupRole WHERE ");
581
582 query.append("roleId = ?");
583
584 query.append(" ");
585
586 if (obc != null) {
587 query.append("ORDER BY ");
588 query.append(obc.getOrderBy());
589 }
590
591 Query q = session.createQuery(query.toString());
592
593 QueryPos qPos = QueryPos.getInstance(q);
594
595 qPos.add(roleId);
596
597 List<OrgGroupRole> list = (List<OrgGroupRole>)QueryUtil.list(q,
598 getDialect(), start, end);
599
600 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
601 finderClassName, finderMethodName, finderParams,
602 finderArgs, list);
603
604 return list;
605 }
606 catch (Exception e) {
607 throw processException(e);
608 }
609 finally {
610 closeSession(session);
611 }
612 }
613 else {
614 return (List<OrgGroupRole>)result;
615 }
616 }
617
618 public OrgGroupRole findByRoleId_First(long roleId, OrderByComparator obc)
619 throws NoSuchOrgGroupRoleException, SystemException {
620 List<OrgGroupRole> list = findByRoleId(roleId, 0, 1, obc);
621
622 if (list.size() == 0) {
623 StringBuilder msg = new StringBuilder();
624
625 msg.append("No OrgGroupRole exists with the key {");
626
627 msg.append("roleId=" + roleId);
628
629 msg.append(StringPool.CLOSE_CURLY_BRACE);
630
631 throw new NoSuchOrgGroupRoleException(msg.toString());
632 }
633 else {
634 return list.get(0);
635 }
636 }
637
638 public OrgGroupRole findByRoleId_Last(long roleId, OrderByComparator obc)
639 throws NoSuchOrgGroupRoleException, SystemException {
640 int count = countByRoleId(roleId);
641
642 List<OrgGroupRole> list = findByRoleId(roleId, count - 1, count, obc);
643
644 if (list.size() == 0) {
645 StringBuilder msg = new StringBuilder();
646
647 msg.append("No OrgGroupRole exists with the key {");
648
649 msg.append("roleId=" + roleId);
650
651 msg.append(StringPool.CLOSE_CURLY_BRACE);
652
653 throw new NoSuchOrgGroupRoleException(msg.toString());
654 }
655 else {
656 return list.get(0);
657 }
658 }
659
660 public OrgGroupRole[] findByRoleId_PrevAndNext(
661 OrgGroupRolePK orgGroupRolePK, long roleId, OrderByComparator obc)
662 throws NoSuchOrgGroupRoleException, SystemException {
663 OrgGroupRole orgGroupRole = findByPrimaryKey(orgGroupRolePK);
664
665 int count = countByRoleId(roleId);
666
667 Session session = null;
668
669 try {
670 session = openSession();
671
672 StringBuilder query = new StringBuilder();
673
674 query.append("FROM com.liferay.portal.model.OrgGroupRole WHERE ");
675
676 query.append("roleId = ?");
677
678 query.append(" ");
679
680 if (obc != null) {
681 query.append("ORDER BY ");
682 query.append(obc.getOrderBy());
683 }
684
685 Query q = session.createQuery(query.toString());
686
687 QueryPos qPos = QueryPos.getInstance(q);
688
689 qPos.add(roleId);
690
691 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
692 orgGroupRole);
693
694 OrgGroupRole[] array = new OrgGroupRoleImpl[3];
695
696 array[0] = (OrgGroupRole)objArray[0];
697 array[1] = (OrgGroupRole)objArray[1];
698 array[2] = (OrgGroupRole)objArray[2];
699
700 return array;
701 }
702 catch (Exception e) {
703 throw processException(e);
704 }
705 finally {
706 closeSession(session);
707 }
708 }
709
710 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
711 throws SystemException {
712 Session session = null;
713
714 try {
715 session = openSession();
716
717 dynamicQuery.compile(session);
718
719 return dynamicQuery.list();
720 }
721 catch (Exception e) {
722 throw processException(e);
723 }
724 finally {
725 closeSession(session);
726 }
727 }
728
729 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
730 int start, int end) throws SystemException {
731 Session session = null;
732
733 try {
734 session = openSession();
735
736 dynamicQuery.setLimit(start, end);
737
738 dynamicQuery.compile(session);
739
740 return dynamicQuery.list();
741 }
742 catch (Exception e) {
743 throw processException(e);
744 }
745 finally {
746 closeSession(session);
747 }
748 }
749
750 public List<OrgGroupRole> findAll() throws SystemException {
751 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
752 }
753
754 public List<OrgGroupRole> findAll(int start, int end)
755 throws SystemException {
756 return findAll(start, end, null);
757 }
758
759 public List<OrgGroupRole> findAll(int start, int end, OrderByComparator obc)
760 throws SystemException {
761 boolean finderClassNameCacheEnabled = OrgGroupRoleModelImpl.CACHE_ENABLED;
762 String finderClassName = OrgGroupRole.class.getName();
763 String finderMethodName = "findAll";
764 String[] finderParams = new String[] {
765 "java.lang.Integer", "java.lang.Integer",
766 "com.liferay.portal.kernel.util.OrderByComparator"
767 };
768 Object[] finderArgs = new Object[] {
769 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
770 };
771
772 Object result = null;
773
774 if (finderClassNameCacheEnabled) {
775 result = FinderCacheUtil.getResult(finderClassName,
776 finderMethodName, finderParams, finderArgs, this);
777 }
778
779 if (result == null) {
780 Session session = null;
781
782 try {
783 session = openSession();
784
785 StringBuilder query = new StringBuilder();
786
787 query.append("FROM com.liferay.portal.model.OrgGroupRole ");
788
789 if (obc != null) {
790 query.append("ORDER BY ");
791 query.append(obc.getOrderBy());
792 }
793
794 Query q = session.createQuery(query.toString());
795
796 List<OrgGroupRole> list = null;
797
798 if (obc == null) {
799 list = (List<OrgGroupRole>)QueryUtil.list(q, getDialect(),
800 start, end, false);
801
802 Collections.sort(list);
803 }
804 else {
805 list = (List<OrgGroupRole>)QueryUtil.list(q, getDialect(),
806 start, end);
807 }
808
809 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
810 finderClassName, finderMethodName, finderParams,
811 finderArgs, list);
812
813 return list;
814 }
815 catch (Exception e) {
816 throw processException(e);
817 }
818 finally {
819 closeSession(session);
820 }
821 }
822 else {
823 return (List<OrgGroupRole>)result;
824 }
825 }
826
827 public void removeByGroupId(long groupId) throws SystemException {
828 for (OrgGroupRole orgGroupRole : findByGroupId(groupId)) {
829 remove(orgGroupRole);
830 }
831 }
832
833 public void removeByRoleId(long roleId) throws SystemException {
834 for (OrgGroupRole orgGroupRole : findByRoleId(roleId)) {
835 remove(orgGroupRole);
836 }
837 }
838
839 public void removeAll() throws SystemException {
840 for (OrgGroupRole orgGroupRole : findAll()) {
841 remove(orgGroupRole);
842 }
843 }
844
845 public int countByGroupId(long groupId) throws SystemException {
846 boolean finderClassNameCacheEnabled = OrgGroupRoleModelImpl.CACHE_ENABLED;
847 String finderClassName = OrgGroupRole.class.getName();
848 String finderMethodName = "countByGroupId";
849 String[] finderParams = new String[] { Long.class.getName() };
850 Object[] finderArgs = new Object[] { new Long(groupId) };
851
852 Object result = null;
853
854 if (finderClassNameCacheEnabled) {
855 result = FinderCacheUtil.getResult(finderClassName,
856 finderMethodName, finderParams, finderArgs, this);
857 }
858
859 if (result == null) {
860 Session session = null;
861
862 try {
863 session = openSession();
864
865 StringBuilder query = new StringBuilder();
866
867 query.append("SELECT COUNT(*) ");
868 query.append(
869 "FROM com.liferay.portal.model.OrgGroupRole WHERE ");
870
871 query.append("groupId = ?");
872
873 query.append(" ");
874
875 Query q = session.createQuery(query.toString());
876
877 QueryPos qPos = QueryPos.getInstance(q);
878
879 qPos.add(groupId);
880
881 Long count = null;
882
883 Iterator<Long> itr = q.list().iterator();
884
885 if (itr.hasNext()) {
886 count = itr.next();
887 }
888
889 if (count == null) {
890 count = new Long(0);
891 }
892
893 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
894 finderClassName, finderMethodName, finderParams,
895 finderArgs, count);
896
897 return count.intValue();
898 }
899 catch (Exception e) {
900 throw processException(e);
901 }
902 finally {
903 closeSession(session);
904 }
905 }
906 else {
907 return ((Long)result).intValue();
908 }
909 }
910
911 public int countByRoleId(long roleId) throws SystemException {
912 boolean finderClassNameCacheEnabled = OrgGroupRoleModelImpl.CACHE_ENABLED;
913 String finderClassName = OrgGroupRole.class.getName();
914 String finderMethodName = "countByRoleId";
915 String[] finderParams = new String[] { Long.class.getName() };
916 Object[] finderArgs = new Object[] { new Long(roleId) };
917
918 Object result = null;
919
920 if (finderClassNameCacheEnabled) {
921 result = FinderCacheUtil.getResult(finderClassName,
922 finderMethodName, finderParams, finderArgs, this);
923 }
924
925 if (result == null) {
926 Session session = null;
927
928 try {
929 session = openSession();
930
931 StringBuilder query = new StringBuilder();
932
933 query.append("SELECT COUNT(*) ");
934 query.append(
935 "FROM com.liferay.portal.model.OrgGroupRole WHERE ");
936
937 query.append("roleId = ?");
938
939 query.append(" ");
940
941 Query q = session.createQuery(query.toString());
942
943 QueryPos qPos = QueryPos.getInstance(q);
944
945 qPos.add(roleId);
946
947 Long count = null;
948
949 Iterator<Long> itr = q.list().iterator();
950
951 if (itr.hasNext()) {
952 count = itr.next();
953 }
954
955 if (count == null) {
956 count = new Long(0);
957 }
958
959 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
960 finderClassName, finderMethodName, finderParams,
961 finderArgs, count);
962
963 return count.intValue();
964 }
965 catch (Exception e) {
966 throw processException(e);
967 }
968 finally {
969 closeSession(session);
970 }
971 }
972 else {
973 return ((Long)result).intValue();
974 }
975 }
976
977 public int countAll() throws SystemException {
978 boolean finderClassNameCacheEnabled = OrgGroupRoleModelImpl.CACHE_ENABLED;
979 String finderClassName = OrgGroupRole.class.getName();
980 String finderMethodName = "countAll";
981 String[] finderParams = new String[] { };
982 Object[] finderArgs = new Object[] { };
983
984 Object result = null;
985
986 if (finderClassNameCacheEnabled) {
987 result = FinderCacheUtil.getResult(finderClassName,
988 finderMethodName, finderParams, finderArgs, this);
989 }
990
991 if (result == null) {
992 Session session = null;
993
994 try {
995 session = openSession();
996
997 Query q = session.createQuery(
998 "SELECT COUNT(*) FROM com.liferay.portal.model.OrgGroupRole");
999
1000 Long count = null;
1001
1002 Iterator<Long> itr = q.list().iterator();
1003
1004 if (itr.hasNext()) {
1005 count = itr.next();
1006 }
1007
1008 if (count == null) {
1009 count = new Long(0);
1010 }
1011
1012 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1013 finderClassName, finderMethodName, finderParams,
1014 finderArgs, count);
1015
1016 return count.intValue();
1017 }
1018 catch (Exception e) {
1019 throw processException(e);
1020 }
1021 finally {
1022 closeSession(session);
1023 }
1024 }
1025 else {
1026 return ((Long)result).intValue();
1027 }
1028 }
1029
1030 public void afterPropertiesSet() {
1031 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1032 com.liferay.portal.util.PropsUtil.get(
1033 "value.object.listener.com.liferay.portal.model.OrgGroupRole")));
1034
1035 if (listenerClassNames.length > 0) {
1036 try {
1037 List<ModelListener> listenersList = new ArrayList<ModelListener>();
1038
1039 for (String listenerClassName : listenerClassNames) {
1040 listenersList.add((ModelListener)Class.forName(
1041 listenerClassName).newInstance());
1042 }
1043
1044 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1045 }
1046 catch (Exception e) {
1047 _log.error(e);
1048 }
1049 }
1050 }
1051
1052 @BeanReference(name = "com.liferay.portal.service.persistence.AccountPersistence.impl")
1053 protected com.liferay.portal.service.persistence.AccountPersistence accountPersistence;
1054 @BeanReference(name = "com.liferay.portal.service.persistence.AddressPersistence.impl")
1055 protected com.liferay.portal.service.persistence.AddressPersistence addressPersistence;
1056 @BeanReference(name = "com.liferay.portal.service.persistence.ClassNamePersistence.impl")
1057 protected com.liferay.portal.service.persistence.ClassNamePersistence classNamePersistence;
1058 @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence.impl")
1059 protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
1060 @BeanReference(name = "com.liferay.portal.service.persistence.ContactPersistence.impl")
1061 protected com.liferay.portal.service.persistence.ContactPersistence contactPersistence;
1062 @BeanReference(name = "com.liferay.portal.service.persistence.CountryPersistence.impl")
1063 protected com.liferay.portal.service.persistence.CountryPersistence countryPersistence;
1064 @BeanReference(name = "com.liferay.portal.service.persistence.EmailAddressPersistence.impl")
1065 protected com.liferay.portal.service.persistence.EmailAddressPersistence emailAddressPersistence;
1066 @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence.impl")
1067 protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
1068 @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence.impl")
1069 protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
1070 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPersistence.impl")
1071 protected com.liferay.portal.service.persistence.LayoutPersistence layoutPersistence;
1072 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutSetPersistence.impl")
1073 protected com.liferay.portal.service.persistence.LayoutSetPersistence layoutSetPersistence;
1074 @BeanReference(name = "com.liferay.portal.service.persistence.ListTypePersistence.impl")
1075 protected com.liferay.portal.service.persistence.ListTypePersistence listTypePersistence;
1076 @BeanReference(name = "com.liferay.portal.service.persistence.MembershipRequestPersistence.impl")
1077 protected com.liferay.portal.service.persistence.MembershipRequestPersistence membershipRequestPersistence;
1078 @BeanReference(name = "com.liferay.portal.service.persistence.OrganizationPersistence.impl")
1079 protected com.liferay.portal.service.persistence.OrganizationPersistence organizationPersistence;
1080 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupPermissionPersistence.impl")
1081 protected com.liferay.portal.service.persistence.OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1082 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupRolePersistence.impl")
1083 protected com.liferay.portal.service.persistence.OrgGroupRolePersistence orgGroupRolePersistence;
1084 @BeanReference(name = "com.liferay.portal.service.persistence.OrgLaborPersistence.impl")
1085 protected com.liferay.portal.service.persistence.OrgLaborPersistence orgLaborPersistence;
1086 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyPersistence.impl")
1087 protected com.liferay.portal.service.persistence.PasswordPolicyPersistence passwordPolicyPersistence;
1088 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyRelPersistence.impl")
1089 protected com.liferay.portal.service.persistence.PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1090 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordTrackerPersistence.impl")
1091 protected com.liferay.portal.service.persistence.PasswordTrackerPersistence passwordTrackerPersistence;
1092 @BeanReference(name = "com.liferay.portal.service.persistence.PermissionPersistence.impl")
1093 protected com.liferay.portal.service.persistence.PermissionPersistence permissionPersistence;
1094 @BeanReference(name = "com.liferay.portal.service.persistence.PhonePersistence.impl")
1095 protected com.liferay.portal.service.persistence.PhonePersistence phonePersistence;
1096 @BeanReference(name = "com.liferay.portal.service.persistence.PluginSettingPersistence.impl")
1097 protected com.liferay.portal.service.persistence.PluginSettingPersistence pluginSettingPersistence;
1098 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPersistence.impl")
1099 protected com.liferay.portal.service.persistence.PortletPersistence portletPersistence;
1100 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence.impl")
1101 protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
1102 @BeanReference(name = "com.liferay.portal.service.persistence.RegionPersistence.impl")
1103 protected com.liferay.portal.service.persistence.RegionPersistence regionPersistence;
1104 @BeanReference(name = "com.liferay.portal.service.persistence.ReleasePersistence.impl")
1105 protected com.liferay.portal.service.persistence.ReleasePersistence releasePersistence;
1106 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
1107 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
1108 @BeanReference(name = "com.liferay.portal.service.persistence.ResourceCodePersistence.impl")
1109 protected com.liferay.portal.service.persistence.ResourceCodePersistence resourceCodePersistence;
1110 @BeanReference(name = "com.liferay.portal.service.persistence.RolePersistence.impl")
1111 protected com.liferay.portal.service.persistence.RolePersistence rolePersistence;
1112 @BeanReference(name = "com.liferay.portal.service.persistence.ServiceComponentPersistence.impl")
1113 protected com.liferay.portal.service.persistence.ServiceComponentPersistence serviceComponentPersistence;
1114 @BeanReference(name = "com.liferay.portal.service.persistence.PortletItemPersistence.impl")
1115 protected com.liferay.portal.service.persistence.PortletItemPersistence portletItemPersistence;
1116 @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence.impl")
1117 protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
1118 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
1119 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1120 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupPersistence.impl")
1121 protected com.liferay.portal.service.persistence.UserGroupPersistence userGroupPersistence;
1122 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupRolePersistence.impl")
1123 protected com.liferay.portal.service.persistence.UserGroupRolePersistence userGroupRolePersistence;
1124 @BeanReference(name = "com.liferay.portal.service.persistence.UserIdMapperPersistence.impl")
1125 protected com.liferay.portal.service.persistence.UserIdMapperPersistence userIdMapperPersistence;
1126 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPersistence.impl")
1127 protected com.liferay.portal.service.persistence.UserTrackerPersistence userTrackerPersistence;
1128 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPathPersistence.impl")
1129 protected com.liferay.portal.service.persistence.UserTrackerPathPersistence userTrackerPathPersistence;
1130 @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence.impl")
1131 protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
1132 @BeanReference(name = "com.liferay.portal.service.persistence.WebsitePersistence.impl")
1133 protected com.liferay.portal.service.persistence.WebsitePersistence websitePersistence;
1134 private static Log _log = LogFactoryUtil.getLog(OrgGroupRolePersistenceImpl.class);
1135}