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