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 "SELECT orgGroupRole FROM OrgGroupRole orgGroupRole WHERE ");
361
362 query.append("orgGroupRole.id.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 "SELECT orgGroupRole FROM OrgGroupRole orgGroupRole WHERE ");
420
421 query.append("orgGroupRole.id.groupId = ?");
422
423 query.append(" ");
424
425 if (obc != null) {
426 query.append("ORDER BY ");
427
428 String[] orderByFields = obc.getOrderByFields();
429
430 for (int i = 0; i < orderByFields.length; i++) {
431 query.append("orgGroupRole.");
432 query.append(orderByFields[i]);
433
434 if (obc.isAscending()) {
435 query.append(" ASC");
436 }
437 else {
438 query.append(" DESC");
439 }
440
441 if ((i + 1) < orderByFields.length) {
442 query.append(", ");
443 }
444 }
445 }
446
447 Query q = session.createQuery(query.toString());
448
449 QueryPos qPos = QueryPos.getInstance(q);
450
451 qPos.add(groupId);
452
453 list = (List<OrgGroupRole>)QueryUtil.list(q, getDialect(),
454 start, end);
455 }
456 catch (Exception e) {
457 throw processException(e);
458 }
459 finally {
460 if (list == null) {
461 list = new ArrayList<OrgGroupRole>();
462 }
463
464 cacheResult(list);
465
466 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
467 finderArgs, list);
468
469 closeSession(session);
470 }
471 }
472
473 return list;
474 }
475
476 public OrgGroupRole findByGroupId_First(long groupId, OrderByComparator obc)
477 throws NoSuchOrgGroupRoleException, SystemException {
478 List<OrgGroupRole> list = findByGroupId(groupId, 0, 1, obc);
479
480 if (list.isEmpty()) {
481 StringBuilder msg = new StringBuilder();
482
483 msg.append("No OrgGroupRole exists with the key {");
484
485 msg.append("groupId=" + groupId);
486
487 msg.append(StringPool.CLOSE_CURLY_BRACE);
488
489 throw new NoSuchOrgGroupRoleException(msg.toString());
490 }
491 else {
492 return list.get(0);
493 }
494 }
495
496 public OrgGroupRole findByGroupId_Last(long groupId, OrderByComparator obc)
497 throws NoSuchOrgGroupRoleException, SystemException {
498 int count = countByGroupId(groupId);
499
500 List<OrgGroupRole> list = findByGroupId(groupId, count - 1, count, obc);
501
502 if (list.isEmpty()) {
503 StringBuilder msg = new StringBuilder();
504
505 msg.append("No OrgGroupRole exists with the key {");
506
507 msg.append("groupId=" + groupId);
508
509 msg.append(StringPool.CLOSE_CURLY_BRACE);
510
511 throw new NoSuchOrgGroupRoleException(msg.toString());
512 }
513 else {
514 return list.get(0);
515 }
516 }
517
518 public OrgGroupRole[] findByGroupId_PrevAndNext(
519 OrgGroupRolePK orgGroupRolePK, long groupId, OrderByComparator obc)
520 throws NoSuchOrgGroupRoleException, SystemException {
521 OrgGroupRole orgGroupRole = findByPrimaryKey(orgGroupRolePK);
522
523 int count = countByGroupId(groupId);
524
525 Session session = null;
526
527 try {
528 session = openSession();
529
530 StringBuilder query = new StringBuilder();
531
532 query.append(
533 "SELECT orgGroupRole FROM OrgGroupRole orgGroupRole WHERE ");
534
535 query.append("orgGroupRole.id.groupId = ?");
536
537 query.append(" ");
538
539 if (obc != null) {
540 query.append("ORDER BY ");
541
542 String[] orderByFields = obc.getOrderByFields();
543
544 for (int i = 0; i < orderByFields.length; i++) {
545 query.append("orgGroupRole.");
546 query.append(orderByFields[i]);
547
548 if (obc.isAscending()) {
549 query.append(" ASC");
550 }
551 else {
552 query.append(" DESC");
553 }
554
555 if ((i + 1) < orderByFields.length) {
556 query.append(", ");
557 }
558 }
559 }
560
561 Query q = session.createQuery(query.toString());
562
563 QueryPos qPos = QueryPos.getInstance(q);
564
565 qPos.add(groupId);
566
567 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
568 orgGroupRole);
569
570 OrgGroupRole[] array = new OrgGroupRoleImpl[3];
571
572 array[0] = (OrgGroupRole)objArray[0];
573 array[1] = (OrgGroupRole)objArray[1];
574 array[2] = (OrgGroupRole)objArray[2];
575
576 return array;
577 }
578 catch (Exception e) {
579 throw processException(e);
580 }
581 finally {
582 closeSession(session);
583 }
584 }
585
586 public List<OrgGroupRole> findByRoleId(long roleId)
587 throws SystemException {
588 Object[] finderArgs = new Object[] { new Long(roleId) };
589
590 List<OrgGroupRole> list = (List<OrgGroupRole>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_ROLEID,
591 finderArgs, this);
592
593 if (list == null) {
594 Session session = null;
595
596 try {
597 session = openSession();
598
599 StringBuilder query = new StringBuilder();
600
601 query.append(
602 "SELECT orgGroupRole FROM OrgGroupRole orgGroupRole WHERE ");
603
604 query.append("orgGroupRole.id.roleId = ?");
605
606 query.append(" ");
607
608 Query q = session.createQuery(query.toString());
609
610 QueryPos qPos = QueryPos.getInstance(q);
611
612 qPos.add(roleId);
613
614 list = q.list();
615 }
616 catch (Exception e) {
617 throw processException(e);
618 }
619 finally {
620 if (list == null) {
621 list = new ArrayList<OrgGroupRole>();
622 }
623
624 cacheResult(list);
625
626 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_ROLEID,
627 finderArgs, list);
628
629 closeSession(session);
630 }
631 }
632
633 return list;
634 }
635
636 public List<OrgGroupRole> findByRoleId(long roleId, int start, int end)
637 throws SystemException {
638 return findByRoleId(roleId, start, end, null);
639 }
640
641 public List<OrgGroupRole> findByRoleId(long roleId, int start, int end,
642 OrderByComparator obc) throws SystemException {
643 Object[] finderArgs = new Object[] {
644 new Long(roleId),
645
646 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
647 };
648
649 List<OrgGroupRole> list = (List<OrgGroupRole>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_ROLEID,
650 finderArgs, this);
651
652 if (list == null) {
653 Session session = null;
654
655 try {
656 session = openSession();
657
658 StringBuilder query = new StringBuilder();
659
660 query.append(
661 "SELECT orgGroupRole FROM OrgGroupRole orgGroupRole WHERE ");
662
663 query.append("orgGroupRole.id.roleId = ?");
664
665 query.append(" ");
666
667 if (obc != null) {
668 query.append("ORDER BY ");
669
670 String[] orderByFields = obc.getOrderByFields();
671
672 for (int i = 0; i < orderByFields.length; i++) {
673 query.append("orgGroupRole.");
674 query.append(orderByFields[i]);
675
676 if (obc.isAscending()) {
677 query.append(" ASC");
678 }
679 else {
680 query.append(" DESC");
681 }
682
683 if ((i + 1) < orderByFields.length) {
684 query.append(", ");
685 }
686 }
687 }
688
689 Query q = session.createQuery(query.toString());
690
691 QueryPos qPos = QueryPos.getInstance(q);
692
693 qPos.add(roleId);
694
695 list = (List<OrgGroupRole>)QueryUtil.list(q, getDialect(),
696 start, end);
697 }
698 catch (Exception e) {
699 throw processException(e);
700 }
701 finally {
702 if (list == null) {
703 list = new ArrayList<OrgGroupRole>();
704 }
705
706 cacheResult(list);
707
708 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_ROLEID,
709 finderArgs, list);
710
711 closeSession(session);
712 }
713 }
714
715 return list;
716 }
717
718 public OrgGroupRole findByRoleId_First(long roleId, OrderByComparator obc)
719 throws NoSuchOrgGroupRoleException, SystemException {
720 List<OrgGroupRole> list = findByRoleId(roleId, 0, 1, obc);
721
722 if (list.isEmpty()) {
723 StringBuilder msg = new StringBuilder();
724
725 msg.append("No OrgGroupRole exists with the key {");
726
727 msg.append("roleId=" + roleId);
728
729 msg.append(StringPool.CLOSE_CURLY_BRACE);
730
731 throw new NoSuchOrgGroupRoleException(msg.toString());
732 }
733 else {
734 return list.get(0);
735 }
736 }
737
738 public OrgGroupRole findByRoleId_Last(long roleId, OrderByComparator obc)
739 throws NoSuchOrgGroupRoleException, SystemException {
740 int count = countByRoleId(roleId);
741
742 List<OrgGroupRole> list = findByRoleId(roleId, count - 1, count, obc);
743
744 if (list.isEmpty()) {
745 StringBuilder msg = new StringBuilder();
746
747 msg.append("No OrgGroupRole exists with the key {");
748
749 msg.append("roleId=" + roleId);
750
751 msg.append(StringPool.CLOSE_CURLY_BRACE);
752
753 throw new NoSuchOrgGroupRoleException(msg.toString());
754 }
755 else {
756 return list.get(0);
757 }
758 }
759
760 public OrgGroupRole[] findByRoleId_PrevAndNext(
761 OrgGroupRolePK orgGroupRolePK, long roleId, OrderByComparator obc)
762 throws NoSuchOrgGroupRoleException, SystemException {
763 OrgGroupRole orgGroupRole = findByPrimaryKey(orgGroupRolePK);
764
765 int count = countByRoleId(roleId);
766
767 Session session = null;
768
769 try {
770 session = openSession();
771
772 StringBuilder query = new StringBuilder();
773
774 query.append(
775 "SELECT orgGroupRole FROM OrgGroupRole orgGroupRole WHERE ");
776
777 query.append("orgGroupRole.id.roleId = ?");
778
779 query.append(" ");
780
781 if (obc != null) {
782 query.append("ORDER BY ");
783
784 String[] orderByFields = obc.getOrderByFields();
785
786 for (int i = 0; i < orderByFields.length; i++) {
787 query.append("orgGroupRole.");
788 query.append(orderByFields[i]);
789
790 if (obc.isAscending()) {
791 query.append(" ASC");
792 }
793 else {
794 query.append(" DESC");
795 }
796
797 if ((i + 1) < orderByFields.length) {
798 query.append(", ");
799 }
800 }
801 }
802
803 Query q = session.createQuery(query.toString());
804
805 QueryPos qPos = QueryPos.getInstance(q);
806
807 qPos.add(roleId);
808
809 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
810 orgGroupRole);
811
812 OrgGroupRole[] array = new OrgGroupRoleImpl[3];
813
814 array[0] = (OrgGroupRole)objArray[0];
815 array[1] = (OrgGroupRole)objArray[1];
816 array[2] = (OrgGroupRole)objArray[2];
817
818 return array;
819 }
820 catch (Exception e) {
821 throw processException(e);
822 }
823 finally {
824 closeSession(session);
825 }
826 }
827
828 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
829 throws SystemException {
830 Session session = null;
831
832 try {
833 session = openSession();
834
835 dynamicQuery.compile(session);
836
837 return dynamicQuery.list();
838 }
839 catch (Exception e) {
840 throw processException(e);
841 }
842 finally {
843 closeSession(session);
844 }
845 }
846
847 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
848 int start, int end) throws SystemException {
849 Session session = null;
850
851 try {
852 session = openSession();
853
854 dynamicQuery.setLimit(start, end);
855
856 dynamicQuery.compile(session);
857
858 return dynamicQuery.list();
859 }
860 catch (Exception e) {
861 throw processException(e);
862 }
863 finally {
864 closeSession(session);
865 }
866 }
867
868 public List<OrgGroupRole> findAll() throws SystemException {
869 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
870 }
871
872 public List<OrgGroupRole> findAll(int start, int end)
873 throws SystemException {
874 return findAll(start, end, null);
875 }
876
877 public List<OrgGroupRole> findAll(int start, int end, OrderByComparator obc)
878 throws SystemException {
879 Object[] finderArgs = new Object[] {
880 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
881 };
882
883 List<OrgGroupRole> list = (List<OrgGroupRole>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
884 finderArgs, this);
885
886 if (list == null) {
887 Session session = null;
888
889 try {
890 session = openSession();
891
892 StringBuilder query = new StringBuilder();
893
894 query.append(
895 "SELECT orgGroupRole FROM OrgGroupRole orgGroupRole ");
896
897 if (obc != null) {
898 query.append("ORDER BY ");
899
900 String[] orderByFields = obc.getOrderByFields();
901
902 for (int i = 0; i < orderByFields.length; i++) {
903 query.append("orgGroupRole.");
904 query.append(orderByFields[i]);
905
906 if (obc.isAscending()) {
907 query.append(" ASC");
908 }
909 else {
910 query.append(" DESC");
911 }
912
913 if ((i + 1) < orderByFields.length) {
914 query.append(", ");
915 }
916 }
917 }
918
919 Query q = session.createQuery(query.toString());
920
921 if (obc == null) {
922 list = (List<OrgGroupRole>)QueryUtil.list(q, getDialect(),
923 start, end, false);
924
925 Collections.sort(list);
926 }
927 else {
928 list = (List<OrgGroupRole>)QueryUtil.list(q, getDialect(),
929 start, end);
930 }
931 }
932 catch (Exception e) {
933 throw processException(e);
934 }
935 finally {
936 if (list == null) {
937 list = new ArrayList<OrgGroupRole>();
938 }
939
940 cacheResult(list);
941
942 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
943
944 closeSession(session);
945 }
946 }
947
948 return list;
949 }
950
951 public void removeByGroupId(long groupId) throws SystemException {
952 for (OrgGroupRole orgGroupRole : findByGroupId(groupId)) {
953 remove(orgGroupRole);
954 }
955 }
956
957 public void removeByRoleId(long roleId) throws SystemException {
958 for (OrgGroupRole orgGroupRole : findByRoleId(roleId)) {
959 remove(orgGroupRole);
960 }
961 }
962
963 public void removeAll() throws SystemException {
964 for (OrgGroupRole orgGroupRole : findAll()) {
965 remove(orgGroupRole);
966 }
967 }
968
969 public int countByGroupId(long groupId) throws SystemException {
970 Object[] finderArgs = new Object[] { new Long(groupId) };
971
972 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
973 finderArgs, this);
974
975 if (count == null) {
976 Session session = null;
977
978 try {
979 session = openSession();
980
981 StringBuilder query = new StringBuilder();
982
983 query.append("SELECT COUNT(orgGroupRole) ");
984 query.append("FROM OrgGroupRole orgGroupRole WHERE ");
985
986 query.append("orgGroupRole.id.groupId = ?");
987
988 query.append(" ");
989
990 Query q = session.createQuery(query.toString());
991
992 QueryPos qPos = QueryPos.getInstance(q);
993
994 qPos.add(groupId);
995
996 count = (Long)q.uniqueResult();
997 }
998 catch (Exception e) {
999 throw processException(e);
1000 }
1001 finally {
1002 if (count == null) {
1003 count = Long.valueOf(0);
1004 }
1005
1006 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1007 finderArgs, count);
1008
1009 closeSession(session);
1010 }
1011 }
1012
1013 return count.intValue();
1014 }
1015
1016 public int countByRoleId(long roleId) throws SystemException {
1017 Object[] finderArgs = new Object[] { new Long(roleId) };
1018
1019 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ROLEID,
1020 finderArgs, this);
1021
1022 if (count == null) {
1023 Session session = null;
1024
1025 try {
1026 session = openSession();
1027
1028 StringBuilder query = new StringBuilder();
1029
1030 query.append("SELECT COUNT(orgGroupRole) ");
1031 query.append("FROM OrgGroupRole orgGroupRole WHERE ");
1032
1033 query.append("orgGroupRole.id.roleId = ?");
1034
1035 query.append(" ");
1036
1037 Query q = session.createQuery(query.toString());
1038
1039 QueryPos qPos = QueryPos.getInstance(q);
1040
1041 qPos.add(roleId);
1042
1043 count = (Long)q.uniqueResult();
1044 }
1045 catch (Exception e) {
1046 throw processException(e);
1047 }
1048 finally {
1049 if (count == null) {
1050 count = Long.valueOf(0);
1051 }
1052
1053 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ROLEID,
1054 finderArgs, count);
1055
1056 closeSession(session);
1057 }
1058 }
1059
1060 return count.intValue();
1061 }
1062
1063 public int countAll() throws SystemException {
1064 Object[] finderArgs = new Object[0];
1065
1066 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1067 finderArgs, this);
1068
1069 if (count == null) {
1070 Session session = null;
1071
1072 try {
1073 session = openSession();
1074
1075 Query q = session.createQuery(
1076 "SELECT COUNT(orgGroupRole) FROM OrgGroupRole orgGroupRole");
1077
1078 count = (Long)q.uniqueResult();
1079 }
1080 catch (Exception e) {
1081 throw processException(e);
1082 }
1083 finally {
1084 if (count == null) {
1085 count = Long.valueOf(0);
1086 }
1087
1088 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1089 count);
1090
1091 closeSession(session);
1092 }
1093 }
1094
1095 return count.intValue();
1096 }
1097
1098 public void afterPropertiesSet() {
1099 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1100 com.liferay.portal.util.PropsUtil.get(
1101 "value.object.listener.com.liferay.portal.model.OrgGroupRole")));
1102
1103 if (listenerClassNames.length > 0) {
1104 try {
1105 List<ModelListener<OrgGroupRole>> listenersList = new ArrayList<ModelListener<OrgGroupRole>>();
1106
1107 for (String listenerClassName : listenerClassNames) {
1108 listenersList.add((ModelListener<OrgGroupRole>)Class.forName(
1109 listenerClassName).newInstance());
1110 }
1111
1112 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1113 }
1114 catch (Exception e) {
1115 _log.error(e);
1116 }
1117 }
1118 }
1119
1120 @BeanReference(name = "com.liferay.portal.service.persistence.AccountPersistence.impl")
1121 protected com.liferay.portal.service.persistence.AccountPersistence accountPersistence;
1122 @BeanReference(name = "com.liferay.portal.service.persistence.AddressPersistence.impl")
1123 protected com.liferay.portal.service.persistence.AddressPersistence addressPersistence;
1124 @BeanReference(name = "com.liferay.portal.service.persistence.BrowserTrackerPersistence.impl")
1125 protected com.liferay.portal.service.persistence.BrowserTrackerPersistence browserTrackerPersistence;
1126 @BeanReference(name = "com.liferay.portal.service.persistence.ClassNamePersistence.impl")
1127 protected com.liferay.portal.service.persistence.ClassNamePersistence classNamePersistence;
1128 @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence.impl")
1129 protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
1130 @BeanReference(name = "com.liferay.portal.service.persistence.ContactPersistence.impl")
1131 protected com.liferay.portal.service.persistence.ContactPersistence contactPersistence;
1132 @BeanReference(name = "com.liferay.portal.service.persistence.CountryPersistence.impl")
1133 protected com.liferay.portal.service.persistence.CountryPersistence countryPersistence;
1134 @BeanReference(name = "com.liferay.portal.service.persistence.EmailAddressPersistence.impl")
1135 protected com.liferay.portal.service.persistence.EmailAddressPersistence emailAddressPersistence;
1136 @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence.impl")
1137 protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
1138 @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence.impl")
1139 protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
1140 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPersistence.impl")
1141 protected com.liferay.portal.service.persistence.LayoutPersistence layoutPersistence;
1142 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutSetPersistence.impl")
1143 protected com.liferay.portal.service.persistence.LayoutSetPersistence layoutSetPersistence;
1144 @BeanReference(name = "com.liferay.portal.service.persistence.ListTypePersistence.impl")
1145 protected com.liferay.portal.service.persistence.ListTypePersistence listTypePersistence;
1146 @BeanReference(name = "com.liferay.portal.service.persistence.MembershipRequestPersistence.impl")
1147 protected com.liferay.portal.service.persistence.MembershipRequestPersistence membershipRequestPersistence;
1148 @BeanReference(name = "com.liferay.portal.service.persistence.OrganizationPersistence.impl")
1149 protected com.liferay.portal.service.persistence.OrganizationPersistence organizationPersistence;
1150 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupPermissionPersistence.impl")
1151 protected com.liferay.portal.service.persistence.OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1152 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupRolePersistence.impl")
1153 protected com.liferay.portal.service.persistence.OrgGroupRolePersistence orgGroupRolePersistence;
1154 @BeanReference(name = "com.liferay.portal.service.persistence.OrgLaborPersistence.impl")
1155 protected com.liferay.portal.service.persistence.OrgLaborPersistence orgLaborPersistence;
1156 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyPersistence.impl")
1157 protected com.liferay.portal.service.persistence.PasswordPolicyPersistence passwordPolicyPersistence;
1158 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyRelPersistence.impl")
1159 protected com.liferay.portal.service.persistence.PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1160 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordTrackerPersistence.impl")
1161 protected com.liferay.portal.service.persistence.PasswordTrackerPersistence passwordTrackerPersistence;
1162 @BeanReference(name = "com.liferay.portal.service.persistence.PermissionPersistence.impl")
1163 protected com.liferay.portal.service.persistence.PermissionPersistence permissionPersistence;
1164 @BeanReference(name = "com.liferay.portal.service.persistence.PhonePersistence.impl")
1165 protected com.liferay.portal.service.persistence.PhonePersistence phonePersistence;
1166 @BeanReference(name = "com.liferay.portal.service.persistence.PluginSettingPersistence.impl")
1167 protected com.liferay.portal.service.persistence.PluginSettingPersistence pluginSettingPersistence;
1168 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPersistence.impl")
1169 protected com.liferay.portal.service.persistence.PortletPersistence portletPersistence;
1170 @BeanReference(name = "com.liferay.portal.service.persistence.PortletItemPersistence.impl")
1171 protected com.liferay.portal.service.persistence.PortletItemPersistence portletItemPersistence;
1172 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence.impl")
1173 protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
1174 @BeanReference(name = "com.liferay.portal.service.persistence.RegionPersistence.impl")
1175 protected com.liferay.portal.service.persistence.RegionPersistence regionPersistence;
1176 @BeanReference(name = "com.liferay.portal.service.persistence.ReleasePersistence.impl")
1177 protected com.liferay.portal.service.persistence.ReleasePersistence releasePersistence;
1178 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
1179 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
1180 @BeanReference(name = "com.liferay.portal.service.persistence.ResourceActionPersistence.impl")
1181 protected com.liferay.portal.service.persistence.ResourceActionPersistence resourceActionPersistence;
1182 @BeanReference(name = "com.liferay.portal.service.persistence.ResourceCodePersistence.impl")
1183 protected com.liferay.portal.service.persistence.ResourceCodePersistence resourceCodePersistence;
1184 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePermissionPersistence.impl")
1185 protected com.liferay.portal.service.persistence.ResourcePermissionPersistence resourcePermissionPersistence;
1186 @BeanReference(name = "com.liferay.portal.service.persistence.RolePersistence.impl")
1187 protected com.liferay.portal.service.persistence.RolePersistence rolePersistence;
1188 @BeanReference(name = "com.liferay.portal.service.persistence.ServiceComponentPersistence.impl")
1189 protected com.liferay.portal.service.persistence.ServiceComponentPersistence serviceComponentPersistence;
1190 @BeanReference(name = "com.liferay.portal.service.persistence.ShardPersistence.impl")
1191 protected com.liferay.portal.service.persistence.ShardPersistence shardPersistence;
1192 @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence.impl")
1193 protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
1194 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
1195 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1196 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupPersistence.impl")
1197 protected com.liferay.portal.service.persistence.UserGroupPersistence userGroupPersistence;
1198 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupRolePersistence.impl")
1199 protected com.liferay.portal.service.persistence.UserGroupRolePersistence userGroupRolePersistence;
1200 @BeanReference(name = "com.liferay.portal.service.persistence.UserIdMapperPersistence.impl")
1201 protected com.liferay.portal.service.persistence.UserIdMapperPersistence userIdMapperPersistence;
1202 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPersistence.impl")
1203 protected com.liferay.portal.service.persistence.UserTrackerPersistence userTrackerPersistence;
1204 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPathPersistence.impl")
1205 protected com.liferay.portal.service.persistence.UserTrackerPathPersistence userTrackerPathPersistence;
1206 @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence.impl")
1207 protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
1208 @BeanReference(name = "com.liferay.portal.service.persistence.WebsitePersistence.impl")
1209 protected com.liferay.portal.service.persistence.WebsitePersistence websitePersistence;
1210 private static Log _log = LogFactoryUtil.getLog(OrgGroupRolePersistenceImpl.class);
1211}