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