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