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