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