001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchGroupException;
018 import com.liferay.portal.kernel.bean.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
021 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
022 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
023 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
024 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
025 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
026 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
027 import com.liferay.portal.kernel.dao.orm.FinderPath;
028 import com.liferay.portal.kernel.dao.orm.Query;
029 import com.liferay.portal.kernel.dao.orm.QueryPos;
030 import com.liferay.portal.kernel.dao.orm.QueryUtil;
031 import com.liferay.portal.kernel.dao.orm.SQLQuery;
032 import com.liferay.portal.kernel.dao.orm.Session;
033 import com.liferay.portal.kernel.exception.SystemException;
034 import com.liferay.portal.kernel.log.Log;
035 import com.liferay.portal.kernel.log.LogFactoryUtil;
036 import com.liferay.portal.kernel.util.GetterUtil;
037 import com.liferay.portal.kernel.util.InstanceFactory;
038 import com.liferay.portal.kernel.util.OrderByComparator;
039 import com.liferay.portal.kernel.util.SetUtil;
040 import com.liferay.portal.kernel.util.StringBundler;
041 import com.liferay.portal.kernel.util.StringPool;
042 import com.liferay.portal.kernel.util.StringUtil;
043 import com.liferay.portal.kernel.util.UnmodifiableList;
044 import com.liferay.portal.kernel.util.Validator;
045 import com.liferay.portal.model.CacheModel;
046 import com.liferay.portal.model.Group;
047 import com.liferay.portal.model.ModelListener;
048 import com.liferay.portal.model.impl.GroupImpl;
049 import com.liferay.portal.model.impl.GroupModelImpl;
050 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
051
052 import java.io.Serializable;
053
054 import java.util.ArrayList;
055 import java.util.Collections;
056 import java.util.List;
057 import java.util.Set;
058
059
071 public class GroupPersistenceImpl extends BasePersistenceImpl<Group>
072 implements GroupPersistence {
073
078 public static final String FINDER_CLASS_NAME_ENTITY = GroupImpl.class.getName();
079 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
080 ".List1";
081 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
082 ".List2";
083 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
084 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
085 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
086 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
087 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
088 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
089 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
090 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
091 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
092 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
093 new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
094 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
095 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
096 new String[] {
097 Long.class.getName(),
098
099 Integer.class.getName(), Integer.class.getName(),
100 OrderByComparator.class.getName()
101 });
102 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
103 new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
104 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
105 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
106 new String[] { Long.class.getName() },
107 GroupModelImpl.COMPANYID_COLUMN_BITMASK |
108 GroupModelImpl.NAME_COLUMN_BITMASK);
109 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
110 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
111 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
112 new String[] { Long.class.getName() });
113
114
121 public List<Group> findByCompanyId(long companyId)
122 throws SystemException {
123 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
124 null);
125 }
126
127
140 public List<Group> findByCompanyId(long companyId, int start, int end)
141 throws SystemException {
142 return findByCompanyId(companyId, start, end, null);
143 }
144
145
159 public List<Group> findByCompanyId(long companyId, int start, int end,
160 OrderByComparator orderByComparator) throws SystemException {
161 boolean pagination = true;
162 FinderPath finderPath = null;
163 Object[] finderArgs = null;
164
165 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
166 (orderByComparator == null)) {
167 pagination = false;
168 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
169 finderArgs = new Object[] { companyId };
170 }
171 else {
172 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
173 finderArgs = new Object[] { companyId, start, end, orderByComparator };
174 }
175
176 List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
177 finderArgs, this);
178
179 if ((list != null) && !list.isEmpty()) {
180 for (Group group : list) {
181 if ((companyId != group.getCompanyId())) {
182 list = null;
183
184 break;
185 }
186 }
187 }
188
189 if (list == null) {
190 StringBundler query = null;
191
192 if (orderByComparator != null) {
193 query = new StringBundler(3 +
194 (orderByComparator.getOrderByFields().length * 3));
195 }
196 else {
197 query = new StringBundler(3);
198 }
199
200 query.append(_SQL_SELECT_GROUP__WHERE);
201
202 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
203
204 if (orderByComparator != null) {
205 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
206 orderByComparator);
207 }
208 else
209 if (pagination) {
210 query.append(GroupModelImpl.ORDER_BY_JPQL);
211 }
212
213 String sql = query.toString();
214
215 Session session = null;
216
217 try {
218 session = openSession();
219
220 Query q = session.createQuery(sql);
221
222 QueryPos qPos = QueryPos.getInstance(q);
223
224 qPos.add(companyId);
225
226 if (!pagination) {
227 list = (List<Group>)QueryUtil.list(q, getDialect(), start,
228 end, false);
229
230 Collections.sort(list);
231
232 list = new UnmodifiableList<Group>(list);
233 }
234 else {
235 list = (List<Group>)QueryUtil.list(q, getDialect(), start,
236 end);
237 }
238
239 cacheResult(list);
240
241 FinderCacheUtil.putResult(finderPath, finderArgs, list);
242 }
243 catch (Exception e) {
244 FinderCacheUtil.removeResult(finderPath, finderArgs);
245
246 throw processException(e);
247 }
248 finally {
249 closeSession(session);
250 }
251 }
252
253 return list;
254 }
255
256
265 public Group findByCompanyId_First(long companyId,
266 OrderByComparator orderByComparator)
267 throws NoSuchGroupException, SystemException {
268 Group group = fetchByCompanyId_First(companyId, orderByComparator);
269
270 if (group != null) {
271 return group;
272 }
273
274 StringBundler msg = new StringBundler(4);
275
276 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
277
278 msg.append("companyId=");
279 msg.append(companyId);
280
281 msg.append(StringPool.CLOSE_CURLY_BRACE);
282
283 throw new NoSuchGroupException(msg.toString());
284 }
285
286
294 public Group fetchByCompanyId_First(long companyId,
295 OrderByComparator orderByComparator) throws SystemException {
296 List<Group> list = findByCompanyId(companyId, 0, 1, orderByComparator);
297
298 if (!list.isEmpty()) {
299 return list.get(0);
300 }
301
302 return null;
303 }
304
305
314 public Group findByCompanyId_Last(long companyId,
315 OrderByComparator orderByComparator)
316 throws NoSuchGroupException, SystemException {
317 Group group = fetchByCompanyId_Last(companyId, orderByComparator);
318
319 if (group != null) {
320 return group;
321 }
322
323 StringBundler msg = new StringBundler(4);
324
325 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
326
327 msg.append("companyId=");
328 msg.append(companyId);
329
330 msg.append(StringPool.CLOSE_CURLY_BRACE);
331
332 throw new NoSuchGroupException(msg.toString());
333 }
334
335
343 public Group fetchByCompanyId_Last(long companyId,
344 OrderByComparator orderByComparator) throws SystemException {
345 int count = countByCompanyId(companyId);
346
347 List<Group> list = findByCompanyId(companyId, count - 1, count,
348 orderByComparator);
349
350 if (!list.isEmpty()) {
351 return list.get(0);
352 }
353
354 return null;
355 }
356
357
367 public Group[] findByCompanyId_PrevAndNext(long groupId, long companyId,
368 OrderByComparator orderByComparator)
369 throws NoSuchGroupException, SystemException {
370 Group group = findByPrimaryKey(groupId);
371
372 Session session = null;
373
374 try {
375 session = openSession();
376
377 Group[] array = new GroupImpl[3];
378
379 array[0] = getByCompanyId_PrevAndNext(session, group, companyId,
380 orderByComparator, true);
381
382 array[1] = group;
383
384 array[2] = getByCompanyId_PrevAndNext(session, group, companyId,
385 orderByComparator, false);
386
387 return array;
388 }
389 catch (Exception e) {
390 throw processException(e);
391 }
392 finally {
393 closeSession(session);
394 }
395 }
396
397 protected Group getByCompanyId_PrevAndNext(Session session, Group group,
398 long companyId, OrderByComparator orderByComparator, boolean previous) {
399 StringBundler query = null;
400
401 if (orderByComparator != null) {
402 query = new StringBundler(6 +
403 (orderByComparator.getOrderByFields().length * 6));
404 }
405 else {
406 query = new StringBundler(3);
407 }
408
409 query.append(_SQL_SELECT_GROUP__WHERE);
410
411 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
412
413 if (orderByComparator != null) {
414 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
415
416 if (orderByConditionFields.length > 0) {
417 query.append(WHERE_AND);
418 }
419
420 for (int i = 0; i < orderByConditionFields.length; i++) {
421 query.append(_ORDER_BY_ENTITY_ALIAS);
422 query.append(orderByConditionFields[i]);
423
424 if ((i + 1) < orderByConditionFields.length) {
425 if (orderByComparator.isAscending() ^ previous) {
426 query.append(WHERE_GREATER_THAN_HAS_NEXT);
427 }
428 else {
429 query.append(WHERE_LESSER_THAN_HAS_NEXT);
430 }
431 }
432 else {
433 if (orderByComparator.isAscending() ^ previous) {
434 query.append(WHERE_GREATER_THAN);
435 }
436 else {
437 query.append(WHERE_LESSER_THAN);
438 }
439 }
440 }
441
442 query.append(ORDER_BY_CLAUSE);
443
444 String[] orderByFields = orderByComparator.getOrderByFields();
445
446 for (int i = 0; i < orderByFields.length; i++) {
447 query.append(_ORDER_BY_ENTITY_ALIAS);
448 query.append(orderByFields[i]);
449
450 if ((i + 1) < orderByFields.length) {
451 if (orderByComparator.isAscending() ^ previous) {
452 query.append(ORDER_BY_ASC_HAS_NEXT);
453 }
454 else {
455 query.append(ORDER_BY_DESC_HAS_NEXT);
456 }
457 }
458 else {
459 if (orderByComparator.isAscending() ^ previous) {
460 query.append(ORDER_BY_ASC);
461 }
462 else {
463 query.append(ORDER_BY_DESC);
464 }
465 }
466 }
467 }
468 else {
469 query.append(GroupModelImpl.ORDER_BY_JPQL);
470 }
471
472 String sql = query.toString();
473
474 Query q = session.createQuery(sql);
475
476 q.setFirstResult(0);
477 q.setMaxResults(2);
478
479 QueryPos qPos = QueryPos.getInstance(q);
480
481 qPos.add(companyId);
482
483 if (orderByComparator != null) {
484 Object[] values = orderByComparator.getOrderByConditionValues(group);
485
486 for (Object value : values) {
487 qPos.add(value);
488 }
489 }
490
491 List<Group> list = q.list();
492
493 if (list.size() == 2) {
494 return list.get(1);
495 }
496 else {
497 return null;
498 }
499 }
500
501
507 public void removeByCompanyId(long companyId) throws SystemException {
508 for (Group group : findByCompanyId(companyId, QueryUtil.ALL_POS,
509 QueryUtil.ALL_POS, null)) {
510 remove(group);
511 }
512 }
513
514
521 public int countByCompanyId(long companyId) throws SystemException {
522 FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
523
524 Object[] finderArgs = new Object[] { companyId };
525
526 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
527 this);
528
529 if (count == null) {
530 StringBundler query = new StringBundler(2);
531
532 query.append(_SQL_COUNT_GROUP__WHERE);
533
534 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
535
536 String sql = query.toString();
537
538 Session session = null;
539
540 try {
541 session = openSession();
542
543 Query q = session.createQuery(sql);
544
545 QueryPos qPos = QueryPos.getInstance(q);
546
547 qPos.add(companyId);
548
549 count = (Long)q.uniqueResult();
550
551 FinderCacheUtil.putResult(finderPath, finderArgs, count);
552 }
553 catch (Exception e) {
554 FinderCacheUtil.removeResult(finderPath, finderArgs);
555
556 throw processException(e);
557 }
558 finally {
559 closeSession(session);
560 }
561 }
562
563 return count.intValue();
564 }
565
566 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "group_.companyId = ?";
567 public static final FinderPath FINDER_PATH_FETCH_BY_LIVEGROUPID = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
568 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
569 FINDER_CLASS_NAME_ENTITY, "fetchByLiveGroupId",
570 new String[] { Long.class.getName() },
571 GroupModelImpl.LIVEGROUPID_COLUMN_BITMASK);
572 public static final FinderPath FINDER_PATH_COUNT_BY_LIVEGROUPID = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
573 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
574 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByLiveGroupId",
575 new String[] { Long.class.getName() });
576
577
585 public Group findByLiveGroupId(long liveGroupId)
586 throws NoSuchGroupException, SystemException {
587 Group group = fetchByLiveGroupId(liveGroupId);
588
589 if (group == null) {
590 StringBundler msg = new StringBundler(4);
591
592 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
593
594 msg.append("liveGroupId=");
595 msg.append(liveGroupId);
596
597 msg.append(StringPool.CLOSE_CURLY_BRACE);
598
599 if (_log.isWarnEnabled()) {
600 _log.warn(msg.toString());
601 }
602
603 throw new NoSuchGroupException(msg.toString());
604 }
605
606 return group;
607 }
608
609
616 public Group fetchByLiveGroupId(long liveGroupId) throws SystemException {
617 return fetchByLiveGroupId(liveGroupId, true);
618 }
619
620
628 public Group fetchByLiveGroupId(long liveGroupId, boolean retrieveFromCache)
629 throws SystemException {
630 Object[] finderArgs = new Object[] { liveGroupId };
631
632 Object result = null;
633
634 if (retrieveFromCache) {
635 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
636 finderArgs, this);
637 }
638
639 if (result instanceof Group) {
640 Group group = (Group)result;
641
642 if ((liveGroupId != group.getLiveGroupId())) {
643 result = null;
644 }
645 }
646
647 if (result == null) {
648 StringBundler query = new StringBundler(3);
649
650 query.append(_SQL_SELECT_GROUP__WHERE);
651
652 query.append(_FINDER_COLUMN_LIVEGROUPID_LIVEGROUPID_2);
653
654 String sql = query.toString();
655
656 Session session = null;
657
658 try {
659 session = openSession();
660
661 Query q = session.createQuery(sql);
662
663 QueryPos qPos = QueryPos.getInstance(q);
664
665 qPos.add(liveGroupId);
666
667 List<Group> list = q.list();
668
669 if (list.isEmpty()) {
670 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
671 finderArgs, list);
672 }
673 else {
674 if ((list.size() > 1) && _log.isWarnEnabled()) {
675 _log.warn(
676 "GroupPersistenceImpl.fetchByLiveGroupId(long, boolean) with parameters (" +
677 StringUtil.merge(finderArgs) +
678 ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder.");
679 }
680
681 Group group = list.get(0);
682
683 result = group;
684
685 cacheResult(group);
686
687 if ((group.getLiveGroupId() != liveGroupId)) {
688 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
689 finderArgs, group);
690 }
691 }
692 }
693 catch (Exception e) {
694 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
695 finderArgs);
696
697 throw processException(e);
698 }
699 finally {
700 closeSession(session);
701 }
702 }
703
704 if (result instanceof List<?>) {
705 return null;
706 }
707 else {
708 return (Group)result;
709 }
710 }
711
712
719 public Group removeByLiveGroupId(long liveGroupId)
720 throws NoSuchGroupException, SystemException {
721 Group group = findByLiveGroupId(liveGroupId);
722
723 return remove(group);
724 }
725
726
733 public int countByLiveGroupId(long liveGroupId) throws SystemException {
734 FinderPath finderPath = FINDER_PATH_COUNT_BY_LIVEGROUPID;
735
736 Object[] finderArgs = new Object[] { liveGroupId };
737
738 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
739 this);
740
741 if (count == null) {
742 StringBundler query = new StringBundler(2);
743
744 query.append(_SQL_COUNT_GROUP__WHERE);
745
746 query.append(_FINDER_COLUMN_LIVEGROUPID_LIVEGROUPID_2);
747
748 String sql = query.toString();
749
750 Session session = null;
751
752 try {
753 session = openSession();
754
755 Query q = session.createQuery(sql);
756
757 QueryPos qPos = QueryPos.getInstance(q);
758
759 qPos.add(liveGroupId);
760
761 count = (Long)q.uniqueResult();
762
763 FinderCacheUtil.putResult(finderPath, finderArgs, count);
764 }
765 catch (Exception e) {
766 FinderCacheUtil.removeResult(finderPath, finderArgs);
767
768 throw processException(e);
769 }
770 finally {
771 closeSession(session);
772 }
773 }
774
775 return count.intValue();
776 }
777
778 private static final String _FINDER_COLUMN_LIVEGROUPID_LIVEGROUPID_2 = "group_.liveGroupId = ?";
779 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
780 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
781 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_P",
782 new String[] {
783 Long.class.getName(), Long.class.getName(),
784
785 Integer.class.getName(), Integer.class.getName(),
786 OrderByComparator.class.getName()
787 });
788 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
789 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
790 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_P",
791 new String[] { Long.class.getName(), Long.class.getName() },
792 GroupModelImpl.COMPANYID_COLUMN_BITMASK |
793 GroupModelImpl.PARENTGROUPID_COLUMN_BITMASK |
794 GroupModelImpl.NAME_COLUMN_BITMASK);
795 public static final FinderPath FINDER_PATH_COUNT_BY_C_P = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
796 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
797 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_P",
798 new String[] { Long.class.getName(), Long.class.getName() });
799
800
808 public List<Group> findByC_P(long companyId, long parentGroupId)
809 throws SystemException {
810 return findByC_P(companyId, parentGroupId, QueryUtil.ALL_POS,
811 QueryUtil.ALL_POS, null);
812 }
813
814
828 public List<Group> findByC_P(long companyId, long parentGroupId, int start,
829 int end) throws SystemException {
830 return findByC_P(companyId, parentGroupId, start, end, null);
831 }
832
833
848 public List<Group> findByC_P(long companyId, long parentGroupId, int start,
849 int end, OrderByComparator orderByComparator) throws SystemException {
850 boolean pagination = true;
851 FinderPath finderPath = null;
852 Object[] finderArgs = null;
853
854 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
855 (orderByComparator == null)) {
856 pagination = false;
857 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P;
858 finderArgs = new Object[] { companyId, parentGroupId };
859 }
860 else {
861 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P;
862 finderArgs = new Object[] {
863 companyId, parentGroupId,
864
865 start, end, orderByComparator
866 };
867 }
868
869 List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
870 finderArgs, this);
871
872 if ((list != null) && !list.isEmpty()) {
873 for (Group group : list) {
874 if ((companyId != group.getCompanyId()) ||
875 (parentGroupId != group.getParentGroupId())) {
876 list = null;
877
878 break;
879 }
880 }
881 }
882
883 if (list == null) {
884 StringBundler query = null;
885
886 if (orderByComparator != null) {
887 query = new StringBundler(4 +
888 (orderByComparator.getOrderByFields().length * 3));
889 }
890 else {
891 query = new StringBundler(4);
892 }
893
894 query.append(_SQL_SELECT_GROUP__WHERE);
895
896 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
897
898 query.append(_FINDER_COLUMN_C_P_PARENTGROUPID_2);
899
900 if (orderByComparator != null) {
901 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
902 orderByComparator);
903 }
904 else
905 if (pagination) {
906 query.append(GroupModelImpl.ORDER_BY_JPQL);
907 }
908
909 String sql = query.toString();
910
911 Session session = null;
912
913 try {
914 session = openSession();
915
916 Query q = session.createQuery(sql);
917
918 QueryPos qPos = QueryPos.getInstance(q);
919
920 qPos.add(companyId);
921
922 qPos.add(parentGroupId);
923
924 if (!pagination) {
925 list = (List<Group>)QueryUtil.list(q, getDialect(), start,
926 end, false);
927
928 Collections.sort(list);
929
930 list = new UnmodifiableList<Group>(list);
931 }
932 else {
933 list = (List<Group>)QueryUtil.list(q, getDialect(), start,
934 end);
935 }
936
937 cacheResult(list);
938
939 FinderCacheUtil.putResult(finderPath, finderArgs, list);
940 }
941 catch (Exception e) {
942 FinderCacheUtil.removeResult(finderPath, finderArgs);
943
944 throw processException(e);
945 }
946 finally {
947 closeSession(session);
948 }
949 }
950
951 return list;
952 }
953
954
964 public Group findByC_P_First(long companyId, long parentGroupId,
965 OrderByComparator orderByComparator)
966 throws NoSuchGroupException, SystemException {
967 Group group = fetchByC_P_First(companyId, parentGroupId,
968 orderByComparator);
969
970 if (group != null) {
971 return group;
972 }
973
974 StringBundler msg = new StringBundler(6);
975
976 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
977
978 msg.append("companyId=");
979 msg.append(companyId);
980
981 msg.append(", parentGroupId=");
982 msg.append(parentGroupId);
983
984 msg.append(StringPool.CLOSE_CURLY_BRACE);
985
986 throw new NoSuchGroupException(msg.toString());
987 }
988
989
998 public Group fetchByC_P_First(long companyId, long parentGroupId,
999 OrderByComparator orderByComparator) throws SystemException {
1000 List<Group> list = findByC_P(companyId, parentGroupId, 0, 1,
1001 orderByComparator);
1002
1003 if (!list.isEmpty()) {
1004 return list.get(0);
1005 }
1006
1007 return null;
1008 }
1009
1010
1020 public Group findByC_P_Last(long companyId, long parentGroupId,
1021 OrderByComparator orderByComparator)
1022 throws NoSuchGroupException, SystemException {
1023 Group group = fetchByC_P_Last(companyId, parentGroupId,
1024 orderByComparator);
1025
1026 if (group != null) {
1027 return group;
1028 }
1029
1030 StringBundler msg = new StringBundler(6);
1031
1032 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1033
1034 msg.append("companyId=");
1035 msg.append(companyId);
1036
1037 msg.append(", parentGroupId=");
1038 msg.append(parentGroupId);
1039
1040 msg.append(StringPool.CLOSE_CURLY_BRACE);
1041
1042 throw new NoSuchGroupException(msg.toString());
1043 }
1044
1045
1054 public Group fetchByC_P_Last(long companyId, long parentGroupId,
1055 OrderByComparator orderByComparator) throws SystemException {
1056 int count = countByC_P(companyId, parentGroupId);
1057
1058 List<Group> list = findByC_P(companyId, parentGroupId, count - 1,
1059 count, orderByComparator);
1060
1061 if (!list.isEmpty()) {
1062 return list.get(0);
1063 }
1064
1065 return null;
1066 }
1067
1068
1079 public Group[] findByC_P_PrevAndNext(long groupId, long companyId,
1080 long parentGroupId, OrderByComparator orderByComparator)
1081 throws NoSuchGroupException, SystemException {
1082 Group group = findByPrimaryKey(groupId);
1083
1084 Session session = null;
1085
1086 try {
1087 session = openSession();
1088
1089 Group[] array = new GroupImpl[3];
1090
1091 array[0] = getByC_P_PrevAndNext(session, group, companyId,
1092 parentGroupId, orderByComparator, true);
1093
1094 array[1] = group;
1095
1096 array[2] = getByC_P_PrevAndNext(session, group, companyId,
1097 parentGroupId, orderByComparator, false);
1098
1099 return array;
1100 }
1101 catch (Exception e) {
1102 throw processException(e);
1103 }
1104 finally {
1105 closeSession(session);
1106 }
1107 }
1108
1109 protected Group getByC_P_PrevAndNext(Session session, Group group,
1110 long companyId, long parentGroupId,
1111 OrderByComparator orderByComparator, boolean previous) {
1112 StringBundler query = null;
1113
1114 if (orderByComparator != null) {
1115 query = new StringBundler(6 +
1116 (orderByComparator.getOrderByFields().length * 6));
1117 }
1118 else {
1119 query = new StringBundler(3);
1120 }
1121
1122 query.append(_SQL_SELECT_GROUP__WHERE);
1123
1124 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
1125
1126 query.append(_FINDER_COLUMN_C_P_PARENTGROUPID_2);
1127
1128 if (orderByComparator != null) {
1129 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1130
1131 if (orderByConditionFields.length > 0) {
1132 query.append(WHERE_AND);
1133 }
1134
1135 for (int i = 0; i < orderByConditionFields.length; i++) {
1136 query.append(_ORDER_BY_ENTITY_ALIAS);
1137 query.append(orderByConditionFields[i]);
1138
1139 if ((i + 1) < orderByConditionFields.length) {
1140 if (orderByComparator.isAscending() ^ previous) {
1141 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1142 }
1143 else {
1144 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1145 }
1146 }
1147 else {
1148 if (orderByComparator.isAscending() ^ previous) {
1149 query.append(WHERE_GREATER_THAN);
1150 }
1151 else {
1152 query.append(WHERE_LESSER_THAN);
1153 }
1154 }
1155 }
1156
1157 query.append(ORDER_BY_CLAUSE);
1158
1159 String[] orderByFields = orderByComparator.getOrderByFields();
1160
1161 for (int i = 0; i < orderByFields.length; i++) {
1162 query.append(_ORDER_BY_ENTITY_ALIAS);
1163 query.append(orderByFields[i]);
1164
1165 if ((i + 1) < orderByFields.length) {
1166 if (orderByComparator.isAscending() ^ previous) {
1167 query.append(ORDER_BY_ASC_HAS_NEXT);
1168 }
1169 else {
1170 query.append(ORDER_BY_DESC_HAS_NEXT);
1171 }
1172 }
1173 else {
1174 if (orderByComparator.isAscending() ^ previous) {
1175 query.append(ORDER_BY_ASC);
1176 }
1177 else {
1178 query.append(ORDER_BY_DESC);
1179 }
1180 }
1181 }
1182 }
1183 else {
1184 query.append(GroupModelImpl.ORDER_BY_JPQL);
1185 }
1186
1187 String sql = query.toString();
1188
1189 Query q = session.createQuery(sql);
1190
1191 q.setFirstResult(0);
1192 q.setMaxResults(2);
1193
1194 QueryPos qPos = QueryPos.getInstance(q);
1195
1196 qPos.add(companyId);
1197
1198 qPos.add(parentGroupId);
1199
1200 if (orderByComparator != null) {
1201 Object[] values = orderByComparator.getOrderByConditionValues(group);
1202
1203 for (Object value : values) {
1204 qPos.add(value);
1205 }
1206 }
1207
1208 List<Group> list = q.list();
1209
1210 if (list.size() == 2) {
1211 return list.get(1);
1212 }
1213 else {
1214 return null;
1215 }
1216 }
1217
1218
1225 public void removeByC_P(long companyId, long parentGroupId)
1226 throws SystemException {
1227 for (Group group : findByC_P(companyId, parentGroupId,
1228 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1229 remove(group);
1230 }
1231 }
1232
1233
1241 public int countByC_P(long companyId, long parentGroupId)
1242 throws SystemException {
1243 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_P;
1244
1245 Object[] finderArgs = new Object[] { companyId, parentGroupId };
1246
1247 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1248 this);
1249
1250 if (count == null) {
1251 StringBundler query = new StringBundler(3);
1252
1253 query.append(_SQL_COUNT_GROUP__WHERE);
1254
1255 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
1256
1257 query.append(_FINDER_COLUMN_C_P_PARENTGROUPID_2);
1258
1259 String sql = query.toString();
1260
1261 Session session = null;
1262
1263 try {
1264 session = openSession();
1265
1266 Query q = session.createQuery(sql);
1267
1268 QueryPos qPos = QueryPos.getInstance(q);
1269
1270 qPos.add(companyId);
1271
1272 qPos.add(parentGroupId);
1273
1274 count = (Long)q.uniqueResult();
1275
1276 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1277 }
1278 catch (Exception e) {
1279 FinderCacheUtil.removeResult(finderPath, finderArgs);
1280
1281 throw processException(e);
1282 }
1283 finally {
1284 closeSession(session);
1285 }
1286 }
1287
1288 return count.intValue();
1289 }
1290
1291 private static final String _FINDER_COLUMN_C_P_COMPANYID_2 = "group_.companyId = ? AND ";
1292 private static final String _FINDER_COLUMN_C_P_PARENTGROUPID_2 = "group_.parentGroupId = ?";
1293 public static final FinderPath FINDER_PATH_FETCH_BY_C_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
1294 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
1295 FINDER_CLASS_NAME_ENTITY, "fetchByC_N",
1296 new String[] { Long.class.getName(), String.class.getName() },
1297 GroupModelImpl.COMPANYID_COLUMN_BITMASK |
1298 GroupModelImpl.NAME_COLUMN_BITMASK);
1299 public static final FinderPath FINDER_PATH_COUNT_BY_C_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
1300 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
1301 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_N",
1302 new String[] { Long.class.getName(), String.class.getName() });
1303
1304
1313 public Group findByC_N(long companyId, String name)
1314 throws NoSuchGroupException, SystemException {
1315 Group group = fetchByC_N(companyId, name);
1316
1317 if (group == null) {
1318 StringBundler msg = new StringBundler(6);
1319
1320 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1321
1322 msg.append("companyId=");
1323 msg.append(companyId);
1324
1325 msg.append(", name=");
1326 msg.append(name);
1327
1328 msg.append(StringPool.CLOSE_CURLY_BRACE);
1329
1330 if (_log.isWarnEnabled()) {
1331 _log.warn(msg.toString());
1332 }
1333
1334 throw new NoSuchGroupException(msg.toString());
1335 }
1336
1337 return group;
1338 }
1339
1340
1348 public Group fetchByC_N(long companyId, String name)
1349 throws SystemException {
1350 return fetchByC_N(companyId, name, true);
1351 }
1352
1353
1362 public Group fetchByC_N(long companyId, String name,
1363 boolean retrieveFromCache) throws SystemException {
1364 Object[] finderArgs = new Object[] { companyId, name };
1365
1366 Object result = null;
1367
1368 if (retrieveFromCache) {
1369 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_N,
1370 finderArgs, this);
1371 }
1372
1373 if (result instanceof Group) {
1374 Group group = (Group)result;
1375
1376 if ((companyId != group.getCompanyId()) ||
1377 !Validator.equals(name, group.getName())) {
1378 result = null;
1379 }
1380 }
1381
1382 if (result == null) {
1383 StringBundler query = new StringBundler(4);
1384
1385 query.append(_SQL_SELECT_GROUP__WHERE);
1386
1387 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
1388
1389 boolean bindName = false;
1390
1391 if (name == null) {
1392 query.append(_FINDER_COLUMN_C_N_NAME_1);
1393 }
1394 else if (name.equals(StringPool.BLANK)) {
1395 query.append(_FINDER_COLUMN_C_N_NAME_3);
1396 }
1397 else {
1398 bindName = true;
1399
1400 query.append(_FINDER_COLUMN_C_N_NAME_2);
1401 }
1402
1403 String sql = query.toString();
1404
1405 Session session = null;
1406
1407 try {
1408 session = openSession();
1409
1410 Query q = session.createQuery(sql);
1411
1412 QueryPos qPos = QueryPos.getInstance(q);
1413
1414 qPos.add(companyId);
1415
1416 if (bindName) {
1417 qPos.add(name);
1418 }
1419
1420 List<Group> list = q.list();
1421
1422 if (list.isEmpty()) {
1423 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
1424 finderArgs, list);
1425 }
1426 else {
1427 Group group = list.get(0);
1428
1429 result = group;
1430
1431 cacheResult(group);
1432
1433 if ((group.getCompanyId() != companyId) ||
1434 (group.getName() == null) ||
1435 !group.getName().equals(name)) {
1436 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
1437 finderArgs, group);
1438 }
1439 }
1440 }
1441 catch (Exception e) {
1442 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
1443 finderArgs);
1444
1445 throw processException(e);
1446 }
1447 finally {
1448 closeSession(session);
1449 }
1450 }
1451
1452 if (result instanceof List<?>) {
1453 return null;
1454 }
1455 else {
1456 return (Group)result;
1457 }
1458 }
1459
1460
1468 public Group removeByC_N(long companyId, String name)
1469 throws NoSuchGroupException, SystemException {
1470 Group group = findByC_N(companyId, name);
1471
1472 return remove(group);
1473 }
1474
1475
1483 public int countByC_N(long companyId, String name)
1484 throws SystemException {
1485 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_N;
1486
1487 Object[] finderArgs = new Object[] { companyId, name };
1488
1489 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1490 this);
1491
1492 if (count == null) {
1493 StringBundler query = new StringBundler(3);
1494
1495 query.append(_SQL_COUNT_GROUP__WHERE);
1496
1497 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
1498
1499 boolean bindName = false;
1500
1501 if (name == null) {
1502 query.append(_FINDER_COLUMN_C_N_NAME_1);
1503 }
1504 else if (name.equals(StringPool.BLANK)) {
1505 query.append(_FINDER_COLUMN_C_N_NAME_3);
1506 }
1507 else {
1508 bindName = true;
1509
1510 query.append(_FINDER_COLUMN_C_N_NAME_2);
1511 }
1512
1513 String sql = query.toString();
1514
1515 Session session = null;
1516
1517 try {
1518 session = openSession();
1519
1520 Query q = session.createQuery(sql);
1521
1522 QueryPos qPos = QueryPos.getInstance(q);
1523
1524 qPos.add(companyId);
1525
1526 if (bindName) {
1527 qPos.add(name);
1528 }
1529
1530 count = (Long)q.uniqueResult();
1531
1532 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1533 }
1534 catch (Exception e) {
1535 FinderCacheUtil.removeResult(finderPath, finderArgs);
1536
1537 throw processException(e);
1538 }
1539 finally {
1540 closeSession(session);
1541 }
1542 }
1543
1544 return count.intValue();
1545 }
1546
1547 private static final String _FINDER_COLUMN_C_N_COMPANYID_2 = "group_.companyId = ? AND ";
1548 private static final String _FINDER_COLUMN_C_N_NAME_1 = "group_.name IS NULL";
1549 private static final String _FINDER_COLUMN_C_N_NAME_2 = "group_.name = ?";
1550 private static final String _FINDER_COLUMN_C_N_NAME_3 = "(group_.name IS NULL OR group_.name = '')";
1551 public static final FinderPath FINDER_PATH_FETCH_BY_C_F = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
1552 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
1553 FINDER_CLASS_NAME_ENTITY, "fetchByC_F",
1554 new String[] { Long.class.getName(), String.class.getName() },
1555 GroupModelImpl.COMPANYID_COLUMN_BITMASK |
1556 GroupModelImpl.FRIENDLYURL_COLUMN_BITMASK);
1557 public static final FinderPath FINDER_PATH_COUNT_BY_C_F = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
1558 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
1559 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_F",
1560 new String[] { Long.class.getName(), String.class.getName() });
1561
1562
1571 public Group findByC_F(long companyId, String friendlyURL)
1572 throws NoSuchGroupException, SystemException {
1573 Group group = fetchByC_F(companyId, friendlyURL);
1574
1575 if (group == null) {
1576 StringBundler msg = new StringBundler(6);
1577
1578 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1579
1580 msg.append("companyId=");
1581 msg.append(companyId);
1582
1583 msg.append(", friendlyURL=");
1584 msg.append(friendlyURL);
1585
1586 msg.append(StringPool.CLOSE_CURLY_BRACE);
1587
1588 if (_log.isWarnEnabled()) {
1589 _log.warn(msg.toString());
1590 }
1591
1592 throw new NoSuchGroupException(msg.toString());
1593 }
1594
1595 return group;
1596 }
1597
1598
1606 public Group fetchByC_F(long companyId, String friendlyURL)
1607 throws SystemException {
1608 return fetchByC_F(companyId, friendlyURL, true);
1609 }
1610
1611
1620 public Group fetchByC_F(long companyId, String friendlyURL,
1621 boolean retrieveFromCache) throws SystemException {
1622 Object[] finderArgs = new Object[] { companyId, friendlyURL };
1623
1624 Object result = null;
1625
1626 if (retrieveFromCache) {
1627 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_F,
1628 finderArgs, this);
1629 }
1630
1631 if (result instanceof Group) {
1632 Group group = (Group)result;
1633
1634 if ((companyId != group.getCompanyId()) ||
1635 !Validator.equals(friendlyURL, group.getFriendlyURL())) {
1636 result = null;
1637 }
1638 }
1639
1640 if (result == null) {
1641 StringBundler query = new StringBundler(4);
1642
1643 query.append(_SQL_SELECT_GROUP__WHERE);
1644
1645 query.append(_FINDER_COLUMN_C_F_COMPANYID_2);
1646
1647 boolean bindFriendlyURL = false;
1648
1649 if (friendlyURL == null) {
1650 query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_1);
1651 }
1652 else if (friendlyURL.equals(StringPool.BLANK)) {
1653 query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_3);
1654 }
1655 else {
1656 bindFriendlyURL = true;
1657
1658 query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_2);
1659 }
1660
1661 String sql = query.toString();
1662
1663 Session session = null;
1664
1665 try {
1666 session = openSession();
1667
1668 Query q = session.createQuery(sql);
1669
1670 QueryPos qPos = QueryPos.getInstance(q);
1671
1672 qPos.add(companyId);
1673
1674 if (bindFriendlyURL) {
1675 qPos.add(friendlyURL);
1676 }
1677
1678 List<Group> list = q.list();
1679
1680 if (list.isEmpty()) {
1681 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
1682 finderArgs, list);
1683 }
1684 else {
1685 Group group = list.get(0);
1686
1687 result = group;
1688
1689 cacheResult(group);
1690
1691 if ((group.getCompanyId() != companyId) ||
1692 (group.getFriendlyURL() == null) ||
1693 !group.getFriendlyURL().equals(friendlyURL)) {
1694 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
1695 finderArgs, group);
1696 }
1697 }
1698 }
1699 catch (Exception e) {
1700 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_F,
1701 finderArgs);
1702
1703 throw processException(e);
1704 }
1705 finally {
1706 closeSession(session);
1707 }
1708 }
1709
1710 if (result instanceof List<?>) {
1711 return null;
1712 }
1713 else {
1714 return (Group)result;
1715 }
1716 }
1717
1718
1726 public Group removeByC_F(long companyId, String friendlyURL)
1727 throws NoSuchGroupException, SystemException {
1728 Group group = findByC_F(companyId, friendlyURL);
1729
1730 return remove(group);
1731 }
1732
1733
1741 public int countByC_F(long companyId, String friendlyURL)
1742 throws SystemException {
1743 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_F;
1744
1745 Object[] finderArgs = new Object[] { companyId, friendlyURL };
1746
1747 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1748 this);
1749
1750 if (count == null) {
1751 StringBundler query = new StringBundler(3);
1752
1753 query.append(_SQL_COUNT_GROUP__WHERE);
1754
1755 query.append(_FINDER_COLUMN_C_F_COMPANYID_2);
1756
1757 boolean bindFriendlyURL = false;
1758
1759 if (friendlyURL == null) {
1760 query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_1);
1761 }
1762 else if (friendlyURL.equals(StringPool.BLANK)) {
1763 query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_3);
1764 }
1765 else {
1766 bindFriendlyURL = true;
1767
1768 query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_2);
1769 }
1770
1771 String sql = query.toString();
1772
1773 Session session = null;
1774
1775 try {
1776 session = openSession();
1777
1778 Query q = session.createQuery(sql);
1779
1780 QueryPos qPos = QueryPos.getInstance(q);
1781
1782 qPos.add(companyId);
1783
1784 if (bindFriendlyURL) {
1785 qPos.add(friendlyURL);
1786 }
1787
1788 count = (Long)q.uniqueResult();
1789
1790 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1791 }
1792 catch (Exception e) {
1793 FinderCacheUtil.removeResult(finderPath, finderArgs);
1794
1795 throw processException(e);
1796 }
1797 finally {
1798 closeSession(session);
1799 }
1800 }
1801
1802 return count.intValue();
1803 }
1804
1805 private static final String _FINDER_COLUMN_C_F_COMPANYID_2 = "group_.companyId = ? AND ";
1806 private static final String _FINDER_COLUMN_C_F_FRIENDLYURL_1 = "group_.friendlyURL IS NULL";
1807 private static final String _FINDER_COLUMN_C_F_FRIENDLYURL_2 = "group_.friendlyURL = ?";
1808 private static final String _FINDER_COLUMN_C_F_FRIENDLYURL_3 = "(group_.friendlyURL IS NULL OR group_.friendlyURL = '')";
1809 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
1810 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
1811 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_S",
1812 new String[] {
1813 Long.class.getName(), Boolean.class.getName(),
1814
1815 Integer.class.getName(), Integer.class.getName(),
1816 OrderByComparator.class.getName()
1817 });
1818 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
1819 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
1820 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_S",
1821 new String[] { Long.class.getName(), Boolean.class.getName() },
1822 GroupModelImpl.COMPANYID_COLUMN_BITMASK |
1823 GroupModelImpl.SITE_COLUMN_BITMASK |
1824 GroupModelImpl.NAME_COLUMN_BITMASK);
1825 public static final FinderPath FINDER_PATH_COUNT_BY_C_S = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
1826 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
1827 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_S",
1828 new String[] { Long.class.getName(), Boolean.class.getName() });
1829
1830
1838 public List<Group> findByC_S(long companyId, boolean site)
1839 throws SystemException {
1840 return findByC_S(companyId, site, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1841 null);
1842 }
1843
1844
1858 public List<Group> findByC_S(long companyId, boolean site, int start,
1859 int end) throws SystemException {
1860 return findByC_S(companyId, site, start, end, null);
1861 }
1862
1863
1878 public List<Group> findByC_S(long companyId, boolean site, int start,
1879 int end, OrderByComparator orderByComparator) throws SystemException {
1880 boolean pagination = true;
1881 FinderPath finderPath = null;
1882 Object[] finderArgs = null;
1883
1884 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1885 (orderByComparator == null)) {
1886 pagination = false;
1887 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S;
1888 finderArgs = new Object[] { companyId, site };
1889 }
1890 else {
1891 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S;
1892 finderArgs = new Object[] {
1893 companyId, site,
1894
1895 start, end, orderByComparator
1896 };
1897 }
1898
1899 List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
1900 finderArgs, this);
1901
1902 if ((list != null) && !list.isEmpty()) {
1903 for (Group group : list) {
1904 if ((companyId != group.getCompanyId()) ||
1905 (site != group.getSite())) {
1906 list = null;
1907
1908 break;
1909 }
1910 }
1911 }
1912
1913 if (list == null) {
1914 StringBundler query = null;
1915
1916 if (orderByComparator != null) {
1917 query = new StringBundler(4 +
1918 (orderByComparator.getOrderByFields().length * 3));
1919 }
1920 else {
1921 query = new StringBundler(4);
1922 }
1923
1924 query.append(_SQL_SELECT_GROUP__WHERE);
1925
1926 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
1927
1928 query.append(_FINDER_COLUMN_C_S_SITE_2);
1929
1930 if (orderByComparator != null) {
1931 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1932 orderByComparator);
1933 }
1934 else
1935 if (pagination) {
1936 query.append(GroupModelImpl.ORDER_BY_JPQL);
1937 }
1938
1939 String sql = query.toString();
1940
1941 Session session = null;
1942
1943 try {
1944 session = openSession();
1945
1946 Query q = session.createQuery(sql);
1947
1948 QueryPos qPos = QueryPos.getInstance(q);
1949
1950 qPos.add(companyId);
1951
1952 qPos.add(site);
1953
1954 if (!pagination) {
1955 list = (List<Group>)QueryUtil.list(q, getDialect(), start,
1956 end, false);
1957
1958 Collections.sort(list);
1959
1960 list = new UnmodifiableList<Group>(list);
1961 }
1962 else {
1963 list = (List<Group>)QueryUtil.list(q, getDialect(), start,
1964 end);
1965 }
1966
1967 cacheResult(list);
1968
1969 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1970 }
1971 catch (Exception e) {
1972 FinderCacheUtil.removeResult(finderPath, finderArgs);
1973
1974 throw processException(e);
1975 }
1976 finally {
1977 closeSession(session);
1978 }
1979 }
1980
1981 return list;
1982 }
1983
1984
1994 public Group findByC_S_First(long companyId, boolean site,
1995 OrderByComparator orderByComparator)
1996 throws NoSuchGroupException, SystemException {
1997 Group group = fetchByC_S_First(companyId, site, orderByComparator);
1998
1999 if (group != null) {
2000 return group;
2001 }
2002
2003 StringBundler msg = new StringBundler(6);
2004
2005 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2006
2007 msg.append("companyId=");
2008 msg.append(companyId);
2009
2010 msg.append(", site=");
2011 msg.append(site);
2012
2013 msg.append(StringPool.CLOSE_CURLY_BRACE);
2014
2015 throw new NoSuchGroupException(msg.toString());
2016 }
2017
2018
2027 public Group fetchByC_S_First(long companyId, boolean site,
2028 OrderByComparator orderByComparator) throws SystemException {
2029 List<Group> list = findByC_S(companyId, site, 0, 1, orderByComparator);
2030
2031 if (!list.isEmpty()) {
2032 return list.get(0);
2033 }
2034
2035 return null;
2036 }
2037
2038
2048 public Group findByC_S_Last(long companyId, boolean site,
2049 OrderByComparator orderByComparator)
2050 throws NoSuchGroupException, SystemException {
2051 Group group = fetchByC_S_Last(companyId, site, orderByComparator);
2052
2053 if (group != null) {
2054 return group;
2055 }
2056
2057 StringBundler msg = new StringBundler(6);
2058
2059 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2060
2061 msg.append("companyId=");
2062 msg.append(companyId);
2063
2064 msg.append(", site=");
2065 msg.append(site);
2066
2067 msg.append(StringPool.CLOSE_CURLY_BRACE);
2068
2069 throw new NoSuchGroupException(msg.toString());
2070 }
2071
2072
2081 public Group fetchByC_S_Last(long companyId, boolean site,
2082 OrderByComparator orderByComparator) throws SystemException {
2083 int count = countByC_S(companyId, site);
2084
2085 List<Group> list = findByC_S(companyId, site, count - 1, count,
2086 orderByComparator);
2087
2088 if (!list.isEmpty()) {
2089 return list.get(0);
2090 }
2091
2092 return null;
2093 }
2094
2095
2106 public Group[] findByC_S_PrevAndNext(long groupId, long companyId,
2107 boolean site, OrderByComparator orderByComparator)
2108 throws NoSuchGroupException, SystemException {
2109 Group group = findByPrimaryKey(groupId);
2110
2111 Session session = null;
2112
2113 try {
2114 session = openSession();
2115
2116 Group[] array = new GroupImpl[3];
2117
2118 array[0] = getByC_S_PrevAndNext(session, group, companyId, site,
2119 orderByComparator, true);
2120
2121 array[1] = group;
2122
2123 array[2] = getByC_S_PrevAndNext(session, group, companyId, site,
2124 orderByComparator, false);
2125
2126 return array;
2127 }
2128 catch (Exception e) {
2129 throw processException(e);
2130 }
2131 finally {
2132 closeSession(session);
2133 }
2134 }
2135
2136 protected Group getByC_S_PrevAndNext(Session session, Group group,
2137 long companyId, boolean site, OrderByComparator orderByComparator,
2138 boolean previous) {
2139 StringBundler query = null;
2140
2141 if (orderByComparator != null) {
2142 query = new StringBundler(6 +
2143 (orderByComparator.getOrderByFields().length * 6));
2144 }
2145 else {
2146 query = new StringBundler(3);
2147 }
2148
2149 query.append(_SQL_SELECT_GROUP__WHERE);
2150
2151 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
2152
2153 query.append(_FINDER_COLUMN_C_S_SITE_2);
2154
2155 if (orderByComparator != null) {
2156 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2157
2158 if (orderByConditionFields.length > 0) {
2159 query.append(WHERE_AND);
2160 }
2161
2162 for (int i = 0; i < orderByConditionFields.length; i++) {
2163 query.append(_ORDER_BY_ENTITY_ALIAS);
2164 query.append(orderByConditionFields[i]);
2165
2166 if ((i + 1) < orderByConditionFields.length) {
2167 if (orderByComparator.isAscending() ^ previous) {
2168 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2169 }
2170 else {
2171 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2172 }
2173 }
2174 else {
2175 if (orderByComparator.isAscending() ^ previous) {
2176 query.append(WHERE_GREATER_THAN);
2177 }
2178 else {
2179 query.append(WHERE_LESSER_THAN);
2180 }
2181 }
2182 }
2183
2184 query.append(ORDER_BY_CLAUSE);
2185
2186 String[] orderByFields = orderByComparator.getOrderByFields();
2187
2188 for (int i = 0; i < orderByFields.length; i++) {
2189 query.append(_ORDER_BY_ENTITY_ALIAS);
2190 query.append(orderByFields[i]);
2191
2192 if ((i + 1) < orderByFields.length) {
2193 if (orderByComparator.isAscending() ^ previous) {
2194 query.append(ORDER_BY_ASC_HAS_NEXT);
2195 }
2196 else {
2197 query.append(ORDER_BY_DESC_HAS_NEXT);
2198 }
2199 }
2200 else {
2201 if (orderByComparator.isAscending() ^ previous) {
2202 query.append(ORDER_BY_ASC);
2203 }
2204 else {
2205 query.append(ORDER_BY_DESC);
2206 }
2207 }
2208 }
2209 }
2210 else {
2211 query.append(GroupModelImpl.ORDER_BY_JPQL);
2212 }
2213
2214 String sql = query.toString();
2215
2216 Query q = session.createQuery(sql);
2217
2218 q.setFirstResult(0);
2219 q.setMaxResults(2);
2220
2221 QueryPos qPos = QueryPos.getInstance(q);
2222
2223 qPos.add(companyId);
2224
2225 qPos.add(site);
2226
2227 if (orderByComparator != null) {
2228 Object[] values = orderByComparator.getOrderByConditionValues(group);
2229
2230 for (Object value : values) {
2231 qPos.add(value);
2232 }
2233 }
2234
2235 List<Group> list = q.list();
2236
2237 if (list.size() == 2) {
2238 return list.get(1);
2239 }
2240 else {
2241 return null;
2242 }
2243 }
2244
2245
2252 public void removeByC_S(long companyId, boolean site)
2253 throws SystemException {
2254 for (Group group : findByC_S(companyId, site, QueryUtil.ALL_POS,
2255 QueryUtil.ALL_POS, null)) {
2256 remove(group);
2257 }
2258 }
2259
2260
2268 public int countByC_S(long companyId, boolean site)
2269 throws SystemException {
2270 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_S;
2271
2272 Object[] finderArgs = new Object[] { companyId, site };
2273
2274 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2275 this);
2276
2277 if (count == null) {
2278 StringBundler query = new StringBundler(3);
2279
2280 query.append(_SQL_COUNT_GROUP__WHERE);
2281
2282 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
2283
2284 query.append(_FINDER_COLUMN_C_S_SITE_2);
2285
2286 String sql = query.toString();
2287
2288 Session session = null;
2289
2290 try {
2291 session = openSession();
2292
2293 Query q = session.createQuery(sql);
2294
2295 QueryPos qPos = QueryPos.getInstance(q);
2296
2297 qPos.add(companyId);
2298
2299 qPos.add(site);
2300
2301 count = (Long)q.uniqueResult();
2302
2303 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2304 }
2305 catch (Exception e) {
2306 FinderCacheUtil.removeResult(finderPath, finderArgs);
2307
2308 throw processException(e);
2309 }
2310 finally {
2311 closeSession(session);
2312 }
2313 }
2314
2315 return count.intValue();
2316 }
2317
2318 private static final String _FINDER_COLUMN_C_S_COMPANYID_2 = "group_.companyId = ? AND ";
2319 private static final String _FINDER_COLUMN_C_S_SITE_2 = "group_.site = ?";
2320 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_T_A = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
2321 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
2322 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByT_A",
2323 new String[] {
2324 Integer.class.getName(), Boolean.class.getName(),
2325
2326 Integer.class.getName(), Integer.class.getName(),
2327 OrderByComparator.class.getName()
2328 });
2329 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
2330 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
2331 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByT_A",
2332 new String[] { Integer.class.getName(), Boolean.class.getName() },
2333 GroupModelImpl.TYPE_COLUMN_BITMASK |
2334 GroupModelImpl.ACTIVE_COLUMN_BITMASK |
2335 GroupModelImpl.NAME_COLUMN_BITMASK);
2336 public static final FinderPath FINDER_PATH_COUNT_BY_T_A = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
2337 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
2338 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByT_A",
2339 new String[] { Integer.class.getName(), Boolean.class.getName() });
2340
2341
2349 public List<Group> findByT_A(int type, boolean active)
2350 throws SystemException {
2351 return findByT_A(type, active, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2352 null);
2353 }
2354
2355
2369 public List<Group> findByT_A(int type, boolean active, int start, int end)
2370 throws SystemException {
2371 return findByT_A(type, active, start, end, null);
2372 }
2373
2374
2389 public List<Group> findByT_A(int type, boolean active, int start, int end,
2390 OrderByComparator orderByComparator) throws SystemException {
2391 boolean pagination = true;
2392 FinderPath finderPath = null;
2393 Object[] finderArgs = null;
2394
2395 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2396 (orderByComparator == null)) {
2397 pagination = false;
2398 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A;
2399 finderArgs = new Object[] { type, active };
2400 }
2401 else {
2402 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_T_A;
2403 finderArgs = new Object[] {
2404 type, active,
2405
2406 start, end, orderByComparator
2407 };
2408 }
2409
2410 List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
2411 finderArgs, this);
2412
2413 if ((list != null) && !list.isEmpty()) {
2414 for (Group group : list) {
2415 if ((type != group.getType()) || (active != group.getActive())) {
2416 list = null;
2417
2418 break;
2419 }
2420 }
2421 }
2422
2423 if (list == null) {
2424 StringBundler query = null;
2425
2426 if (orderByComparator != null) {
2427 query = new StringBundler(4 +
2428 (orderByComparator.getOrderByFields().length * 3));
2429 }
2430 else {
2431 query = new StringBundler(4);
2432 }
2433
2434 query.append(_SQL_SELECT_GROUP__WHERE);
2435
2436 query.append(_FINDER_COLUMN_T_A_TYPE_2);
2437
2438 query.append(_FINDER_COLUMN_T_A_ACTIVE_2);
2439
2440 if (orderByComparator != null) {
2441 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2442 orderByComparator);
2443 }
2444 else
2445 if (pagination) {
2446 query.append(GroupModelImpl.ORDER_BY_JPQL);
2447 }
2448
2449 String sql = query.toString();
2450
2451 Session session = null;
2452
2453 try {
2454 session = openSession();
2455
2456 Query q = session.createQuery(sql);
2457
2458 QueryPos qPos = QueryPos.getInstance(q);
2459
2460 qPos.add(type);
2461
2462 qPos.add(active);
2463
2464 if (!pagination) {
2465 list = (List<Group>)QueryUtil.list(q, getDialect(), start,
2466 end, false);
2467
2468 Collections.sort(list);
2469
2470 list = new UnmodifiableList<Group>(list);
2471 }
2472 else {
2473 list = (List<Group>)QueryUtil.list(q, getDialect(), start,
2474 end);
2475 }
2476
2477 cacheResult(list);
2478
2479 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2480 }
2481 catch (Exception e) {
2482 FinderCacheUtil.removeResult(finderPath, finderArgs);
2483
2484 throw processException(e);
2485 }
2486 finally {
2487 closeSession(session);
2488 }
2489 }
2490
2491 return list;
2492 }
2493
2494
2504 public Group findByT_A_First(int type, boolean active,
2505 OrderByComparator orderByComparator)
2506 throws NoSuchGroupException, SystemException {
2507 Group group = fetchByT_A_First(type, active, orderByComparator);
2508
2509 if (group != null) {
2510 return group;
2511 }
2512
2513 StringBundler msg = new StringBundler(6);
2514
2515 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2516
2517 msg.append("type=");
2518 msg.append(type);
2519
2520 msg.append(", active=");
2521 msg.append(active);
2522
2523 msg.append(StringPool.CLOSE_CURLY_BRACE);
2524
2525 throw new NoSuchGroupException(msg.toString());
2526 }
2527
2528
2537 public Group fetchByT_A_First(int type, boolean active,
2538 OrderByComparator orderByComparator) throws SystemException {
2539 List<Group> list = findByT_A(type, active, 0, 1, orderByComparator);
2540
2541 if (!list.isEmpty()) {
2542 return list.get(0);
2543 }
2544
2545 return null;
2546 }
2547
2548
2558 public Group findByT_A_Last(int type, boolean active,
2559 OrderByComparator orderByComparator)
2560 throws NoSuchGroupException, SystemException {
2561 Group group = fetchByT_A_Last(type, active, orderByComparator);
2562
2563 if (group != null) {
2564 return group;
2565 }
2566
2567 StringBundler msg = new StringBundler(6);
2568
2569 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2570
2571 msg.append("type=");
2572 msg.append(type);
2573
2574 msg.append(", active=");
2575 msg.append(active);
2576
2577 msg.append(StringPool.CLOSE_CURLY_BRACE);
2578
2579 throw new NoSuchGroupException(msg.toString());
2580 }
2581
2582
2591 public Group fetchByT_A_Last(int type, boolean active,
2592 OrderByComparator orderByComparator) throws SystemException {
2593 int count = countByT_A(type, active);
2594
2595 List<Group> list = findByT_A(type, active, count - 1, count,
2596 orderByComparator);
2597
2598 if (!list.isEmpty()) {
2599 return list.get(0);
2600 }
2601
2602 return null;
2603 }
2604
2605
2616 public Group[] findByT_A_PrevAndNext(long groupId, int type,
2617 boolean active, OrderByComparator orderByComparator)
2618 throws NoSuchGroupException, SystemException {
2619 Group group = findByPrimaryKey(groupId);
2620
2621 Session session = null;
2622
2623 try {
2624 session = openSession();
2625
2626 Group[] array = new GroupImpl[3];
2627
2628 array[0] = getByT_A_PrevAndNext(session, group, type, active,
2629 orderByComparator, true);
2630
2631 array[1] = group;
2632
2633 array[2] = getByT_A_PrevAndNext(session, group, type, active,
2634 orderByComparator, false);
2635
2636 return array;
2637 }
2638 catch (Exception e) {
2639 throw processException(e);
2640 }
2641 finally {
2642 closeSession(session);
2643 }
2644 }
2645
2646 protected Group getByT_A_PrevAndNext(Session session, Group group,
2647 int type, boolean active, OrderByComparator orderByComparator,
2648 boolean previous) {
2649 StringBundler query = null;
2650
2651 if (orderByComparator != null) {
2652 query = new StringBundler(6 +
2653 (orderByComparator.getOrderByFields().length * 6));
2654 }
2655 else {
2656 query = new StringBundler(3);
2657 }
2658
2659 query.append(_SQL_SELECT_GROUP__WHERE);
2660
2661 query.append(_FINDER_COLUMN_T_A_TYPE_2);
2662
2663 query.append(_FINDER_COLUMN_T_A_ACTIVE_2);
2664
2665 if (orderByComparator != null) {
2666 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2667
2668 if (orderByConditionFields.length > 0) {
2669 query.append(WHERE_AND);
2670 }
2671
2672 for (int i = 0; i < orderByConditionFields.length; i++) {
2673 query.append(_ORDER_BY_ENTITY_ALIAS);
2674 query.append(orderByConditionFields[i]);
2675
2676 if ((i + 1) < orderByConditionFields.length) {
2677 if (orderByComparator.isAscending() ^ previous) {
2678 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2679 }
2680 else {
2681 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2682 }
2683 }
2684 else {
2685 if (orderByComparator.isAscending() ^ previous) {
2686 query.append(WHERE_GREATER_THAN);
2687 }
2688 else {
2689 query.append(WHERE_LESSER_THAN);
2690 }
2691 }
2692 }
2693
2694 query.append(ORDER_BY_CLAUSE);
2695
2696 String[] orderByFields = orderByComparator.getOrderByFields();
2697
2698 for (int i = 0; i < orderByFields.length; i++) {
2699 query.append(_ORDER_BY_ENTITY_ALIAS);
2700 query.append(orderByFields[i]);
2701
2702 if ((i + 1) < orderByFields.length) {
2703 if (orderByComparator.isAscending() ^ previous) {
2704 query.append(ORDER_BY_ASC_HAS_NEXT);
2705 }
2706 else {
2707 query.append(ORDER_BY_DESC_HAS_NEXT);
2708 }
2709 }
2710 else {
2711 if (orderByComparator.isAscending() ^ previous) {
2712 query.append(ORDER_BY_ASC);
2713 }
2714 else {
2715 query.append(ORDER_BY_DESC);
2716 }
2717 }
2718 }
2719 }
2720 else {
2721 query.append(GroupModelImpl.ORDER_BY_JPQL);
2722 }
2723
2724 String sql = query.toString();
2725
2726 Query q = session.createQuery(sql);
2727
2728 q.setFirstResult(0);
2729 q.setMaxResults(2);
2730
2731 QueryPos qPos = QueryPos.getInstance(q);
2732
2733 qPos.add(type);
2734
2735 qPos.add(active);
2736
2737 if (orderByComparator != null) {
2738 Object[] values = orderByComparator.getOrderByConditionValues(group);
2739
2740 for (Object value : values) {
2741 qPos.add(value);
2742 }
2743 }
2744
2745 List<Group> list = q.list();
2746
2747 if (list.size() == 2) {
2748 return list.get(1);
2749 }
2750 else {
2751 return null;
2752 }
2753 }
2754
2755
2762 public void removeByT_A(int type, boolean active) throws SystemException {
2763 for (Group group : findByT_A(type, active, QueryUtil.ALL_POS,
2764 QueryUtil.ALL_POS, null)) {
2765 remove(group);
2766 }
2767 }
2768
2769
2777 public int countByT_A(int type, boolean active) throws SystemException {
2778 FinderPath finderPath = FINDER_PATH_COUNT_BY_T_A;
2779
2780 Object[] finderArgs = new Object[] { type, active };
2781
2782 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2783 this);
2784
2785 if (count == null) {
2786 StringBundler query = new StringBundler(3);
2787
2788 query.append(_SQL_COUNT_GROUP__WHERE);
2789
2790 query.append(_FINDER_COLUMN_T_A_TYPE_2);
2791
2792 query.append(_FINDER_COLUMN_T_A_ACTIVE_2);
2793
2794 String sql = query.toString();
2795
2796 Session session = null;
2797
2798 try {
2799 session = openSession();
2800
2801 Query q = session.createQuery(sql);
2802
2803 QueryPos qPos = QueryPos.getInstance(q);
2804
2805 qPos.add(type);
2806
2807 qPos.add(active);
2808
2809 count = (Long)q.uniqueResult();
2810
2811 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2812 }
2813 catch (Exception e) {
2814 FinderCacheUtil.removeResult(finderPath, finderArgs);
2815
2816 throw processException(e);
2817 }
2818 finally {
2819 closeSession(session);
2820 }
2821 }
2822
2823 return count.intValue();
2824 }
2825
2826 private static final String _FINDER_COLUMN_T_A_TYPE_2 = "group_.type = ? AND ";
2827 private static final String _FINDER_COLUMN_T_A_ACTIVE_2 = "group_.active = ?";
2828 public static final FinderPath FINDER_PATH_FETCH_BY_C_C_C = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
2829 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
2830 FINDER_CLASS_NAME_ENTITY, "fetchByC_C_C",
2831 new String[] {
2832 Long.class.getName(), Long.class.getName(), Long.class.getName()
2833 },
2834 GroupModelImpl.COMPANYID_COLUMN_BITMASK |
2835 GroupModelImpl.CLASSNAMEID_COLUMN_BITMASK |
2836 GroupModelImpl.CLASSPK_COLUMN_BITMASK);
2837 public static final FinderPath FINDER_PATH_COUNT_BY_C_C_C = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
2838 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
2839 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_C",
2840 new String[] {
2841 Long.class.getName(), Long.class.getName(), Long.class.getName()
2842 });
2843
2844
2854 public Group findByC_C_C(long companyId, long classNameId, long classPK)
2855 throws NoSuchGroupException, SystemException {
2856 Group group = fetchByC_C_C(companyId, classNameId, classPK);
2857
2858 if (group == null) {
2859 StringBundler msg = new StringBundler(8);
2860
2861 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2862
2863 msg.append("companyId=");
2864 msg.append(companyId);
2865
2866 msg.append(", classNameId=");
2867 msg.append(classNameId);
2868
2869 msg.append(", classPK=");
2870 msg.append(classPK);
2871
2872 msg.append(StringPool.CLOSE_CURLY_BRACE);
2873
2874 if (_log.isWarnEnabled()) {
2875 _log.warn(msg.toString());
2876 }
2877
2878 throw new NoSuchGroupException(msg.toString());
2879 }
2880
2881 return group;
2882 }
2883
2884
2893 public Group fetchByC_C_C(long companyId, long classNameId, long classPK)
2894 throws SystemException {
2895 return fetchByC_C_C(companyId, classNameId, classPK, true);
2896 }
2897
2898
2908 public Group fetchByC_C_C(long companyId, long classNameId, long classPK,
2909 boolean retrieveFromCache) throws SystemException {
2910 Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
2911
2912 Object result = null;
2913
2914 if (retrieveFromCache) {
2915 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C_C,
2916 finderArgs, this);
2917 }
2918
2919 if (result instanceof Group) {
2920 Group group = (Group)result;
2921
2922 if ((companyId != group.getCompanyId()) ||
2923 (classNameId != group.getClassNameId()) ||
2924 (classPK != group.getClassPK())) {
2925 result = null;
2926 }
2927 }
2928
2929 if (result == null) {
2930 StringBundler query = new StringBundler(5);
2931
2932 query.append(_SQL_SELECT_GROUP__WHERE);
2933
2934 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
2935
2936 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
2937
2938 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
2939
2940 String sql = query.toString();
2941
2942 Session session = null;
2943
2944 try {
2945 session = openSession();
2946
2947 Query q = session.createQuery(sql);
2948
2949 QueryPos qPos = QueryPos.getInstance(q);
2950
2951 qPos.add(companyId);
2952
2953 qPos.add(classNameId);
2954
2955 qPos.add(classPK);
2956
2957 List<Group> list = q.list();
2958
2959 if (list.isEmpty()) {
2960 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
2961 finderArgs, list);
2962 }
2963 else {
2964 Group group = list.get(0);
2965
2966 result = group;
2967
2968 cacheResult(group);
2969
2970 if ((group.getCompanyId() != companyId) ||
2971 (group.getClassNameId() != classNameId) ||
2972 (group.getClassPK() != classPK)) {
2973 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
2974 finderArgs, group);
2975 }
2976 }
2977 }
2978 catch (Exception e) {
2979 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C,
2980 finderArgs);
2981
2982 throw processException(e);
2983 }
2984 finally {
2985 closeSession(session);
2986 }
2987 }
2988
2989 if (result instanceof List<?>) {
2990 return null;
2991 }
2992 else {
2993 return (Group)result;
2994 }
2995 }
2996
2997
3006 public Group removeByC_C_C(long companyId, long classNameId, long classPK)
3007 throws NoSuchGroupException, SystemException {
3008 Group group = findByC_C_C(companyId, classNameId, classPK);
3009
3010 return remove(group);
3011 }
3012
3013
3022 public int countByC_C_C(long companyId, long classNameId, long classPK)
3023 throws SystemException {
3024 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C_C;
3025
3026 Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
3027
3028 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3029 this);
3030
3031 if (count == null) {
3032 StringBundler query = new StringBundler(4);
3033
3034 query.append(_SQL_COUNT_GROUP__WHERE);
3035
3036 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
3037
3038 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
3039
3040 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
3041
3042 String sql = query.toString();
3043
3044 Session session = null;
3045
3046 try {
3047 session = openSession();
3048
3049 Query q = session.createQuery(sql);
3050
3051 QueryPos qPos = QueryPos.getInstance(q);
3052
3053 qPos.add(companyId);
3054
3055 qPos.add(classNameId);
3056
3057 qPos.add(classPK);
3058
3059 count = (Long)q.uniqueResult();
3060
3061 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3062 }
3063 catch (Exception e) {
3064 FinderCacheUtil.removeResult(finderPath, finderArgs);
3065
3066 throw processException(e);
3067 }
3068 finally {
3069 closeSession(session);
3070 }
3071 }
3072
3073 return count.intValue();
3074 }
3075
3076 private static final String _FINDER_COLUMN_C_C_C_COMPANYID_2 = "group_.companyId = ? AND ";
3077 private static final String _FINDER_COLUMN_C_C_C_CLASSNAMEID_2 = "group_.classNameId = ? AND ";
3078 private static final String _FINDER_COLUMN_C_C_C_CLASSPK_2 = "group_.classPK = ?";
3079 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_P = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
3080 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
3081 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C_P",
3082 new String[] {
3083 Long.class.getName(), Long.class.getName(), Long.class.getName(),
3084
3085 Integer.class.getName(), Integer.class.getName(),
3086 OrderByComparator.class.getName()
3087 });
3088 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_P = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
3089 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
3090 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C_P",
3091 new String[] {
3092 Long.class.getName(), Long.class.getName(), Long.class.getName()
3093 },
3094 GroupModelImpl.COMPANYID_COLUMN_BITMASK |
3095 GroupModelImpl.CLASSNAMEID_COLUMN_BITMASK |
3096 GroupModelImpl.PARENTGROUPID_COLUMN_BITMASK |
3097 GroupModelImpl.NAME_COLUMN_BITMASK);
3098 public static final FinderPath FINDER_PATH_COUNT_BY_C_C_P = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
3099 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
3100 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_P",
3101 new String[] {
3102 Long.class.getName(), Long.class.getName(), Long.class.getName()
3103 });
3104
3105
3114 public List<Group> findByC_C_P(long companyId, long classNameId,
3115 long parentGroupId) throws SystemException {
3116 return findByC_C_P(companyId, classNameId, parentGroupId,
3117 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3118 }
3119
3120
3135 public List<Group> findByC_C_P(long companyId, long classNameId,
3136 long parentGroupId, int start, int end) throws SystemException {
3137 return findByC_C_P(companyId, classNameId, parentGroupId, start, end,
3138 null);
3139 }
3140
3141
3157 public List<Group> findByC_C_P(long companyId, long classNameId,
3158 long parentGroupId, int start, int end,
3159 OrderByComparator orderByComparator) throws SystemException {
3160 boolean pagination = true;
3161 FinderPath finderPath = null;
3162 Object[] finderArgs = null;
3163
3164 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3165 (orderByComparator == null)) {
3166 pagination = false;
3167 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_P;
3168 finderArgs = new Object[] { companyId, classNameId, parentGroupId };
3169 }
3170 else {
3171 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_P;
3172 finderArgs = new Object[] {
3173 companyId, classNameId, parentGroupId,
3174
3175 start, end, orderByComparator
3176 };
3177 }
3178
3179 List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
3180 finderArgs, this);
3181
3182 if ((list != null) && !list.isEmpty()) {
3183 for (Group group : list) {
3184 if ((companyId != group.getCompanyId()) ||
3185 (classNameId != group.getClassNameId()) ||
3186 (parentGroupId != group.getParentGroupId())) {
3187 list = null;
3188
3189 break;
3190 }
3191 }
3192 }
3193
3194 if (list == null) {
3195 StringBundler query = null;
3196
3197 if (orderByComparator != null) {
3198 query = new StringBundler(5 +
3199 (orderByComparator.getOrderByFields().length * 3));
3200 }
3201 else {
3202 query = new StringBundler(5);
3203 }
3204
3205 query.append(_SQL_SELECT_GROUP__WHERE);
3206
3207 query.append(_FINDER_COLUMN_C_C_P_COMPANYID_2);
3208
3209 query.append(_FINDER_COLUMN_C_C_P_CLASSNAMEID_2);
3210
3211 query.append(_FINDER_COLUMN_C_C_P_PARENTGROUPID_2);
3212
3213 if (orderByComparator != null) {
3214 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3215 orderByComparator);
3216 }
3217 else
3218 if (pagination) {
3219 query.append(GroupModelImpl.ORDER_BY_JPQL);
3220 }
3221
3222 String sql = query.toString();
3223
3224 Session session = null;
3225
3226 try {
3227 session = openSession();
3228
3229 Query q = session.createQuery(sql);
3230
3231 QueryPos qPos = QueryPos.getInstance(q);
3232
3233 qPos.add(companyId);
3234
3235 qPos.add(classNameId);
3236
3237 qPos.add(parentGroupId);
3238
3239 if (!pagination) {
3240 list = (List<Group>)QueryUtil.list(q, getDialect(), start,
3241 end, false);
3242
3243 Collections.sort(list);
3244
3245 list = new UnmodifiableList<Group>(list);
3246 }
3247 else {
3248 list = (List<Group>)QueryUtil.list(q, getDialect(), start,
3249 end);
3250 }
3251
3252 cacheResult(list);
3253
3254 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3255 }
3256 catch (Exception e) {
3257 FinderCacheUtil.removeResult(finderPath, finderArgs);
3258
3259 throw processException(e);
3260 }
3261 finally {
3262 closeSession(session);
3263 }
3264 }
3265
3266 return list;
3267 }
3268
3269
3280 public Group findByC_C_P_First(long companyId, long classNameId,
3281 long parentGroupId, OrderByComparator orderByComparator)
3282 throws NoSuchGroupException, SystemException {
3283 Group group = fetchByC_C_P_First(companyId, classNameId, parentGroupId,
3284 orderByComparator);
3285
3286 if (group != null) {
3287 return group;
3288 }
3289
3290 StringBundler msg = new StringBundler(8);
3291
3292 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3293
3294 msg.append("companyId=");
3295 msg.append(companyId);
3296
3297 msg.append(", classNameId=");
3298 msg.append(classNameId);
3299
3300 msg.append(", parentGroupId=");
3301 msg.append(parentGroupId);
3302
3303 msg.append(StringPool.CLOSE_CURLY_BRACE);
3304
3305 throw new NoSuchGroupException(msg.toString());
3306 }
3307
3308
3318 public Group fetchByC_C_P_First(long companyId, long classNameId,
3319 long parentGroupId, OrderByComparator orderByComparator)
3320 throws SystemException {
3321 List<Group> list = findByC_C_P(companyId, classNameId, parentGroupId,
3322 0, 1, orderByComparator);
3323
3324 if (!list.isEmpty()) {
3325 return list.get(0);
3326 }
3327
3328 return null;
3329 }
3330
3331
3342 public Group findByC_C_P_Last(long companyId, long classNameId,
3343 long parentGroupId, OrderByComparator orderByComparator)
3344 throws NoSuchGroupException, SystemException {
3345 Group group = fetchByC_C_P_Last(companyId, classNameId, parentGroupId,
3346 orderByComparator);
3347
3348 if (group != null) {
3349 return group;
3350 }
3351
3352 StringBundler msg = new StringBundler(8);
3353
3354 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3355
3356 msg.append("companyId=");
3357 msg.append(companyId);
3358
3359 msg.append(", classNameId=");
3360 msg.append(classNameId);
3361
3362 msg.append(", parentGroupId=");
3363 msg.append(parentGroupId);
3364
3365 msg.append(StringPool.CLOSE_CURLY_BRACE);
3366
3367 throw new NoSuchGroupException(msg.toString());
3368 }
3369
3370
3380 public Group fetchByC_C_P_Last(long companyId, long classNameId,
3381 long parentGroupId, OrderByComparator orderByComparator)
3382 throws SystemException {
3383 int count = countByC_C_P(companyId, classNameId, parentGroupId);
3384
3385 List<Group> list = findByC_C_P(companyId, classNameId, parentGroupId,
3386 count - 1, count, orderByComparator);
3387
3388 if (!list.isEmpty()) {
3389 return list.get(0);
3390 }
3391
3392 return null;
3393 }
3394
3395
3407 public Group[] findByC_C_P_PrevAndNext(long groupId, long companyId,
3408 long classNameId, long parentGroupId,
3409 OrderByComparator orderByComparator)
3410 throws NoSuchGroupException, SystemException {
3411 Group group = findByPrimaryKey(groupId);
3412
3413 Session session = null;
3414
3415 try {
3416 session = openSession();
3417
3418 Group[] array = new GroupImpl[3];
3419
3420 array[0] = getByC_C_P_PrevAndNext(session, group, companyId,
3421 classNameId, parentGroupId, orderByComparator, true);
3422
3423 array[1] = group;
3424
3425 array[2] = getByC_C_P_PrevAndNext(session, group, companyId,
3426 classNameId, parentGroupId, orderByComparator, false);
3427
3428 return array;
3429 }
3430 catch (Exception e) {
3431 throw processException(e);
3432 }
3433 finally {
3434 closeSession(session);
3435 }
3436 }
3437
3438 protected Group getByC_C_P_PrevAndNext(Session session, Group group,
3439 long companyId, long classNameId, long parentGroupId,
3440 OrderByComparator orderByComparator, boolean previous) {
3441 StringBundler query = null;
3442
3443 if (orderByComparator != null) {
3444 query = new StringBundler(6 +
3445 (orderByComparator.getOrderByFields().length * 6));
3446 }
3447 else {
3448 query = new StringBundler(3);
3449 }
3450
3451 query.append(_SQL_SELECT_GROUP__WHERE);
3452
3453 query.append(_FINDER_COLUMN_C_C_P_COMPANYID_2);
3454
3455 query.append(_FINDER_COLUMN_C_C_P_CLASSNAMEID_2);
3456
3457 query.append(_FINDER_COLUMN_C_C_P_PARENTGROUPID_2);
3458
3459 if (orderByComparator != null) {
3460 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3461
3462 if (orderByConditionFields.length > 0) {
3463 query.append(WHERE_AND);
3464 }
3465
3466 for (int i = 0; i < orderByConditionFields.length; i++) {
3467 query.append(_ORDER_BY_ENTITY_ALIAS);
3468 query.append(orderByConditionFields[i]);
3469
3470 if ((i + 1) < orderByConditionFields.length) {
3471 if (orderByComparator.isAscending() ^ previous) {
3472 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3473 }
3474 else {
3475 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3476 }
3477 }
3478 else {
3479 if (orderByComparator.isAscending() ^ previous) {
3480 query.append(WHERE_GREATER_THAN);
3481 }
3482 else {
3483 query.append(WHERE_LESSER_THAN);
3484 }
3485 }
3486 }
3487
3488 query.append(ORDER_BY_CLAUSE);
3489
3490 String[] orderByFields = orderByComparator.getOrderByFields();
3491
3492 for (int i = 0; i < orderByFields.length; i++) {
3493 query.append(_ORDER_BY_ENTITY_ALIAS);
3494 query.append(orderByFields[i]);
3495
3496 if ((i + 1) < orderByFields.length) {
3497 if (orderByComparator.isAscending() ^ previous) {
3498 query.append(ORDER_BY_ASC_HAS_NEXT);
3499 }
3500 else {
3501 query.append(ORDER_BY_DESC_HAS_NEXT);
3502 }
3503 }
3504 else {
3505 if (orderByComparator.isAscending() ^ previous) {
3506 query.append(ORDER_BY_ASC);
3507 }
3508 else {
3509 query.append(ORDER_BY_DESC);
3510 }
3511 }
3512 }
3513 }
3514 else {
3515 query.append(GroupModelImpl.ORDER_BY_JPQL);
3516 }
3517
3518 String sql = query.toString();
3519
3520 Query q = session.createQuery(sql);
3521
3522 q.setFirstResult(0);
3523 q.setMaxResults(2);
3524
3525 QueryPos qPos = QueryPos.getInstance(q);
3526
3527 qPos.add(companyId);
3528
3529 qPos.add(classNameId);
3530
3531 qPos.add(parentGroupId);
3532
3533 if (orderByComparator != null) {
3534 Object[] values = orderByComparator.getOrderByConditionValues(group);
3535
3536 for (Object value : values) {
3537 qPos.add(value);
3538 }
3539 }
3540
3541 List<Group> list = q.list();
3542
3543 if (list.size() == 2) {
3544 return list.get(1);
3545 }
3546 else {
3547 return null;
3548 }
3549 }
3550
3551
3559 public void removeByC_C_P(long companyId, long classNameId,
3560 long parentGroupId) throws SystemException {
3561 for (Group group : findByC_C_P(companyId, classNameId, parentGroupId,
3562 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3563 remove(group);
3564 }
3565 }
3566
3567
3576 public int countByC_C_P(long companyId, long classNameId, long parentGroupId)
3577 throws SystemException {
3578 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C_P;
3579
3580 Object[] finderArgs = new Object[] { companyId, classNameId, parentGroupId };
3581
3582 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3583 this);
3584
3585 if (count == null) {
3586 StringBundler query = new StringBundler(4);
3587
3588 query.append(_SQL_COUNT_GROUP__WHERE);
3589
3590 query.append(_FINDER_COLUMN_C_C_P_COMPANYID_2);
3591
3592 query.append(_FINDER_COLUMN_C_C_P_CLASSNAMEID_2);
3593
3594 query.append(_FINDER_COLUMN_C_C_P_PARENTGROUPID_2);
3595
3596 String sql = query.toString();
3597
3598 Session session = null;
3599
3600 try {
3601 session = openSession();
3602
3603 Query q = session.createQuery(sql);
3604
3605 QueryPos qPos = QueryPos.getInstance(q);
3606
3607 qPos.add(companyId);
3608
3609 qPos.add(classNameId);
3610
3611 qPos.add(parentGroupId);
3612
3613 count = (Long)q.uniqueResult();
3614
3615 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3616 }
3617 catch (Exception e) {
3618 FinderCacheUtil.removeResult(finderPath, finderArgs);
3619
3620 throw processException(e);
3621 }
3622 finally {
3623 closeSession(session);
3624 }
3625 }
3626
3627 return count.intValue();
3628 }
3629
3630 private static final String _FINDER_COLUMN_C_C_P_COMPANYID_2 = "group_.companyId = ? AND ";
3631 private static final String _FINDER_COLUMN_C_C_P_CLASSNAMEID_2 = "group_.classNameId = ? AND ";
3632 private static final String _FINDER_COLUMN_C_C_P_PARENTGROUPID_2 = "group_.parentGroupId = ?";
3633 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P_S = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
3634 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
3635 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_P_S",
3636 new String[] {
3637 Long.class.getName(), Long.class.getName(),
3638 Boolean.class.getName(),
3639
3640 Integer.class.getName(), Integer.class.getName(),
3641 OrderByComparator.class.getName()
3642 });
3643 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P_S = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
3644 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
3645 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_P_S",
3646 new String[] {
3647 Long.class.getName(), Long.class.getName(),
3648 Boolean.class.getName()
3649 },
3650 GroupModelImpl.COMPANYID_COLUMN_BITMASK |
3651 GroupModelImpl.PARENTGROUPID_COLUMN_BITMASK |
3652 GroupModelImpl.SITE_COLUMN_BITMASK |
3653 GroupModelImpl.NAME_COLUMN_BITMASK);
3654 public static final FinderPath FINDER_PATH_COUNT_BY_C_P_S = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
3655 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
3656 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_P_S",
3657 new String[] {
3658 Long.class.getName(), Long.class.getName(),
3659 Boolean.class.getName()
3660 });
3661
3662
3671 public List<Group> findByC_P_S(long companyId, long parentGroupId,
3672 boolean site) throws SystemException {
3673 return findByC_P_S(companyId, parentGroupId, site, QueryUtil.ALL_POS,
3674 QueryUtil.ALL_POS, null);
3675 }
3676
3677
3692 public List<Group> findByC_P_S(long companyId, long parentGroupId,
3693 boolean site, int start, int end) throws SystemException {
3694 return findByC_P_S(companyId, parentGroupId, site, start, end, null);
3695 }
3696
3697
3713 public List<Group> findByC_P_S(long companyId, long parentGroupId,
3714 boolean site, int start, int end, OrderByComparator orderByComparator)
3715 throws SystemException {
3716 boolean pagination = true;
3717 FinderPath finderPath = null;
3718 Object[] finderArgs = null;
3719
3720 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3721 (orderByComparator == null)) {
3722 pagination = false;
3723 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P_S;
3724 finderArgs = new Object[] { companyId, parentGroupId, site };
3725 }
3726 else {
3727 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P_S;
3728 finderArgs = new Object[] {
3729 companyId, parentGroupId, site,
3730
3731 start, end, orderByComparator
3732 };
3733 }
3734
3735 List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
3736 finderArgs, this);
3737
3738 if ((list != null) && !list.isEmpty()) {
3739 for (Group group : list) {
3740 if ((companyId != group.getCompanyId()) ||
3741 (parentGroupId != group.getParentGroupId()) ||
3742 (site != group.getSite())) {
3743 list = null;
3744
3745 break;
3746 }
3747 }
3748 }
3749
3750 if (list == null) {
3751 StringBundler query = null;
3752
3753 if (orderByComparator != null) {
3754 query = new StringBundler(5 +
3755 (orderByComparator.getOrderByFields().length * 3));
3756 }
3757 else {
3758 query = new StringBundler(5);
3759 }
3760
3761 query.append(_SQL_SELECT_GROUP__WHERE);
3762
3763 query.append(_FINDER_COLUMN_C_P_S_COMPANYID_2);
3764
3765 query.append(_FINDER_COLUMN_C_P_S_PARENTGROUPID_2);
3766
3767 query.append(_FINDER_COLUMN_C_P_S_SITE_2);
3768
3769 if (orderByComparator != null) {
3770 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3771 orderByComparator);
3772 }
3773 else
3774 if (pagination) {
3775 query.append(GroupModelImpl.ORDER_BY_JPQL);
3776 }
3777
3778 String sql = query.toString();
3779
3780 Session session = null;
3781
3782 try {
3783 session = openSession();
3784
3785 Query q = session.createQuery(sql);
3786
3787 QueryPos qPos = QueryPos.getInstance(q);
3788
3789 qPos.add(companyId);
3790
3791 qPos.add(parentGroupId);
3792
3793 qPos.add(site);
3794
3795 if (!pagination) {
3796 list = (List<Group>)QueryUtil.list(q, getDialect(), start,
3797 end, false);
3798
3799 Collections.sort(list);
3800
3801 list = new UnmodifiableList<Group>(list);
3802 }
3803 else {
3804 list = (List<Group>)QueryUtil.list(q, getDialect(), start,
3805 end);
3806 }
3807
3808 cacheResult(list);
3809
3810 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3811 }
3812 catch (Exception e) {
3813 FinderCacheUtil.removeResult(finderPath, finderArgs);
3814
3815 throw processException(e);
3816 }
3817 finally {
3818 closeSession(session);
3819 }
3820 }
3821
3822 return list;
3823 }
3824
3825
3836 public Group findByC_P_S_First(long companyId, long parentGroupId,
3837 boolean site, OrderByComparator orderByComparator)
3838 throws NoSuchGroupException, SystemException {
3839 Group group = fetchByC_P_S_First(companyId, parentGroupId, site,
3840 orderByComparator);
3841
3842 if (group != null) {
3843 return group;
3844 }
3845
3846 StringBundler msg = new StringBundler(8);
3847
3848 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3849
3850 msg.append("companyId=");
3851 msg.append(companyId);
3852
3853 msg.append(", parentGroupId=");
3854 msg.append(parentGroupId);
3855
3856 msg.append(", site=");
3857 msg.append(site);
3858
3859 msg.append(StringPool.CLOSE_CURLY_BRACE);
3860
3861 throw new NoSuchGroupException(msg.toString());
3862 }
3863
3864
3874 public Group fetchByC_P_S_First(long companyId, long parentGroupId,
3875 boolean site, OrderByComparator orderByComparator)
3876 throws SystemException {
3877 List<Group> list = findByC_P_S(companyId, parentGroupId, site, 0, 1,
3878 orderByComparator);
3879
3880 if (!list.isEmpty()) {
3881 return list.get(0);
3882 }
3883
3884 return null;
3885 }
3886
3887
3898 public Group findByC_P_S_Last(long companyId, long parentGroupId,
3899 boolean site, OrderByComparator orderByComparator)
3900 throws NoSuchGroupException, SystemException {
3901 Group group = fetchByC_P_S_Last(companyId, parentGroupId, site,
3902 orderByComparator);
3903
3904 if (group != null) {
3905 return group;
3906 }
3907
3908 StringBundler msg = new StringBundler(8);
3909
3910 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3911
3912 msg.append("companyId=");
3913 msg.append(companyId);
3914
3915 msg.append(", parentGroupId=");
3916 msg.append(parentGroupId);
3917
3918 msg.append(", site=");
3919 msg.append(site);
3920
3921 msg.append(StringPool.CLOSE_CURLY_BRACE);
3922
3923 throw new NoSuchGroupException(msg.toString());
3924 }
3925
3926
3936 public Group fetchByC_P_S_Last(long companyId, long parentGroupId,
3937 boolean site, OrderByComparator orderByComparator)
3938 throws SystemException {
3939 int count = countByC_P_S(companyId, parentGroupId, site);
3940
3941 List<Group> list = findByC_P_S(companyId, parentGroupId, site,
3942 count - 1, count, orderByComparator);
3943
3944 if (!list.isEmpty()) {
3945 return list.get(0);
3946 }
3947
3948 return null;
3949 }
3950
3951
3963 public Group[] findByC_P_S_PrevAndNext(long groupId, long companyId,
3964 long parentGroupId, boolean site, OrderByComparator orderByComparator)
3965 throws NoSuchGroupException, SystemException {
3966 Group group = findByPrimaryKey(groupId);
3967
3968 Session session = null;
3969
3970 try {
3971 session = openSession();
3972
3973 Group[] array = new GroupImpl[3];
3974
3975 array[0] = getByC_P_S_PrevAndNext(session, group, companyId,
3976 parentGroupId, site, orderByComparator, true);
3977
3978 array[1] = group;
3979
3980 array[2] = getByC_P_S_PrevAndNext(session, group, companyId,
3981 parentGroupId, site, orderByComparator, false);
3982
3983 return array;
3984 }
3985 catch (Exception e) {
3986 throw processException(e);
3987 }
3988 finally {
3989 closeSession(session);
3990 }
3991 }
3992
3993 protected Group getByC_P_S_PrevAndNext(Session session, Group group,
3994 long companyId, long parentGroupId, boolean site,
3995 OrderByComparator orderByComparator, boolean previous) {
3996 StringBundler query = null;
3997
3998 if (orderByComparator != null) {
3999 query = new StringBundler(6 +
4000 (orderByComparator.getOrderByFields().length * 6));
4001 }
4002 else {
4003 query = new StringBundler(3);
4004 }
4005
4006 query.append(_SQL_SELECT_GROUP__WHERE);
4007
4008 query.append(_FINDER_COLUMN_C_P_S_COMPANYID_2);
4009
4010 query.append(_FINDER_COLUMN_C_P_S_PARENTGROUPID_2);
4011
4012 query.append(_FINDER_COLUMN_C_P_S_SITE_2);
4013
4014 if (orderByComparator != null) {
4015 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4016
4017 if (orderByConditionFields.length > 0) {
4018 query.append(WHERE_AND);
4019 }
4020
4021 for (int i = 0; i < orderByConditionFields.length; i++) {
4022 query.append(_ORDER_BY_ENTITY_ALIAS);
4023 query.append(orderByConditionFields[i]);
4024
4025 if ((i + 1) < orderByConditionFields.length) {
4026 if (orderByComparator.isAscending() ^ previous) {
4027 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4028 }
4029 else {
4030 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4031 }
4032 }
4033 else {
4034 if (orderByComparator.isAscending() ^ previous) {
4035 query.append(WHERE_GREATER_THAN);
4036 }
4037 else {
4038 query.append(WHERE_LESSER_THAN);
4039 }
4040 }
4041 }
4042
4043 query.append(ORDER_BY_CLAUSE);
4044
4045 String[] orderByFields = orderByComparator.getOrderByFields();
4046
4047 for (int i = 0; i < orderByFields.length; i++) {
4048 query.append(_ORDER_BY_ENTITY_ALIAS);
4049 query.append(orderByFields[i]);
4050
4051 if ((i + 1) < orderByFields.length) {
4052 if (orderByComparator.isAscending() ^ previous) {
4053 query.append(ORDER_BY_ASC_HAS_NEXT);
4054 }
4055 else {
4056 query.append(ORDER_BY_DESC_HAS_NEXT);
4057 }
4058 }
4059 else {
4060 if (orderByComparator.isAscending() ^ previous) {
4061 query.append(ORDER_BY_ASC);
4062 }
4063 else {
4064 query.append(ORDER_BY_DESC);
4065 }
4066 }
4067 }
4068 }
4069 else {
4070 query.append(GroupModelImpl.ORDER_BY_JPQL);
4071 }
4072
4073 String sql = query.toString();
4074
4075 Query q = session.createQuery(sql);
4076
4077 q.setFirstResult(0);
4078 q.setMaxResults(2);
4079
4080 QueryPos qPos = QueryPos.getInstance(q);
4081
4082 qPos.add(companyId);
4083
4084 qPos.add(parentGroupId);
4085
4086 qPos.add(site);
4087
4088 if (orderByComparator != null) {
4089 Object[] values = orderByComparator.getOrderByConditionValues(group);
4090
4091 for (Object value : values) {
4092 qPos.add(value);
4093 }
4094 }
4095
4096 List<Group> list = q.list();
4097
4098 if (list.size() == 2) {
4099 return list.get(1);
4100 }
4101 else {
4102 return null;
4103 }
4104 }
4105
4106
4114 public void removeByC_P_S(long companyId, long parentGroupId, boolean site)
4115 throws SystemException {
4116 for (Group group : findByC_P_S(companyId, parentGroupId, site,
4117 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4118 remove(group);
4119 }
4120 }
4121
4122
4131 public int countByC_P_S(long companyId, long parentGroupId, boolean site)
4132 throws SystemException {
4133 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_P_S;
4134
4135 Object[] finderArgs = new Object[] { companyId, parentGroupId, site };
4136
4137 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4138 this);
4139
4140 if (count == null) {
4141 StringBundler query = new StringBundler(4);
4142
4143 query.append(_SQL_COUNT_GROUP__WHERE);
4144
4145 query.append(_FINDER_COLUMN_C_P_S_COMPANYID_2);
4146
4147 query.append(_FINDER_COLUMN_C_P_S_PARENTGROUPID_2);
4148
4149 query.append(_FINDER_COLUMN_C_P_S_SITE_2);
4150
4151 String sql = query.toString();
4152
4153 Session session = null;
4154
4155 try {
4156 session = openSession();
4157
4158 Query q = session.createQuery(sql);
4159
4160 QueryPos qPos = QueryPos.getInstance(q);
4161
4162 qPos.add(companyId);
4163
4164 qPos.add(parentGroupId);
4165
4166 qPos.add(site);
4167
4168 count = (Long)q.uniqueResult();
4169
4170 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4171 }
4172 catch (Exception e) {
4173 FinderCacheUtil.removeResult(finderPath, finderArgs);
4174
4175 throw processException(e);
4176 }
4177 finally {
4178 closeSession(session);
4179 }
4180 }
4181
4182 return count.intValue();
4183 }
4184
4185 private static final String _FINDER_COLUMN_C_P_S_COMPANYID_2 = "group_.companyId = ? AND ";
4186 private static final String _FINDER_COLUMN_C_P_S_PARENTGROUPID_2 = "group_.parentGroupId = ? AND ";
4187 private static final String _FINDER_COLUMN_C_P_S_SITE_2 = "group_.site = ?";
4188 public static final FinderPath FINDER_PATH_FETCH_BY_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
4189 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
4190 FINDER_CLASS_NAME_ENTITY, "fetchByC_L_N",
4191 new String[] {
4192 Long.class.getName(), Long.class.getName(),
4193 String.class.getName()
4194 },
4195 GroupModelImpl.COMPANYID_COLUMN_BITMASK |
4196 GroupModelImpl.LIVEGROUPID_COLUMN_BITMASK |
4197 GroupModelImpl.NAME_COLUMN_BITMASK);
4198 public static final FinderPath FINDER_PATH_COUNT_BY_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
4199 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
4200 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_L_N",
4201 new String[] {
4202 Long.class.getName(), Long.class.getName(),
4203 String.class.getName()
4204 });
4205
4206
4216 public Group findByC_L_N(long companyId, long liveGroupId, String name)
4217 throws NoSuchGroupException, SystemException {
4218 Group group = fetchByC_L_N(companyId, liveGroupId, name);
4219
4220 if (group == null) {
4221 StringBundler msg = new StringBundler(8);
4222
4223 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4224
4225 msg.append("companyId=");
4226 msg.append(companyId);
4227
4228 msg.append(", liveGroupId=");
4229 msg.append(liveGroupId);
4230
4231 msg.append(", name=");
4232 msg.append(name);
4233
4234 msg.append(StringPool.CLOSE_CURLY_BRACE);
4235
4236 if (_log.isWarnEnabled()) {
4237 _log.warn(msg.toString());
4238 }
4239
4240 throw new NoSuchGroupException(msg.toString());
4241 }
4242
4243 return group;
4244 }
4245
4246
4255 public Group fetchByC_L_N(long companyId, long liveGroupId, String name)
4256 throws SystemException {
4257 return fetchByC_L_N(companyId, liveGroupId, name, true);
4258 }
4259
4260
4270 public Group fetchByC_L_N(long companyId, long liveGroupId, String name,
4271 boolean retrieveFromCache) throws SystemException {
4272 Object[] finderArgs = new Object[] { companyId, liveGroupId, name };
4273
4274 Object result = null;
4275
4276 if (retrieveFromCache) {
4277 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_L_N,
4278 finderArgs, this);
4279 }
4280
4281 if (result instanceof Group) {
4282 Group group = (Group)result;
4283
4284 if ((companyId != group.getCompanyId()) ||
4285 (liveGroupId != group.getLiveGroupId()) ||
4286 !Validator.equals(name, group.getName())) {
4287 result = null;
4288 }
4289 }
4290
4291 if (result == null) {
4292 StringBundler query = new StringBundler(5);
4293
4294 query.append(_SQL_SELECT_GROUP__WHERE);
4295
4296 query.append(_FINDER_COLUMN_C_L_N_COMPANYID_2);
4297
4298 query.append(_FINDER_COLUMN_C_L_N_LIVEGROUPID_2);
4299
4300 boolean bindName = false;
4301
4302 if (name == null) {
4303 query.append(_FINDER_COLUMN_C_L_N_NAME_1);
4304 }
4305 else if (name.equals(StringPool.BLANK)) {
4306 query.append(_FINDER_COLUMN_C_L_N_NAME_3);
4307 }
4308 else {
4309 bindName = true;
4310
4311 query.append(_FINDER_COLUMN_C_L_N_NAME_2);
4312 }
4313
4314 String sql = query.toString();
4315
4316 Session session = null;
4317
4318 try {
4319 session = openSession();
4320
4321 Query q = session.createQuery(sql);
4322
4323 QueryPos qPos = QueryPos.getInstance(q);
4324
4325 qPos.add(companyId);
4326
4327 qPos.add(liveGroupId);
4328
4329 if (bindName) {
4330 qPos.add(name);
4331 }
4332
4333 List<Group> list = q.list();
4334
4335 if (list.isEmpty()) {
4336 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
4337 finderArgs, list);
4338 }
4339 else {
4340 Group group = list.get(0);
4341
4342 result = group;
4343
4344 cacheResult(group);
4345
4346 if ((group.getCompanyId() != companyId) ||
4347 (group.getLiveGroupId() != liveGroupId) ||
4348 (group.getName() == null) ||
4349 !group.getName().equals(name)) {
4350 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
4351 finderArgs, group);
4352 }
4353 }
4354 }
4355 catch (Exception e) {
4356 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L_N,
4357 finderArgs);
4358
4359 throw processException(e);
4360 }
4361 finally {
4362 closeSession(session);
4363 }
4364 }
4365
4366 if (result instanceof List<?>) {
4367 return null;
4368 }
4369 else {
4370 return (Group)result;
4371 }
4372 }
4373
4374
4383 public Group removeByC_L_N(long companyId, long liveGroupId, String name)
4384 throws NoSuchGroupException, SystemException {
4385 Group group = findByC_L_N(companyId, liveGroupId, name);
4386
4387 return remove(group);
4388 }
4389
4390
4399 public int countByC_L_N(long companyId, long liveGroupId, String name)
4400 throws SystemException {
4401 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_L_N;
4402
4403 Object[] finderArgs = new Object[] { companyId, liveGroupId, name };
4404
4405 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4406 this);
4407
4408 if (count == null) {
4409 StringBundler query = new StringBundler(4);
4410
4411 query.append(_SQL_COUNT_GROUP__WHERE);
4412
4413 query.append(_FINDER_COLUMN_C_L_N_COMPANYID_2);
4414
4415 query.append(_FINDER_COLUMN_C_L_N_LIVEGROUPID_2);
4416
4417 boolean bindName = false;
4418
4419 if (name == null) {
4420 query.append(_FINDER_COLUMN_C_L_N_NAME_1);
4421 }
4422 else if (name.equals(StringPool.BLANK)) {
4423 query.append(_FINDER_COLUMN_C_L_N_NAME_3);
4424 }
4425 else {
4426 bindName = true;
4427
4428 query.append(_FINDER_COLUMN_C_L_N_NAME_2);
4429 }
4430
4431 String sql = query.toString();
4432
4433 Session session = null;
4434
4435 try {
4436 session = openSession();
4437
4438 Query q = session.createQuery(sql);
4439
4440 QueryPos qPos = QueryPos.getInstance(q);
4441
4442 qPos.add(companyId);
4443
4444 qPos.add(liveGroupId);
4445
4446 if (bindName) {
4447 qPos.add(name);
4448 }
4449
4450 count = (Long)q.uniqueResult();
4451
4452 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4453 }
4454 catch (Exception e) {
4455 FinderCacheUtil.removeResult(finderPath, finderArgs);
4456
4457 throw processException(e);
4458 }
4459 finally {
4460 closeSession(session);
4461 }
4462 }
4463
4464 return count.intValue();
4465 }
4466
4467 private static final String _FINDER_COLUMN_C_L_N_COMPANYID_2 = "group_.companyId = ? AND ";
4468 private static final String _FINDER_COLUMN_C_L_N_LIVEGROUPID_2 = "group_.liveGroupId = ? AND ";
4469 private static final String _FINDER_COLUMN_C_L_N_NAME_1 = "group_.name IS NULL";
4470 private static final String _FINDER_COLUMN_C_L_N_NAME_2 = "group_.name = ?";
4471 private static final String _FINDER_COLUMN_C_L_N_NAME_3 = "(group_.name IS NULL OR group_.name = '')";
4472 public static final FinderPath FINDER_PATH_FETCH_BY_C_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
4473 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
4474 FINDER_CLASS_NAME_ENTITY, "fetchByC_C_L_N",
4475 new String[] {
4476 Long.class.getName(), Long.class.getName(), Long.class.getName(),
4477 String.class.getName()
4478 },
4479 GroupModelImpl.COMPANYID_COLUMN_BITMASK |
4480 GroupModelImpl.CLASSNAMEID_COLUMN_BITMASK |
4481 GroupModelImpl.LIVEGROUPID_COLUMN_BITMASK |
4482 GroupModelImpl.NAME_COLUMN_BITMASK);
4483 public static final FinderPath FINDER_PATH_COUNT_BY_C_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
4484 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
4485 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_L_N",
4486 new String[] {
4487 Long.class.getName(), Long.class.getName(), Long.class.getName(),
4488 String.class.getName()
4489 });
4490
4491
4502 public Group findByC_C_L_N(long companyId, long classNameId,
4503 long liveGroupId, String name)
4504 throws NoSuchGroupException, SystemException {
4505 Group group = fetchByC_C_L_N(companyId, classNameId, liveGroupId, name);
4506
4507 if (group == null) {
4508 StringBundler msg = new StringBundler(10);
4509
4510 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4511
4512 msg.append("companyId=");
4513 msg.append(companyId);
4514
4515 msg.append(", classNameId=");
4516 msg.append(classNameId);
4517
4518 msg.append(", liveGroupId=");
4519 msg.append(liveGroupId);
4520
4521 msg.append(", name=");
4522 msg.append(name);
4523
4524 msg.append(StringPool.CLOSE_CURLY_BRACE);
4525
4526 if (_log.isWarnEnabled()) {
4527 _log.warn(msg.toString());
4528 }
4529
4530 throw new NoSuchGroupException(msg.toString());
4531 }
4532
4533 return group;
4534 }
4535
4536
4546 public Group fetchByC_C_L_N(long companyId, long classNameId,
4547 long liveGroupId, String name) throws SystemException {
4548 return fetchByC_C_L_N(companyId, classNameId, liveGroupId, name, true);
4549 }
4550
4551
4562 public Group fetchByC_C_L_N(long companyId, long classNameId,
4563 long liveGroupId, String name, boolean retrieveFromCache)
4564 throws SystemException {
4565 Object[] finderArgs = new Object[] {
4566 companyId, classNameId, liveGroupId, name
4567 };
4568
4569 Object result = null;
4570
4571 if (retrieveFromCache) {
4572 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C_L_N,
4573 finderArgs, this);
4574 }
4575
4576 if (result instanceof Group) {
4577 Group group = (Group)result;
4578
4579 if ((companyId != group.getCompanyId()) ||
4580 (classNameId != group.getClassNameId()) ||
4581 (liveGroupId != group.getLiveGroupId()) ||
4582 !Validator.equals(name, group.getName())) {
4583 result = null;
4584 }
4585 }
4586
4587 if (result == null) {
4588 StringBundler query = new StringBundler(6);
4589
4590 query.append(_SQL_SELECT_GROUP__WHERE);
4591
4592 query.append(_FINDER_COLUMN_C_C_L_N_COMPANYID_2);
4593
4594 query.append(_FINDER_COLUMN_C_C_L_N_CLASSNAMEID_2);
4595
4596 query.append(_FINDER_COLUMN_C_C_L_N_LIVEGROUPID_2);
4597
4598 boolean bindName = false;
4599
4600 if (name == null) {
4601 query.append(_FINDER_COLUMN_C_C_L_N_NAME_1);
4602 }
4603 else if (name.equals(StringPool.BLANK)) {
4604 query.append(_FINDER_COLUMN_C_C_L_N_NAME_3);
4605 }
4606 else {
4607 bindName = true;
4608
4609 query.append(_FINDER_COLUMN_C_C_L_N_NAME_2);
4610 }
4611
4612 String sql = query.toString();
4613
4614 Session session = null;
4615
4616 try {
4617 session = openSession();
4618
4619 Query q = session.createQuery(sql);
4620
4621 QueryPos qPos = QueryPos.getInstance(q);
4622
4623 qPos.add(companyId);
4624
4625 qPos.add(classNameId);
4626
4627 qPos.add(liveGroupId);
4628
4629 if (bindName) {
4630 qPos.add(name);
4631 }
4632
4633 List<Group> list = q.list();
4634
4635 if (list.isEmpty()) {
4636 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
4637 finderArgs, list);
4638 }
4639 else {
4640 Group group = list.get(0);
4641
4642 result = group;
4643
4644 cacheResult(group);
4645
4646 if ((group.getCompanyId() != companyId) ||
4647 (group.getClassNameId() != classNameId) ||
4648 (group.getLiveGroupId() != liveGroupId) ||
4649 (group.getName() == null) ||
4650 !group.getName().equals(name)) {
4651 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
4652 finderArgs, group);
4653 }
4654 }
4655 }
4656 catch (Exception e) {
4657 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_L_N,
4658 finderArgs);
4659
4660 throw processException(e);
4661 }
4662 finally {
4663 closeSession(session);
4664 }
4665 }
4666
4667 if (result instanceof List<?>) {
4668 return null;
4669 }
4670 else {
4671 return (Group)result;
4672 }
4673 }
4674
4675
4685 public Group removeByC_C_L_N(long companyId, long classNameId,
4686 long liveGroupId, String name)
4687 throws NoSuchGroupException, SystemException {
4688 Group group = findByC_C_L_N(companyId, classNameId, liveGroupId, name);
4689
4690 return remove(group);
4691 }
4692
4693
4703 public int countByC_C_L_N(long companyId, long classNameId,
4704 long liveGroupId, String name) throws SystemException {
4705 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C_L_N;
4706
4707 Object[] finderArgs = new Object[] {
4708 companyId, classNameId, liveGroupId, name
4709 };
4710
4711 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4712 this);
4713
4714 if (count == null) {
4715 StringBundler query = new StringBundler(5);
4716
4717 query.append(_SQL_COUNT_GROUP__WHERE);
4718
4719 query.append(_FINDER_COLUMN_C_C_L_N_COMPANYID_2);
4720
4721 query.append(_FINDER_COLUMN_C_C_L_N_CLASSNAMEID_2);
4722
4723 query.append(_FINDER_COLUMN_C_C_L_N_LIVEGROUPID_2);
4724
4725 boolean bindName = false;
4726
4727 if (name == null) {
4728 query.append(_FINDER_COLUMN_C_C_L_N_NAME_1);
4729 }
4730 else if (name.equals(StringPool.BLANK)) {
4731 query.append(_FINDER_COLUMN_C_C_L_N_NAME_3);
4732 }
4733 else {
4734 bindName = true;
4735
4736 query.append(_FINDER_COLUMN_C_C_L_N_NAME_2);
4737 }
4738
4739 String sql = query.toString();
4740
4741 Session session = null;
4742
4743 try {
4744 session = openSession();
4745
4746 Query q = session.createQuery(sql);
4747
4748 QueryPos qPos = QueryPos.getInstance(q);
4749
4750 qPos.add(companyId);
4751
4752 qPos.add(classNameId);
4753
4754 qPos.add(liveGroupId);
4755
4756 if (bindName) {
4757 qPos.add(name);
4758 }
4759
4760 count = (Long)q.uniqueResult();
4761
4762 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4763 }
4764 catch (Exception e) {
4765 FinderCacheUtil.removeResult(finderPath, finderArgs);
4766
4767 throw processException(e);
4768 }
4769 finally {
4770 closeSession(session);
4771 }
4772 }
4773
4774 return count.intValue();
4775 }
4776
4777 private static final String _FINDER_COLUMN_C_C_L_N_COMPANYID_2 = "group_.companyId = ? AND ";
4778 private static final String _FINDER_COLUMN_C_C_L_N_CLASSNAMEID_2 = "group_.classNameId = ? AND ";
4779 private static final String _FINDER_COLUMN_C_C_L_N_LIVEGROUPID_2 = "group_.liveGroupId = ? AND ";
4780 private static final String _FINDER_COLUMN_C_C_L_N_NAME_1 = "group_.name IS NULL";
4781 private static final String _FINDER_COLUMN_C_C_L_N_NAME_2 = "group_.name = ?";
4782 private static final String _FINDER_COLUMN_C_C_L_N_NAME_3 = "(group_.name IS NULL OR group_.name = '')";
4783
4784
4789 public void cacheResult(Group group) {
4790 EntityCacheUtil.putResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
4791 GroupImpl.class, group.getPrimaryKey(), group);
4792
4793 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
4794 new Object[] { group.getLiveGroupId() }, group);
4795
4796 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
4797 new Object[] { group.getCompanyId(), group.getName() }, group);
4798
4799 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
4800 new Object[] { group.getCompanyId(), group.getFriendlyURL() }, group);
4801
4802 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
4803 new Object[] {
4804 group.getCompanyId(), group.getClassNameId(), group.getClassPK()
4805 }, group);
4806
4807 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
4808 new Object[] {
4809 group.getCompanyId(), group.getLiveGroupId(), group.getName()
4810 }, group);
4811
4812 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
4813 new Object[] {
4814 group.getCompanyId(), group.getClassNameId(),
4815 group.getLiveGroupId(), group.getName()
4816 }, group);
4817
4818 group.resetOriginalValues();
4819 }
4820
4821
4826 public void cacheResult(List<Group> groups) {
4827 for (Group group : groups) {
4828 if (EntityCacheUtil.getResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
4829 GroupImpl.class, group.getPrimaryKey()) == null) {
4830 cacheResult(group);
4831 }
4832 else {
4833 group.resetOriginalValues();
4834 }
4835 }
4836 }
4837
4838
4845 @Override
4846 public void clearCache() {
4847 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
4848 CacheRegistryUtil.clear(GroupImpl.class.getName());
4849 }
4850
4851 EntityCacheUtil.clearCache(GroupImpl.class.getName());
4852
4853 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
4854 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4855 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4856 }
4857
4858
4865 @Override
4866 public void clearCache(Group group) {
4867 EntityCacheUtil.removeResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
4868 GroupImpl.class, group.getPrimaryKey());
4869
4870 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4871 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4872
4873 clearUniqueFindersCache(group);
4874 }
4875
4876 @Override
4877 public void clearCache(List<Group> groups) {
4878 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4879 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4880
4881 for (Group group : groups) {
4882 EntityCacheUtil.removeResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
4883 GroupImpl.class, group.getPrimaryKey());
4884
4885 clearUniqueFindersCache(group);
4886 }
4887 }
4888
4889 protected void cacheUniqueFindersCache(Group group) {
4890 if (group.isNew()) {
4891 Object[] args = new Object[] { group.getLiveGroupId() };
4892
4893 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LIVEGROUPID, args,
4894 Long.valueOf(1));
4895 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID, args,
4896 group);
4897
4898 args = new Object[] { group.getCompanyId(), group.getName() };
4899
4900 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, args,
4901 Long.valueOf(1));
4902 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N, args, group);
4903
4904 args = new Object[] { group.getCompanyId(), group.getFriendlyURL() };
4905
4906 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_F, args,
4907 Long.valueOf(1));
4908 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F, args, group);
4909
4910 args = new Object[] {
4911 group.getCompanyId(), group.getClassNameId(),
4912 group.getClassPK()
4913 };
4914
4915 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C, args,
4916 Long.valueOf(1));
4917 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C, args, group);
4918
4919 args = new Object[] {
4920 group.getCompanyId(), group.getLiveGroupId(),
4921 group.getName()
4922 };
4923
4924 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_L_N, args,
4925 Long.valueOf(1));
4926 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N, args, group);
4927
4928 args = new Object[] {
4929 group.getCompanyId(), group.getClassNameId(),
4930 group.getLiveGroupId(), group.getName()
4931 };
4932
4933 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_L_N, args,
4934 Long.valueOf(1));
4935 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N, args, group);
4936 }
4937 else {
4938 GroupModelImpl groupModelImpl = (GroupModelImpl)group;
4939
4940 if ((groupModelImpl.getColumnBitmask() &
4941 FINDER_PATH_FETCH_BY_LIVEGROUPID.getColumnBitmask()) != 0) {
4942 Object[] args = new Object[] { group.getLiveGroupId() };
4943
4944 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LIVEGROUPID,
4945 args, Long.valueOf(1));
4946 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
4947 args, group);
4948 }
4949
4950 if ((groupModelImpl.getColumnBitmask() &
4951 FINDER_PATH_FETCH_BY_C_N.getColumnBitmask()) != 0) {
4952 Object[] args = new Object[] {
4953 group.getCompanyId(), group.getName()
4954 };
4955
4956 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, args,
4957 Long.valueOf(1));
4958 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N, args, group);
4959 }
4960
4961 if ((groupModelImpl.getColumnBitmask() &
4962 FINDER_PATH_FETCH_BY_C_F.getColumnBitmask()) != 0) {
4963 Object[] args = new Object[] {
4964 group.getCompanyId(), group.getFriendlyURL()
4965 };
4966
4967 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_F, args,
4968 Long.valueOf(1));
4969 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F, args, group);
4970 }
4971
4972 if ((groupModelImpl.getColumnBitmask() &
4973 FINDER_PATH_FETCH_BY_C_C_C.getColumnBitmask()) != 0) {
4974 Object[] args = new Object[] {
4975 group.getCompanyId(), group.getClassNameId(),
4976 group.getClassPK()
4977 };
4978
4979 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C, args,
4980 Long.valueOf(1));
4981 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C, args,
4982 group);
4983 }
4984
4985 if ((groupModelImpl.getColumnBitmask() &
4986 FINDER_PATH_FETCH_BY_C_L_N.getColumnBitmask()) != 0) {
4987 Object[] args = new Object[] {
4988 group.getCompanyId(), group.getLiveGroupId(),
4989 group.getName()
4990 };
4991
4992 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_L_N, args,
4993 Long.valueOf(1));
4994 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N, args,
4995 group);
4996 }
4997
4998 if ((groupModelImpl.getColumnBitmask() &
4999 FINDER_PATH_FETCH_BY_C_C_L_N.getColumnBitmask()) != 0) {
5000 Object[] args = new Object[] {
5001 group.getCompanyId(), group.getClassNameId(),
5002 group.getLiveGroupId(), group.getName()
5003 };
5004
5005 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_L_N, args,
5006 Long.valueOf(1));
5007 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N, args,
5008 group);
5009 }
5010 }
5011 }
5012
5013 protected void clearUniqueFindersCache(Group group) {
5014 GroupModelImpl groupModelImpl = (GroupModelImpl)group;
5015
5016 Object[] args = new Object[] { group.getLiveGroupId() };
5017
5018 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LIVEGROUPID, args);
5019 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LIVEGROUPID, args);
5020
5021 if ((groupModelImpl.getColumnBitmask() &
5022 FINDER_PATH_FETCH_BY_LIVEGROUPID.getColumnBitmask()) != 0) {
5023 args = new Object[] { groupModelImpl.getOriginalLiveGroupId() };
5024
5025 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LIVEGROUPID, args);
5026 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LIVEGROUPID, args);
5027 }
5028
5029 args = new Object[] { group.getCompanyId(), group.getName() };
5030
5031 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_N, args);
5032 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N, args);
5033
5034 if ((groupModelImpl.getColumnBitmask() &
5035 FINDER_PATH_FETCH_BY_C_N.getColumnBitmask()) != 0) {
5036 args = new Object[] {
5037 groupModelImpl.getOriginalCompanyId(),
5038 groupModelImpl.getOriginalName()
5039 };
5040
5041 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_N, args);
5042 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N, args);
5043 }
5044
5045 args = new Object[] { group.getCompanyId(), group.getFriendlyURL() };
5046
5047 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_F, args);
5048 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_F, args);
5049
5050 if ((groupModelImpl.getColumnBitmask() &
5051 FINDER_PATH_FETCH_BY_C_F.getColumnBitmask()) != 0) {
5052 args = new Object[] {
5053 groupModelImpl.getOriginalCompanyId(),
5054 groupModelImpl.getOriginalFriendlyURL()
5055 };
5056
5057 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_F, args);
5058 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_F, args);
5059 }
5060
5061 args = new Object[] {
5062 group.getCompanyId(), group.getClassNameId(), group.getClassPK()
5063 };
5064
5065 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
5066 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C, args);
5067
5068 if ((groupModelImpl.getColumnBitmask() &
5069 FINDER_PATH_FETCH_BY_C_C_C.getColumnBitmask()) != 0) {
5070 args = new Object[] {
5071 groupModelImpl.getOriginalCompanyId(),
5072 groupModelImpl.getOriginalClassNameId(),
5073 groupModelImpl.getOriginalClassPK()
5074 };
5075
5076 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
5077 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C, args);
5078 }
5079
5080 args = new Object[] {
5081 group.getCompanyId(), group.getLiveGroupId(), group.getName()
5082 };
5083
5084 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_L_N, args);
5085 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L_N, args);
5086
5087 if ((groupModelImpl.getColumnBitmask() &
5088 FINDER_PATH_FETCH_BY_C_L_N.getColumnBitmask()) != 0) {
5089 args = new Object[] {
5090 groupModelImpl.getOriginalCompanyId(),
5091 groupModelImpl.getOriginalLiveGroupId(),
5092 groupModelImpl.getOriginalName()
5093 };
5094
5095 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_L_N, args);
5096 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L_N, args);
5097 }
5098
5099 args = new Object[] {
5100 group.getCompanyId(), group.getClassNameId(),
5101 group.getLiveGroupId(), group.getName()
5102 };
5103
5104 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_L_N, args);
5105 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_L_N, args);
5106
5107 if ((groupModelImpl.getColumnBitmask() &
5108 FINDER_PATH_FETCH_BY_C_C_L_N.getColumnBitmask()) != 0) {
5109 args = new Object[] {
5110 groupModelImpl.getOriginalCompanyId(),
5111 groupModelImpl.getOriginalClassNameId(),
5112 groupModelImpl.getOriginalLiveGroupId(),
5113 groupModelImpl.getOriginalName()
5114 };
5115
5116 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_L_N, args);
5117 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_L_N, args);
5118 }
5119 }
5120
5121
5127 public Group create(long groupId) {
5128 Group group = new GroupImpl();
5129
5130 group.setNew(true);
5131 group.setPrimaryKey(groupId);
5132
5133 return group;
5134 }
5135
5136
5144 public Group remove(long groupId)
5145 throws NoSuchGroupException, SystemException {
5146 return remove((Serializable)groupId);
5147 }
5148
5149
5157 @Override
5158 public Group remove(Serializable primaryKey)
5159 throws NoSuchGroupException, SystemException {
5160 Session session = null;
5161
5162 try {
5163 session = openSession();
5164
5165 Group group = (Group)session.get(GroupImpl.class, primaryKey);
5166
5167 if (group == null) {
5168 if (_log.isWarnEnabled()) {
5169 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
5170 }
5171
5172 throw new NoSuchGroupException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
5173 primaryKey);
5174 }
5175
5176 return remove(group);
5177 }
5178 catch (NoSuchGroupException nsee) {
5179 throw nsee;
5180 }
5181 catch (Exception e) {
5182 throw processException(e);
5183 }
5184 finally {
5185 closeSession(session);
5186 }
5187 }
5188
5189 @Override
5190 protected Group removeImpl(Group group) throws SystemException {
5191 group = toUnwrappedModel(group);
5192
5193 try {
5194 clearOrganizations.clear(group.getPrimaryKey());
5195 }
5196 catch (Exception e) {
5197 throw processException(e);
5198 }
5199 finally {
5200 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
5201 }
5202
5203 try {
5204 clearRoles.clear(group.getPrimaryKey());
5205 }
5206 catch (Exception e) {
5207 throw processException(e);
5208 }
5209 finally {
5210 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5211 }
5212
5213 try {
5214 clearUserGroups.clear(group.getPrimaryKey());
5215 }
5216 catch (Exception e) {
5217 throw processException(e);
5218 }
5219 finally {
5220 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5221 }
5222
5223 try {
5224 clearUsers.clear(group.getPrimaryKey());
5225 }
5226 catch (Exception e) {
5227 throw processException(e);
5228 }
5229 finally {
5230 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5231 }
5232
5233 Session session = null;
5234
5235 try {
5236 session = openSession();
5237
5238 if (!session.contains(group)) {
5239 group = (Group)session.get(GroupImpl.class,
5240 group.getPrimaryKeyObj());
5241 }
5242
5243 if (group != null) {
5244 session.delete(group);
5245 }
5246 }
5247 catch (Exception e) {
5248 throw processException(e);
5249 }
5250 finally {
5251 closeSession(session);
5252 }
5253
5254 if (group != null) {
5255 clearCache(group);
5256 }
5257
5258 return group;
5259 }
5260
5261 @Override
5262 public Group updateImpl(com.liferay.portal.model.Group group)
5263 throws SystemException {
5264 group = toUnwrappedModel(group);
5265
5266 boolean isNew = group.isNew();
5267
5268 GroupModelImpl groupModelImpl = (GroupModelImpl)group;
5269
5270 Session session = null;
5271
5272 try {
5273 session = openSession();
5274
5275 if (group.isNew()) {
5276 session.save(group);
5277
5278 group.setNew(false);
5279 }
5280 else {
5281 session.merge(group);
5282 }
5283 }
5284 catch (Exception e) {
5285 throw processException(e);
5286 }
5287 finally {
5288 closeSession(session);
5289 }
5290
5291 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
5292
5293 if (isNew || !GroupModelImpl.COLUMN_BITMASK_ENABLED) {
5294 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5295 }
5296
5297 else {
5298 if ((groupModelImpl.getColumnBitmask() &
5299 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
5300 Object[] args = new Object[] {
5301 groupModelImpl.getOriginalCompanyId()
5302 };
5303
5304 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
5305 args);
5306 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
5307 args);
5308
5309 args = new Object[] { groupModelImpl.getCompanyId() };
5310
5311 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
5312 args);
5313 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
5314 args);
5315 }
5316
5317 if ((groupModelImpl.getColumnBitmask() &
5318 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P.getColumnBitmask()) != 0) {
5319 Object[] args = new Object[] {
5320 groupModelImpl.getOriginalCompanyId(),
5321 groupModelImpl.getOriginalParentGroupId()
5322 };
5323
5324 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_P, args);
5325 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P,
5326 args);
5327
5328 args = new Object[] {
5329 groupModelImpl.getCompanyId(),
5330 groupModelImpl.getParentGroupId()
5331 };
5332
5333 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_P, args);
5334 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P,
5335 args);
5336 }
5337
5338 if ((groupModelImpl.getColumnBitmask() &
5339 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S.getColumnBitmask()) != 0) {
5340 Object[] args = new Object[] {
5341 groupModelImpl.getOriginalCompanyId(),
5342 groupModelImpl.getOriginalSite()
5343 };
5344
5345 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
5346 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
5347 args);
5348
5349 args = new Object[] {
5350 groupModelImpl.getCompanyId(), groupModelImpl.getSite()
5351 };
5352
5353 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
5354 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
5355 args);
5356 }
5357
5358 if ((groupModelImpl.getColumnBitmask() &
5359 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A.getColumnBitmask()) != 0) {
5360 Object[] args = new Object[] {
5361 groupModelImpl.getOriginalType(),
5362 groupModelImpl.getOriginalActive()
5363 };
5364
5365 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_A, args);
5366 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A,
5367 args);
5368
5369 args = new Object[] {
5370 groupModelImpl.getType(), groupModelImpl.getActive()
5371 };
5372
5373 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_A, args);
5374 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A,
5375 args);
5376 }
5377
5378 if ((groupModelImpl.getColumnBitmask() &
5379 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_P.getColumnBitmask()) != 0) {
5380 Object[] args = new Object[] {
5381 groupModelImpl.getOriginalCompanyId(),
5382 groupModelImpl.getOriginalClassNameId(),
5383 groupModelImpl.getOriginalParentGroupId()
5384 };
5385
5386 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_P, args);
5387 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_P,
5388 args);
5389
5390 args = new Object[] {
5391 groupModelImpl.getCompanyId(),
5392 groupModelImpl.getClassNameId(),
5393 groupModelImpl.getParentGroupId()
5394 };
5395
5396 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_P, args);
5397 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_P,
5398 args);
5399 }
5400
5401 if ((groupModelImpl.getColumnBitmask() &
5402 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P_S.getColumnBitmask()) != 0) {
5403 Object[] args = new Object[] {
5404 groupModelImpl.getOriginalCompanyId(),
5405 groupModelImpl.getOriginalParentGroupId(),
5406 groupModelImpl.getOriginalSite()
5407 };
5408
5409 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_P_S, args);
5410 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P_S,
5411 args);
5412
5413 args = new Object[] {
5414 groupModelImpl.getCompanyId(),
5415 groupModelImpl.getParentGroupId(),
5416 groupModelImpl.getSite()
5417 };
5418
5419 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_P_S, args);
5420 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P_S,
5421 args);
5422 }
5423 }
5424
5425 EntityCacheUtil.putResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
5426 GroupImpl.class, group.getPrimaryKey(), group);
5427
5428 clearUniqueFindersCache(group);
5429 cacheUniqueFindersCache(group);
5430
5431 return group;
5432 }
5433
5434 protected Group toUnwrappedModel(Group group) {
5435 if (group instanceof GroupImpl) {
5436 return group;
5437 }
5438
5439 GroupImpl groupImpl = new GroupImpl();
5440
5441 groupImpl.setNew(group.isNew());
5442 groupImpl.setPrimaryKey(group.getPrimaryKey());
5443
5444 groupImpl.setGroupId(group.getGroupId());
5445 groupImpl.setCompanyId(group.getCompanyId());
5446 groupImpl.setCreatorUserId(group.getCreatorUserId());
5447 groupImpl.setClassNameId(group.getClassNameId());
5448 groupImpl.setClassPK(group.getClassPK());
5449 groupImpl.setParentGroupId(group.getParentGroupId());
5450 groupImpl.setLiveGroupId(group.getLiveGroupId());
5451 groupImpl.setTreePath(group.getTreePath());
5452 groupImpl.setName(group.getName());
5453 groupImpl.setDescription(group.getDescription());
5454 groupImpl.setType(group.getType());
5455 groupImpl.setTypeSettings(group.getTypeSettings());
5456 groupImpl.setFriendlyURL(group.getFriendlyURL());
5457 groupImpl.setSite(group.isSite());
5458 groupImpl.setActive(group.isActive());
5459
5460 return groupImpl;
5461 }
5462
5463
5471 @Override
5472 public Group findByPrimaryKey(Serializable primaryKey)
5473 throws NoSuchGroupException, SystemException {
5474 Group group = fetchByPrimaryKey(primaryKey);
5475
5476 if (group == null) {
5477 if (_log.isWarnEnabled()) {
5478 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
5479 }
5480
5481 throw new NoSuchGroupException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
5482 primaryKey);
5483 }
5484
5485 return group;
5486 }
5487
5488
5496 public Group findByPrimaryKey(long groupId)
5497 throws NoSuchGroupException, SystemException {
5498 return findByPrimaryKey((Serializable)groupId);
5499 }
5500
5501
5508 @Override
5509 public Group fetchByPrimaryKey(Serializable primaryKey)
5510 throws SystemException {
5511 Group group = (Group)EntityCacheUtil.getResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
5512 GroupImpl.class, primaryKey);
5513
5514 if (group == _nullGroup) {
5515 return null;
5516 }
5517
5518 if (group == null) {
5519 Session session = null;
5520
5521 try {
5522 session = openSession();
5523
5524 group = (Group)session.get(GroupImpl.class, primaryKey);
5525
5526 if (group != null) {
5527 cacheResult(group);
5528 }
5529 else {
5530 EntityCacheUtil.putResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
5531 GroupImpl.class, primaryKey, _nullGroup);
5532 }
5533 }
5534 catch (Exception e) {
5535 EntityCacheUtil.removeResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
5536 GroupImpl.class, primaryKey);
5537
5538 throw processException(e);
5539 }
5540 finally {
5541 closeSession(session);
5542 }
5543 }
5544
5545 return group;
5546 }
5547
5548
5555 public Group fetchByPrimaryKey(long groupId) throws SystemException {
5556 return fetchByPrimaryKey((Serializable)groupId);
5557 }
5558
5559
5565 public List<Group> findAll() throws SystemException {
5566 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5567 }
5568
5569
5581 public List<Group> findAll(int start, int end) throws SystemException {
5582 return findAll(start, end, null);
5583 }
5584
5585
5598 public List<Group> findAll(int start, int end,
5599 OrderByComparator orderByComparator) throws SystemException {
5600 boolean pagination = true;
5601 FinderPath finderPath = null;
5602 Object[] finderArgs = null;
5603
5604 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5605 (orderByComparator == null)) {
5606 pagination = false;
5607 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
5608 finderArgs = FINDER_ARGS_EMPTY;
5609 }
5610 else {
5611 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
5612 finderArgs = new Object[] { start, end, orderByComparator };
5613 }
5614
5615 List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
5616 finderArgs, this);
5617
5618 if (list == null) {
5619 StringBundler query = null;
5620 String sql = null;
5621
5622 if (orderByComparator != null) {
5623 query = new StringBundler(2 +
5624 (orderByComparator.getOrderByFields().length * 3));
5625
5626 query.append(_SQL_SELECT_GROUP_);
5627
5628 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5629 orderByComparator);
5630
5631 sql = query.toString();
5632 }
5633 else {
5634 sql = _SQL_SELECT_GROUP_;
5635
5636 if (pagination) {
5637 sql = sql.concat(GroupModelImpl.ORDER_BY_JPQL);
5638 }
5639 }
5640
5641 Session session = null;
5642
5643 try {
5644 session = openSession();
5645
5646 Query q = session.createQuery(sql);
5647
5648 if (!pagination) {
5649 list = (List<Group>)QueryUtil.list(q, getDialect(), start,
5650 end, false);
5651
5652 Collections.sort(list);
5653
5654 list = new UnmodifiableList<Group>(list);
5655 }
5656 else {
5657 list = (List<Group>)QueryUtil.list(q, getDialect(), start,
5658 end);
5659 }
5660
5661 cacheResult(list);
5662
5663 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5664 }
5665 catch (Exception e) {
5666 FinderCacheUtil.removeResult(finderPath, finderArgs);
5667
5668 throw processException(e);
5669 }
5670 finally {
5671 closeSession(session);
5672 }
5673 }
5674
5675 return list;
5676 }
5677
5678
5683 public void removeAll() throws SystemException {
5684 for (Group group : findAll()) {
5685 remove(group);
5686 }
5687 }
5688
5689
5695 public int countAll() throws SystemException {
5696 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
5697 FINDER_ARGS_EMPTY, this);
5698
5699 if (count == null) {
5700 Session session = null;
5701
5702 try {
5703 session = openSession();
5704
5705 Query q = session.createQuery(_SQL_COUNT_GROUP_);
5706
5707 count = (Long)q.uniqueResult();
5708
5709 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
5710 FINDER_ARGS_EMPTY, count);
5711 }
5712 catch (Exception e) {
5713 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
5714 FINDER_ARGS_EMPTY);
5715
5716 throw processException(e);
5717 }
5718 finally {
5719 closeSession(session);
5720 }
5721 }
5722
5723 return count.intValue();
5724 }
5725
5726
5733 public List<com.liferay.portal.model.Organization> getOrganizations(long pk)
5734 throws SystemException {
5735 return getOrganizations(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
5736 }
5737
5738
5751 public List<com.liferay.portal.model.Organization> getOrganizations(
5752 long pk, int start, int end) throws SystemException {
5753 return getOrganizations(pk, start, end, null);
5754 }
5755
5756 public static final FinderPath FINDER_PATH_GET_ORGANIZATIONS = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
5757 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ORGS,
5758 com.liferay.portal.model.impl.OrganizationImpl.class,
5759 GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME, "getOrganizations",
5760 new String[] {
5761 Long.class.getName(), Integer.class.getName(),
5762 Integer.class.getName(), OrderByComparator.class.getName()
5763 });
5764
5765 static {
5766 FINDER_PATH_GET_ORGANIZATIONS.setCacheKeyGeneratorCacheName(null);
5767 }
5768
5769
5783 public List<com.liferay.portal.model.Organization> getOrganizations(
5784 long pk, int start, int end, OrderByComparator orderByComparator)
5785 throws SystemException {
5786 boolean pagination = true;
5787 Object[] finderArgs = null;
5788
5789 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5790 (orderByComparator == null)) {
5791 pagination = false;
5792 finderArgs = new Object[] { pk };
5793 }
5794 else {
5795 finderArgs = new Object[] { pk, start, end, orderByComparator };
5796 }
5797
5798 List<com.liferay.portal.model.Organization> list = (List<com.liferay.portal.model.Organization>)FinderCacheUtil.getResult(FINDER_PATH_GET_ORGANIZATIONS,
5799 finderArgs, this);
5800
5801 if (list == null) {
5802 Session session = null;
5803
5804 try {
5805 session = openSession();
5806
5807 String sql = null;
5808
5809 if (orderByComparator != null) {
5810 sql = _SQL_GETORGANIZATIONS.concat(ORDER_BY_CLAUSE)
5811 .concat(orderByComparator.getOrderBy());
5812 }
5813 else {
5814 sql = _SQL_GETORGANIZATIONS;
5815
5816 if (pagination) {
5817 sql = sql.concat(com.liferay.portal.model.impl.OrganizationModelImpl.ORDER_BY_SQL);
5818 }
5819 }
5820
5821 SQLQuery q = session.createSQLQuery(sql);
5822
5823 q.addEntity("Organization_",
5824 com.liferay.portal.model.impl.OrganizationImpl.class);
5825
5826 QueryPos qPos = QueryPos.getInstance(q);
5827
5828 qPos.add(pk);
5829
5830 if (!pagination) {
5831 list = (List<com.liferay.portal.model.Organization>)QueryUtil.list(q,
5832 getDialect(), start, end, false);
5833
5834 Collections.sort(list);
5835
5836 list = new UnmodifiableList<com.liferay.portal.model.Organization>(list);
5837 }
5838 else {
5839 list = (List<com.liferay.portal.model.Organization>)QueryUtil.list(q,
5840 getDialect(), start, end);
5841 }
5842
5843 organizationPersistence.cacheResult(list);
5844
5845 FinderCacheUtil.putResult(FINDER_PATH_GET_ORGANIZATIONS,
5846 finderArgs, list);
5847 }
5848 catch (Exception e) {
5849 FinderCacheUtil.removeResult(FINDER_PATH_GET_ORGANIZATIONS,
5850 finderArgs);
5851
5852 throw processException(e);
5853 }
5854 finally {
5855 closeSession(session);
5856 }
5857 }
5858
5859 return list;
5860 }
5861
5862 public static final FinderPath FINDER_PATH_GET_ORGANIZATIONS_SIZE = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
5863 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ORGS, Long.class,
5864 GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME,
5865 "getOrganizationsSize", new String[] { Long.class.getName() });
5866
5867 static {
5868 FINDER_PATH_GET_ORGANIZATIONS_SIZE.setCacheKeyGeneratorCacheName(null);
5869 }
5870
5871
5878 public int getOrganizationsSize(long pk) throws SystemException {
5879 Object[] finderArgs = new Object[] { pk };
5880
5881 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ORGANIZATIONS_SIZE,
5882 finderArgs, this);
5883
5884 if (count == null) {
5885 Session session = null;
5886
5887 try {
5888 session = openSession();
5889
5890 SQLQuery q = session.createSQLQuery(_SQL_GETORGANIZATIONSSIZE);
5891
5892 q.addScalar(COUNT_COLUMN_NAME,
5893 com.liferay.portal.kernel.dao.orm.Type.LONG);
5894
5895 QueryPos qPos = QueryPos.getInstance(q);
5896
5897 qPos.add(pk);
5898
5899 count = (Long)q.uniqueResult();
5900
5901 FinderCacheUtil.putResult(FINDER_PATH_GET_ORGANIZATIONS_SIZE,
5902 finderArgs, count);
5903 }
5904 catch (Exception e) {
5905 FinderCacheUtil.removeResult(FINDER_PATH_GET_ORGANIZATIONS_SIZE,
5906 finderArgs);
5907
5908 throw processException(e);
5909 }
5910 finally {
5911 closeSession(session);
5912 }
5913 }
5914
5915 return count.intValue();
5916 }
5917
5918 public static final FinderPath FINDER_PATH_CONTAINS_ORGANIZATION = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
5919 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ORGS, Boolean.class,
5920 GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME,
5921 "containsOrganization",
5922 new String[] { Long.class.getName(), Long.class.getName() });
5923
5924
5932 public boolean containsOrganization(long pk, long organizationPK)
5933 throws SystemException {
5934 Object[] finderArgs = new Object[] { pk, organizationPK };
5935
5936 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ORGANIZATION,
5937 finderArgs, this);
5938
5939 if (value == null) {
5940 try {
5941 value = Boolean.valueOf(containsOrganization.contains(pk,
5942 organizationPK));
5943
5944 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ORGANIZATION,
5945 finderArgs, value);
5946 }
5947 catch (Exception e) {
5948 FinderCacheUtil.removeResult(FINDER_PATH_CONTAINS_ORGANIZATION,
5949 finderArgs);
5950
5951 throw processException(e);
5952 }
5953 }
5954
5955 return value.booleanValue();
5956 }
5957
5958
5965 public boolean containsOrganizations(long pk) throws SystemException {
5966 if (getOrganizationsSize(pk) > 0) {
5967 return true;
5968 }
5969 else {
5970 return false;
5971 }
5972 }
5973
5974
5981 public void addOrganization(long pk, long organizationPK)
5982 throws SystemException {
5983 try {
5984 addOrganization.add(pk, organizationPK);
5985 }
5986 catch (Exception e) {
5987 throw processException(e);
5988 }
5989 finally {
5990 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
5991 }
5992 }
5993
5994
6001 public void addOrganization(long pk,
6002 com.liferay.portal.model.Organization organization)
6003 throws SystemException {
6004 try {
6005 addOrganization.add(pk, organization.getPrimaryKey());
6006 }
6007 catch (Exception e) {
6008 throw processException(e);
6009 }
6010 finally {
6011 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
6012 }
6013 }
6014
6015
6022 public void addOrganizations(long pk, long[] organizationPKs)
6023 throws SystemException {
6024 try {
6025 for (long organizationPK : organizationPKs) {
6026 addOrganization.add(pk, organizationPK);
6027 }
6028 }
6029 catch (Exception e) {
6030 throw processException(e);
6031 }
6032 finally {
6033 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
6034 }
6035 }
6036
6037
6044 public void addOrganizations(long pk,
6045 List<com.liferay.portal.model.Organization> organizations)
6046 throws SystemException {
6047 try {
6048 for (com.liferay.portal.model.Organization organization : organizations) {
6049 addOrganization.add(pk, organization.getPrimaryKey());
6050 }
6051 }
6052 catch (Exception e) {
6053 throw processException(e);
6054 }
6055 finally {
6056 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
6057 }
6058 }
6059
6060
6066 public void clearOrganizations(long pk) throws SystemException {
6067 try {
6068 clearOrganizations.clear(pk);
6069 }
6070 catch (Exception e) {
6071 throw processException(e);
6072 }
6073 finally {
6074 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
6075 }
6076 }
6077
6078
6085 public void removeOrganization(long pk, long organizationPK)
6086 throws SystemException {
6087 try {
6088 removeOrganization.remove(pk, organizationPK);
6089 }
6090 catch (Exception e) {
6091 throw processException(e);
6092 }
6093 finally {
6094 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
6095 }
6096 }
6097
6098
6105 public void removeOrganization(long pk,
6106 com.liferay.portal.model.Organization organization)
6107 throws SystemException {
6108 try {
6109 removeOrganization.remove(pk, organization.getPrimaryKey());
6110 }
6111 catch (Exception e) {
6112 throw processException(e);
6113 }
6114 finally {
6115 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
6116 }
6117 }
6118
6119
6126 public void removeOrganizations(long pk, long[] organizationPKs)
6127 throws SystemException {
6128 try {
6129 for (long organizationPK : organizationPKs) {
6130 removeOrganization.remove(pk, organizationPK);
6131 }
6132 }
6133 catch (Exception e) {
6134 throw processException(e);
6135 }
6136 finally {
6137 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
6138 }
6139 }
6140
6141
6148 public void removeOrganizations(long pk,
6149 List<com.liferay.portal.model.Organization> organizations)
6150 throws SystemException {
6151 try {
6152 for (com.liferay.portal.model.Organization organization : organizations) {
6153 removeOrganization.remove(pk, organization.getPrimaryKey());
6154 }
6155 }
6156 catch (Exception e) {
6157 throw processException(e);
6158 }
6159 finally {
6160 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
6161 }
6162 }
6163
6164
6171 public void setOrganizations(long pk, long[] organizationPKs)
6172 throws SystemException {
6173 try {
6174 Set<Long> organizationPKSet = SetUtil.fromArray(organizationPKs);
6175
6176 List<com.liferay.portal.model.Organization> organizations = getOrganizations(pk);
6177
6178 for (com.liferay.portal.model.Organization organization : organizations) {
6179 if (!organizationPKSet.remove(organization.getPrimaryKey())) {
6180 removeOrganization.remove(pk, organization.getPrimaryKey());
6181 }
6182 }
6183
6184 for (Long organizationPK : organizationPKSet) {
6185 addOrganization.add(pk, organizationPK);
6186 }
6187 }
6188 catch (Exception e) {
6189 throw processException(e);
6190 }
6191 finally {
6192 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
6193 }
6194 }
6195
6196
6203 public void setOrganizations(long pk,
6204 List<com.liferay.portal.model.Organization> organizations)
6205 throws SystemException {
6206 try {
6207 long[] organizationPKs = new long[organizations.size()];
6208
6209 for (int i = 0; i < organizations.size(); i++) {
6210 com.liferay.portal.model.Organization organization = organizations.get(i);
6211
6212 organizationPKs[i] = organization.getPrimaryKey();
6213 }
6214
6215 setOrganizations(pk, organizationPKs);
6216 }
6217 catch (Exception e) {
6218 throw processException(e);
6219 }
6220 finally {
6221 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
6222 }
6223 }
6224
6225
6232 public List<com.liferay.portal.model.Role> getRoles(long pk)
6233 throws SystemException {
6234 return getRoles(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
6235 }
6236
6237
6250 public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
6251 int end) throws SystemException {
6252 return getRoles(pk, start, end, null);
6253 }
6254
6255 public static final FinderPath FINDER_PATH_GET_ROLES = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
6256 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES,
6257 com.liferay.portal.model.impl.RoleImpl.class,
6258 GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "getRoles",
6259 new String[] {
6260 Long.class.getName(), Integer.class.getName(),
6261 Integer.class.getName(), OrderByComparator.class.getName()
6262 });
6263
6264 static {
6265 FINDER_PATH_GET_ROLES.setCacheKeyGeneratorCacheName(null);
6266 }
6267
6268
6282 public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
6283 int end, OrderByComparator orderByComparator) throws SystemException {
6284 boolean pagination = true;
6285 Object[] finderArgs = null;
6286
6287 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6288 (orderByComparator == null)) {
6289 pagination = false;
6290 finderArgs = new Object[] { pk };
6291 }
6292 else {
6293 finderArgs = new Object[] { pk, start, end, orderByComparator };
6294 }
6295
6296 List<com.liferay.portal.model.Role> list = (List<com.liferay.portal.model.Role>)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES,
6297 finderArgs, this);
6298
6299 if (list == null) {
6300 Session session = null;
6301
6302 try {
6303 session = openSession();
6304
6305 String sql = null;
6306
6307 if (orderByComparator != null) {
6308 sql = _SQL_GETROLES.concat(ORDER_BY_CLAUSE)
6309 .concat(orderByComparator.getOrderBy());
6310 }
6311 else {
6312 sql = _SQL_GETROLES;
6313
6314 if (pagination) {
6315 sql = sql.concat(com.liferay.portal.model.impl.RoleModelImpl.ORDER_BY_SQL);
6316 }
6317 }
6318
6319 SQLQuery q = session.createSQLQuery(sql);
6320
6321 q.addEntity("Role_",
6322 com.liferay.portal.model.impl.RoleImpl.class);
6323
6324 QueryPos qPos = QueryPos.getInstance(q);
6325
6326 qPos.add(pk);
6327
6328 if (!pagination) {
6329 list = (List<com.liferay.portal.model.Role>)QueryUtil.list(q,
6330 getDialect(), start, end, false);
6331
6332 Collections.sort(list);
6333
6334 list = new UnmodifiableList<com.liferay.portal.model.Role>(list);
6335 }
6336 else {
6337 list = (List<com.liferay.portal.model.Role>)QueryUtil.list(q,
6338 getDialect(), start, end);
6339 }
6340
6341 rolePersistence.cacheResult(list);
6342
6343 FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES, finderArgs,
6344 list);
6345 }
6346 catch (Exception e) {
6347 FinderCacheUtil.removeResult(FINDER_PATH_GET_ROLES, finderArgs);
6348
6349 throw processException(e);
6350 }
6351 finally {
6352 closeSession(session);
6353 }
6354 }
6355
6356 return list;
6357 }
6358
6359 public static final FinderPath FINDER_PATH_GET_ROLES_SIZE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
6360 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES, Long.class,
6361 GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "getRolesSize",
6362 new String[] { Long.class.getName() });
6363
6364 static {
6365 FINDER_PATH_GET_ROLES_SIZE.setCacheKeyGeneratorCacheName(null);
6366 }
6367
6368
6375 public int getRolesSize(long pk) throws SystemException {
6376 Object[] finderArgs = new Object[] { pk };
6377
6378 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES_SIZE,
6379 finderArgs, this);
6380
6381 if (count == null) {
6382 Session session = null;
6383
6384 try {
6385 session = openSession();
6386
6387 SQLQuery q = session.createSQLQuery(_SQL_GETROLESSIZE);
6388
6389 q.addScalar(COUNT_COLUMN_NAME,
6390 com.liferay.portal.kernel.dao.orm.Type.LONG);
6391
6392 QueryPos qPos = QueryPos.getInstance(q);
6393
6394 qPos.add(pk);
6395
6396 count = (Long)q.uniqueResult();
6397
6398 FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES_SIZE,
6399 finderArgs, count);
6400 }
6401 catch (Exception e) {
6402 FinderCacheUtil.removeResult(FINDER_PATH_GET_ROLES_SIZE,
6403 finderArgs);
6404
6405 throw processException(e);
6406 }
6407 finally {
6408 closeSession(session);
6409 }
6410 }
6411
6412 return count.intValue();
6413 }
6414
6415 public static final FinderPath FINDER_PATH_CONTAINS_ROLE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
6416 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES, Boolean.class,
6417 GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "containsRole",
6418 new String[] { Long.class.getName(), Long.class.getName() });
6419
6420
6428 public boolean containsRole(long pk, long rolePK) throws SystemException {
6429 Object[] finderArgs = new Object[] { pk, rolePK };
6430
6431 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ROLE,
6432 finderArgs, this);
6433
6434 if (value == null) {
6435 try {
6436 value = Boolean.valueOf(containsRole.contains(pk, rolePK));
6437
6438 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ROLE,
6439 finderArgs, value);
6440 }
6441 catch (Exception e) {
6442 FinderCacheUtil.removeResult(FINDER_PATH_CONTAINS_ROLE,
6443 finderArgs);
6444
6445 throw processException(e);
6446 }
6447 }
6448
6449 return value.booleanValue();
6450 }
6451
6452
6459 public boolean containsRoles(long pk) throws SystemException {
6460 if (getRolesSize(pk) > 0) {
6461 return true;
6462 }
6463 else {
6464 return false;
6465 }
6466 }
6467
6468
6475 public void addRole(long pk, long rolePK) throws SystemException {
6476 try {
6477 addRole.add(pk, rolePK);
6478 }
6479 catch (Exception e) {
6480 throw processException(e);
6481 }
6482 finally {
6483 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
6484 }
6485 }
6486
6487
6494 public void addRole(long pk, com.liferay.portal.model.Role role)
6495 throws SystemException {
6496 try {
6497 addRole.add(pk, role.getPrimaryKey());
6498 }
6499 catch (Exception e) {
6500 throw processException(e);
6501 }
6502 finally {
6503 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
6504 }
6505 }
6506
6507
6514 public void addRoles(long pk, long[] rolePKs) throws SystemException {
6515 try {
6516 for (long rolePK : rolePKs) {
6517 addRole.add(pk, rolePK);
6518 }
6519 }
6520 catch (Exception e) {
6521 throw processException(e);
6522 }
6523 finally {
6524 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
6525 }
6526 }
6527
6528
6535 public void addRoles(long pk, List<com.liferay.portal.model.Role> roles)
6536 throws SystemException {
6537 try {
6538 for (com.liferay.portal.model.Role role : roles) {
6539 addRole.add(pk, role.getPrimaryKey());
6540 }
6541 }
6542 catch (Exception e) {
6543 throw processException(e);
6544 }
6545 finally {
6546 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
6547 }
6548 }
6549
6550
6556 public void clearRoles(long pk) throws SystemException {
6557 try {
6558 clearRoles.clear(pk);
6559 }
6560 catch (Exception e) {
6561 throw processException(e);
6562 }
6563 finally {
6564 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
6565 }
6566 }
6567
6568
6575 public void removeRole(long pk, long rolePK) throws SystemException {
6576 try {
6577 removeRole.remove(pk, rolePK);
6578 }
6579 catch (Exception e) {
6580 throw processException(e);
6581 }
6582 finally {
6583 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
6584 }
6585 }
6586
6587
6594 public void removeRole(long pk, com.liferay.portal.model.Role role)
6595 throws SystemException {
6596 try {
6597 removeRole.remove(pk, role.getPrimaryKey());
6598 }
6599 catch (Exception e) {
6600 throw processException(e);
6601 }
6602 finally {
6603 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
6604 }
6605 }
6606
6607
6614 public void removeRoles(long pk, long[] rolePKs) throws SystemException {
6615 try {
6616 for (long rolePK : rolePKs) {
6617 removeRole.remove(pk, rolePK);
6618 }
6619 }
6620 catch (Exception e) {
6621 throw processException(e);
6622 }
6623 finally {
6624 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
6625 }
6626 }
6627
6628
6635 public void removeRoles(long pk, List<com.liferay.portal.model.Role> roles)
6636 throws SystemException {
6637 try {
6638 for (com.liferay.portal.model.Role role : roles) {
6639 removeRole.remove(pk, role.getPrimaryKey());
6640 }
6641 }
6642 catch (Exception e) {
6643 throw processException(e);
6644 }
6645 finally {
6646 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
6647 }
6648 }
6649
6650
6657 public void setRoles(long pk, long[] rolePKs) throws SystemException {
6658 try {
6659 Set<Long> rolePKSet = SetUtil.fromArray(rolePKs);
6660
6661 List<com.liferay.portal.model.Role> roles = getRoles(pk);
6662
6663 for (com.liferay.portal.model.Role role : roles) {
6664 if (!rolePKSet.remove(role.getPrimaryKey())) {
6665 removeRole.remove(pk, role.getPrimaryKey());
6666 }
6667 }
6668
6669 for (Long rolePK : rolePKSet) {
6670 addRole.add(pk, rolePK);
6671 }
6672 }
6673 catch (Exception e) {
6674 throw processException(e);
6675 }
6676 finally {
6677 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
6678 }
6679 }
6680
6681
6688 public void setRoles(long pk, List<com.liferay.portal.model.Role> roles)
6689 throws SystemException {
6690 try {
6691 long[] rolePKs = new long[roles.size()];
6692
6693 for (int i = 0; i < roles.size(); i++) {
6694 com.liferay.portal.model.Role role = roles.get(i);
6695
6696 rolePKs[i] = role.getPrimaryKey();
6697 }
6698
6699 setRoles(pk, rolePKs);
6700 }
6701 catch (Exception e) {
6702 throw processException(e);
6703 }
6704 finally {
6705 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
6706 }
6707 }
6708
6709
6716 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk)
6717 throws SystemException {
6718 return getUserGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
6719 }
6720
6721
6734 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
6735 int start, int end) throws SystemException {
6736 return getUserGroups(pk, start, end, null);
6737 }
6738
6739 public static final FinderPath FINDER_PATH_GET_USERGROUPS = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
6740 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS,
6741 com.liferay.portal.model.impl.UserGroupImpl.class,
6742 GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
6743 "getUserGroups",
6744 new String[] {
6745 Long.class.getName(), Integer.class.getName(),
6746 Integer.class.getName(), OrderByComparator.class.getName()
6747 });
6748
6749 static {
6750 FINDER_PATH_GET_USERGROUPS.setCacheKeyGeneratorCacheName(null);
6751 }
6752
6753
6767 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
6768 int start, int end, OrderByComparator orderByComparator)
6769 throws SystemException {
6770 boolean pagination = true;
6771 Object[] finderArgs = null;
6772
6773 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6774 (orderByComparator == null)) {
6775 pagination = false;
6776 finderArgs = new Object[] { pk };
6777 }
6778 else {
6779 finderArgs = new Object[] { pk, start, end, orderByComparator };
6780 }
6781
6782 List<com.liferay.portal.model.UserGroup> list = (List<com.liferay.portal.model.UserGroup>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS,
6783 finderArgs, this);
6784
6785 if (list == null) {
6786 Session session = null;
6787
6788 try {
6789 session = openSession();
6790
6791 String sql = null;
6792
6793 if (orderByComparator != null) {
6794 sql = _SQL_GETUSERGROUPS.concat(ORDER_BY_CLAUSE)
6795 .concat(orderByComparator.getOrderBy());
6796 }
6797 else {
6798 sql = _SQL_GETUSERGROUPS;
6799
6800 if (pagination) {
6801 sql = sql.concat(com.liferay.portal.model.impl.UserGroupModelImpl.ORDER_BY_SQL);
6802 }
6803 }
6804
6805 SQLQuery q = session.createSQLQuery(sql);
6806
6807 q.addEntity("UserGroup",
6808 com.liferay.portal.model.impl.UserGroupImpl.class);
6809
6810 QueryPos qPos = QueryPos.getInstance(q);
6811
6812 qPos.add(pk);
6813
6814 if (!pagination) {
6815 list = (List<com.liferay.portal.model.UserGroup>)QueryUtil.list(q,
6816 getDialect(), start, end, false);
6817
6818 Collections.sort(list);
6819
6820 list = new UnmodifiableList<com.liferay.portal.model.UserGroup>(list);
6821 }
6822 else {
6823 list = (List<com.liferay.portal.model.UserGroup>)QueryUtil.list(q,
6824 getDialect(), start, end);
6825 }
6826
6827 userGroupPersistence.cacheResult(list);
6828
6829 FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS,
6830 finderArgs, list);
6831 }
6832 catch (Exception e) {
6833 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERGROUPS,
6834 finderArgs);
6835
6836 throw processException(e);
6837 }
6838 finally {
6839 closeSession(session);
6840 }
6841 }
6842
6843 return list;
6844 }
6845
6846 public static final FinderPath FINDER_PATH_GET_USERGROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
6847 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS, Long.class,
6848 GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
6849 "getUserGroupsSize", new String[] { Long.class.getName() });
6850
6851 static {
6852 FINDER_PATH_GET_USERGROUPS_SIZE.setCacheKeyGeneratorCacheName(null);
6853 }
6854
6855
6862 public int getUserGroupsSize(long pk) throws SystemException {
6863 Object[] finderArgs = new Object[] { pk };
6864
6865 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS_SIZE,
6866 finderArgs, this);
6867
6868 if (count == null) {
6869 Session session = null;
6870
6871 try {
6872 session = openSession();
6873
6874 SQLQuery q = session.createSQLQuery(_SQL_GETUSERGROUPSSIZE);
6875
6876 q.addScalar(COUNT_COLUMN_NAME,
6877 com.liferay.portal.kernel.dao.orm.Type.LONG);
6878
6879 QueryPos qPos = QueryPos.getInstance(q);
6880
6881 qPos.add(pk);
6882
6883 count = (Long)q.uniqueResult();
6884
6885 FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS_SIZE,
6886 finderArgs, count);
6887 }
6888 catch (Exception e) {
6889 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERGROUPS_SIZE,
6890 finderArgs);
6891
6892 throw processException(e);
6893 }
6894 finally {
6895 closeSession(session);
6896 }
6897 }
6898
6899 return count.intValue();
6900 }
6901
6902 public static final FinderPath FINDER_PATH_CONTAINS_USERGROUP = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
6903 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS,
6904 Boolean.class, GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
6905 "containsUserGroup",
6906 new String[] { Long.class.getName(), Long.class.getName() });
6907
6908
6916 public boolean containsUserGroup(long pk, long userGroupPK)
6917 throws SystemException {
6918 Object[] finderArgs = new Object[] { pk, userGroupPK };
6919
6920 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USERGROUP,
6921 finderArgs, this);
6922
6923 if (value == null) {
6924 try {
6925 value = Boolean.valueOf(containsUserGroup.contains(pk,
6926 userGroupPK));
6927
6928 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USERGROUP,
6929 finderArgs, value);
6930 }
6931 catch (Exception e) {
6932 FinderCacheUtil.removeResult(FINDER_PATH_CONTAINS_USERGROUP,
6933 finderArgs);
6934
6935 throw processException(e);
6936 }
6937 }
6938
6939 return value.booleanValue();
6940 }
6941
6942
6949 public boolean containsUserGroups(long pk) throws SystemException {
6950 if (getUserGroupsSize(pk) > 0) {
6951 return true;
6952 }
6953 else {
6954 return false;
6955 }
6956 }
6957
6958
6965 public void addUserGroup(long pk, long userGroupPK)
6966 throws SystemException {
6967 try {
6968 addUserGroup.add(pk, userGroupPK);
6969 }
6970 catch (Exception e) {
6971 throw processException(e);
6972 }
6973 finally {
6974 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
6975 }
6976 }
6977
6978
6985 public void addUserGroup(long pk,
6986 com.liferay.portal.model.UserGroup userGroup) throws SystemException {
6987 try {
6988 addUserGroup.add(pk, userGroup.getPrimaryKey());
6989 }
6990 catch (Exception e) {
6991 throw processException(e);
6992 }
6993 finally {
6994 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
6995 }
6996 }
6997
6998
7005 public void addUserGroups(long pk, long[] userGroupPKs)
7006 throws SystemException {
7007 try {
7008 for (long userGroupPK : userGroupPKs) {
7009 addUserGroup.add(pk, userGroupPK);
7010 }
7011 }
7012 catch (Exception e) {
7013 throw processException(e);
7014 }
7015 finally {
7016 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
7017 }
7018 }
7019
7020
7027 public void addUserGroups(long pk,
7028 List<com.liferay.portal.model.UserGroup> userGroups)
7029 throws SystemException {
7030 try {
7031 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
7032 addUserGroup.add(pk, userGroup.getPrimaryKey());
7033 }
7034 }
7035 catch (Exception e) {
7036 throw processException(e);
7037 }
7038 finally {
7039 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
7040 }
7041 }
7042
7043
7049 public void clearUserGroups(long pk) throws SystemException {
7050 try {
7051 clearUserGroups.clear(pk);
7052 }
7053 catch (Exception e) {
7054 throw processException(e);
7055 }
7056 finally {
7057 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
7058 }
7059 }
7060
7061
7068 public void removeUserGroup(long pk, long userGroupPK)
7069 throws SystemException {
7070 try {
7071 removeUserGroup.remove(pk, userGroupPK);
7072 }
7073 catch (Exception e) {
7074 throw processException(e);
7075 }
7076 finally {
7077 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
7078 }
7079 }
7080
7081
7088 public void removeUserGroup(long pk,
7089 com.liferay.portal.model.UserGroup userGroup) throws SystemException {
7090 try {
7091 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
7092 }
7093 catch (Exception e) {
7094 throw processException(e);
7095 }
7096 finally {
7097 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
7098 }
7099 }
7100
7101
7108 public void removeUserGroups(long pk, long[] userGroupPKs)
7109 throws SystemException {
7110 try {
7111 for (long userGroupPK : userGroupPKs) {
7112 removeUserGroup.remove(pk, userGroupPK);
7113 }
7114 }
7115 catch (Exception e) {
7116 throw processException(e);
7117 }
7118 finally {
7119 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
7120 }
7121 }
7122
7123
7130 public void removeUserGroups(long pk,
7131 List<com.liferay.portal.model.UserGroup> userGroups)
7132 throws SystemException {
7133 try {
7134 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
7135 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
7136 }
7137 }
7138 catch (Exception e) {
7139 throw processException(e);
7140 }
7141 finally {
7142 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
7143 }
7144 }
7145
7146
7153 public void setUserGroups(long pk, long[] userGroupPKs)
7154 throws SystemException {
7155 try {
7156 Set<Long> userGroupPKSet = SetUtil.fromArray(userGroupPKs);
7157
7158 List<com.liferay.portal.model.UserGroup> userGroups = getUserGroups(pk);
7159
7160 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
7161 if (!userGroupPKSet.remove(userGroup.getPrimaryKey())) {
7162 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
7163 }
7164 }
7165
7166 for (Long userGroupPK : userGroupPKSet) {
7167 addUserGroup.add(pk, userGroupPK);
7168 }
7169 }
7170 catch (Exception e) {
7171 throw processException(e);
7172 }
7173 finally {
7174 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
7175 }
7176 }
7177
7178
7185 public void setUserGroups(long pk,
7186 List<com.liferay.portal.model.UserGroup> userGroups)
7187 throws SystemException {
7188 try {
7189 long[] userGroupPKs = new long[userGroups.size()];
7190
7191 for (int i = 0; i < userGroups.size(); i++) {
7192 com.liferay.portal.model.UserGroup userGroup = userGroups.get(i);
7193
7194 userGroupPKs[i] = userGroup.getPrimaryKey();
7195 }
7196
7197 setUserGroups(pk, userGroupPKs);
7198 }
7199 catch (Exception e) {
7200 throw processException(e);
7201 }
7202 finally {
7203 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
7204 }
7205 }
7206
7207
7214 public List<com.liferay.portal.model.User> getUsers(long pk)
7215 throws SystemException {
7216 return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
7217 }
7218
7219
7232 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
7233 int end) throws SystemException {
7234 return getUsers(pk, start, end, null);
7235 }
7236
7237 public static final FinderPath FINDER_PATH_GET_USERS = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
7238 GroupModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS,
7239 com.liferay.portal.model.impl.UserImpl.class,
7240 GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "getUsers",
7241 new String[] {
7242 Long.class.getName(), Integer.class.getName(),
7243 Integer.class.getName(), OrderByComparator.class.getName()
7244 });
7245
7246 static {
7247 FINDER_PATH_GET_USERS.setCacheKeyGeneratorCacheName(null);
7248 }
7249
7250
7264 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
7265 int end, OrderByComparator orderByComparator) throws SystemException {
7266 boolean pagination = true;
7267 Object[] finderArgs = null;
7268
7269 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7270 (orderByComparator == null)) {
7271 pagination = false;
7272 finderArgs = new Object[] { pk };
7273 }
7274 else {
7275 finderArgs = new Object[] { pk, start, end, orderByComparator };
7276 }
7277
7278 List<com.liferay.portal.model.User> list = (List<com.liferay.portal.model.User>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS,
7279 finderArgs, this);
7280
7281 if (list == null) {
7282 Session session = null;
7283
7284 try {
7285 session = openSession();
7286
7287 String sql = null;
7288
7289 if (orderByComparator != null) {
7290 sql = _SQL_GETUSERS.concat(ORDER_BY_CLAUSE)
7291 .concat(orderByComparator.getOrderBy());
7292 }
7293 else {
7294 sql = _SQL_GETUSERS;
7295
7296 if (pagination) {
7297 sql = sql.concat(com.liferay.portal.model.impl.UserModelImpl.ORDER_BY_SQL);
7298 }
7299 }
7300
7301 SQLQuery q = session.createSQLQuery(sql);
7302
7303 q.addEntity("User_",
7304 com.liferay.portal.model.impl.UserImpl.class);
7305
7306 QueryPos qPos = QueryPos.getInstance(q);
7307
7308 qPos.add(pk);
7309
7310 if (!pagination) {
7311 list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
7312 getDialect(), start, end, false);
7313
7314 Collections.sort(list);
7315
7316 list = new UnmodifiableList<com.liferay.portal.model.User>(list);
7317 }
7318 else {
7319 list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
7320 getDialect(), start, end);
7321 }
7322
7323 userPersistence.cacheResult(list);
7324
7325 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS, finderArgs,
7326 list);
7327 }
7328 catch (Exception e) {
7329 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERS, finderArgs);
7330
7331 throw processException(e);
7332 }
7333 finally {
7334 closeSession(session);
7335 }
7336 }
7337
7338 return list;
7339 }
7340
7341 public static final FinderPath FINDER_PATH_GET_USERS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
7342 GroupModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS, Long.class,
7343 GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "getUsersSize",
7344 new String[] { Long.class.getName() });
7345
7346 static {
7347 FINDER_PATH_GET_USERS_SIZE.setCacheKeyGeneratorCacheName(null);
7348 }
7349
7350
7357 public int getUsersSize(long pk) throws SystemException {
7358 Object[] finderArgs = new Object[] { pk };
7359
7360 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS_SIZE,
7361 finderArgs, this);
7362
7363 if (count == null) {
7364 Session session = null;
7365
7366 try {
7367 session = openSession();
7368
7369 SQLQuery q = session.createSQLQuery(_SQL_GETUSERSSIZE);
7370
7371 q.addScalar(COUNT_COLUMN_NAME,
7372 com.liferay.portal.kernel.dao.orm.Type.LONG);
7373
7374 QueryPos qPos = QueryPos.getInstance(q);
7375
7376 qPos.add(pk);
7377
7378 count = (Long)q.uniqueResult();
7379
7380 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS_SIZE,
7381 finderArgs, count);
7382 }
7383 catch (Exception e) {
7384 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERS_SIZE,
7385 finderArgs);
7386
7387 throw processException(e);
7388 }
7389 finally {
7390 closeSession(session);
7391 }
7392 }
7393
7394 return count.intValue();
7395 }
7396
7397 public static final FinderPath FINDER_PATH_CONTAINS_USER = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
7398 GroupModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS, Boolean.class,
7399 GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "containsUser",
7400 new String[] { Long.class.getName(), Long.class.getName() });
7401
7402
7410 public boolean containsUser(long pk, long userPK) throws SystemException {
7411 Object[] finderArgs = new Object[] { pk, userPK };
7412
7413 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USER,
7414 finderArgs, this);
7415
7416 if (value == null) {
7417 try {
7418 value = Boolean.valueOf(containsUser.contains(pk, userPK));
7419
7420 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USER,
7421 finderArgs, value);
7422 }
7423 catch (Exception e) {
7424 FinderCacheUtil.removeResult(FINDER_PATH_CONTAINS_USER,
7425 finderArgs);
7426
7427 throw processException(e);
7428 }
7429 }
7430
7431 return value.booleanValue();
7432 }
7433
7434
7441 public boolean containsUsers(long pk) throws SystemException {
7442 if (getUsersSize(pk) > 0) {
7443 return true;
7444 }
7445 else {
7446 return false;
7447 }
7448 }
7449
7450
7457 public void addUser(long pk, long userPK) throws SystemException {
7458 try {
7459 addUser.add(pk, userPK);
7460 }
7461 catch (Exception e) {
7462 throw processException(e);
7463 }
7464 finally {
7465 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
7466 }
7467 }
7468
7469
7476 public void addUser(long pk, com.liferay.portal.model.User user)
7477 throws SystemException {
7478 try {
7479 addUser.add(pk, user.getPrimaryKey());
7480 }
7481 catch (Exception e) {
7482 throw processException(e);
7483 }
7484 finally {
7485 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
7486 }
7487 }
7488
7489
7496 public void addUsers(long pk, long[] userPKs) throws SystemException {
7497 try {
7498 for (long userPK : userPKs) {
7499 addUser.add(pk, userPK);
7500 }
7501 }
7502 catch (Exception e) {
7503 throw processException(e);
7504 }
7505 finally {
7506 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
7507 }
7508 }
7509
7510
7517 public void addUsers(long pk, List<com.liferay.portal.model.User> users)
7518 throws SystemException {
7519 try {
7520 for (com.liferay.portal.model.User user : users) {
7521 addUser.add(pk, user.getPrimaryKey());
7522 }
7523 }
7524 catch (Exception e) {
7525 throw processException(e);
7526 }
7527 finally {
7528 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
7529 }
7530 }
7531
7532
7538 public void clearUsers(long pk) throws SystemException {
7539 try {
7540 clearUsers.clear(pk);
7541 }
7542 catch (Exception e) {
7543 throw processException(e);
7544 }
7545 finally {
7546 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
7547 }
7548 }
7549
7550
7557 public void removeUser(long pk, long userPK) throws SystemException {
7558 try {
7559 removeUser.remove(pk, userPK);
7560 }
7561 catch (Exception e) {
7562 throw processException(e);
7563 }
7564 finally {
7565 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
7566 }
7567 }
7568
7569
7576 public void removeUser(long pk, com.liferay.portal.model.User user)
7577 throws SystemException {
7578 try {
7579 removeUser.remove(pk, user.getPrimaryKey());
7580 }
7581 catch (Exception e) {
7582 throw processException(e);
7583 }
7584 finally {
7585 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
7586 }
7587 }
7588
7589
7596 public void removeUsers(long pk, long[] userPKs) throws SystemException {
7597 try {
7598 for (long userPK : userPKs) {
7599 removeUser.remove(pk, userPK);
7600 }
7601 }
7602 catch (Exception e) {
7603 throw processException(e);
7604 }
7605 finally {
7606 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
7607 }
7608 }
7609
7610
7617 public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
7618 throws SystemException {
7619 try {
7620 for (com.liferay.portal.model.User user : users) {
7621 removeUser.remove(pk, user.getPrimaryKey());
7622 }
7623 }
7624 catch (Exception e) {
7625 throw processException(e);
7626 }
7627 finally {
7628 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
7629 }
7630 }
7631
7632
7639 public void setUsers(long pk, long[] userPKs) throws SystemException {
7640 try {
7641 Set<Long> userPKSet = SetUtil.fromArray(userPKs);
7642
7643 List<com.liferay.portal.model.User> users = getUsers(pk);
7644
7645 for (com.liferay.portal.model.User user : users) {
7646 if (!userPKSet.remove(user.getPrimaryKey())) {
7647 removeUser.remove(pk, user.getPrimaryKey());
7648 }
7649 }
7650
7651 for (Long userPK : userPKSet) {
7652 addUser.add(pk, userPK);
7653 }
7654 }
7655 catch (Exception e) {
7656 throw processException(e);
7657 }
7658 finally {
7659 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
7660 }
7661 }
7662
7663
7670 public void setUsers(long pk, List<com.liferay.portal.model.User> users)
7671 throws SystemException {
7672 try {
7673 long[] userPKs = new long[users.size()];
7674
7675 for (int i = 0; i < users.size(); i++) {
7676 com.liferay.portal.model.User user = users.get(i);
7677
7678 userPKs[i] = user.getPrimaryKey();
7679 }
7680
7681 setUsers(pk, userPKs);
7682 }
7683 catch (Exception e) {
7684 throw processException(e);
7685 }
7686 finally {
7687 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
7688 }
7689 }
7690
7691
7694 public void afterPropertiesSet() {
7695 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
7696 com.liferay.portal.util.PropsUtil.get(
7697 "value.object.listener.com.liferay.portal.model.Group")));
7698
7699 if (listenerClassNames.length > 0) {
7700 try {
7701 List<ModelListener<Group>> listenersList = new ArrayList<ModelListener<Group>>();
7702
7703 for (String listenerClassName : listenerClassNames) {
7704 listenersList.add((ModelListener<Group>)InstanceFactory.newInstance(
7705 listenerClassName));
7706 }
7707
7708 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
7709 }
7710 catch (Exception e) {
7711 _log.error(e);
7712 }
7713 }
7714
7715 containsOrganization = new ContainsOrganization();
7716
7717 addOrganization = new AddOrganization();
7718 clearOrganizations = new ClearOrganizations();
7719 removeOrganization = new RemoveOrganization();
7720
7721 containsRole = new ContainsRole();
7722
7723 addRole = new AddRole();
7724 clearRoles = new ClearRoles();
7725 removeRole = new RemoveRole();
7726
7727 containsUserGroup = new ContainsUserGroup();
7728
7729 addUserGroup = new AddUserGroup();
7730 clearUserGroups = new ClearUserGroups();
7731 removeUserGroup = new RemoveUserGroup();
7732
7733 containsUser = new ContainsUser();
7734
7735 addUser = new AddUser();
7736 clearUsers = new ClearUsers();
7737 removeUser = new RemoveUser();
7738 }
7739
7740 public void destroy() {
7741 EntityCacheUtil.removeCache(GroupImpl.class.getName());
7742 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
7743 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
7744 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
7745 }
7746
7747 @BeanReference(type = OrganizationPersistence.class)
7748 protected OrganizationPersistence organizationPersistence;
7749 protected ContainsOrganization containsOrganization;
7750 protected AddOrganization addOrganization;
7751 protected ClearOrganizations clearOrganizations;
7752 protected RemoveOrganization removeOrganization;
7753 @BeanReference(type = RolePersistence.class)
7754 protected RolePersistence rolePersistence;
7755 protected ContainsRole containsRole;
7756 protected AddRole addRole;
7757 protected ClearRoles clearRoles;
7758 protected RemoveRole removeRole;
7759 @BeanReference(type = UserGroupPersistence.class)
7760 protected UserGroupPersistence userGroupPersistence;
7761 protected ContainsUserGroup containsUserGroup;
7762 protected AddUserGroup addUserGroup;
7763 protected ClearUserGroups clearUserGroups;
7764 protected RemoveUserGroup removeUserGroup;
7765 @BeanReference(type = UserPersistence.class)
7766 protected UserPersistence userPersistence;
7767 protected ContainsUser containsUser;
7768 protected AddUser addUser;
7769 protected ClearUsers clearUsers;
7770 protected RemoveUser removeUser;
7771
7772 protected class ContainsOrganization {
7773 protected ContainsOrganization() {
7774 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
7775 _SQL_CONTAINSORGANIZATION,
7776 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
7777 RowMapper.COUNT);
7778 }
7779
7780 protected boolean contains(long groupId, long organizationId) {
7781 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
7782 new Long(groupId), new Long(organizationId)
7783 });
7784
7785 if (results.size() > 0) {
7786 Integer count = results.get(0);
7787
7788 if (count.intValue() > 0) {
7789 return true;
7790 }
7791 }
7792
7793 return false;
7794 }
7795
7796 private MappingSqlQuery<Integer> _mappingSqlQuery;
7797 }
7798
7799 protected class AddOrganization {
7800 protected AddOrganization() {
7801 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
7802 "INSERT INTO Groups_Orgs (groupId, organizationId) VALUES (?, ?)",
7803 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
7804 }
7805
7806 protected void add(long groupId, long organizationId)
7807 throws SystemException {
7808 if (!containsOrganization.contains(groupId, organizationId)) {
7809 ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
7810 organizationPersistence.getListeners();
7811
7812 for (ModelListener<Group> listener : listeners) {
7813 listener.onBeforeAddAssociation(groupId,
7814 com.liferay.portal.model.Organization.class.getName(),
7815 organizationId);
7816 }
7817
7818 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
7819 listener.onBeforeAddAssociation(organizationId,
7820 Group.class.getName(), groupId);
7821 }
7822
7823 _sqlUpdate.update(new Object[] {
7824 new Long(groupId), new Long(organizationId)
7825 });
7826
7827 for (ModelListener<Group> listener : listeners) {
7828 listener.onAfterAddAssociation(groupId,
7829 com.liferay.portal.model.Organization.class.getName(),
7830 organizationId);
7831 }
7832
7833 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
7834 listener.onAfterAddAssociation(organizationId,
7835 Group.class.getName(), groupId);
7836 }
7837 }
7838 }
7839
7840 private SqlUpdate _sqlUpdate;
7841 }
7842
7843 protected class ClearOrganizations {
7844 protected ClearOrganizations() {
7845 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
7846 "DELETE FROM Groups_Orgs WHERE groupId = ?",
7847 new int[] { java.sql.Types.BIGINT });
7848 }
7849
7850 protected void clear(long groupId) throws SystemException {
7851 ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
7852 organizationPersistence.getListeners();
7853
7854 List<com.liferay.portal.model.Organization> organizations = null;
7855
7856 if ((listeners.length > 0) || (organizationListeners.length > 0)) {
7857 organizations = getOrganizations(groupId);
7858
7859 for (com.liferay.portal.model.Organization organization : organizations) {
7860 for (ModelListener<Group> listener : listeners) {
7861 listener.onBeforeRemoveAssociation(groupId,
7862 com.liferay.portal.model.Organization.class.getName(),
7863 organization.getPrimaryKey());
7864 }
7865
7866 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
7867 listener.onBeforeRemoveAssociation(organization.getPrimaryKey(),
7868 Group.class.getName(), groupId);
7869 }
7870 }
7871 }
7872
7873 _sqlUpdate.update(new Object[] { new Long(groupId) });
7874
7875 if ((listeners.length > 0) || (organizationListeners.length > 0)) {
7876 for (com.liferay.portal.model.Organization organization : organizations) {
7877 for (ModelListener<Group> listener : listeners) {
7878 listener.onAfterRemoveAssociation(groupId,
7879 com.liferay.portal.model.Organization.class.getName(),
7880 organization.getPrimaryKey());
7881 }
7882
7883 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
7884 listener.onAfterRemoveAssociation(organization.getPrimaryKey(),
7885 Group.class.getName(), groupId);
7886 }
7887 }
7888 }
7889 }
7890
7891 private SqlUpdate _sqlUpdate;
7892 }
7893
7894 protected class RemoveOrganization {
7895 protected RemoveOrganization() {
7896 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
7897 "DELETE FROM Groups_Orgs WHERE groupId = ? AND organizationId = ?",
7898 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
7899 }
7900
7901 protected void remove(long groupId, long organizationId)
7902 throws SystemException {
7903 if (containsOrganization.contains(groupId, organizationId)) {
7904 ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
7905 organizationPersistence.getListeners();
7906
7907 for (ModelListener<Group> listener : listeners) {
7908 listener.onBeforeRemoveAssociation(groupId,
7909 com.liferay.portal.model.Organization.class.getName(),
7910 organizationId);
7911 }
7912
7913 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
7914 listener.onBeforeRemoveAssociation(organizationId,
7915 Group.class.getName(), groupId);
7916 }
7917
7918 _sqlUpdate.update(new Object[] {
7919 new Long(groupId), new Long(organizationId)
7920 });
7921
7922 for (ModelListener<Group> listener : listeners) {
7923 listener.onAfterRemoveAssociation(groupId,
7924 com.liferay.portal.model.Organization.class.getName(),
7925 organizationId);
7926 }
7927
7928 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
7929 listener.onAfterRemoveAssociation(organizationId,
7930 Group.class.getName(), groupId);
7931 }
7932 }
7933 }
7934
7935 private SqlUpdate _sqlUpdate;
7936 }
7937
7938 protected class ContainsRole {
7939 protected ContainsRole() {
7940 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
7941 _SQL_CONTAINSROLE,
7942 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
7943 RowMapper.COUNT);
7944 }
7945
7946 protected boolean contains(long groupId, long roleId) {
7947 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
7948 new Long(groupId), new Long(roleId)
7949 });
7950
7951 if (results.size() > 0) {
7952 Integer count = results.get(0);
7953
7954 if (count.intValue() > 0) {
7955 return true;
7956 }
7957 }
7958
7959 return false;
7960 }
7961
7962 private MappingSqlQuery<Integer> _mappingSqlQuery;
7963 }
7964
7965 protected class AddRole {
7966 protected AddRole() {
7967 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
7968 "INSERT INTO Groups_Roles (groupId, roleId) VALUES (?, ?)",
7969 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
7970 }
7971
7972 protected void add(long groupId, long roleId) throws SystemException {
7973 if (!containsRole.contains(groupId, roleId)) {
7974 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
7975
7976 for (ModelListener<Group> listener : listeners) {
7977 listener.onBeforeAddAssociation(groupId,
7978 com.liferay.portal.model.Role.class.getName(), roleId);
7979 }
7980
7981 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
7982 listener.onBeforeAddAssociation(roleId,
7983 Group.class.getName(), groupId);
7984 }
7985
7986 _sqlUpdate.update(new Object[] {
7987 new Long(groupId), new Long(roleId)
7988 });
7989
7990 for (ModelListener<Group> listener : listeners) {
7991 listener.onAfterAddAssociation(groupId,
7992 com.liferay.portal.model.Role.class.getName(), roleId);
7993 }
7994
7995 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
7996 listener.onAfterAddAssociation(roleId,
7997 Group.class.getName(), groupId);
7998 }
7999 }
8000 }
8001
8002 private SqlUpdate _sqlUpdate;
8003 }
8004
8005 protected class ClearRoles {
8006 protected ClearRoles() {
8007 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8008 "DELETE FROM Groups_Roles WHERE groupId = ?",
8009 new int[] { java.sql.Types.BIGINT });
8010 }
8011
8012 protected void clear(long groupId) throws SystemException {
8013 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
8014
8015 List<com.liferay.portal.model.Role> roles = null;
8016
8017 if ((listeners.length > 0) || (roleListeners.length > 0)) {
8018 roles = getRoles(groupId);
8019
8020 for (com.liferay.portal.model.Role role : roles) {
8021 for (ModelListener<Group> listener : listeners) {
8022 listener.onBeforeRemoveAssociation(groupId,
8023 com.liferay.portal.model.Role.class.getName(),
8024 role.getPrimaryKey());
8025 }
8026
8027 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
8028 listener.onBeforeRemoveAssociation(role.getPrimaryKey(),
8029 Group.class.getName(), groupId);
8030 }
8031 }
8032 }
8033
8034 _sqlUpdate.update(new Object[] { new Long(groupId) });
8035
8036 if ((listeners.length > 0) || (roleListeners.length > 0)) {
8037 for (com.liferay.portal.model.Role role : roles) {
8038 for (ModelListener<Group> listener : listeners) {
8039 listener.onAfterRemoveAssociation(groupId,
8040 com.liferay.portal.model.Role.class.getName(),
8041 role.getPrimaryKey());
8042 }
8043
8044 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
8045 listener.onAfterRemoveAssociation(role.getPrimaryKey(),
8046 Group.class.getName(), groupId);
8047 }
8048 }
8049 }
8050 }
8051
8052 private SqlUpdate _sqlUpdate;
8053 }
8054
8055 protected class RemoveRole {
8056 protected RemoveRole() {
8057 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8058 "DELETE FROM Groups_Roles WHERE groupId = ? AND roleId = ?",
8059 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8060 }
8061
8062 protected void remove(long groupId, long roleId)
8063 throws SystemException {
8064 if (containsRole.contains(groupId, roleId)) {
8065 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
8066
8067 for (ModelListener<Group> listener : listeners) {
8068 listener.onBeforeRemoveAssociation(groupId,
8069 com.liferay.portal.model.Role.class.getName(), roleId);
8070 }
8071
8072 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
8073 listener.onBeforeRemoveAssociation(roleId,
8074 Group.class.getName(), groupId);
8075 }
8076
8077 _sqlUpdate.update(new Object[] {
8078 new Long(groupId), new Long(roleId)
8079 });
8080
8081 for (ModelListener<Group> listener : listeners) {
8082 listener.onAfterRemoveAssociation(groupId,
8083 com.liferay.portal.model.Role.class.getName(), roleId);
8084 }
8085
8086 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
8087 listener.onAfterRemoveAssociation(roleId,
8088 Group.class.getName(), groupId);
8089 }
8090 }
8091 }
8092
8093 private SqlUpdate _sqlUpdate;
8094 }
8095
8096 protected class ContainsUserGroup {
8097 protected ContainsUserGroup() {
8098 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
8099 _SQL_CONTAINSUSERGROUP,
8100 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
8101 RowMapper.COUNT);
8102 }
8103
8104 protected boolean contains(long groupId, long userGroupId) {
8105 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
8106 new Long(groupId), new Long(userGroupId)
8107 });
8108
8109 if (results.size() > 0) {
8110 Integer count = results.get(0);
8111
8112 if (count.intValue() > 0) {
8113 return true;
8114 }
8115 }
8116
8117 return false;
8118 }
8119
8120 private MappingSqlQuery<Integer> _mappingSqlQuery;
8121 }
8122
8123 protected class AddUserGroup {
8124 protected AddUserGroup() {
8125 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8126 "INSERT INTO Groups_UserGroups (groupId, userGroupId) VALUES (?, ?)",
8127 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8128 }
8129
8130 protected void add(long groupId, long userGroupId)
8131 throws SystemException {
8132 if (!containsUserGroup.contains(groupId, userGroupId)) {
8133 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
8134 userGroupPersistence.getListeners();
8135
8136 for (ModelListener<Group> listener : listeners) {
8137 listener.onBeforeAddAssociation(groupId,
8138 com.liferay.portal.model.UserGroup.class.getName(),
8139 userGroupId);
8140 }
8141
8142 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
8143 listener.onBeforeAddAssociation(userGroupId,
8144 Group.class.getName(), groupId);
8145 }
8146
8147 _sqlUpdate.update(new Object[] {
8148 new Long(groupId), new Long(userGroupId)
8149 });
8150
8151 for (ModelListener<Group> listener : listeners) {
8152 listener.onAfterAddAssociation(groupId,
8153 com.liferay.portal.model.UserGroup.class.getName(),
8154 userGroupId);
8155 }
8156
8157 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
8158 listener.onAfterAddAssociation(userGroupId,
8159 Group.class.getName(), groupId);
8160 }
8161 }
8162 }
8163
8164 private SqlUpdate _sqlUpdate;
8165 }
8166
8167 protected class ClearUserGroups {
8168 protected ClearUserGroups() {
8169 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8170 "DELETE FROM Groups_UserGroups WHERE groupId = ?",
8171 new int[] { java.sql.Types.BIGINT });
8172 }
8173
8174 protected void clear(long groupId) throws SystemException {
8175 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
8176 userGroupPersistence.getListeners();
8177
8178 List<com.liferay.portal.model.UserGroup> userGroups = null;
8179
8180 if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
8181 userGroups = getUserGroups(groupId);
8182
8183 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
8184 for (ModelListener<Group> listener : listeners) {
8185 listener.onBeforeRemoveAssociation(groupId,
8186 com.liferay.portal.model.UserGroup.class.getName(),
8187 userGroup.getPrimaryKey());
8188 }
8189
8190 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
8191 listener.onBeforeRemoveAssociation(userGroup.getPrimaryKey(),
8192 Group.class.getName(), groupId);
8193 }
8194 }
8195 }
8196
8197 _sqlUpdate.update(new Object[] { new Long(groupId) });
8198
8199 if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
8200 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
8201 for (ModelListener<Group> listener : listeners) {
8202 listener.onAfterRemoveAssociation(groupId,
8203 com.liferay.portal.model.UserGroup.class.getName(),
8204 userGroup.getPrimaryKey());
8205 }
8206
8207 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
8208 listener.onAfterRemoveAssociation(userGroup.getPrimaryKey(),
8209 Group.class.getName(), groupId);
8210 }
8211 }
8212 }
8213 }
8214
8215 private SqlUpdate _sqlUpdate;
8216 }
8217
8218 protected class RemoveUserGroup {
8219 protected RemoveUserGroup() {
8220 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8221 "DELETE FROM Groups_UserGroups WHERE groupId = ? AND userGroupId = ?",
8222 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8223 }
8224
8225 protected void remove(long groupId, long userGroupId)
8226 throws SystemException {
8227 if (containsUserGroup.contains(groupId, userGroupId)) {
8228 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
8229 userGroupPersistence.getListeners();
8230
8231 for (ModelListener<Group> listener : listeners) {
8232 listener.onBeforeRemoveAssociation(groupId,
8233 com.liferay.portal.model.UserGroup.class.getName(),
8234 userGroupId);
8235 }
8236
8237 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
8238 listener.onBeforeRemoveAssociation(userGroupId,
8239 Group.class.getName(), groupId);
8240 }
8241
8242 _sqlUpdate.update(new Object[] {
8243 new Long(groupId), new Long(userGroupId)
8244 });
8245
8246 for (ModelListener<Group> listener : listeners) {
8247 listener.onAfterRemoveAssociation(groupId,
8248 com.liferay.portal.model.UserGroup.class.getName(),
8249 userGroupId);
8250 }
8251
8252 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
8253 listener.onAfterRemoveAssociation(userGroupId,
8254 Group.class.getName(), groupId);
8255 }
8256 }
8257 }
8258
8259 private SqlUpdate _sqlUpdate;
8260 }
8261
8262 protected class ContainsUser {
8263 protected ContainsUser() {
8264 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
8265 _SQL_CONTAINSUSER,
8266 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
8267 RowMapper.COUNT);
8268 }
8269
8270 protected boolean contains(long groupId, long userId) {
8271 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
8272 new Long(groupId), new Long(userId)
8273 });
8274
8275 if (results.size() > 0) {
8276 Integer count = results.get(0);
8277
8278 if (count.intValue() > 0) {
8279 return true;
8280 }
8281 }
8282
8283 return false;
8284 }
8285
8286 private MappingSqlQuery<Integer> _mappingSqlQuery;
8287 }
8288
8289 protected class AddUser {
8290 protected AddUser() {
8291 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8292 "INSERT INTO Users_Groups (groupId, userId) VALUES (?, ?)",
8293 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8294 }
8295
8296 protected void add(long groupId, long userId) throws SystemException {
8297 if (!containsUser.contains(groupId, userId)) {
8298 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
8299
8300 for (ModelListener<Group> listener : listeners) {
8301 listener.onBeforeAddAssociation(groupId,
8302 com.liferay.portal.model.User.class.getName(), userId);
8303 }
8304
8305 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
8306 listener.onBeforeAddAssociation(userId,
8307 Group.class.getName(), groupId);
8308 }
8309
8310 _sqlUpdate.update(new Object[] {
8311 new Long(groupId), new Long(userId)
8312 });
8313
8314 for (ModelListener<Group> listener : listeners) {
8315 listener.onAfterAddAssociation(groupId,
8316 com.liferay.portal.model.User.class.getName(), userId);
8317 }
8318
8319 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
8320 listener.onAfterAddAssociation(userId,
8321 Group.class.getName(), groupId);
8322 }
8323 }
8324 }
8325
8326 private SqlUpdate _sqlUpdate;
8327 }
8328
8329 protected class ClearUsers {
8330 protected ClearUsers() {
8331 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8332 "DELETE FROM Users_Groups WHERE groupId = ?",
8333 new int[] { java.sql.Types.BIGINT });
8334 }
8335
8336 protected void clear(long groupId) throws SystemException {
8337 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
8338
8339 List<com.liferay.portal.model.User> users = null;
8340
8341 if ((listeners.length > 0) || (userListeners.length > 0)) {
8342 users = getUsers(groupId);
8343
8344 for (com.liferay.portal.model.User user : users) {
8345 for (ModelListener<Group> listener : listeners) {
8346 listener.onBeforeRemoveAssociation(groupId,
8347 com.liferay.portal.model.User.class.getName(),
8348 user.getPrimaryKey());
8349 }
8350
8351 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
8352 listener.onBeforeRemoveAssociation(user.getPrimaryKey(),
8353 Group.class.getName(), groupId);
8354 }
8355 }
8356 }
8357
8358 _sqlUpdate.update(new Object[] { new Long(groupId) });
8359
8360 if ((listeners.length > 0) || (userListeners.length > 0)) {
8361 for (com.liferay.portal.model.User user : users) {
8362 for (ModelListener<Group> listener : listeners) {
8363 listener.onAfterRemoveAssociation(groupId,
8364 com.liferay.portal.model.User.class.getName(),
8365 user.getPrimaryKey());
8366 }
8367
8368 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
8369 listener.onAfterRemoveAssociation(user.getPrimaryKey(),
8370 Group.class.getName(), groupId);
8371 }
8372 }
8373 }
8374 }
8375
8376 private SqlUpdate _sqlUpdate;
8377 }
8378
8379 protected class RemoveUser {
8380 protected RemoveUser() {
8381 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8382 "DELETE FROM Users_Groups WHERE groupId = ? AND userId = ?",
8383 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8384 }
8385
8386 protected void remove(long groupId, long userId)
8387 throws SystemException {
8388 if (containsUser.contains(groupId, userId)) {
8389 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
8390
8391 for (ModelListener<Group> listener : listeners) {
8392 listener.onBeforeRemoveAssociation(groupId,
8393 com.liferay.portal.model.User.class.getName(), userId);
8394 }
8395
8396 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
8397 listener.onBeforeRemoveAssociation(userId,
8398 Group.class.getName(), groupId);
8399 }
8400
8401 _sqlUpdate.update(new Object[] {
8402 new Long(groupId), new Long(userId)
8403 });
8404
8405 for (ModelListener<Group> listener : listeners) {
8406 listener.onAfterRemoveAssociation(groupId,
8407 com.liferay.portal.model.User.class.getName(), userId);
8408 }
8409
8410 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
8411 listener.onAfterRemoveAssociation(userId,
8412 Group.class.getName(), groupId);
8413 }
8414 }
8415 }
8416
8417 private SqlUpdate _sqlUpdate;
8418 }
8419
8420 private static final String _SQL_SELECT_GROUP_ = "SELECT group_ FROM Group group_";
8421 private static final String _SQL_SELECT_GROUP__WHERE = "SELECT group_ FROM Group group_ WHERE ";
8422 private static final String _SQL_COUNT_GROUP_ = "SELECT COUNT(group_) FROM Group group_";
8423 private static final String _SQL_COUNT_GROUP__WHERE = "SELECT COUNT(group_) FROM Group group_ WHERE ";
8424 private static final String _SQL_GETORGANIZATIONS = "SELECT {Organization_.*} FROM Organization_ INNER JOIN Groups_Orgs ON (Groups_Orgs.organizationId = Organization_.organizationId) WHERE (Groups_Orgs.groupId = ?)";
8425 private static final String _SQL_GETORGANIZATIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Orgs WHERE groupId = ?";
8426 private static final String _SQL_CONTAINSORGANIZATION = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Orgs WHERE groupId = ? AND organizationId = ?";
8427 private static final String _SQL_GETROLES = "SELECT {Role_.*} FROM Role_ INNER JOIN Groups_Roles ON (Groups_Roles.roleId = Role_.roleId) WHERE (Groups_Roles.groupId = ?)";
8428 private static final String _SQL_GETROLESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Roles WHERE groupId = ?";
8429 private static final String _SQL_CONTAINSROLE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Roles WHERE groupId = ? AND roleId = ?";
8430 private static final String _SQL_GETUSERGROUPS = "SELECT {UserGroup.*} FROM UserGroup INNER JOIN Groups_UserGroups ON (Groups_UserGroups.userGroupId = UserGroup.userGroupId) WHERE (Groups_UserGroups.groupId = ?)";
8431 private static final String _SQL_GETUSERGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_UserGroups WHERE groupId = ?";
8432 private static final String _SQL_CONTAINSUSERGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_UserGroups WHERE groupId = ? AND userGroupId = ?";
8433 private static final String _SQL_GETUSERS = "SELECT {User_.*} FROM User_ INNER JOIN Users_Groups ON (Users_Groups.userId = User_.userId) WHERE (Users_Groups.groupId = ?)";
8434 private static final String _SQL_GETUSERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Groups WHERE groupId = ?";
8435 private static final String _SQL_CONTAINSUSER = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Groups WHERE groupId = ? AND userId = ?";
8436 private static final String _ORDER_BY_ENTITY_ALIAS = "group_.";
8437 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Group exists with the primary key ";
8438 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Group exists with the key {";
8439 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
8440 private static Log _log = LogFactoryUtil.getLog(GroupPersistenceImpl.class);
8441 private static Group _nullGroup = new GroupImpl() {
8442 @Override
8443 public Object clone() {
8444 return this;
8445 }
8446
8447 @Override
8448 public CacheModel<Group> toCacheModel() {
8449 return _nullGroupCacheModel;
8450 }
8451 };
8452
8453 private static CacheModel<Group> _nullGroupCacheModel = new CacheModel<Group>() {
8454 public Group toEntityModel() {
8455 return _nullGroup;
8456 }
8457 };
8458 }