1
22
23 package com.liferay.portal.service.persistence;
24
25 import com.liferay.portal.NoSuchOrgGroupPermissionException;
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.OrgGroupPermission;
36 import com.liferay.portal.model.impl.OrgGroupPermissionImpl;
37 import com.liferay.portal.model.impl.OrgGroupPermissionModelImpl;
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 OrgGroupPermissionPersistenceImpl extends BasePersistence
61 implements OrgGroupPermissionPersistence {
62 public OrgGroupPermission create(OrgGroupPermissionPK orgGroupPermissionPK) {
63 OrgGroupPermission orgGroupPermission = new OrgGroupPermissionImpl();
64
65 orgGroupPermission.setNew(true);
66 orgGroupPermission.setPrimaryKey(orgGroupPermissionPK);
67
68 return orgGroupPermission;
69 }
70
71 public OrgGroupPermission remove(OrgGroupPermissionPK orgGroupPermissionPK)
72 throws NoSuchOrgGroupPermissionException, SystemException {
73 Session session = null;
74
75 try {
76 session = openSession();
77
78 OrgGroupPermission orgGroupPermission = (OrgGroupPermission)session.get(OrgGroupPermissionImpl.class,
79 orgGroupPermissionPK);
80
81 if (orgGroupPermission == null) {
82 if (_log.isWarnEnabled()) {
83 _log.warn(
84 "No OrgGroupPermission exists with the primary key " +
85 orgGroupPermissionPK);
86 }
87
88 throw new NoSuchOrgGroupPermissionException(
89 "No OrgGroupPermission exists with the primary key " +
90 orgGroupPermissionPK);
91 }
92
93 return remove(orgGroupPermission);
94 }
95 catch (NoSuchOrgGroupPermissionException nsee) {
96 throw nsee;
97 }
98 catch (Exception e) {
99 throw HibernateUtil.processException(e);
100 }
101 finally {
102 closeSession(session);
103 }
104 }
105
106 public OrgGroupPermission remove(OrgGroupPermission orgGroupPermission)
107 throws SystemException {
108 ModelListener listener = _getListener();
109
110 if (listener != null) {
111 listener.onBeforeRemove(orgGroupPermission);
112 }
113
114 orgGroupPermission = removeImpl(orgGroupPermission);
115
116 if (listener != null) {
117 listener.onAfterRemove(orgGroupPermission);
118 }
119
120 return orgGroupPermission;
121 }
122
123 protected OrgGroupPermission removeImpl(
124 OrgGroupPermission orgGroupPermission) throws SystemException {
125 Session session = null;
126
127 try {
128 session = openSession();
129
130 session.delete(orgGroupPermission);
131
132 session.flush();
133
134 return orgGroupPermission;
135 }
136 catch (Exception e) {
137 throw HibernateUtil.processException(e);
138 }
139 finally {
140 closeSession(session);
141
142 FinderCache.clearCache(OrgGroupPermission.class.getName());
143 }
144 }
145
146 public OrgGroupPermission update(OrgGroupPermission orgGroupPermission)
147 throws SystemException {
148 return update(orgGroupPermission, false);
149 }
150
151 public OrgGroupPermission update(OrgGroupPermission orgGroupPermission,
152 boolean merge) throws SystemException {
153 ModelListener listener = _getListener();
154
155 boolean isNew = orgGroupPermission.isNew();
156
157 if (listener != null) {
158 if (isNew) {
159 listener.onBeforeCreate(orgGroupPermission);
160 }
161 else {
162 listener.onBeforeUpdate(orgGroupPermission);
163 }
164 }
165
166 orgGroupPermission = updateImpl(orgGroupPermission, merge);
167
168 if (listener != null) {
169 if (isNew) {
170 listener.onAfterCreate(orgGroupPermission);
171 }
172 else {
173 listener.onAfterUpdate(orgGroupPermission);
174 }
175 }
176
177 return orgGroupPermission;
178 }
179
180 public OrgGroupPermission updateImpl(
181 com.liferay.portal.model.OrgGroupPermission orgGroupPermission,
182 boolean merge) throws SystemException {
183 Session session = null;
184
185 try {
186 session = openSession();
187
188 if (merge) {
189 session.merge(orgGroupPermission);
190 }
191 else {
192 if (orgGroupPermission.isNew()) {
193 session.save(orgGroupPermission);
194 }
195 }
196
197 session.flush();
198
199 orgGroupPermission.setNew(false);
200
201 return orgGroupPermission;
202 }
203 catch (Exception e) {
204 throw HibernateUtil.processException(e);
205 }
206 finally {
207 closeSession(session);
208
209 FinderCache.clearCache(OrgGroupPermission.class.getName());
210 }
211 }
212
213 public OrgGroupPermission findByPrimaryKey(
214 OrgGroupPermissionPK orgGroupPermissionPK)
215 throws NoSuchOrgGroupPermissionException, SystemException {
216 OrgGroupPermission orgGroupPermission = fetchByPrimaryKey(orgGroupPermissionPK);
217
218 if (orgGroupPermission == null) {
219 if (_log.isWarnEnabled()) {
220 _log.warn("No OrgGroupPermission exists with the primary key " +
221 orgGroupPermissionPK);
222 }
223
224 throw new NoSuchOrgGroupPermissionException(
225 "No OrgGroupPermission exists with the primary key " +
226 orgGroupPermissionPK);
227 }
228
229 return orgGroupPermission;
230 }
231
232 public OrgGroupPermission fetchByPrimaryKey(
233 OrgGroupPermissionPK orgGroupPermissionPK) throws SystemException {
234 Session session = null;
235
236 try {
237 session = openSession();
238
239 return (OrgGroupPermission)session.get(OrgGroupPermissionImpl.class,
240 orgGroupPermissionPK);
241 }
242 catch (Exception e) {
243 throw HibernateUtil.processException(e);
244 }
245 finally {
246 closeSession(session);
247 }
248 }
249
250 public List findByGroupId(long groupId) throws SystemException {
251 boolean finderClassNameCacheEnabled = OrgGroupPermissionModelImpl.CACHE_ENABLED;
252 String finderClassName = OrgGroupPermission.class.getName();
253 String finderMethodName = "findByGroupId";
254 String[] finderParams = new String[] { Long.class.getName() };
255 Object[] finderArgs = new Object[] { new Long(groupId) };
256
257 Object result = null;
258
259 if (finderClassNameCacheEnabled) {
260 result = FinderCache.getResult(finderClassName, finderMethodName,
261 finderParams, finderArgs, getSessionFactory());
262 }
263
264 if (result == null) {
265 Session session = null;
266
267 try {
268 session = openSession();
269
270 StringMaker query = new StringMaker();
271
272 query.append(
273 "FROM com.liferay.portal.model.OrgGroupPermission WHERE ");
274
275 query.append("groupId = ?");
276
277 query.append(" ");
278
279 Query q = session.createQuery(query.toString());
280
281 int queryPos = 0;
282
283 q.setLong(queryPos++, groupId);
284
285 List list = q.list();
286
287 FinderCache.putResult(finderClassNameCacheEnabled,
288 finderClassName, finderMethodName, finderParams,
289 finderArgs, list);
290
291 return list;
292 }
293 catch (Exception e) {
294 throw HibernateUtil.processException(e);
295 }
296 finally {
297 closeSession(session);
298 }
299 }
300 else {
301 return (List)result;
302 }
303 }
304
305 public List findByGroupId(long groupId, int begin, int end)
306 throws SystemException {
307 return findByGroupId(groupId, begin, end, null);
308 }
309
310 public List findByGroupId(long groupId, int begin, int end,
311 OrderByComparator obc) throws SystemException {
312 boolean finderClassNameCacheEnabled = OrgGroupPermissionModelImpl.CACHE_ENABLED;
313 String finderClassName = OrgGroupPermission.class.getName();
314 String finderMethodName = "findByGroupId";
315 String[] finderParams = new String[] {
316 Long.class.getName(),
317
318 "java.lang.Integer", "java.lang.Integer",
319 "com.liferay.portal.kernel.util.OrderByComparator"
320 };
321 Object[] finderArgs = new Object[] {
322 new Long(groupId),
323
324 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
325 };
326
327 Object result = null;
328
329 if (finderClassNameCacheEnabled) {
330 result = FinderCache.getResult(finderClassName, finderMethodName,
331 finderParams, finderArgs, getSessionFactory());
332 }
333
334 if (result == null) {
335 Session session = null;
336
337 try {
338 session = openSession();
339
340 StringMaker query = new StringMaker();
341
342 query.append(
343 "FROM com.liferay.portal.model.OrgGroupPermission WHERE ");
344
345 query.append("groupId = ?");
346
347 query.append(" ");
348
349 if (obc != null) {
350 query.append("ORDER BY ");
351 query.append(obc.getOrderBy());
352 }
353
354 Query q = session.createQuery(query.toString());
355
356 int queryPos = 0;
357
358 q.setLong(queryPos++, groupId);
359
360 List list = QueryUtil.list(q, getDialect(), begin, end);
361
362 FinderCache.putResult(finderClassNameCacheEnabled,
363 finderClassName, finderMethodName, finderParams,
364 finderArgs, list);
365
366 return list;
367 }
368 catch (Exception e) {
369 throw HibernateUtil.processException(e);
370 }
371 finally {
372 closeSession(session);
373 }
374 }
375 else {
376 return (List)result;
377 }
378 }
379
380 public OrgGroupPermission findByGroupId_First(long groupId,
381 OrderByComparator obc)
382 throws NoSuchOrgGroupPermissionException, SystemException {
383 List list = findByGroupId(groupId, 0, 1, obc);
384
385 if (list.size() == 0) {
386 StringMaker msg = new StringMaker();
387
388 msg.append("No OrgGroupPermission exists with the key {");
389
390 msg.append("groupId=" + groupId);
391
392 msg.append(StringPool.CLOSE_CURLY_BRACE);
393
394 throw new NoSuchOrgGroupPermissionException(msg.toString());
395 }
396 else {
397 return (OrgGroupPermission)list.get(0);
398 }
399 }
400
401 public OrgGroupPermission findByGroupId_Last(long groupId,
402 OrderByComparator obc)
403 throws NoSuchOrgGroupPermissionException, SystemException {
404 int count = countByGroupId(groupId);
405
406 List list = findByGroupId(groupId, count - 1, count, obc);
407
408 if (list.size() == 0) {
409 StringMaker msg = new StringMaker();
410
411 msg.append("No OrgGroupPermission exists with the key {");
412
413 msg.append("groupId=" + groupId);
414
415 msg.append(StringPool.CLOSE_CURLY_BRACE);
416
417 throw new NoSuchOrgGroupPermissionException(msg.toString());
418 }
419 else {
420 return (OrgGroupPermission)list.get(0);
421 }
422 }
423
424 public OrgGroupPermission[] findByGroupId_PrevAndNext(
425 OrgGroupPermissionPK orgGroupPermissionPK, long groupId,
426 OrderByComparator obc)
427 throws NoSuchOrgGroupPermissionException, SystemException {
428 OrgGroupPermission orgGroupPermission = findByPrimaryKey(orgGroupPermissionPK);
429
430 int count = countByGroupId(groupId);
431
432 Session session = null;
433
434 try {
435 session = openSession();
436
437 StringMaker query = new StringMaker();
438
439 query.append(
440 "FROM com.liferay.portal.model.OrgGroupPermission WHERE ");
441
442 query.append("groupId = ?");
443
444 query.append(" ");
445
446 if (obc != null) {
447 query.append("ORDER BY ");
448 query.append(obc.getOrderBy());
449 }
450
451 Query q = session.createQuery(query.toString());
452
453 int queryPos = 0;
454
455 q.setLong(queryPos++, groupId);
456
457 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
458 orgGroupPermission);
459
460 OrgGroupPermission[] array = new OrgGroupPermissionImpl[3];
461
462 array[0] = (OrgGroupPermission)objArray[0];
463 array[1] = (OrgGroupPermission)objArray[1];
464 array[2] = (OrgGroupPermission)objArray[2];
465
466 return array;
467 }
468 catch (Exception e) {
469 throw HibernateUtil.processException(e);
470 }
471 finally {
472 closeSession(session);
473 }
474 }
475
476 public List findByPermissionId(long permissionId) throws SystemException {
477 boolean finderClassNameCacheEnabled = OrgGroupPermissionModelImpl.CACHE_ENABLED;
478 String finderClassName = OrgGroupPermission.class.getName();
479 String finderMethodName = "findByPermissionId";
480 String[] finderParams = new String[] { Long.class.getName() };
481 Object[] finderArgs = new Object[] { new Long(permissionId) };
482
483 Object result = null;
484
485 if (finderClassNameCacheEnabled) {
486 result = FinderCache.getResult(finderClassName, finderMethodName,
487 finderParams, finderArgs, getSessionFactory());
488 }
489
490 if (result == null) {
491 Session session = null;
492
493 try {
494 session = openSession();
495
496 StringMaker query = new StringMaker();
497
498 query.append(
499 "FROM com.liferay.portal.model.OrgGroupPermission WHERE ");
500
501 query.append("permissionId = ?");
502
503 query.append(" ");
504
505 Query q = session.createQuery(query.toString());
506
507 int queryPos = 0;
508
509 q.setLong(queryPos++, permissionId);
510
511 List list = q.list();
512
513 FinderCache.putResult(finderClassNameCacheEnabled,
514 finderClassName, finderMethodName, finderParams,
515 finderArgs, list);
516
517 return list;
518 }
519 catch (Exception e) {
520 throw HibernateUtil.processException(e);
521 }
522 finally {
523 closeSession(session);
524 }
525 }
526 else {
527 return (List)result;
528 }
529 }
530
531 public List findByPermissionId(long permissionId, int begin, int end)
532 throws SystemException {
533 return findByPermissionId(permissionId, begin, end, null);
534 }
535
536 public List findByPermissionId(long permissionId, int begin, int end,
537 OrderByComparator obc) throws SystemException {
538 boolean finderClassNameCacheEnabled = OrgGroupPermissionModelImpl.CACHE_ENABLED;
539 String finderClassName = OrgGroupPermission.class.getName();
540 String finderMethodName = "findByPermissionId";
541 String[] finderParams = new String[] {
542 Long.class.getName(),
543
544 "java.lang.Integer", "java.lang.Integer",
545 "com.liferay.portal.kernel.util.OrderByComparator"
546 };
547 Object[] finderArgs = new Object[] {
548 new Long(permissionId),
549
550 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
551 };
552
553 Object result = null;
554
555 if (finderClassNameCacheEnabled) {
556 result = FinderCache.getResult(finderClassName, finderMethodName,
557 finderParams, finderArgs, getSessionFactory());
558 }
559
560 if (result == null) {
561 Session session = null;
562
563 try {
564 session = openSession();
565
566 StringMaker query = new StringMaker();
567
568 query.append(
569 "FROM com.liferay.portal.model.OrgGroupPermission WHERE ");
570
571 query.append("permissionId = ?");
572
573 query.append(" ");
574
575 if (obc != null) {
576 query.append("ORDER BY ");
577 query.append(obc.getOrderBy());
578 }
579
580 Query q = session.createQuery(query.toString());
581
582 int queryPos = 0;
583
584 q.setLong(queryPos++, permissionId);
585
586 List list = QueryUtil.list(q, getDialect(), begin, end);
587
588 FinderCache.putResult(finderClassNameCacheEnabled,
589 finderClassName, finderMethodName, finderParams,
590 finderArgs, list);
591
592 return list;
593 }
594 catch (Exception e) {
595 throw HibernateUtil.processException(e);
596 }
597 finally {
598 closeSession(session);
599 }
600 }
601 else {
602 return (List)result;
603 }
604 }
605
606 public OrgGroupPermission findByPermissionId_First(long permissionId,
607 OrderByComparator obc)
608 throws NoSuchOrgGroupPermissionException, SystemException {
609 List list = findByPermissionId(permissionId, 0, 1, obc);
610
611 if (list.size() == 0) {
612 StringMaker msg = new StringMaker();
613
614 msg.append("No OrgGroupPermission exists with the key {");
615
616 msg.append("permissionId=" + permissionId);
617
618 msg.append(StringPool.CLOSE_CURLY_BRACE);
619
620 throw new NoSuchOrgGroupPermissionException(msg.toString());
621 }
622 else {
623 return (OrgGroupPermission)list.get(0);
624 }
625 }
626
627 public OrgGroupPermission findByPermissionId_Last(long permissionId,
628 OrderByComparator obc)
629 throws NoSuchOrgGroupPermissionException, SystemException {
630 int count = countByPermissionId(permissionId);
631
632 List list = findByPermissionId(permissionId, count - 1, count, obc);
633
634 if (list.size() == 0) {
635 StringMaker msg = new StringMaker();
636
637 msg.append("No OrgGroupPermission exists with the key {");
638
639 msg.append("permissionId=" + permissionId);
640
641 msg.append(StringPool.CLOSE_CURLY_BRACE);
642
643 throw new NoSuchOrgGroupPermissionException(msg.toString());
644 }
645 else {
646 return (OrgGroupPermission)list.get(0);
647 }
648 }
649
650 public OrgGroupPermission[] findByPermissionId_PrevAndNext(
651 OrgGroupPermissionPK orgGroupPermissionPK, long permissionId,
652 OrderByComparator obc)
653 throws NoSuchOrgGroupPermissionException, SystemException {
654 OrgGroupPermission orgGroupPermission = findByPrimaryKey(orgGroupPermissionPK);
655
656 int count = countByPermissionId(permissionId);
657
658 Session session = null;
659
660 try {
661 session = openSession();
662
663 StringMaker query = new StringMaker();
664
665 query.append(
666 "FROM com.liferay.portal.model.OrgGroupPermission WHERE ");
667
668 query.append("permissionId = ?");
669
670 query.append(" ");
671
672 if (obc != null) {
673 query.append("ORDER BY ");
674 query.append(obc.getOrderBy());
675 }
676
677 Query q = session.createQuery(query.toString());
678
679 int queryPos = 0;
680
681 q.setLong(queryPos++, permissionId);
682
683 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
684 orgGroupPermission);
685
686 OrgGroupPermission[] array = new OrgGroupPermissionImpl[3];
687
688 array[0] = (OrgGroupPermission)objArray[0];
689 array[1] = (OrgGroupPermission)objArray[1];
690 array[2] = (OrgGroupPermission)objArray[2];
691
692 return array;
693 }
694 catch (Exception e) {
695 throw HibernateUtil.processException(e);
696 }
697 finally {
698 closeSession(session);
699 }
700 }
701
702 public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer)
703 throws SystemException {
704 Session session = null;
705
706 try {
707 session = openSession();
708
709 DynamicQuery query = queryInitializer.initialize(session);
710
711 return query.list();
712 }
713 catch (Exception e) {
714 throw HibernateUtil.processException(e);
715 }
716 finally {
717 closeSession(session);
718 }
719 }
720
721 public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer,
722 int begin, int end) throws SystemException {
723 Session session = null;
724
725 try {
726 session = openSession();
727
728 DynamicQuery query = queryInitializer.initialize(session);
729
730 query.setLimit(begin, end);
731
732 return query.list();
733 }
734 catch (Exception e) {
735 throw HibernateUtil.processException(e);
736 }
737 finally {
738 closeSession(session);
739 }
740 }
741
742 public List findAll() throws SystemException {
743 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
744 }
745
746 public List findAll(int begin, int end) throws SystemException {
747 return findAll(begin, end, null);
748 }
749
750 public List findAll(int begin, int end, OrderByComparator obc)
751 throws SystemException {
752 boolean finderClassNameCacheEnabled = OrgGroupPermissionModelImpl.CACHE_ENABLED;
753 String finderClassName = OrgGroupPermission.class.getName();
754 String finderMethodName = "findAll";
755 String[] finderParams = new String[] {
756 "java.lang.Integer", "java.lang.Integer",
757 "com.liferay.portal.kernel.util.OrderByComparator"
758 };
759 Object[] finderArgs = new Object[] {
760 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
761 };
762
763 Object result = null;
764
765 if (finderClassNameCacheEnabled) {
766 result = FinderCache.getResult(finderClassName, finderMethodName,
767 finderParams, finderArgs, getSessionFactory());
768 }
769
770 if (result == null) {
771 Session session = null;
772
773 try {
774 session = openSession();
775
776 StringMaker query = new StringMaker();
777
778 query.append(
779 "FROM com.liferay.portal.model.OrgGroupPermission ");
780
781 if (obc != null) {
782 query.append("ORDER BY ");
783 query.append(obc.getOrderBy());
784 }
785
786 Query q = session.createQuery(query.toString());
787
788 List list = QueryUtil.list(q, getDialect(), begin, end);
789
790 if (obc == null) {
791 Collections.sort(list);
792 }
793
794 FinderCache.putResult(finderClassNameCacheEnabled,
795 finderClassName, finderMethodName, finderParams,
796 finderArgs, list);
797
798 return list;
799 }
800 catch (Exception e) {
801 throw HibernateUtil.processException(e);
802 }
803 finally {
804 closeSession(session);
805 }
806 }
807 else {
808 return (List)result;
809 }
810 }
811
812 public void removeByGroupId(long groupId) throws SystemException {
813 Iterator itr = findByGroupId(groupId).iterator();
814
815 while (itr.hasNext()) {
816 OrgGroupPermission orgGroupPermission = (OrgGroupPermission)itr.next();
817
818 remove(orgGroupPermission);
819 }
820 }
821
822 public void removeByPermissionId(long permissionId)
823 throws SystemException {
824 Iterator itr = findByPermissionId(permissionId).iterator();
825
826 while (itr.hasNext()) {
827 OrgGroupPermission orgGroupPermission = (OrgGroupPermission)itr.next();
828
829 remove(orgGroupPermission);
830 }
831 }
832
833 public void removeAll() throws SystemException {
834 Iterator itr = findAll().iterator();
835
836 while (itr.hasNext()) {
837 remove((OrgGroupPermission)itr.next());
838 }
839 }
840
841 public int countByGroupId(long groupId) throws SystemException {
842 boolean finderClassNameCacheEnabled = OrgGroupPermissionModelImpl.CACHE_ENABLED;
843 String finderClassName = OrgGroupPermission.class.getName();
844 String finderMethodName = "countByGroupId";
845 String[] finderParams = new String[] { Long.class.getName() };
846 Object[] finderArgs = new Object[] { new Long(groupId) };
847
848 Object result = null;
849
850 if (finderClassNameCacheEnabled) {
851 result = FinderCache.getResult(finderClassName, finderMethodName,
852 finderParams, finderArgs, getSessionFactory());
853 }
854
855 if (result == null) {
856 Session session = null;
857
858 try {
859 session = openSession();
860
861 StringMaker query = new StringMaker();
862
863 query.append("SELECT COUNT(*) ");
864 query.append(
865 "FROM com.liferay.portal.model.OrgGroupPermission WHERE ");
866
867 query.append("groupId = ?");
868
869 query.append(" ");
870
871 Query q = session.createQuery(query.toString());
872
873 int queryPos = 0;
874
875 q.setLong(queryPos++, groupId);
876
877 Long count = null;
878
879 Iterator itr = q.list().iterator();
880
881 if (itr.hasNext()) {
882 count = (Long)itr.next();
883 }
884
885 if (count == null) {
886 count = new Long(0);
887 }
888
889 FinderCache.putResult(finderClassNameCacheEnabled,
890 finderClassName, finderMethodName, finderParams,
891 finderArgs, count);
892
893 return count.intValue();
894 }
895 catch (Exception e) {
896 throw HibernateUtil.processException(e);
897 }
898 finally {
899 closeSession(session);
900 }
901 }
902 else {
903 return ((Long)result).intValue();
904 }
905 }
906
907 public int countByPermissionId(long permissionId) throws SystemException {
908 boolean finderClassNameCacheEnabled = OrgGroupPermissionModelImpl.CACHE_ENABLED;
909 String finderClassName = OrgGroupPermission.class.getName();
910 String finderMethodName = "countByPermissionId";
911 String[] finderParams = new String[] { Long.class.getName() };
912 Object[] finderArgs = new Object[] { new Long(permissionId) };
913
914 Object result = null;
915
916 if (finderClassNameCacheEnabled) {
917 result = FinderCache.getResult(finderClassName, finderMethodName,
918 finderParams, finderArgs, getSessionFactory());
919 }
920
921 if (result == null) {
922 Session session = null;
923
924 try {
925 session = openSession();
926
927 StringMaker query = new StringMaker();
928
929 query.append("SELECT COUNT(*) ");
930 query.append(
931 "FROM com.liferay.portal.model.OrgGroupPermission WHERE ");
932
933 query.append("permissionId = ?");
934
935 query.append(" ");
936
937 Query q = session.createQuery(query.toString());
938
939 int queryPos = 0;
940
941 q.setLong(queryPos++, permissionId);
942
943 Long count = null;
944
945 Iterator itr = q.list().iterator();
946
947 if (itr.hasNext()) {
948 count = (Long)itr.next();
949 }
950
951 if (count == null) {
952 count = new Long(0);
953 }
954
955 FinderCache.putResult(finderClassNameCacheEnabled,
956 finderClassName, finderMethodName, finderParams,
957 finderArgs, count);
958
959 return count.intValue();
960 }
961 catch (Exception e) {
962 throw HibernateUtil.processException(e);
963 }
964 finally {
965 closeSession(session);
966 }
967 }
968 else {
969 return ((Long)result).intValue();
970 }
971 }
972
973 public int countAll() throws SystemException {
974 boolean finderClassNameCacheEnabled = OrgGroupPermissionModelImpl.CACHE_ENABLED;
975 String finderClassName = OrgGroupPermission.class.getName();
976 String finderMethodName = "countAll";
977 String[] finderParams = new String[] { };
978 Object[] finderArgs = new Object[] { };
979
980 Object result = null;
981
982 if (finderClassNameCacheEnabled) {
983 result = FinderCache.getResult(finderClassName, finderMethodName,
984 finderParams, finderArgs, getSessionFactory());
985 }
986
987 if (result == null) {
988 Session session = null;
989
990 try {
991 session = openSession();
992
993 Query q = session.createQuery(
994 "SELECT COUNT(*) FROM com.liferay.portal.model.OrgGroupPermission");
995
996 Long count = null;
997
998 Iterator itr = q.list().iterator();
999
1000 if (itr.hasNext()) {
1001 count = (Long)itr.next();
1002 }
1003
1004 if (count == null) {
1005 count = new Long(0);
1006 }
1007
1008 FinderCache.putResult(finderClassNameCacheEnabled,
1009 finderClassName, finderMethodName, finderParams,
1010 finderArgs, count);
1011
1012 return count.intValue();
1013 }
1014 catch (Exception e) {
1015 throw HibernateUtil.processException(e);
1016 }
1017 finally {
1018 closeSession(session);
1019 }
1020 }
1021 else {
1022 return ((Long)result).intValue();
1023 }
1024 }
1025
1026 protected void initDao() {
1027 }
1028
1029 private static ModelListener _getListener() {
1030 if (Validator.isNotNull(_LISTENER)) {
1031 try {
1032 return (ModelListener)Class.forName(_LISTENER).newInstance();
1033 }
1034 catch (Exception e) {
1035 _log.error(e);
1036 }
1037 }
1038
1039 return null;
1040 }
1041
1042 private static final String _LISTENER = GetterUtil.getString(PropsUtil.get(
1043 "value.object.listener.com.liferay.portal.model.OrgGroupPermission"));
1044 private static Log _log = LogFactory.getLog(OrgGroupPermissionPersistenceImpl.class);
1045}