001
014
015 package com.liferay.portal.service.persistence.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.NoSuchRoleException;
020 import com.liferay.portal.kernel.bean.BeanReference;
021 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
022 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
023 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
024 import com.liferay.portal.kernel.dao.orm.FinderPath;
025 import com.liferay.portal.kernel.dao.orm.Query;
026 import com.liferay.portal.kernel.dao.orm.QueryPos;
027 import com.liferay.portal.kernel.dao.orm.QueryUtil;
028 import com.liferay.portal.kernel.dao.orm.SQLQuery;
029 import com.liferay.portal.kernel.dao.orm.Session;
030 import com.liferay.portal.kernel.log.Log;
031 import com.liferay.portal.kernel.log.LogFactoryUtil;
032 import com.liferay.portal.kernel.util.ArrayUtil;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.SetUtil;
035 import com.liferay.portal.kernel.util.StringBundler;
036 import com.liferay.portal.kernel.util.StringPool;
037 import com.liferay.portal.kernel.util.StringUtil;
038 import com.liferay.portal.kernel.util.Validator;
039 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
040 import com.liferay.portal.model.CacheModel;
041 import com.liferay.portal.model.MVCCModel;
042 import com.liferay.portal.model.Role;
043 import com.liferay.portal.model.impl.RoleImpl;
044 import com.liferay.portal.model.impl.RoleModelImpl;
045 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
046 import com.liferay.portal.service.persistence.GroupPersistence;
047 import com.liferay.portal.service.persistence.RolePersistence;
048 import com.liferay.portal.service.persistence.UserPersistence;
049
050 import java.io.Serializable;
051
052 import java.util.Collections;
053 import java.util.HashMap;
054 import java.util.HashSet;
055 import java.util.Iterator;
056 import java.util.List;
057 import java.util.Map;
058 import java.util.Set;
059
060
072 @ProviderType
073 public class RolePersistenceImpl extends BasePersistenceImpl<Role>
074 implements RolePersistence {
075
080 public static final String FINDER_CLASS_NAME_ENTITY = RoleImpl.class.getName();
081 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
082 ".List1";
083 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
084 ".List2";
085 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
086 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
087 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
088 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
089 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
090 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
091 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
092 RoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
093 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
094 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
095 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
096 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
097 new String[] {
098 String.class.getName(),
099
100 Integer.class.getName(), Integer.class.getName(),
101 OrderByComparator.class.getName()
102 });
103 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
104 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
105 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
106 new String[] { String.class.getName() },
107 RoleModelImpl.UUID_COLUMN_BITMASK |
108 RoleModelImpl.NAME_COLUMN_BITMASK);
109 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
110 RoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
111 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
112 new String[] { String.class.getName() });
113
114
120 @Override
121 public List<Role> findByUuid(String uuid) {
122 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
123 }
124
125
137 @Override
138 public List<Role> findByUuid(String uuid, int start, int end) {
139 return findByUuid(uuid, start, end, null);
140 }
141
142
155 @Override
156 public List<Role> findByUuid(String uuid, int start, int end,
157 OrderByComparator<Role> orderByComparator) {
158 boolean pagination = true;
159 FinderPath finderPath = null;
160 Object[] finderArgs = null;
161
162 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
163 (orderByComparator == null)) {
164 pagination = false;
165 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
166 finderArgs = new Object[] { uuid };
167 }
168 else {
169 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
170 finderArgs = new Object[] { uuid, start, end, orderByComparator };
171 }
172
173 List<Role> list = (List<Role>)FinderCacheUtil.getResult(finderPath,
174 finderArgs, this);
175
176 if ((list != null) && !list.isEmpty()) {
177 for (Role role : list) {
178 if (!Validator.equals(uuid, role.getUuid())) {
179 list = null;
180
181 break;
182 }
183 }
184 }
185
186 if (list == null) {
187 StringBundler query = null;
188
189 if (orderByComparator != null) {
190 query = new StringBundler(3 +
191 (orderByComparator.getOrderByFields().length * 3));
192 }
193 else {
194 query = new StringBundler(3);
195 }
196
197 query.append(_SQL_SELECT_ROLE_WHERE);
198
199 boolean bindUuid = false;
200
201 if (uuid == null) {
202 query.append(_FINDER_COLUMN_UUID_UUID_1);
203 }
204 else if (uuid.equals(StringPool.BLANK)) {
205 query.append(_FINDER_COLUMN_UUID_UUID_3);
206 }
207 else {
208 bindUuid = true;
209
210 query.append(_FINDER_COLUMN_UUID_UUID_2);
211 }
212
213 if (orderByComparator != null) {
214 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
215 orderByComparator);
216 }
217 else
218 if (pagination) {
219 query.append(RoleModelImpl.ORDER_BY_JPQL);
220 }
221
222 String sql = query.toString();
223
224 Session session = null;
225
226 try {
227 session = openSession();
228
229 Query q = session.createQuery(sql);
230
231 QueryPos qPos = QueryPos.getInstance(q);
232
233 if (bindUuid) {
234 qPos.add(uuid);
235 }
236
237 if (!pagination) {
238 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
239 end, false);
240
241 Collections.sort(list);
242
243 list = Collections.unmodifiableList(list);
244 }
245 else {
246 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
247 end);
248 }
249
250 cacheResult(list);
251
252 FinderCacheUtil.putResult(finderPath, finderArgs, list);
253 }
254 catch (Exception e) {
255 FinderCacheUtil.removeResult(finderPath, finderArgs);
256
257 throw processException(e);
258 }
259 finally {
260 closeSession(session);
261 }
262 }
263
264 return list;
265 }
266
267
275 @Override
276 public Role findByUuid_First(String uuid,
277 OrderByComparator<Role> orderByComparator) throws NoSuchRoleException {
278 Role role = fetchByUuid_First(uuid, orderByComparator);
279
280 if (role != null) {
281 return role;
282 }
283
284 StringBundler msg = new StringBundler(4);
285
286 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
287
288 msg.append("uuid=");
289 msg.append(uuid);
290
291 msg.append(StringPool.CLOSE_CURLY_BRACE);
292
293 throw new NoSuchRoleException(msg.toString());
294 }
295
296
303 @Override
304 public Role fetchByUuid_First(String uuid,
305 OrderByComparator<Role> orderByComparator) {
306 List<Role> list = findByUuid(uuid, 0, 1, orderByComparator);
307
308 if (!list.isEmpty()) {
309 return list.get(0);
310 }
311
312 return null;
313 }
314
315
323 @Override
324 public Role findByUuid_Last(String uuid,
325 OrderByComparator<Role> orderByComparator) throws NoSuchRoleException {
326 Role role = fetchByUuid_Last(uuid, orderByComparator);
327
328 if (role != null) {
329 return role;
330 }
331
332 StringBundler msg = new StringBundler(4);
333
334 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
335
336 msg.append("uuid=");
337 msg.append(uuid);
338
339 msg.append(StringPool.CLOSE_CURLY_BRACE);
340
341 throw new NoSuchRoleException(msg.toString());
342 }
343
344
351 @Override
352 public Role fetchByUuid_Last(String uuid,
353 OrderByComparator<Role> orderByComparator) {
354 int count = countByUuid(uuid);
355
356 if (count == 0) {
357 return null;
358 }
359
360 List<Role> list = findByUuid(uuid, count - 1, count, orderByComparator);
361
362 if (!list.isEmpty()) {
363 return list.get(0);
364 }
365
366 return null;
367 }
368
369
378 @Override
379 public Role[] findByUuid_PrevAndNext(long roleId, String uuid,
380 OrderByComparator<Role> orderByComparator) throws NoSuchRoleException {
381 Role role = findByPrimaryKey(roleId);
382
383 Session session = null;
384
385 try {
386 session = openSession();
387
388 Role[] array = new RoleImpl[3];
389
390 array[0] = getByUuid_PrevAndNext(session, role, uuid,
391 orderByComparator, true);
392
393 array[1] = role;
394
395 array[2] = getByUuid_PrevAndNext(session, role, uuid,
396 orderByComparator, false);
397
398 return array;
399 }
400 catch (Exception e) {
401 throw processException(e);
402 }
403 finally {
404 closeSession(session);
405 }
406 }
407
408 protected Role getByUuid_PrevAndNext(Session session, Role role,
409 String uuid, OrderByComparator<Role> orderByComparator, boolean previous) {
410 StringBundler query = null;
411
412 if (orderByComparator != null) {
413 query = new StringBundler(6 +
414 (orderByComparator.getOrderByFields().length * 6));
415 }
416 else {
417 query = new StringBundler(3);
418 }
419
420 query.append(_SQL_SELECT_ROLE_WHERE);
421
422 boolean bindUuid = false;
423
424 if (uuid == null) {
425 query.append(_FINDER_COLUMN_UUID_UUID_1);
426 }
427 else if (uuid.equals(StringPool.BLANK)) {
428 query.append(_FINDER_COLUMN_UUID_UUID_3);
429 }
430 else {
431 bindUuid = true;
432
433 query.append(_FINDER_COLUMN_UUID_UUID_2);
434 }
435
436 if (orderByComparator != null) {
437 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
438
439 if (orderByConditionFields.length > 0) {
440 query.append(WHERE_AND);
441 }
442
443 for (int i = 0; i < orderByConditionFields.length; i++) {
444 query.append(_ORDER_BY_ENTITY_ALIAS);
445 query.append(orderByConditionFields[i]);
446
447 if ((i + 1) < orderByConditionFields.length) {
448 if (orderByComparator.isAscending() ^ previous) {
449 query.append(WHERE_GREATER_THAN_HAS_NEXT);
450 }
451 else {
452 query.append(WHERE_LESSER_THAN_HAS_NEXT);
453 }
454 }
455 else {
456 if (orderByComparator.isAscending() ^ previous) {
457 query.append(WHERE_GREATER_THAN);
458 }
459 else {
460 query.append(WHERE_LESSER_THAN);
461 }
462 }
463 }
464
465 query.append(ORDER_BY_CLAUSE);
466
467 String[] orderByFields = orderByComparator.getOrderByFields();
468
469 for (int i = 0; i < orderByFields.length; i++) {
470 query.append(_ORDER_BY_ENTITY_ALIAS);
471 query.append(orderByFields[i]);
472
473 if ((i + 1) < orderByFields.length) {
474 if (orderByComparator.isAscending() ^ previous) {
475 query.append(ORDER_BY_ASC_HAS_NEXT);
476 }
477 else {
478 query.append(ORDER_BY_DESC_HAS_NEXT);
479 }
480 }
481 else {
482 if (orderByComparator.isAscending() ^ previous) {
483 query.append(ORDER_BY_ASC);
484 }
485 else {
486 query.append(ORDER_BY_DESC);
487 }
488 }
489 }
490 }
491 else {
492 query.append(RoleModelImpl.ORDER_BY_JPQL);
493 }
494
495 String sql = query.toString();
496
497 Query q = session.createQuery(sql);
498
499 q.setFirstResult(0);
500 q.setMaxResults(2);
501
502 QueryPos qPos = QueryPos.getInstance(q);
503
504 if (bindUuid) {
505 qPos.add(uuid);
506 }
507
508 if (orderByComparator != null) {
509 Object[] values = orderByComparator.getOrderByConditionValues(role);
510
511 for (Object value : values) {
512 qPos.add(value);
513 }
514 }
515
516 List<Role> list = q.list();
517
518 if (list.size() == 2) {
519 return list.get(1);
520 }
521 else {
522 return null;
523 }
524 }
525
526
532 @Override
533 public List<Role> filterFindByUuid(String uuid) {
534 return filterFindByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
535 }
536
537
549 @Override
550 public List<Role> filterFindByUuid(String uuid, int start, int end) {
551 return filterFindByUuid(uuid, start, end, null);
552 }
553
554
567 @Override
568 public List<Role> filterFindByUuid(String uuid, int start, int end,
569 OrderByComparator<Role> orderByComparator) {
570 if (!InlineSQLHelperUtil.isEnabled()) {
571 return findByUuid(uuid, start, end, orderByComparator);
572 }
573
574 StringBundler query = null;
575
576 if (orderByComparator != null) {
577 query = new StringBundler(3 +
578 (orderByComparator.getOrderByFields().length * 3));
579 }
580 else {
581 query = new StringBundler(3);
582 }
583
584 if (getDB().isSupportsInlineDistinct()) {
585 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
586 }
587 else {
588 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
589 }
590
591 boolean bindUuid = false;
592
593 if (uuid == null) {
594 query.append(_FINDER_COLUMN_UUID_UUID_1_SQL);
595 }
596 else if (uuid.equals(StringPool.BLANK)) {
597 query.append(_FINDER_COLUMN_UUID_UUID_3_SQL);
598 }
599 else {
600 bindUuid = true;
601
602 query.append(_FINDER_COLUMN_UUID_UUID_2_SQL);
603 }
604
605 if (!getDB().isSupportsInlineDistinct()) {
606 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
607 }
608
609 if (orderByComparator != null) {
610 if (getDB().isSupportsInlineDistinct()) {
611 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
612 orderByComparator, true);
613 }
614 else {
615 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
616 orderByComparator, true);
617 }
618 }
619 else {
620 if (getDB().isSupportsInlineDistinct()) {
621 query.append(RoleModelImpl.ORDER_BY_JPQL);
622 }
623 else {
624 query.append(RoleModelImpl.ORDER_BY_SQL);
625 }
626 }
627
628 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
629 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
630
631 Session session = null;
632
633 try {
634 session = openSession();
635
636 SQLQuery q = session.createSynchronizedSQLQuery(sql);
637
638 if (getDB().isSupportsInlineDistinct()) {
639 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
640 }
641 else {
642 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
643 }
644
645 QueryPos qPos = QueryPos.getInstance(q);
646
647 if (bindUuid) {
648 qPos.add(uuid);
649 }
650
651 return (List<Role>)QueryUtil.list(q, getDialect(), start, end);
652 }
653 catch (Exception e) {
654 throw processException(e);
655 }
656 finally {
657 closeSession(session);
658 }
659 }
660
661
670 @Override
671 public Role[] filterFindByUuid_PrevAndNext(long roleId, String uuid,
672 OrderByComparator<Role> orderByComparator) throws NoSuchRoleException {
673 if (!InlineSQLHelperUtil.isEnabled()) {
674 return findByUuid_PrevAndNext(roleId, uuid, orderByComparator);
675 }
676
677 Role role = findByPrimaryKey(roleId);
678
679 Session session = null;
680
681 try {
682 session = openSession();
683
684 Role[] array = new RoleImpl[3];
685
686 array[0] = filterGetByUuid_PrevAndNext(session, role, uuid,
687 orderByComparator, true);
688
689 array[1] = role;
690
691 array[2] = filterGetByUuid_PrevAndNext(session, role, uuid,
692 orderByComparator, false);
693
694 return array;
695 }
696 catch (Exception e) {
697 throw processException(e);
698 }
699 finally {
700 closeSession(session);
701 }
702 }
703
704 protected Role filterGetByUuid_PrevAndNext(Session session, Role role,
705 String uuid, OrderByComparator<Role> orderByComparator, boolean previous) {
706 StringBundler query = null;
707
708 if (orderByComparator != null) {
709 query = new StringBundler(6 +
710 (orderByComparator.getOrderByFields().length * 6));
711 }
712 else {
713 query = new StringBundler(3);
714 }
715
716 if (getDB().isSupportsInlineDistinct()) {
717 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
718 }
719 else {
720 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
721 }
722
723 boolean bindUuid = false;
724
725 if (uuid == null) {
726 query.append(_FINDER_COLUMN_UUID_UUID_1_SQL);
727 }
728 else if (uuid.equals(StringPool.BLANK)) {
729 query.append(_FINDER_COLUMN_UUID_UUID_3_SQL);
730 }
731 else {
732 bindUuid = true;
733
734 query.append(_FINDER_COLUMN_UUID_UUID_2_SQL);
735 }
736
737 if (!getDB().isSupportsInlineDistinct()) {
738 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
739 }
740
741 if (orderByComparator != null) {
742 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
743
744 if (orderByConditionFields.length > 0) {
745 query.append(WHERE_AND);
746 }
747
748 for (int i = 0; i < orderByConditionFields.length; i++) {
749 if (getDB().isSupportsInlineDistinct()) {
750 query.append(_ORDER_BY_ENTITY_ALIAS);
751 }
752 else {
753 query.append(_ORDER_BY_ENTITY_TABLE);
754 }
755
756 query.append(orderByConditionFields[i]);
757
758 if ((i + 1) < orderByConditionFields.length) {
759 if (orderByComparator.isAscending() ^ previous) {
760 query.append(WHERE_GREATER_THAN_HAS_NEXT);
761 }
762 else {
763 query.append(WHERE_LESSER_THAN_HAS_NEXT);
764 }
765 }
766 else {
767 if (orderByComparator.isAscending() ^ previous) {
768 query.append(WHERE_GREATER_THAN);
769 }
770 else {
771 query.append(WHERE_LESSER_THAN);
772 }
773 }
774 }
775
776 query.append(ORDER_BY_CLAUSE);
777
778 String[] orderByFields = orderByComparator.getOrderByFields();
779
780 for (int i = 0; i < orderByFields.length; i++) {
781 if (getDB().isSupportsInlineDistinct()) {
782 query.append(_ORDER_BY_ENTITY_ALIAS);
783 }
784 else {
785 query.append(_ORDER_BY_ENTITY_TABLE);
786 }
787
788 query.append(orderByFields[i]);
789
790 if ((i + 1) < orderByFields.length) {
791 if (orderByComparator.isAscending() ^ previous) {
792 query.append(ORDER_BY_ASC_HAS_NEXT);
793 }
794 else {
795 query.append(ORDER_BY_DESC_HAS_NEXT);
796 }
797 }
798 else {
799 if (orderByComparator.isAscending() ^ previous) {
800 query.append(ORDER_BY_ASC);
801 }
802 else {
803 query.append(ORDER_BY_DESC);
804 }
805 }
806 }
807 }
808 else {
809 if (getDB().isSupportsInlineDistinct()) {
810 query.append(RoleModelImpl.ORDER_BY_JPQL);
811 }
812 else {
813 query.append(RoleModelImpl.ORDER_BY_SQL);
814 }
815 }
816
817 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
818 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
819
820 SQLQuery q = session.createSynchronizedSQLQuery(sql);
821
822 q.setFirstResult(0);
823 q.setMaxResults(2);
824
825 if (getDB().isSupportsInlineDistinct()) {
826 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
827 }
828 else {
829 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
830 }
831
832 QueryPos qPos = QueryPos.getInstance(q);
833
834 if (bindUuid) {
835 qPos.add(uuid);
836 }
837
838 if (orderByComparator != null) {
839 Object[] values = orderByComparator.getOrderByConditionValues(role);
840
841 for (Object value : values) {
842 qPos.add(value);
843 }
844 }
845
846 List<Role> list = q.list();
847
848 if (list.size() == 2) {
849 return list.get(1);
850 }
851 else {
852 return null;
853 }
854 }
855
856
861 @Override
862 public void removeByUuid(String uuid) {
863 for (Role role : findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
864 null)) {
865 remove(role);
866 }
867 }
868
869
875 @Override
876 public int countByUuid(String uuid) {
877 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
878
879 Object[] finderArgs = new Object[] { uuid };
880
881 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
882 this);
883
884 if (count == null) {
885 StringBundler query = new StringBundler(2);
886
887 query.append(_SQL_COUNT_ROLE_WHERE);
888
889 boolean bindUuid = false;
890
891 if (uuid == null) {
892 query.append(_FINDER_COLUMN_UUID_UUID_1);
893 }
894 else if (uuid.equals(StringPool.BLANK)) {
895 query.append(_FINDER_COLUMN_UUID_UUID_3);
896 }
897 else {
898 bindUuid = true;
899
900 query.append(_FINDER_COLUMN_UUID_UUID_2);
901 }
902
903 String sql = query.toString();
904
905 Session session = null;
906
907 try {
908 session = openSession();
909
910 Query q = session.createQuery(sql);
911
912 QueryPos qPos = QueryPos.getInstance(q);
913
914 if (bindUuid) {
915 qPos.add(uuid);
916 }
917
918 count = (Long)q.uniqueResult();
919
920 FinderCacheUtil.putResult(finderPath, finderArgs, count);
921 }
922 catch (Exception e) {
923 FinderCacheUtil.removeResult(finderPath, finderArgs);
924
925 throw processException(e);
926 }
927 finally {
928 closeSession(session);
929 }
930 }
931
932 return count.intValue();
933 }
934
935
941 @Override
942 public int filterCountByUuid(String uuid) {
943 if (!InlineSQLHelperUtil.isEnabled()) {
944 return countByUuid(uuid);
945 }
946
947 StringBundler query = new StringBundler(2);
948
949 query.append(_FILTER_SQL_COUNT_ROLE_WHERE);
950
951 boolean bindUuid = false;
952
953 if (uuid == null) {
954 query.append(_FINDER_COLUMN_UUID_UUID_1_SQL);
955 }
956 else if (uuid.equals(StringPool.BLANK)) {
957 query.append(_FINDER_COLUMN_UUID_UUID_3_SQL);
958 }
959 else {
960 bindUuid = true;
961
962 query.append(_FINDER_COLUMN_UUID_UUID_2_SQL);
963 }
964
965 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
966 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
967
968 Session session = null;
969
970 try {
971 session = openSession();
972
973 SQLQuery q = session.createSynchronizedSQLQuery(sql);
974
975 q.addScalar(COUNT_COLUMN_NAME,
976 com.liferay.portal.kernel.dao.orm.Type.LONG);
977
978 QueryPos qPos = QueryPos.getInstance(q);
979
980 if (bindUuid) {
981 qPos.add(uuid);
982 }
983
984 Long count = (Long)q.uniqueResult();
985
986 return count.intValue();
987 }
988 catch (Exception e) {
989 throw processException(e);
990 }
991 finally {
992 closeSession(session);
993 }
994 }
995
996 private static final String _FINDER_COLUMN_UUID_UUID_1 = "role.uuid IS NULL";
997 private static final String _FINDER_COLUMN_UUID_UUID_2 = "role.uuid = ?";
998 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(role.uuid IS NULL OR role.uuid = '')";
999 private static final String _FINDER_COLUMN_UUID_UUID_1_SQL = "role.uuid_ IS NULL";
1000 private static final String _FINDER_COLUMN_UUID_UUID_2_SQL = "role.uuid_ = ?";
1001 private static final String _FINDER_COLUMN_UUID_UUID_3_SQL = "(role.uuid_ IS NULL OR role.uuid_ = '')";
1002 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
1003 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
1004 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
1005 new String[] {
1006 String.class.getName(), Long.class.getName(),
1007
1008 Integer.class.getName(), Integer.class.getName(),
1009 OrderByComparator.class.getName()
1010 });
1011 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
1012 new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
1013 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
1014 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
1015 new String[] { String.class.getName(), Long.class.getName() },
1016 RoleModelImpl.UUID_COLUMN_BITMASK |
1017 RoleModelImpl.COMPANYID_COLUMN_BITMASK |
1018 RoleModelImpl.NAME_COLUMN_BITMASK);
1019 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
1020 RoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
1021 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
1022 new String[] { String.class.getName(), Long.class.getName() });
1023
1024
1031 @Override
1032 public List<Role> findByUuid_C(String uuid, long companyId) {
1033 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1034 QueryUtil.ALL_POS, null);
1035 }
1036
1037
1050 @Override
1051 public List<Role> findByUuid_C(String uuid, long companyId, int start,
1052 int end) {
1053 return findByUuid_C(uuid, companyId, start, end, null);
1054 }
1055
1056
1070 @Override
1071 public List<Role> findByUuid_C(String uuid, long companyId, int start,
1072 int end, OrderByComparator<Role> orderByComparator) {
1073 boolean pagination = true;
1074 FinderPath finderPath = null;
1075 Object[] finderArgs = null;
1076
1077 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1078 (orderByComparator == null)) {
1079 pagination = false;
1080 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1081 finderArgs = new Object[] { uuid, companyId };
1082 }
1083 else {
1084 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1085 finderArgs = new Object[] {
1086 uuid, companyId,
1087
1088 start, end, orderByComparator
1089 };
1090 }
1091
1092 List<Role> list = (List<Role>)FinderCacheUtil.getResult(finderPath,
1093 finderArgs, this);
1094
1095 if ((list != null) && !list.isEmpty()) {
1096 for (Role role : list) {
1097 if (!Validator.equals(uuid, role.getUuid()) ||
1098 (companyId != role.getCompanyId())) {
1099 list = null;
1100
1101 break;
1102 }
1103 }
1104 }
1105
1106 if (list == null) {
1107 StringBundler query = null;
1108
1109 if (orderByComparator != null) {
1110 query = new StringBundler(4 +
1111 (orderByComparator.getOrderByFields().length * 3));
1112 }
1113 else {
1114 query = new StringBundler(4);
1115 }
1116
1117 query.append(_SQL_SELECT_ROLE_WHERE);
1118
1119 boolean bindUuid = false;
1120
1121 if (uuid == null) {
1122 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1123 }
1124 else if (uuid.equals(StringPool.BLANK)) {
1125 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1126 }
1127 else {
1128 bindUuid = true;
1129
1130 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1131 }
1132
1133 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1134
1135 if (orderByComparator != null) {
1136 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1137 orderByComparator);
1138 }
1139 else
1140 if (pagination) {
1141 query.append(RoleModelImpl.ORDER_BY_JPQL);
1142 }
1143
1144 String sql = query.toString();
1145
1146 Session session = null;
1147
1148 try {
1149 session = openSession();
1150
1151 Query q = session.createQuery(sql);
1152
1153 QueryPos qPos = QueryPos.getInstance(q);
1154
1155 if (bindUuid) {
1156 qPos.add(uuid);
1157 }
1158
1159 qPos.add(companyId);
1160
1161 if (!pagination) {
1162 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
1163 end, false);
1164
1165 Collections.sort(list);
1166
1167 list = Collections.unmodifiableList(list);
1168 }
1169 else {
1170 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
1171 end);
1172 }
1173
1174 cacheResult(list);
1175
1176 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1177 }
1178 catch (Exception e) {
1179 FinderCacheUtil.removeResult(finderPath, finderArgs);
1180
1181 throw processException(e);
1182 }
1183 finally {
1184 closeSession(session);
1185 }
1186 }
1187
1188 return list;
1189 }
1190
1191
1200 @Override
1201 public Role findByUuid_C_First(String uuid, long companyId,
1202 OrderByComparator<Role> orderByComparator) throws NoSuchRoleException {
1203 Role role = fetchByUuid_C_First(uuid, companyId, orderByComparator);
1204
1205 if (role != null) {
1206 return role;
1207 }
1208
1209 StringBundler msg = new StringBundler(6);
1210
1211 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1212
1213 msg.append("uuid=");
1214 msg.append(uuid);
1215
1216 msg.append(", companyId=");
1217 msg.append(companyId);
1218
1219 msg.append(StringPool.CLOSE_CURLY_BRACE);
1220
1221 throw new NoSuchRoleException(msg.toString());
1222 }
1223
1224
1232 @Override
1233 public Role fetchByUuid_C_First(String uuid, long companyId,
1234 OrderByComparator<Role> orderByComparator) {
1235 List<Role> list = findByUuid_C(uuid, companyId, 0, 1, orderByComparator);
1236
1237 if (!list.isEmpty()) {
1238 return list.get(0);
1239 }
1240
1241 return null;
1242 }
1243
1244
1253 @Override
1254 public Role findByUuid_C_Last(String uuid, long companyId,
1255 OrderByComparator<Role> orderByComparator) throws NoSuchRoleException {
1256 Role role = fetchByUuid_C_Last(uuid, companyId, orderByComparator);
1257
1258 if (role != null) {
1259 return role;
1260 }
1261
1262 StringBundler msg = new StringBundler(6);
1263
1264 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1265
1266 msg.append("uuid=");
1267 msg.append(uuid);
1268
1269 msg.append(", companyId=");
1270 msg.append(companyId);
1271
1272 msg.append(StringPool.CLOSE_CURLY_BRACE);
1273
1274 throw new NoSuchRoleException(msg.toString());
1275 }
1276
1277
1285 @Override
1286 public Role fetchByUuid_C_Last(String uuid, long companyId,
1287 OrderByComparator<Role> orderByComparator) {
1288 int count = countByUuid_C(uuid, companyId);
1289
1290 if (count == 0) {
1291 return null;
1292 }
1293
1294 List<Role> list = findByUuid_C(uuid, companyId, count - 1, count,
1295 orderByComparator);
1296
1297 if (!list.isEmpty()) {
1298 return list.get(0);
1299 }
1300
1301 return null;
1302 }
1303
1304
1314 @Override
1315 public Role[] findByUuid_C_PrevAndNext(long roleId, String uuid,
1316 long companyId, OrderByComparator<Role> orderByComparator)
1317 throws NoSuchRoleException {
1318 Role role = findByPrimaryKey(roleId);
1319
1320 Session session = null;
1321
1322 try {
1323 session = openSession();
1324
1325 Role[] array = new RoleImpl[3];
1326
1327 array[0] = getByUuid_C_PrevAndNext(session, role, uuid, companyId,
1328 orderByComparator, true);
1329
1330 array[1] = role;
1331
1332 array[2] = getByUuid_C_PrevAndNext(session, role, uuid, companyId,
1333 orderByComparator, false);
1334
1335 return array;
1336 }
1337 catch (Exception e) {
1338 throw processException(e);
1339 }
1340 finally {
1341 closeSession(session);
1342 }
1343 }
1344
1345 protected Role getByUuid_C_PrevAndNext(Session session, Role role,
1346 String uuid, long companyId, OrderByComparator<Role> orderByComparator,
1347 boolean previous) {
1348 StringBundler query = null;
1349
1350 if (orderByComparator != null) {
1351 query = new StringBundler(6 +
1352 (orderByComparator.getOrderByFields().length * 6));
1353 }
1354 else {
1355 query = new StringBundler(3);
1356 }
1357
1358 query.append(_SQL_SELECT_ROLE_WHERE);
1359
1360 boolean bindUuid = false;
1361
1362 if (uuid == null) {
1363 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1364 }
1365 else if (uuid.equals(StringPool.BLANK)) {
1366 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1367 }
1368 else {
1369 bindUuid = true;
1370
1371 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1372 }
1373
1374 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1375
1376 if (orderByComparator != null) {
1377 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1378
1379 if (orderByConditionFields.length > 0) {
1380 query.append(WHERE_AND);
1381 }
1382
1383 for (int i = 0; i < orderByConditionFields.length; i++) {
1384 query.append(_ORDER_BY_ENTITY_ALIAS);
1385 query.append(orderByConditionFields[i]);
1386
1387 if ((i + 1) < orderByConditionFields.length) {
1388 if (orderByComparator.isAscending() ^ previous) {
1389 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1390 }
1391 else {
1392 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1393 }
1394 }
1395 else {
1396 if (orderByComparator.isAscending() ^ previous) {
1397 query.append(WHERE_GREATER_THAN);
1398 }
1399 else {
1400 query.append(WHERE_LESSER_THAN);
1401 }
1402 }
1403 }
1404
1405 query.append(ORDER_BY_CLAUSE);
1406
1407 String[] orderByFields = orderByComparator.getOrderByFields();
1408
1409 for (int i = 0; i < orderByFields.length; i++) {
1410 query.append(_ORDER_BY_ENTITY_ALIAS);
1411 query.append(orderByFields[i]);
1412
1413 if ((i + 1) < orderByFields.length) {
1414 if (orderByComparator.isAscending() ^ previous) {
1415 query.append(ORDER_BY_ASC_HAS_NEXT);
1416 }
1417 else {
1418 query.append(ORDER_BY_DESC_HAS_NEXT);
1419 }
1420 }
1421 else {
1422 if (orderByComparator.isAscending() ^ previous) {
1423 query.append(ORDER_BY_ASC);
1424 }
1425 else {
1426 query.append(ORDER_BY_DESC);
1427 }
1428 }
1429 }
1430 }
1431 else {
1432 query.append(RoleModelImpl.ORDER_BY_JPQL);
1433 }
1434
1435 String sql = query.toString();
1436
1437 Query q = session.createQuery(sql);
1438
1439 q.setFirstResult(0);
1440 q.setMaxResults(2);
1441
1442 QueryPos qPos = QueryPos.getInstance(q);
1443
1444 if (bindUuid) {
1445 qPos.add(uuid);
1446 }
1447
1448 qPos.add(companyId);
1449
1450 if (orderByComparator != null) {
1451 Object[] values = orderByComparator.getOrderByConditionValues(role);
1452
1453 for (Object value : values) {
1454 qPos.add(value);
1455 }
1456 }
1457
1458 List<Role> list = q.list();
1459
1460 if (list.size() == 2) {
1461 return list.get(1);
1462 }
1463 else {
1464 return null;
1465 }
1466 }
1467
1468
1475 @Override
1476 public List<Role> filterFindByUuid_C(String uuid, long companyId) {
1477 return filterFindByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1478 QueryUtil.ALL_POS, null);
1479 }
1480
1481
1494 @Override
1495 public List<Role> filterFindByUuid_C(String uuid, long companyId,
1496 int start, int end) {
1497 return filterFindByUuid_C(uuid, companyId, start, end, null);
1498 }
1499
1500
1514 @Override
1515 public List<Role> filterFindByUuid_C(String uuid, long companyId,
1516 int start, int end, OrderByComparator<Role> orderByComparator) {
1517 if (!InlineSQLHelperUtil.isEnabled()) {
1518 return findByUuid_C(uuid, companyId, start, end, orderByComparator);
1519 }
1520
1521 StringBundler query = null;
1522
1523 if (orderByComparator != null) {
1524 query = new StringBundler(4 +
1525 (orderByComparator.getOrderByFields().length * 3));
1526 }
1527 else {
1528 query = new StringBundler(4);
1529 }
1530
1531 if (getDB().isSupportsInlineDistinct()) {
1532 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
1533 }
1534 else {
1535 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
1536 }
1537
1538 boolean bindUuid = false;
1539
1540 if (uuid == null) {
1541 query.append(_FINDER_COLUMN_UUID_C_UUID_1_SQL);
1542 }
1543 else if (uuid.equals(StringPool.BLANK)) {
1544 query.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL);
1545 }
1546 else {
1547 bindUuid = true;
1548
1549 query.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL);
1550 }
1551
1552 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1553
1554 if (!getDB().isSupportsInlineDistinct()) {
1555 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
1556 }
1557
1558 if (orderByComparator != null) {
1559 if (getDB().isSupportsInlineDistinct()) {
1560 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1561 orderByComparator, true);
1562 }
1563 else {
1564 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1565 orderByComparator, true);
1566 }
1567 }
1568 else {
1569 if (getDB().isSupportsInlineDistinct()) {
1570 query.append(RoleModelImpl.ORDER_BY_JPQL);
1571 }
1572 else {
1573 query.append(RoleModelImpl.ORDER_BY_SQL);
1574 }
1575 }
1576
1577 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1578 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1579
1580 Session session = null;
1581
1582 try {
1583 session = openSession();
1584
1585 SQLQuery q = session.createSynchronizedSQLQuery(sql);
1586
1587 if (getDB().isSupportsInlineDistinct()) {
1588 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
1589 }
1590 else {
1591 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
1592 }
1593
1594 QueryPos qPos = QueryPos.getInstance(q);
1595
1596 if (bindUuid) {
1597 qPos.add(uuid);
1598 }
1599
1600 qPos.add(companyId);
1601
1602 return (List<Role>)QueryUtil.list(q, getDialect(), start, end);
1603 }
1604 catch (Exception e) {
1605 throw processException(e);
1606 }
1607 finally {
1608 closeSession(session);
1609 }
1610 }
1611
1612
1622 @Override
1623 public Role[] filterFindByUuid_C_PrevAndNext(long roleId, String uuid,
1624 long companyId, OrderByComparator<Role> orderByComparator)
1625 throws NoSuchRoleException {
1626 if (!InlineSQLHelperUtil.isEnabled()) {
1627 return findByUuid_C_PrevAndNext(roleId, uuid, companyId,
1628 orderByComparator);
1629 }
1630
1631 Role role = findByPrimaryKey(roleId);
1632
1633 Session session = null;
1634
1635 try {
1636 session = openSession();
1637
1638 Role[] array = new RoleImpl[3];
1639
1640 array[0] = filterGetByUuid_C_PrevAndNext(session, role, uuid,
1641 companyId, orderByComparator, true);
1642
1643 array[1] = role;
1644
1645 array[2] = filterGetByUuid_C_PrevAndNext(session, role, uuid,
1646 companyId, orderByComparator, false);
1647
1648 return array;
1649 }
1650 catch (Exception e) {
1651 throw processException(e);
1652 }
1653 finally {
1654 closeSession(session);
1655 }
1656 }
1657
1658 protected Role filterGetByUuid_C_PrevAndNext(Session session, Role role,
1659 String uuid, long companyId, OrderByComparator<Role> orderByComparator,
1660 boolean previous) {
1661 StringBundler query = null;
1662
1663 if (orderByComparator != null) {
1664 query = new StringBundler(6 +
1665 (orderByComparator.getOrderByFields().length * 6));
1666 }
1667 else {
1668 query = new StringBundler(3);
1669 }
1670
1671 if (getDB().isSupportsInlineDistinct()) {
1672 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
1673 }
1674 else {
1675 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
1676 }
1677
1678 boolean bindUuid = false;
1679
1680 if (uuid == null) {
1681 query.append(_FINDER_COLUMN_UUID_C_UUID_1_SQL);
1682 }
1683 else if (uuid.equals(StringPool.BLANK)) {
1684 query.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL);
1685 }
1686 else {
1687 bindUuid = true;
1688
1689 query.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL);
1690 }
1691
1692 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1693
1694 if (!getDB().isSupportsInlineDistinct()) {
1695 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
1696 }
1697
1698 if (orderByComparator != null) {
1699 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1700
1701 if (orderByConditionFields.length > 0) {
1702 query.append(WHERE_AND);
1703 }
1704
1705 for (int i = 0; i < orderByConditionFields.length; i++) {
1706 if (getDB().isSupportsInlineDistinct()) {
1707 query.append(_ORDER_BY_ENTITY_ALIAS);
1708 }
1709 else {
1710 query.append(_ORDER_BY_ENTITY_TABLE);
1711 }
1712
1713 query.append(orderByConditionFields[i]);
1714
1715 if ((i + 1) < orderByConditionFields.length) {
1716 if (orderByComparator.isAscending() ^ previous) {
1717 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1718 }
1719 else {
1720 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1721 }
1722 }
1723 else {
1724 if (orderByComparator.isAscending() ^ previous) {
1725 query.append(WHERE_GREATER_THAN);
1726 }
1727 else {
1728 query.append(WHERE_LESSER_THAN);
1729 }
1730 }
1731 }
1732
1733 query.append(ORDER_BY_CLAUSE);
1734
1735 String[] orderByFields = orderByComparator.getOrderByFields();
1736
1737 for (int i = 0; i < orderByFields.length; i++) {
1738 if (getDB().isSupportsInlineDistinct()) {
1739 query.append(_ORDER_BY_ENTITY_ALIAS);
1740 }
1741 else {
1742 query.append(_ORDER_BY_ENTITY_TABLE);
1743 }
1744
1745 query.append(orderByFields[i]);
1746
1747 if ((i + 1) < orderByFields.length) {
1748 if (orderByComparator.isAscending() ^ previous) {
1749 query.append(ORDER_BY_ASC_HAS_NEXT);
1750 }
1751 else {
1752 query.append(ORDER_BY_DESC_HAS_NEXT);
1753 }
1754 }
1755 else {
1756 if (orderByComparator.isAscending() ^ previous) {
1757 query.append(ORDER_BY_ASC);
1758 }
1759 else {
1760 query.append(ORDER_BY_DESC);
1761 }
1762 }
1763 }
1764 }
1765 else {
1766 if (getDB().isSupportsInlineDistinct()) {
1767 query.append(RoleModelImpl.ORDER_BY_JPQL);
1768 }
1769 else {
1770 query.append(RoleModelImpl.ORDER_BY_SQL);
1771 }
1772 }
1773
1774 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1775 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1776
1777 SQLQuery q = session.createSynchronizedSQLQuery(sql);
1778
1779 q.setFirstResult(0);
1780 q.setMaxResults(2);
1781
1782 if (getDB().isSupportsInlineDistinct()) {
1783 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
1784 }
1785 else {
1786 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
1787 }
1788
1789 QueryPos qPos = QueryPos.getInstance(q);
1790
1791 if (bindUuid) {
1792 qPos.add(uuid);
1793 }
1794
1795 qPos.add(companyId);
1796
1797 if (orderByComparator != null) {
1798 Object[] values = orderByComparator.getOrderByConditionValues(role);
1799
1800 for (Object value : values) {
1801 qPos.add(value);
1802 }
1803 }
1804
1805 List<Role> list = q.list();
1806
1807 if (list.size() == 2) {
1808 return list.get(1);
1809 }
1810 else {
1811 return null;
1812 }
1813 }
1814
1815
1821 @Override
1822 public void removeByUuid_C(String uuid, long companyId) {
1823 for (Role role : findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1824 QueryUtil.ALL_POS, null)) {
1825 remove(role);
1826 }
1827 }
1828
1829
1836 @Override
1837 public int countByUuid_C(String uuid, long companyId) {
1838 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1839
1840 Object[] finderArgs = new Object[] { uuid, companyId };
1841
1842 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1843 this);
1844
1845 if (count == null) {
1846 StringBundler query = new StringBundler(3);
1847
1848 query.append(_SQL_COUNT_ROLE_WHERE);
1849
1850 boolean bindUuid = false;
1851
1852 if (uuid == null) {
1853 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1854 }
1855 else if (uuid.equals(StringPool.BLANK)) {
1856 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1857 }
1858 else {
1859 bindUuid = true;
1860
1861 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1862 }
1863
1864 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1865
1866 String sql = query.toString();
1867
1868 Session session = null;
1869
1870 try {
1871 session = openSession();
1872
1873 Query q = session.createQuery(sql);
1874
1875 QueryPos qPos = QueryPos.getInstance(q);
1876
1877 if (bindUuid) {
1878 qPos.add(uuid);
1879 }
1880
1881 qPos.add(companyId);
1882
1883 count = (Long)q.uniqueResult();
1884
1885 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1886 }
1887 catch (Exception e) {
1888 FinderCacheUtil.removeResult(finderPath, finderArgs);
1889
1890 throw processException(e);
1891 }
1892 finally {
1893 closeSession(session);
1894 }
1895 }
1896
1897 return count.intValue();
1898 }
1899
1900
1907 @Override
1908 public int filterCountByUuid_C(String uuid, long companyId) {
1909 if (!InlineSQLHelperUtil.isEnabled()) {
1910 return countByUuid_C(uuid, companyId);
1911 }
1912
1913 StringBundler query = new StringBundler(3);
1914
1915 query.append(_FILTER_SQL_COUNT_ROLE_WHERE);
1916
1917 boolean bindUuid = false;
1918
1919 if (uuid == null) {
1920 query.append(_FINDER_COLUMN_UUID_C_UUID_1_SQL);
1921 }
1922 else if (uuid.equals(StringPool.BLANK)) {
1923 query.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL);
1924 }
1925 else {
1926 bindUuid = true;
1927
1928 query.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL);
1929 }
1930
1931 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1932
1933 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1934 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1935
1936 Session session = null;
1937
1938 try {
1939 session = openSession();
1940
1941 SQLQuery q = session.createSynchronizedSQLQuery(sql);
1942
1943 q.addScalar(COUNT_COLUMN_NAME,
1944 com.liferay.portal.kernel.dao.orm.Type.LONG);
1945
1946 QueryPos qPos = QueryPos.getInstance(q);
1947
1948 if (bindUuid) {
1949 qPos.add(uuid);
1950 }
1951
1952 qPos.add(companyId);
1953
1954 Long count = (Long)q.uniqueResult();
1955
1956 return count.intValue();
1957 }
1958 catch (Exception e) {
1959 throw processException(e);
1960 }
1961 finally {
1962 closeSession(session);
1963 }
1964 }
1965
1966 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "role.uuid IS NULL AND ";
1967 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "role.uuid = ? AND ";
1968 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(role.uuid IS NULL OR role.uuid = '') AND ";
1969 private static final String _FINDER_COLUMN_UUID_C_UUID_1_SQL = "role.uuid_ IS NULL AND ";
1970 private static final String _FINDER_COLUMN_UUID_C_UUID_2_SQL = "role.uuid_ = ? AND ";
1971 private static final String _FINDER_COLUMN_UUID_C_UUID_3_SQL = "(role.uuid_ IS NULL OR role.uuid_ = '') AND ";
1972 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "role.companyId = ?";
1973 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
1974 new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
1975 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
1976 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
1977 new String[] {
1978 Long.class.getName(),
1979
1980 Integer.class.getName(), Integer.class.getName(),
1981 OrderByComparator.class.getName()
1982 });
1983 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
1984 new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
1985 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
1986 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
1987 new String[] { Long.class.getName() },
1988 RoleModelImpl.COMPANYID_COLUMN_BITMASK |
1989 RoleModelImpl.NAME_COLUMN_BITMASK);
1990 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
1991 RoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
1992 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
1993 new String[] { Long.class.getName() });
1994
1995
2001 @Override
2002 public List<Role> findByCompanyId(long companyId) {
2003 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2004 null);
2005 }
2006
2007
2019 @Override
2020 public List<Role> findByCompanyId(long companyId, int start, int end) {
2021 return findByCompanyId(companyId, start, end, null);
2022 }
2023
2024
2037 @Override
2038 public List<Role> findByCompanyId(long companyId, int start, int end,
2039 OrderByComparator<Role> orderByComparator) {
2040 boolean pagination = true;
2041 FinderPath finderPath = null;
2042 Object[] finderArgs = null;
2043
2044 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2045 (orderByComparator == null)) {
2046 pagination = false;
2047 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2048 finderArgs = new Object[] { companyId };
2049 }
2050 else {
2051 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2052 finderArgs = new Object[] { companyId, start, end, orderByComparator };
2053 }
2054
2055 List<Role> list = (List<Role>)FinderCacheUtil.getResult(finderPath,
2056 finderArgs, this);
2057
2058 if ((list != null) && !list.isEmpty()) {
2059 for (Role role : list) {
2060 if ((companyId != role.getCompanyId())) {
2061 list = null;
2062
2063 break;
2064 }
2065 }
2066 }
2067
2068 if (list == null) {
2069 StringBundler query = null;
2070
2071 if (orderByComparator != null) {
2072 query = new StringBundler(3 +
2073 (orderByComparator.getOrderByFields().length * 3));
2074 }
2075 else {
2076 query = new StringBundler(3);
2077 }
2078
2079 query.append(_SQL_SELECT_ROLE_WHERE);
2080
2081 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2082
2083 if (orderByComparator != null) {
2084 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2085 orderByComparator);
2086 }
2087 else
2088 if (pagination) {
2089 query.append(RoleModelImpl.ORDER_BY_JPQL);
2090 }
2091
2092 String sql = query.toString();
2093
2094 Session session = null;
2095
2096 try {
2097 session = openSession();
2098
2099 Query q = session.createQuery(sql);
2100
2101 QueryPos qPos = QueryPos.getInstance(q);
2102
2103 qPos.add(companyId);
2104
2105 if (!pagination) {
2106 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
2107 end, false);
2108
2109 Collections.sort(list);
2110
2111 list = Collections.unmodifiableList(list);
2112 }
2113 else {
2114 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
2115 end);
2116 }
2117
2118 cacheResult(list);
2119
2120 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2121 }
2122 catch (Exception e) {
2123 FinderCacheUtil.removeResult(finderPath, finderArgs);
2124
2125 throw processException(e);
2126 }
2127 finally {
2128 closeSession(session);
2129 }
2130 }
2131
2132 return list;
2133 }
2134
2135
2143 @Override
2144 public Role findByCompanyId_First(long companyId,
2145 OrderByComparator<Role> orderByComparator) throws NoSuchRoleException {
2146 Role role = fetchByCompanyId_First(companyId, orderByComparator);
2147
2148 if (role != null) {
2149 return role;
2150 }
2151
2152 StringBundler msg = new StringBundler(4);
2153
2154 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2155
2156 msg.append("companyId=");
2157 msg.append(companyId);
2158
2159 msg.append(StringPool.CLOSE_CURLY_BRACE);
2160
2161 throw new NoSuchRoleException(msg.toString());
2162 }
2163
2164
2171 @Override
2172 public Role fetchByCompanyId_First(long companyId,
2173 OrderByComparator<Role> orderByComparator) {
2174 List<Role> list = findByCompanyId(companyId, 0, 1, orderByComparator);
2175
2176 if (!list.isEmpty()) {
2177 return list.get(0);
2178 }
2179
2180 return null;
2181 }
2182
2183
2191 @Override
2192 public Role findByCompanyId_Last(long companyId,
2193 OrderByComparator<Role> orderByComparator) throws NoSuchRoleException {
2194 Role role = fetchByCompanyId_Last(companyId, orderByComparator);
2195
2196 if (role != null) {
2197 return role;
2198 }
2199
2200 StringBundler msg = new StringBundler(4);
2201
2202 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2203
2204 msg.append("companyId=");
2205 msg.append(companyId);
2206
2207 msg.append(StringPool.CLOSE_CURLY_BRACE);
2208
2209 throw new NoSuchRoleException(msg.toString());
2210 }
2211
2212
2219 @Override
2220 public Role fetchByCompanyId_Last(long companyId,
2221 OrderByComparator<Role> orderByComparator) {
2222 int count = countByCompanyId(companyId);
2223
2224 if (count == 0) {
2225 return null;
2226 }
2227
2228 List<Role> list = findByCompanyId(companyId, count - 1, count,
2229 orderByComparator);
2230
2231 if (!list.isEmpty()) {
2232 return list.get(0);
2233 }
2234
2235 return null;
2236 }
2237
2238
2247 @Override
2248 public Role[] findByCompanyId_PrevAndNext(long roleId, long companyId,
2249 OrderByComparator<Role> orderByComparator) throws NoSuchRoleException {
2250 Role role = findByPrimaryKey(roleId);
2251
2252 Session session = null;
2253
2254 try {
2255 session = openSession();
2256
2257 Role[] array = new RoleImpl[3];
2258
2259 array[0] = getByCompanyId_PrevAndNext(session, role, companyId,
2260 orderByComparator, true);
2261
2262 array[1] = role;
2263
2264 array[2] = getByCompanyId_PrevAndNext(session, role, companyId,
2265 orderByComparator, false);
2266
2267 return array;
2268 }
2269 catch (Exception e) {
2270 throw processException(e);
2271 }
2272 finally {
2273 closeSession(session);
2274 }
2275 }
2276
2277 protected Role getByCompanyId_PrevAndNext(Session session, Role role,
2278 long companyId, OrderByComparator<Role> orderByComparator,
2279 boolean previous) {
2280 StringBundler query = null;
2281
2282 if (orderByComparator != null) {
2283 query = new StringBundler(6 +
2284 (orderByComparator.getOrderByFields().length * 6));
2285 }
2286 else {
2287 query = new StringBundler(3);
2288 }
2289
2290 query.append(_SQL_SELECT_ROLE_WHERE);
2291
2292 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2293
2294 if (orderByComparator != null) {
2295 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2296
2297 if (orderByConditionFields.length > 0) {
2298 query.append(WHERE_AND);
2299 }
2300
2301 for (int i = 0; i < orderByConditionFields.length; i++) {
2302 query.append(_ORDER_BY_ENTITY_ALIAS);
2303 query.append(orderByConditionFields[i]);
2304
2305 if ((i + 1) < orderByConditionFields.length) {
2306 if (orderByComparator.isAscending() ^ previous) {
2307 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2308 }
2309 else {
2310 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2311 }
2312 }
2313 else {
2314 if (orderByComparator.isAscending() ^ previous) {
2315 query.append(WHERE_GREATER_THAN);
2316 }
2317 else {
2318 query.append(WHERE_LESSER_THAN);
2319 }
2320 }
2321 }
2322
2323 query.append(ORDER_BY_CLAUSE);
2324
2325 String[] orderByFields = orderByComparator.getOrderByFields();
2326
2327 for (int i = 0; i < orderByFields.length; i++) {
2328 query.append(_ORDER_BY_ENTITY_ALIAS);
2329 query.append(orderByFields[i]);
2330
2331 if ((i + 1) < orderByFields.length) {
2332 if (orderByComparator.isAscending() ^ previous) {
2333 query.append(ORDER_BY_ASC_HAS_NEXT);
2334 }
2335 else {
2336 query.append(ORDER_BY_DESC_HAS_NEXT);
2337 }
2338 }
2339 else {
2340 if (orderByComparator.isAscending() ^ previous) {
2341 query.append(ORDER_BY_ASC);
2342 }
2343 else {
2344 query.append(ORDER_BY_DESC);
2345 }
2346 }
2347 }
2348 }
2349 else {
2350 query.append(RoleModelImpl.ORDER_BY_JPQL);
2351 }
2352
2353 String sql = query.toString();
2354
2355 Query q = session.createQuery(sql);
2356
2357 q.setFirstResult(0);
2358 q.setMaxResults(2);
2359
2360 QueryPos qPos = QueryPos.getInstance(q);
2361
2362 qPos.add(companyId);
2363
2364 if (orderByComparator != null) {
2365 Object[] values = orderByComparator.getOrderByConditionValues(role);
2366
2367 for (Object value : values) {
2368 qPos.add(value);
2369 }
2370 }
2371
2372 List<Role> list = q.list();
2373
2374 if (list.size() == 2) {
2375 return list.get(1);
2376 }
2377 else {
2378 return null;
2379 }
2380 }
2381
2382
2388 @Override
2389 public List<Role> filterFindByCompanyId(long companyId) {
2390 return filterFindByCompanyId(companyId, QueryUtil.ALL_POS,
2391 QueryUtil.ALL_POS, null);
2392 }
2393
2394
2406 @Override
2407 public List<Role> filterFindByCompanyId(long companyId, int start, int end) {
2408 return filterFindByCompanyId(companyId, start, end, null);
2409 }
2410
2411
2424 @Override
2425 public List<Role> filterFindByCompanyId(long companyId, int start, int end,
2426 OrderByComparator<Role> orderByComparator) {
2427 if (!InlineSQLHelperUtil.isEnabled()) {
2428 return findByCompanyId(companyId, start, end, orderByComparator);
2429 }
2430
2431 StringBundler query = null;
2432
2433 if (orderByComparator != null) {
2434 query = new StringBundler(3 +
2435 (orderByComparator.getOrderByFields().length * 3));
2436 }
2437 else {
2438 query = new StringBundler(3);
2439 }
2440
2441 if (getDB().isSupportsInlineDistinct()) {
2442 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
2443 }
2444 else {
2445 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
2446 }
2447
2448 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2449
2450 if (!getDB().isSupportsInlineDistinct()) {
2451 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
2452 }
2453
2454 if (orderByComparator != null) {
2455 if (getDB().isSupportsInlineDistinct()) {
2456 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2457 orderByComparator, true);
2458 }
2459 else {
2460 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2461 orderByComparator, true);
2462 }
2463 }
2464 else {
2465 if (getDB().isSupportsInlineDistinct()) {
2466 query.append(RoleModelImpl.ORDER_BY_JPQL);
2467 }
2468 else {
2469 query.append(RoleModelImpl.ORDER_BY_SQL);
2470 }
2471 }
2472
2473 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2474 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2475
2476 Session session = null;
2477
2478 try {
2479 session = openSession();
2480
2481 SQLQuery q = session.createSynchronizedSQLQuery(sql);
2482
2483 if (getDB().isSupportsInlineDistinct()) {
2484 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
2485 }
2486 else {
2487 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
2488 }
2489
2490 QueryPos qPos = QueryPos.getInstance(q);
2491
2492 qPos.add(companyId);
2493
2494 return (List<Role>)QueryUtil.list(q, getDialect(), start, end);
2495 }
2496 catch (Exception e) {
2497 throw processException(e);
2498 }
2499 finally {
2500 closeSession(session);
2501 }
2502 }
2503
2504
2513 @Override
2514 public Role[] filterFindByCompanyId_PrevAndNext(long roleId,
2515 long companyId, OrderByComparator<Role> orderByComparator)
2516 throws NoSuchRoleException {
2517 if (!InlineSQLHelperUtil.isEnabled()) {
2518 return findByCompanyId_PrevAndNext(roleId, companyId,
2519 orderByComparator);
2520 }
2521
2522 Role role = findByPrimaryKey(roleId);
2523
2524 Session session = null;
2525
2526 try {
2527 session = openSession();
2528
2529 Role[] array = new RoleImpl[3];
2530
2531 array[0] = filterGetByCompanyId_PrevAndNext(session, role,
2532 companyId, orderByComparator, true);
2533
2534 array[1] = role;
2535
2536 array[2] = filterGetByCompanyId_PrevAndNext(session, role,
2537 companyId, orderByComparator, false);
2538
2539 return array;
2540 }
2541 catch (Exception e) {
2542 throw processException(e);
2543 }
2544 finally {
2545 closeSession(session);
2546 }
2547 }
2548
2549 protected Role filterGetByCompanyId_PrevAndNext(Session session, Role role,
2550 long companyId, OrderByComparator<Role> orderByComparator,
2551 boolean previous) {
2552 StringBundler query = null;
2553
2554 if (orderByComparator != null) {
2555 query = new StringBundler(6 +
2556 (orderByComparator.getOrderByFields().length * 6));
2557 }
2558 else {
2559 query = new StringBundler(3);
2560 }
2561
2562 if (getDB().isSupportsInlineDistinct()) {
2563 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
2564 }
2565 else {
2566 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
2567 }
2568
2569 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2570
2571 if (!getDB().isSupportsInlineDistinct()) {
2572 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
2573 }
2574
2575 if (orderByComparator != null) {
2576 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2577
2578 if (orderByConditionFields.length > 0) {
2579 query.append(WHERE_AND);
2580 }
2581
2582 for (int i = 0; i < orderByConditionFields.length; i++) {
2583 if (getDB().isSupportsInlineDistinct()) {
2584 query.append(_ORDER_BY_ENTITY_ALIAS);
2585 }
2586 else {
2587 query.append(_ORDER_BY_ENTITY_TABLE);
2588 }
2589
2590 query.append(orderByConditionFields[i]);
2591
2592 if ((i + 1) < orderByConditionFields.length) {
2593 if (orderByComparator.isAscending() ^ previous) {
2594 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2595 }
2596 else {
2597 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2598 }
2599 }
2600 else {
2601 if (orderByComparator.isAscending() ^ previous) {
2602 query.append(WHERE_GREATER_THAN);
2603 }
2604 else {
2605 query.append(WHERE_LESSER_THAN);
2606 }
2607 }
2608 }
2609
2610 query.append(ORDER_BY_CLAUSE);
2611
2612 String[] orderByFields = orderByComparator.getOrderByFields();
2613
2614 for (int i = 0; i < orderByFields.length; i++) {
2615 if (getDB().isSupportsInlineDistinct()) {
2616 query.append(_ORDER_BY_ENTITY_ALIAS);
2617 }
2618 else {
2619 query.append(_ORDER_BY_ENTITY_TABLE);
2620 }
2621
2622 query.append(orderByFields[i]);
2623
2624 if ((i + 1) < orderByFields.length) {
2625 if (orderByComparator.isAscending() ^ previous) {
2626 query.append(ORDER_BY_ASC_HAS_NEXT);
2627 }
2628 else {
2629 query.append(ORDER_BY_DESC_HAS_NEXT);
2630 }
2631 }
2632 else {
2633 if (orderByComparator.isAscending() ^ previous) {
2634 query.append(ORDER_BY_ASC);
2635 }
2636 else {
2637 query.append(ORDER_BY_DESC);
2638 }
2639 }
2640 }
2641 }
2642 else {
2643 if (getDB().isSupportsInlineDistinct()) {
2644 query.append(RoleModelImpl.ORDER_BY_JPQL);
2645 }
2646 else {
2647 query.append(RoleModelImpl.ORDER_BY_SQL);
2648 }
2649 }
2650
2651 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2652 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2653
2654 SQLQuery q = session.createSynchronizedSQLQuery(sql);
2655
2656 q.setFirstResult(0);
2657 q.setMaxResults(2);
2658
2659 if (getDB().isSupportsInlineDistinct()) {
2660 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
2661 }
2662 else {
2663 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
2664 }
2665
2666 QueryPos qPos = QueryPos.getInstance(q);
2667
2668 qPos.add(companyId);
2669
2670 if (orderByComparator != null) {
2671 Object[] values = orderByComparator.getOrderByConditionValues(role);
2672
2673 for (Object value : values) {
2674 qPos.add(value);
2675 }
2676 }
2677
2678 List<Role> list = q.list();
2679
2680 if (list.size() == 2) {
2681 return list.get(1);
2682 }
2683 else {
2684 return null;
2685 }
2686 }
2687
2688
2693 @Override
2694 public void removeByCompanyId(long companyId) {
2695 for (Role role : findByCompanyId(companyId, QueryUtil.ALL_POS,
2696 QueryUtil.ALL_POS, null)) {
2697 remove(role);
2698 }
2699 }
2700
2701
2707 @Override
2708 public int countByCompanyId(long companyId) {
2709 FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2710
2711 Object[] finderArgs = new Object[] { companyId };
2712
2713 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2714 this);
2715
2716 if (count == null) {
2717 StringBundler query = new StringBundler(2);
2718
2719 query.append(_SQL_COUNT_ROLE_WHERE);
2720
2721 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2722
2723 String sql = query.toString();
2724
2725 Session session = null;
2726
2727 try {
2728 session = openSession();
2729
2730 Query q = session.createQuery(sql);
2731
2732 QueryPos qPos = QueryPos.getInstance(q);
2733
2734 qPos.add(companyId);
2735
2736 count = (Long)q.uniqueResult();
2737
2738 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2739 }
2740 catch (Exception e) {
2741 FinderCacheUtil.removeResult(finderPath, finderArgs);
2742
2743 throw processException(e);
2744 }
2745 finally {
2746 closeSession(session);
2747 }
2748 }
2749
2750 return count.intValue();
2751 }
2752
2753
2759 @Override
2760 public int filterCountByCompanyId(long companyId) {
2761 if (!InlineSQLHelperUtil.isEnabled()) {
2762 return countByCompanyId(companyId);
2763 }
2764
2765 StringBundler query = new StringBundler(2);
2766
2767 query.append(_FILTER_SQL_COUNT_ROLE_WHERE);
2768
2769 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2770
2771 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2772 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2773
2774 Session session = null;
2775
2776 try {
2777 session = openSession();
2778
2779 SQLQuery q = session.createSynchronizedSQLQuery(sql);
2780
2781 q.addScalar(COUNT_COLUMN_NAME,
2782 com.liferay.portal.kernel.dao.orm.Type.LONG);
2783
2784 QueryPos qPos = QueryPos.getInstance(q);
2785
2786 qPos.add(companyId);
2787
2788 Long count = (Long)q.uniqueResult();
2789
2790 return count.intValue();
2791 }
2792 catch (Exception e) {
2793 throw processException(e);
2794 }
2795 finally {
2796 closeSession(session);
2797 }
2798 }
2799
2800 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "role.companyId = ?";
2801 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_NAME = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
2802 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
2803 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByName",
2804 new String[] {
2805 String.class.getName(),
2806
2807 Integer.class.getName(), Integer.class.getName(),
2808 OrderByComparator.class.getName()
2809 });
2810 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NAME = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
2811 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
2812 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByName",
2813 new String[] { String.class.getName() },
2814 RoleModelImpl.NAME_COLUMN_BITMASK);
2815 public static final FinderPath FINDER_PATH_COUNT_BY_NAME = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
2816 RoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
2817 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByName",
2818 new String[] { String.class.getName() });
2819
2820
2826 @Override
2827 public List<Role> findByName(String name) {
2828 return findByName(name, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2829 }
2830
2831
2843 @Override
2844 public List<Role> findByName(String name, int start, int end) {
2845 return findByName(name, start, end, null);
2846 }
2847
2848
2861 @Override
2862 public List<Role> findByName(String name, int start, int end,
2863 OrderByComparator<Role> orderByComparator) {
2864 boolean pagination = true;
2865 FinderPath finderPath = null;
2866 Object[] finderArgs = null;
2867
2868 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2869 (orderByComparator == null)) {
2870 pagination = false;
2871 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NAME;
2872 finderArgs = new Object[] { name };
2873 }
2874 else {
2875 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_NAME;
2876 finderArgs = new Object[] { name, start, end, orderByComparator };
2877 }
2878
2879 List<Role> list = (List<Role>)FinderCacheUtil.getResult(finderPath,
2880 finderArgs, this);
2881
2882 if ((list != null) && !list.isEmpty()) {
2883 for (Role role : list) {
2884 if (!Validator.equals(name, role.getName())) {
2885 list = null;
2886
2887 break;
2888 }
2889 }
2890 }
2891
2892 if (list == null) {
2893 StringBundler query = null;
2894
2895 if (orderByComparator != null) {
2896 query = new StringBundler(3 +
2897 (orderByComparator.getOrderByFields().length * 3));
2898 }
2899 else {
2900 query = new StringBundler(3);
2901 }
2902
2903 query.append(_SQL_SELECT_ROLE_WHERE);
2904
2905 boolean bindName = false;
2906
2907 if (name == null) {
2908 query.append(_FINDER_COLUMN_NAME_NAME_1);
2909 }
2910 else if (name.equals(StringPool.BLANK)) {
2911 query.append(_FINDER_COLUMN_NAME_NAME_3);
2912 }
2913 else {
2914 bindName = true;
2915
2916 query.append(_FINDER_COLUMN_NAME_NAME_2);
2917 }
2918
2919 if (orderByComparator != null) {
2920 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2921 orderByComparator);
2922 }
2923 else
2924 if (pagination) {
2925 query.append(RoleModelImpl.ORDER_BY_JPQL);
2926 }
2927
2928 String sql = query.toString();
2929
2930 Session session = null;
2931
2932 try {
2933 session = openSession();
2934
2935 Query q = session.createQuery(sql);
2936
2937 QueryPos qPos = QueryPos.getInstance(q);
2938
2939 if (bindName) {
2940 qPos.add(name);
2941 }
2942
2943 if (!pagination) {
2944 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
2945 end, false);
2946
2947 Collections.sort(list);
2948
2949 list = Collections.unmodifiableList(list);
2950 }
2951 else {
2952 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
2953 end);
2954 }
2955
2956 cacheResult(list);
2957
2958 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2959 }
2960 catch (Exception e) {
2961 FinderCacheUtil.removeResult(finderPath, finderArgs);
2962
2963 throw processException(e);
2964 }
2965 finally {
2966 closeSession(session);
2967 }
2968 }
2969
2970 return list;
2971 }
2972
2973
2981 @Override
2982 public Role findByName_First(String name,
2983 OrderByComparator<Role> orderByComparator) throws NoSuchRoleException {
2984 Role role = fetchByName_First(name, orderByComparator);
2985
2986 if (role != null) {
2987 return role;
2988 }
2989
2990 StringBundler msg = new StringBundler(4);
2991
2992 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2993
2994 msg.append("name=");
2995 msg.append(name);
2996
2997 msg.append(StringPool.CLOSE_CURLY_BRACE);
2998
2999 throw new NoSuchRoleException(msg.toString());
3000 }
3001
3002
3009 @Override
3010 public Role fetchByName_First(String name,
3011 OrderByComparator<Role> orderByComparator) {
3012 List<Role> list = findByName(name, 0, 1, orderByComparator);
3013
3014 if (!list.isEmpty()) {
3015 return list.get(0);
3016 }
3017
3018 return null;
3019 }
3020
3021
3029 @Override
3030 public Role findByName_Last(String name,
3031 OrderByComparator<Role> orderByComparator) throws NoSuchRoleException {
3032 Role role = fetchByName_Last(name, orderByComparator);
3033
3034 if (role != null) {
3035 return role;
3036 }
3037
3038 StringBundler msg = new StringBundler(4);
3039
3040 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3041
3042 msg.append("name=");
3043 msg.append(name);
3044
3045 msg.append(StringPool.CLOSE_CURLY_BRACE);
3046
3047 throw new NoSuchRoleException(msg.toString());
3048 }
3049
3050
3057 @Override
3058 public Role fetchByName_Last(String name,
3059 OrderByComparator<Role> orderByComparator) {
3060 int count = countByName(name);
3061
3062 if (count == 0) {
3063 return null;
3064 }
3065
3066 List<Role> list = findByName(name, count - 1, count, orderByComparator);
3067
3068 if (!list.isEmpty()) {
3069 return list.get(0);
3070 }
3071
3072 return null;
3073 }
3074
3075
3084 @Override
3085 public Role[] findByName_PrevAndNext(long roleId, String name,
3086 OrderByComparator<Role> orderByComparator) throws NoSuchRoleException {
3087 Role role = findByPrimaryKey(roleId);
3088
3089 Session session = null;
3090
3091 try {
3092 session = openSession();
3093
3094 Role[] array = new RoleImpl[3];
3095
3096 array[0] = getByName_PrevAndNext(session, role, name,
3097 orderByComparator, true);
3098
3099 array[1] = role;
3100
3101 array[2] = getByName_PrevAndNext(session, role, name,
3102 orderByComparator, false);
3103
3104 return array;
3105 }
3106 catch (Exception e) {
3107 throw processException(e);
3108 }
3109 finally {
3110 closeSession(session);
3111 }
3112 }
3113
3114 protected Role getByName_PrevAndNext(Session session, Role role,
3115 String name, OrderByComparator<Role> orderByComparator, boolean previous) {
3116 StringBundler query = null;
3117
3118 if (orderByComparator != null) {
3119 query = new StringBundler(6 +
3120 (orderByComparator.getOrderByFields().length * 6));
3121 }
3122 else {
3123 query = new StringBundler(3);
3124 }
3125
3126 query.append(_SQL_SELECT_ROLE_WHERE);
3127
3128 boolean bindName = false;
3129
3130 if (name == null) {
3131 query.append(_FINDER_COLUMN_NAME_NAME_1);
3132 }
3133 else if (name.equals(StringPool.BLANK)) {
3134 query.append(_FINDER_COLUMN_NAME_NAME_3);
3135 }
3136 else {
3137 bindName = true;
3138
3139 query.append(_FINDER_COLUMN_NAME_NAME_2);
3140 }
3141
3142 if (orderByComparator != null) {
3143 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3144
3145 if (orderByConditionFields.length > 0) {
3146 query.append(WHERE_AND);
3147 }
3148
3149 for (int i = 0; i < orderByConditionFields.length; i++) {
3150 query.append(_ORDER_BY_ENTITY_ALIAS);
3151 query.append(orderByConditionFields[i]);
3152
3153 if ((i + 1) < orderByConditionFields.length) {
3154 if (orderByComparator.isAscending() ^ previous) {
3155 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3156 }
3157 else {
3158 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3159 }
3160 }
3161 else {
3162 if (orderByComparator.isAscending() ^ previous) {
3163 query.append(WHERE_GREATER_THAN);
3164 }
3165 else {
3166 query.append(WHERE_LESSER_THAN);
3167 }
3168 }
3169 }
3170
3171 query.append(ORDER_BY_CLAUSE);
3172
3173 String[] orderByFields = orderByComparator.getOrderByFields();
3174
3175 for (int i = 0; i < orderByFields.length; i++) {
3176 query.append(_ORDER_BY_ENTITY_ALIAS);
3177 query.append(orderByFields[i]);
3178
3179 if ((i + 1) < orderByFields.length) {
3180 if (orderByComparator.isAscending() ^ previous) {
3181 query.append(ORDER_BY_ASC_HAS_NEXT);
3182 }
3183 else {
3184 query.append(ORDER_BY_DESC_HAS_NEXT);
3185 }
3186 }
3187 else {
3188 if (orderByComparator.isAscending() ^ previous) {
3189 query.append(ORDER_BY_ASC);
3190 }
3191 else {
3192 query.append(ORDER_BY_DESC);
3193 }
3194 }
3195 }
3196 }
3197 else {
3198 query.append(RoleModelImpl.ORDER_BY_JPQL);
3199 }
3200
3201 String sql = query.toString();
3202
3203 Query q = session.createQuery(sql);
3204
3205 q.setFirstResult(0);
3206 q.setMaxResults(2);
3207
3208 QueryPos qPos = QueryPos.getInstance(q);
3209
3210 if (bindName) {
3211 qPos.add(name);
3212 }
3213
3214 if (orderByComparator != null) {
3215 Object[] values = orderByComparator.getOrderByConditionValues(role);
3216
3217 for (Object value : values) {
3218 qPos.add(value);
3219 }
3220 }
3221
3222 List<Role> list = q.list();
3223
3224 if (list.size() == 2) {
3225 return list.get(1);
3226 }
3227 else {
3228 return null;
3229 }
3230 }
3231
3232
3238 @Override
3239 public List<Role> filterFindByName(String name) {
3240 return filterFindByName(name, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3241 }
3242
3243
3255 @Override
3256 public List<Role> filterFindByName(String name, int start, int end) {
3257 return filterFindByName(name, start, end, null);
3258 }
3259
3260
3273 @Override
3274 public List<Role> filterFindByName(String name, int start, int end,
3275 OrderByComparator<Role> orderByComparator) {
3276 if (!InlineSQLHelperUtil.isEnabled()) {
3277 return findByName(name, start, end, orderByComparator);
3278 }
3279
3280 StringBundler query = null;
3281
3282 if (orderByComparator != null) {
3283 query = new StringBundler(3 +
3284 (orderByComparator.getOrderByFields().length * 3));
3285 }
3286 else {
3287 query = new StringBundler(3);
3288 }
3289
3290 if (getDB().isSupportsInlineDistinct()) {
3291 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
3292 }
3293 else {
3294 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
3295 }
3296
3297 boolean bindName = false;
3298
3299 if (name == null) {
3300 query.append(_FINDER_COLUMN_NAME_NAME_1);
3301 }
3302 else if (name.equals(StringPool.BLANK)) {
3303 query.append(_FINDER_COLUMN_NAME_NAME_3);
3304 }
3305 else {
3306 bindName = true;
3307
3308 query.append(_FINDER_COLUMN_NAME_NAME_2);
3309 }
3310
3311 if (!getDB().isSupportsInlineDistinct()) {
3312 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
3313 }
3314
3315 if (orderByComparator != null) {
3316 if (getDB().isSupportsInlineDistinct()) {
3317 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3318 orderByComparator, true);
3319 }
3320 else {
3321 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3322 orderByComparator, true);
3323 }
3324 }
3325 else {
3326 if (getDB().isSupportsInlineDistinct()) {
3327 query.append(RoleModelImpl.ORDER_BY_JPQL);
3328 }
3329 else {
3330 query.append(RoleModelImpl.ORDER_BY_SQL);
3331 }
3332 }
3333
3334 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3335 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3336
3337 Session session = null;
3338
3339 try {
3340 session = openSession();
3341
3342 SQLQuery q = session.createSynchronizedSQLQuery(sql);
3343
3344 if (getDB().isSupportsInlineDistinct()) {
3345 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
3346 }
3347 else {
3348 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
3349 }
3350
3351 QueryPos qPos = QueryPos.getInstance(q);
3352
3353 if (bindName) {
3354 qPos.add(name);
3355 }
3356
3357 return (List<Role>)QueryUtil.list(q, getDialect(), start, end);
3358 }
3359 catch (Exception e) {
3360 throw processException(e);
3361 }
3362 finally {
3363 closeSession(session);
3364 }
3365 }
3366
3367
3376 @Override
3377 public Role[] filterFindByName_PrevAndNext(long roleId, String name,
3378 OrderByComparator<Role> orderByComparator) throws NoSuchRoleException {
3379 if (!InlineSQLHelperUtil.isEnabled()) {
3380 return findByName_PrevAndNext(roleId, name, orderByComparator);
3381 }
3382
3383 Role role = findByPrimaryKey(roleId);
3384
3385 Session session = null;
3386
3387 try {
3388 session = openSession();
3389
3390 Role[] array = new RoleImpl[3];
3391
3392 array[0] = filterGetByName_PrevAndNext(session, role, name,
3393 orderByComparator, true);
3394
3395 array[1] = role;
3396
3397 array[2] = filterGetByName_PrevAndNext(session, role, name,
3398 orderByComparator, false);
3399
3400 return array;
3401 }
3402 catch (Exception e) {
3403 throw processException(e);
3404 }
3405 finally {
3406 closeSession(session);
3407 }
3408 }
3409
3410 protected Role filterGetByName_PrevAndNext(Session session, Role role,
3411 String name, OrderByComparator<Role> orderByComparator, boolean previous) {
3412 StringBundler query = null;
3413
3414 if (orderByComparator != null) {
3415 query = new StringBundler(6 +
3416 (orderByComparator.getOrderByFields().length * 6));
3417 }
3418 else {
3419 query = new StringBundler(3);
3420 }
3421
3422 if (getDB().isSupportsInlineDistinct()) {
3423 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
3424 }
3425 else {
3426 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
3427 }
3428
3429 boolean bindName = false;
3430
3431 if (name == null) {
3432 query.append(_FINDER_COLUMN_NAME_NAME_1);
3433 }
3434 else if (name.equals(StringPool.BLANK)) {
3435 query.append(_FINDER_COLUMN_NAME_NAME_3);
3436 }
3437 else {
3438 bindName = true;
3439
3440 query.append(_FINDER_COLUMN_NAME_NAME_2);
3441 }
3442
3443 if (!getDB().isSupportsInlineDistinct()) {
3444 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
3445 }
3446
3447 if (orderByComparator != null) {
3448 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3449
3450 if (orderByConditionFields.length > 0) {
3451 query.append(WHERE_AND);
3452 }
3453
3454 for (int i = 0; i < orderByConditionFields.length; i++) {
3455 if (getDB().isSupportsInlineDistinct()) {
3456 query.append(_ORDER_BY_ENTITY_ALIAS);
3457 }
3458 else {
3459 query.append(_ORDER_BY_ENTITY_TABLE);
3460 }
3461
3462 query.append(orderByConditionFields[i]);
3463
3464 if ((i + 1) < orderByConditionFields.length) {
3465 if (orderByComparator.isAscending() ^ previous) {
3466 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3467 }
3468 else {
3469 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3470 }
3471 }
3472 else {
3473 if (orderByComparator.isAscending() ^ previous) {
3474 query.append(WHERE_GREATER_THAN);
3475 }
3476 else {
3477 query.append(WHERE_LESSER_THAN);
3478 }
3479 }
3480 }
3481
3482 query.append(ORDER_BY_CLAUSE);
3483
3484 String[] orderByFields = orderByComparator.getOrderByFields();
3485
3486 for (int i = 0; i < orderByFields.length; i++) {
3487 if (getDB().isSupportsInlineDistinct()) {
3488 query.append(_ORDER_BY_ENTITY_ALIAS);
3489 }
3490 else {
3491 query.append(_ORDER_BY_ENTITY_TABLE);
3492 }
3493
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 if (getDB().isSupportsInlineDistinct()) {
3516 query.append(RoleModelImpl.ORDER_BY_JPQL);
3517 }
3518 else {
3519 query.append(RoleModelImpl.ORDER_BY_SQL);
3520 }
3521 }
3522
3523 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3524 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3525
3526 SQLQuery q = session.createSynchronizedSQLQuery(sql);
3527
3528 q.setFirstResult(0);
3529 q.setMaxResults(2);
3530
3531 if (getDB().isSupportsInlineDistinct()) {
3532 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
3533 }
3534 else {
3535 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
3536 }
3537
3538 QueryPos qPos = QueryPos.getInstance(q);
3539
3540 if (bindName) {
3541 qPos.add(name);
3542 }
3543
3544 if (orderByComparator != null) {
3545 Object[] values = orderByComparator.getOrderByConditionValues(role);
3546
3547 for (Object value : values) {
3548 qPos.add(value);
3549 }
3550 }
3551
3552 List<Role> list = q.list();
3553
3554 if (list.size() == 2) {
3555 return list.get(1);
3556 }
3557 else {
3558 return null;
3559 }
3560 }
3561
3562
3567 @Override
3568 public void removeByName(String name) {
3569 for (Role role : findByName(name, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3570 null)) {
3571 remove(role);
3572 }
3573 }
3574
3575
3581 @Override
3582 public int countByName(String name) {
3583 FinderPath finderPath = FINDER_PATH_COUNT_BY_NAME;
3584
3585 Object[] finderArgs = new Object[] { name };
3586
3587 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3588 this);
3589
3590 if (count == null) {
3591 StringBundler query = new StringBundler(2);
3592
3593 query.append(_SQL_COUNT_ROLE_WHERE);
3594
3595 boolean bindName = false;
3596
3597 if (name == null) {
3598 query.append(_FINDER_COLUMN_NAME_NAME_1);
3599 }
3600 else if (name.equals(StringPool.BLANK)) {
3601 query.append(_FINDER_COLUMN_NAME_NAME_3);
3602 }
3603 else {
3604 bindName = true;
3605
3606 query.append(_FINDER_COLUMN_NAME_NAME_2);
3607 }
3608
3609 String sql = query.toString();
3610
3611 Session session = null;
3612
3613 try {
3614 session = openSession();
3615
3616 Query q = session.createQuery(sql);
3617
3618 QueryPos qPos = QueryPos.getInstance(q);
3619
3620 if (bindName) {
3621 qPos.add(name);
3622 }
3623
3624 count = (Long)q.uniqueResult();
3625
3626 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3627 }
3628 catch (Exception e) {
3629 FinderCacheUtil.removeResult(finderPath, finderArgs);
3630
3631 throw processException(e);
3632 }
3633 finally {
3634 closeSession(session);
3635 }
3636 }
3637
3638 return count.intValue();
3639 }
3640
3641
3647 @Override
3648 public int filterCountByName(String name) {
3649 if (!InlineSQLHelperUtil.isEnabled()) {
3650 return countByName(name);
3651 }
3652
3653 StringBundler query = new StringBundler(2);
3654
3655 query.append(_FILTER_SQL_COUNT_ROLE_WHERE);
3656
3657 boolean bindName = false;
3658
3659 if (name == null) {
3660 query.append(_FINDER_COLUMN_NAME_NAME_1);
3661 }
3662 else if (name.equals(StringPool.BLANK)) {
3663 query.append(_FINDER_COLUMN_NAME_NAME_3);
3664 }
3665 else {
3666 bindName = true;
3667
3668 query.append(_FINDER_COLUMN_NAME_NAME_2);
3669 }
3670
3671 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3672 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3673
3674 Session session = null;
3675
3676 try {
3677 session = openSession();
3678
3679 SQLQuery q = session.createSynchronizedSQLQuery(sql);
3680
3681 q.addScalar(COUNT_COLUMN_NAME,
3682 com.liferay.portal.kernel.dao.orm.Type.LONG);
3683
3684 QueryPos qPos = QueryPos.getInstance(q);
3685
3686 if (bindName) {
3687 qPos.add(name);
3688 }
3689
3690 Long count = (Long)q.uniqueResult();
3691
3692 return count.intValue();
3693 }
3694 catch (Exception e) {
3695 throw processException(e);
3696 }
3697 finally {
3698 closeSession(session);
3699 }
3700 }
3701
3702 private static final String _FINDER_COLUMN_NAME_NAME_1 = "role.name IS NULL";
3703 private static final String _FINDER_COLUMN_NAME_NAME_2 = "role.name = ?";
3704 private static final String _FINDER_COLUMN_NAME_NAME_3 = "(role.name IS NULL OR role.name = '')";
3705 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_TYPE = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
3706 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
3707 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByType",
3708 new String[] {
3709 Integer.class.getName(),
3710
3711 Integer.class.getName(), Integer.class.getName(),
3712 OrderByComparator.class.getName()
3713 });
3714 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYPE = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
3715 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
3716 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByType",
3717 new String[] { Integer.class.getName() },
3718 RoleModelImpl.TYPE_COLUMN_BITMASK |
3719 RoleModelImpl.NAME_COLUMN_BITMASK);
3720 public static final FinderPath FINDER_PATH_COUNT_BY_TYPE = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
3721 RoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
3722 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByType",
3723 new String[] { Integer.class.getName() });
3724
3725
3731 @Override
3732 public List<Role> findByType(int type) {
3733 return findByType(type, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3734 }
3735
3736
3748 @Override
3749 public List<Role> findByType(int type, int start, int end) {
3750 return findByType(type, start, end, null);
3751 }
3752
3753
3766 @Override
3767 public List<Role> findByType(int type, int start, int end,
3768 OrderByComparator<Role> orderByComparator) {
3769 boolean pagination = true;
3770 FinderPath finderPath = null;
3771 Object[] finderArgs = null;
3772
3773 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3774 (orderByComparator == null)) {
3775 pagination = false;
3776 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYPE;
3777 finderArgs = new Object[] { type };
3778 }
3779 else {
3780 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_TYPE;
3781 finderArgs = new Object[] { type, start, end, orderByComparator };
3782 }
3783
3784 List<Role> list = (List<Role>)FinderCacheUtil.getResult(finderPath,
3785 finderArgs, this);
3786
3787 if ((list != null) && !list.isEmpty()) {
3788 for (Role role : list) {
3789 if ((type != role.getType())) {
3790 list = null;
3791
3792 break;
3793 }
3794 }
3795 }
3796
3797 if (list == null) {
3798 StringBundler query = null;
3799
3800 if (orderByComparator != null) {
3801 query = new StringBundler(3 +
3802 (orderByComparator.getOrderByFields().length * 3));
3803 }
3804 else {
3805 query = new StringBundler(3);
3806 }
3807
3808 query.append(_SQL_SELECT_ROLE_WHERE);
3809
3810 query.append(_FINDER_COLUMN_TYPE_TYPE_2);
3811
3812 if (orderByComparator != null) {
3813 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3814 orderByComparator);
3815 }
3816 else
3817 if (pagination) {
3818 query.append(RoleModelImpl.ORDER_BY_JPQL);
3819 }
3820
3821 String sql = query.toString();
3822
3823 Session session = null;
3824
3825 try {
3826 session = openSession();
3827
3828 Query q = session.createQuery(sql);
3829
3830 QueryPos qPos = QueryPos.getInstance(q);
3831
3832 qPos.add(type);
3833
3834 if (!pagination) {
3835 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
3836 end, false);
3837
3838 Collections.sort(list);
3839
3840 list = Collections.unmodifiableList(list);
3841 }
3842 else {
3843 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
3844 end);
3845 }
3846
3847 cacheResult(list);
3848
3849 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3850 }
3851 catch (Exception e) {
3852 FinderCacheUtil.removeResult(finderPath, finderArgs);
3853
3854 throw processException(e);
3855 }
3856 finally {
3857 closeSession(session);
3858 }
3859 }
3860
3861 return list;
3862 }
3863
3864
3872 @Override
3873 public Role findByType_First(int type,
3874 OrderByComparator<Role> orderByComparator) throws NoSuchRoleException {
3875 Role role = fetchByType_First(type, orderByComparator);
3876
3877 if (role != null) {
3878 return role;
3879 }
3880
3881 StringBundler msg = new StringBundler(4);
3882
3883 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3884
3885 msg.append("type=");
3886 msg.append(type);
3887
3888 msg.append(StringPool.CLOSE_CURLY_BRACE);
3889
3890 throw new NoSuchRoleException(msg.toString());
3891 }
3892
3893
3900 @Override
3901 public Role fetchByType_First(int type,
3902 OrderByComparator<Role> orderByComparator) {
3903 List<Role> list = findByType(type, 0, 1, orderByComparator);
3904
3905 if (!list.isEmpty()) {
3906 return list.get(0);
3907 }
3908
3909 return null;
3910 }
3911
3912
3920 @Override
3921 public Role findByType_Last(int type,
3922 OrderByComparator<Role> orderByComparator) throws NoSuchRoleException {
3923 Role role = fetchByType_Last(type, orderByComparator);
3924
3925 if (role != null) {
3926 return role;
3927 }
3928
3929 StringBundler msg = new StringBundler(4);
3930
3931 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3932
3933 msg.append("type=");
3934 msg.append(type);
3935
3936 msg.append(StringPool.CLOSE_CURLY_BRACE);
3937
3938 throw new NoSuchRoleException(msg.toString());
3939 }
3940
3941
3948 @Override
3949 public Role fetchByType_Last(int type,
3950 OrderByComparator<Role> orderByComparator) {
3951 int count = countByType(type);
3952
3953 if (count == 0) {
3954 return null;
3955 }
3956
3957 List<Role> list = findByType(type, count - 1, count, orderByComparator);
3958
3959 if (!list.isEmpty()) {
3960 return list.get(0);
3961 }
3962
3963 return null;
3964 }
3965
3966
3975 @Override
3976 public Role[] findByType_PrevAndNext(long roleId, int type,
3977 OrderByComparator<Role> orderByComparator) throws NoSuchRoleException {
3978 Role role = findByPrimaryKey(roleId);
3979
3980 Session session = null;
3981
3982 try {
3983 session = openSession();
3984
3985 Role[] array = new RoleImpl[3];
3986
3987 array[0] = getByType_PrevAndNext(session, role, type,
3988 orderByComparator, true);
3989
3990 array[1] = role;
3991
3992 array[2] = getByType_PrevAndNext(session, role, type,
3993 orderByComparator, false);
3994
3995 return array;
3996 }
3997 catch (Exception e) {
3998 throw processException(e);
3999 }
4000 finally {
4001 closeSession(session);
4002 }
4003 }
4004
4005 protected Role getByType_PrevAndNext(Session session, Role role, int type,
4006 OrderByComparator<Role> orderByComparator, boolean previous) {
4007 StringBundler query = null;
4008
4009 if (orderByComparator != null) {
4010 query = new StringBundler(6 +
4011 (orderByComparator.getOrderByFields().length * 6));
4012 }
4013 else {
4014 query = new StringBundler(3);
4015 }
4016
4017 query.append(_SQL_SELECT_ROLE_WHERE);
4018
4019 query.append(_FINDER_COLUMN_TYPE_TYPE_2);
4020
4021 if (orderByComparator != null) {
4022 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4023
4024 if (orderByConditionFields.length > 0) {
4025 query.append(WHERE_AND);
4026 }
4027
4028 for (int i = 0; i < orderByConditionFields.length; i++) {
4029 query.append(_ORDER_BY_ENTITY_ALIAS);
4030 query.append(orderByConditionFields[i]);
4031
4032 if ((i + 1) < orderByConditionFields.length) {
4033 if (orderByComparator.isAscending() ^ previous) {
4034 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4035 }
4036 else {
4037 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4038 }
4039 }
4040 else {
4041 if (orderByComparator.isAscending() ^ previous) {
4042 query.append(WHERE_GREATER_THAN);
4043 }
4044 else {
4045 query.append(WHERE_LESSER_THAN);
4046 }
4047 }
4048 }
4049
4050 query.append(ORDER_BY_CLAUSE);
4051
4052 String[] orderByFields = orderByComparator.getOrderByFields();
4053
4054 for (int i = 0; i < orderByFields.length; i++) {
4055 query.append(_ORDER_BY_ENTITY_ALIAS);
4056 query.append(orderByFields[i]);
4057
4058 if ((i + 1) < orderByFields.length) {
4059 if (orderByComparator.isAscending() ^ previous) {
4060 query.append(ORDER_BY_ASC_HAS_NEXT);
4061 }
4062 else {
4063 query.append(ORDER_BY_DESC_HAS_NEXT);
4064 }
4065 }
4066 else {
4067 if (orderByComparator.isAscending() ^ previous) {
4068 query.append(ORDER_BY_ASC);
4069 }
4070 else {
4071 query.append(ORDER_BY_DESC);
4072 }
4073 }
4074 }
4075 }
4076 else {
4077 query.append(RoleModelImpl.ORDER_BY_JPQL);
4078 }
4079
4080 String sql = query.toString();
4081
4082 Query q = session.createQuery(sql);
4083
4084 q.setFirstResult(0);
4085 q.setMaxResults(2);
4086
4087 QueryPos qPos = QueryPos.getInstance(q);
4088
4089 qPos.add(type);
4090
4091 if (orderByComparator != null) {
4092 Object[] values = orderByComparator.getOrderByConditionValues(role);
4093
4094 for (Object value : values) {
4095 qPos.add(value);
4096 }
4097 }
4098
4099 List<Role> list = q.list();
4100
4101 if (list.size() == 2) {
4102 return list.get(1);
4103 }
4104 else {
4105 return null;
4106 }
4107 }
4108
4109
4115 @Override
4116 public List<Role> filterFindByType(int type) {
4117 return filterFindByType(type, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4118 }
4119
4120
4132 @Override
4133 public List<Role> filterFindByType(int type, int start, int end) {
4134 return filterFindByType(type, start, end, null);
4135 }
4136
4137
4150 @Override
4151 public List<Role> filterFindByType(int type, int start, int end,
4152 OrderByComparator<Role> orderByComparator) {
4153 if (!InlineSQLHelperUtil.isEnabled()) {
4154 return findByType(type, start, end, orderByComparator);
4155 }
4156
4157 StringBundler query = null;
4158
4159 if (orderByComparator != null) {
4160 query = new StringBundler(3 +
4161 (orderByComparator.getOrderByFields().length * 3));
4162 }
4163 else {
4164 query = new StringBundler(3);
4165 }
4166
4167 if (getDB().isSupportsInlineDistinct()) {
4168 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
4169 }
4170 else {
4171 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
4172 }
4173
4174 query.append(_FINDER_COLUMN_TYPE_TYPE_2_SQL);
4175
4176 if (!getDB().isSupportsInlineDistinct()) {
4177 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
4178 }
4179
4180 if (orderByComparator != null) {
4181 if (getDB().isSupportsInlineDistinct()) {
4182 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4183 orderByComparator, true);
4184 }
4185 else {
4186 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4187 orderByComparator, true);
4188 }
4189 }
4190 else {
4191 if (getDB().isSupportsInlineDistinct()) {
4192 query.append(RoleModelImpl.ORDER_BY_JPQL);
4193 }
4194 else {
4195 query.append(RoleModelImpl.ORDER_BY_SQL);
4196 }
4197 }
4198
4199 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4200 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4201
4202 Session session = null;
4203
4204 try {
4205 session = openSession();
4206
4207 SQLQuery q = session.createSynchronizedSQLQuery(sql);
4208
4209 if (getDB().isSupportsInlineDistinct()) {
4210 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
4211 }
4212 else {
4213 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
4214 }
4215
4216 QueryPos qPos = QueryPos.getInstance(q);
4217
4218 qPos.add(type);
4219
4220 return (List<Role>)QueryUtil.list(q, getDialect(), start, end);
4221 }
4222 catch (Exception e) {
4223 throw processException(e);
4224 }
4225 finally {
4226 closeSession(session);
4227 }
4228 }
4229
4230
4239 @Override
4240 public Role[] filterFindByType_PrevAndNext(long roleId, int type,
4241 OrderByComparator<Role> orderByComparator) throws NoSuchRoleException {
4242 if (!InlineSQLHelperUtil.isEnabled()) {
4243 return findByType_PrevAndNext(roleId, type, orderByComparator);
4244 }
4245
4246 Role role = findByPrimaryKey(roleId);
4247
4248 Session session = null;
4249
4250 try {
4251 session = openSession();
4252
4253 Role[] array = new RoleImpl[3];
4254
4255 array[0] = filterGetByType_PrevAndNext(session, role, type,
4256 orderByComparator, true);
4257
4258 array[1] = role;
4259
4260 array[2] = filterGetByType_PrevAndNext(session, role, type,
4261 orderByComparator, false);
4262
4263 return array;
4264 }
4265 catch (Exception e) {
4266 throw processException(e);
4267 }
4268 finally {
4269 closeSession(session);
4270 }
4271 }
4272
4273 protected Role filterGetByType_PrevAndNext(Session session, Role role,
4274 int type, OrderByComparator<Role> orderByComparator, boolean previous) {
4275 StringBundler query = null;
4276
4277 if (orderByComparator != null) {
4278 query = new StringBundler(6 +
4279 (orderByComparator.getOrderByFields().length * 6));
4280 }
4281 else {
4282 query = new StringBundler(3);
4283 }
4284
4285 if (getDB().isSupportsInlineDistinct()) {
4286 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
4287 }
4288 else {
4289 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
4290 }
4291
4292 query.append(_FINDER_COLUMN_TYPE_TYPE_2_SQL);
4293
4294 if (!getDB().isSupportsInlineDistinct()) {
4295 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
4296 }
4297
4298 if (orderByComparator != null) {
4299 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4300
4301 if (orderByConditionFields.length > 0) {
4302 query.append(WHERE_AND);
4303 }
4304
4305 for (int i = 0; i < orderByConditionFields.length; i++) {
4306 if (getDB().isSupportsInlineDistinct()) {
4307 query.append(_ORDER_BY_ENTITY_ALIAS);
4308 }
4309 else {
4310 query.append(_ORDER_BY_ENTITY_TABLE);
4311 }
4312
4313 query.append(orderByConditionFields[i]);
4314
4315 if ((i + 1) < orderByConditionFields.length) {
4316 if (orderByComparator.isAscending() ^ previous) {
4317 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4318 }
4319 else {
4320 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4321 }
4322 }
4323 else {
4324 if (orderByComparator.isAscending() ^ previous) {
4325 query.append(WHERE_GREATER_THAN);
4326 }
4327 else {
4328 query.append(WHERE_LESSER_THAN);
4329 }
4330 }
4331 }
4332
4333 query.append(ORDER_BY_CLAUSE);
4334
4335 String[] orderByFields = orderByComparator.getOrderByFields();
4336
4337 for (int i = 0; i < orderByFields.length; i++) {
4338 if (getDB().isSupportsInlineDistinct()) {
4339 query.append(_ORDER_BY_ENTITY_ALIAS);
4340 }
4341 else {
4342 query.append(_ORDER_BY_ENTITY_TABLE);
4343 }
4344
4345 query.append(orderByFields[i]);
4346
4347 if ((i + 1) < orderByFields.length) {
4348 if (orderByComparator.isAscending() ^ previous) {
4349 query.append(ORDER_BY_ASC_HAS_NEXT);
4350 }
4351 else {
4352 query.append(ORDER_BY_DESC_HAS_NEXT);
4353 }
4354 }
4355 else {
4356 if (orderByComparator.isAscending() ^ previous) {
4357 query.append(ORDER_BY_ASC);
4358 }
4359 else {
4360 query.append(ORDER_BY_DESC);
4361 }
4362 }
4363 }
4364 }
4365 else {
4366 if (getDB().isSupportsInlineDistinct()) {
4367 query.append(RoleModelImpl.ORDER_BY_JPQL);
4368 }
4369 else {
4370 query.append(RoleModelImpl.ORDER_BY_SQL);
4371 }
4372 }
4373
4374 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4375 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4376
4377 SQLQuery q = session.createSynchronizedSQLQuery(sql);
4378
4379 q.setFirstResult(0);
4380 q.setMaxResults(2);
4381
4382 if (getDB().isSupportsInlineDistinct()) {
4383 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
4384 }
4385 else {
4386 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
4387 }
4388
4389 QueryPos qPos = QueryPos.getInstance(q);
4390
4391 qPos.add(type);
4392
4393 if (orderByComparator != null) {
4394 Object[] values = orderByComparator.getOrderByConditionValues(role);
4395
4396 for (Object value : values) {
4397 qPos.add(value);
4398 }
4399 }
4400
4401 List<Role> list = q.list();
4402
4403 if (list.size() == 2) {
4404 return list.get(1);
4405 }
4406 else {
4407 return null;
4408 }
4409 }
4410
4411
4416 @Override
4417 public void removeByType(int type) {
4418 for (Role role : findByType(type, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
4419 null)) {
4420 remove(role);
4421 }
4422 }
4423
4424
4430 @Override
4431 public int countByType(int type) {
4432 FinderPath finderPath = FINDER_PATH_COUNT_BY_TYPE;
4433
4434 Object[] finderArgs = new Object[] { type };
4435
4436 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4437 this);
4438
4439 if (count == null) {
4440 StringBundler query = new StringBundler(2);
4441
4442 query.append(_SQL_COUNT_ROLE_WHERE);
4443
4444 query.append(_FINDER_COLUMN_TYPE_TYPE_2);
4445
4446 String sql = query.toString();
4447
4448 Session session = null;
4449
4450 try {
4451 session = openSession();
4452
4453 Query q = session.createQuery(sql);
4454
4455 QueryPos qPos = QueryPos.getInstance(q);
4456
4457 qPos.add(type);
4458
4459 count = (Long)q.uniqueResult();
4460
4461 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4462 }
4463 catch (Exception e) {
4464 FinderCacheUtil.removeResult(finderPath, finderArgs);
4465
4466 throw processException(e);
4467 }
4468 finally {
4469 closeSession(session);
4470 }
4471 }
4472
4473 return count.intValue();
4474 }
4475
4476
4482 @Override
4483 public int filterCountByType(int type) {
4484 if (!InlineSQLHelperUtil.isEnabled()) {
4485 return countByType(type);
4486 }
4487
4488 StringBundler query = new StringBundler(2);
4489
4490 query.append(_FILTER_SQL_COUNT_ROLE_WHERE);
4491
4492 query.append(_FINDER_COLUMN_TYPE_TYPE_2_SQL);
4493
4494 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4495 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4496
4497 Session session = null;
4498
4499 try {
4500 session = openSession();
4501
4502 SQLQuery q = session.createSynchronizedSQLQuery(sql);
4503
4504 q.addScalar(COUNT_COLUMN_NAME,
4505 com.liferay.portal.kernel.dao.orm.Type.LONG);
4506
4507 QueryPos qPos = QueryPos.getInstance(q);
4508
4509 qPos.add(type);
4510
4511 Long count = (Long)q.uniqueResult();
4512
4513 return count.intValue();
4514 }
4515 catch (Exception e) {
4516 throw processException(e);
4517 }
4518 finally {
4519 closeSession(session);
4520 }
4521 }
4522
4523 private static final String _FINDER_COLUMN_TYPE_TYPE_2 = "role.type = ?";
4524 private static final String _FINDER_COLUMN_TYPE_TYPE_2_SQL = "role.type_ = ?";
4525 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_SUBTYPE = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
4526 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
4527 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findBySubtype",
4528 new String[] {
4529 String.class.getName(),
4530
4531 Integer.class.getName(), Integer.class.getName(),
4532 OrderByComparator.class.getName()
4533 });
4534 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SUBTYPE =
4535 new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
4536 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
4537 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findBySubtype",
4538 new String[] { String.class.getName() },
4539 RoleModelImpl.SUBTYPE_COLUMN_BITMASK |
4540 RoleModelImpl.NAME_COLUMN_BITMASK);
4541 public static final FinderPath FINDER_PATH_COUNT_BY_SUBTYPE = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
4542 RoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
4543 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countBySubtype",
4544 new String[] { String.class.getName() });
4545
4546
4552 @Override
4553 public List<Role> findBySubtype(String subtype) {
4554 return findBySubtype(subtype, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4555 }
4556
4557
4569 @Override
4570 public List<Role> findBySubtype(String subtype, int start, int end) {
4571 return findBySubtype(subtype, start, end, null);
4572 }
4573
4574
4587 @Override
4588 public List<Role> findBySubtype(String subtype, int start, int end,
4589 OrderByComparator<Role> orderByComparator) {
4590 boolean pagination = true;
4591 FinderPath finderPath = null;
4592 Object[] finderArgs = null;
4593
4594 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4595 (orderByComparator == null)) {
4596 pagination = false;
4597 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SUBTYPE;
4598 finderArgs = new Object[] { subtype };
4599 }
4600 else {
4601 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SUBTYPE;
4602 finderArgs = new Object[] { subtype, start, end, orderByComparator };
4603 }
4604
4605 List<Role> list = (List<Role>)FinderCacheUtil.getResult(finderPath,
4606 finderArgs, this);
4607
4608 if ((list != null) && !list.isEmpty()) {
4609 for (Role role : list) {
4610 if (!Validator.equals(subtype, role.getSubtype())) {
4611 list = null;
4612
4613 break;
4614 }
4615 }
4616 }
4617
4618 if (list == null) {
4619 StringBundler query = null;
4620
4621 if (orderByComparator != null) {
4622 query = new StringBundler(3 +
4623 (orderByComparator.getOrderByFields().length * 3));
4624 }
4625 else {
4626 query = new StringBundler(3);
4627 }
4628
4629 query.append(_SQL_SELECT_ROLE_WHERE);
4630
4631 boolean bindSubtype = false;
4632
4633 if (subtype == null) {
4634 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
4635 }
4636 else if (subtype.equals(StringPool.BLANK)) {
4637 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
4638 }
4639 else {
4640 bindSubtype = true;
4641
4642 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
4643 }
4644
4645 if (orderByComparator != null) {
4646 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4647 orderByComparator);
4648 }
4649 else
4650 if (pagination) {
4651 query.append(RoleModelImpl.ORDER_BY_JPQL);
4652 }
4653
4654 String sql = query.toString();
4655
4656 Session session = null;
4657
4658 try {
4659 session = openSession();
4660
4661 Query q = session.createQuery(sql);
4662
4663 QueryPos qPos = QueryPos.getInstance(q);
4664
4665 if (bindSubtype) {
4666 qPos.add(subtype);
4667 }
4668
4669 if (!pagination) {
4670 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
4671 end, false);
4672
4673 Collections.sort(list);
4674
4675 list = Collections.unmodifiableList(list);
4676 }
4677 else {
4678 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
4679 end);
4680 }
4681
4682 cacheResult(list);
4683
4684 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4685 }
4686 catch (Exception e) {
4687 FinderCacheUtil.removeResult(finderPath, finderArgs);
4688
4689 throw processException(e);
4690 }
4691 finally {
4692 closeSession(session);
4693 }
4694 }
4695
4696 return list;
4697 }
4698
4699
4707 @Override
4708 public Role findBySubtype_First(String subtype,
4709 OrderByComparator<Role> orderByComparator) throws NoSuchRoleException {
4710 Role role = fetchBySubtype_First(subtype, orderByComparator);
4711
4712 if (role != null) {
4713 return role;
4714 }
4715
4716 StringBundler msg = new StringBundler(4);
4717
4718 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4719
4720 msg.append("subtype=");
4721 msg.append(subtype);
4722
4723 msg.append(StringPool.CLOSE_CURLY_BRACE);
4724
4725 throw new NoSuchRoleException(msg.toString());
4726 }
4727
4728
4735 @Override
4736 public Role fetchBySubtype_First(String subtype,
4737 OrderByComparator<Role> orderByComparator) {
4738 List<Role> list = findBySubtype(subtype, 0, 1, orderByComparator);
4739
4740 if (!list.isEmpty()) {
4741 return list.get(0);
4742 }
4743
4744 return null;
4745 }
4746
4747
4755 @Override
4756 public Role findBySubtype_Last(String subtype,
4757 OrderByComparator<Role> orderByComparator) throws NoSuchRoleException {
4758 Role role = fetchBySubtype_Last(subtype, orderByComparator);
4759
4760 if (role != null) {
4761 return role;
4762 }
4763
4764 StringBundler msg = new StringBundler(4);
4765
4766 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4767
4768 msg.append("subtype=");
4769 msg.append(subtype);
4770
4771 msg.append(StringPool.CLOSE_CURLY_BRACE);
4772
4773 throw new NoSuchRoleException(msg.toString());
4774 }
4775
4776
4783 @Override
4784 public Role fetchBySubtype_Last(String subtype,
4785 OrderByComparator<Role> orderByComparator) {
4786 int count = countBySubtype(subtype);
4787
4788 if (count == 0) {
4789 return null;
4790 }
4791
4792 List<Role> list = findBySubtype(subtype, count - 1, count,
4793 orderByComparator);
4794
4795 if (!list.isEmpty()) {
4796 return list.get(0);
4797 }
4798
4799 return null;
4800 }
4801
4802
4811 @Override
4812 public Role[] findBySubtype_PrevAndNext(long roleId, String subtype,
4813 OrderByComparator<Role> orderByComparator) throws NoSuchRoleException {
4814 Role role = findByPrimaryKey(roleId);
4815
4816 Session session = null;
4817
4818 try {
4819 session = openSession();
4820
4821 Role[] array = new RoleImpl[3];
4822
4823 array[0] = getBySubtype_PrevAndNext(session, role, subtype,
4824 orderByComparator, true);
4825
4826 array[1] = role;
4827
4828 array[2] = getBySubtype_PrevAndNext(session, role, subtype,
4829 orderByComparator, false);
4830
4831 return array;
4832 }
4833 catch (Exception e) {
4834 throw processException(e);
4835 }
4836 finally {
4837 closeSession(session);
4838 }
4839 }
4840
4841 protected Role getBySubtype_PrevAndNext(Session session, Role role,
4842 String subtype, OrderByComparator<Role> orderByComparator,
4843 boolean previous) {
4844 StringBundler query = null;
4845
4846 if (orderByComparator != null) {
4847 query = new StringBundler(6 +
4848 (orderByComparator.getOrderByFields().length * 6));
4849 }
4850 else {
4851 query = new StringBundler(3);
4852 }
4853
4854 query.append(_SQL_SELECT_ROLE_WHERE);
4855
4856 boolean bindSubtype = false;
4857
4858 if (subtype == null) {
4859 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
4860 }
4861 else if (subtype.equals(StringPool.BLANK)) {
4862 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
4863 }
4864 else {
4865 bindSubtype = true;
4866
4867 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
4868 }
4869
4870 if (orderByComparator != null) {
4871 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4872
4873 if (orderByConditionFields.length > 0) {
4874 query.append(WHERE_AND);
4875 }
4876
4877 for (int i = 0; i < orderByConditionFields.length; i++) {
4878 query.append(_ORDER_BY_ENTITY_ALIAS);
4879 query.append(orderByConditionFields[i]);
4880
4881 if ((i + 1) < orderByConditionFields.length) {
4882 if (orderByComparator.isAscending() ^ previous) {
4883 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4884 }
4885 else {
4886 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4887 }
4888 }
4889 else {
4890 if (orderByComparator.isAscending() ^ previous) {
4891 query.append(WHERE_GREATER_THAN);
4892 }
4893 else {
4894 query.append(WHERE_LESSER_THAN);
4895 }
4896 }
4897 }
4898
4899 query.append(ORDER_BY_CLAUSE);
4900
4901 String[] orderByFields = orderByComparator.getOrderByFields();
4902
4903 for (int i = 0; i < orderByFields.length; i++) {
4904 query.append(_ORDER_BY_ENTITY_ALIAS);
4905 query.append(orderByFields[i]);
4906
4907 if ((i + 1) < orderByFields.length) {
4908 if (orderByComparator.isAscending() ^ previous) {
4909 query.append(ORDER_BY_ASC_HAS_NEXT);
4910 }
4911 else {
4912 query.append(ORDER_BY_DESC_HAS_NEXT);
4913 }
4914 }
4915 else {
4916 if (orderByComparator.isAscending() ^ previous) {
4917 query.append(ORDER_BY_ASC);
4918 }
4919 else {
4920 query.append(ORDER_BY_DESC);
4921 }
4922 }
4923 }
4924 }
4925 else {
4926 query.append(RoleModelImpl.ORDER_BY_JPQL);
4927 }
4928
4929 String sql = query.toString();
4930
4931 Query q = session.createQuery(sql);
4932
4933 q.setFirstResult(0);
4934 q.setMaxResults(2);
4935
4936 QueryPos qPos = QueryPos.getInstance(q);
4937
4938 if (bindSubtype) {
4939 qPos.add(subtype);
4940 }
4941
4942 if (orderByComparator != null) {
4943 Object[] values = orderByComparator.getOrderByConditionValues(role);
4944
4945 for (Object value : values) {
4946 qPos.add(value);
4947 }
4948 }
4949
4950 List<Role> list = q.list();
4951
4952 if (list.size() == 2) {
4953 return list.get(1);
4954 }
4955 else {
4956 return null;
4957 }
4958 }
4959
4960
4966 @Override
4967 public List<Role> filterFindBySubtype(String subtype) {
4968 return filterFindBySubtype(subtype, QueryUtil.ALL_POS,
4969 QueryUtil.ALL_POS, null);
4970 }
4971
4972
4984 @Override
4985 public List<Role> filterFindBySubtype(String subtype, int start, int end) {
4986 return filterFindBySubtype(subtype, start, end, null);
4987 }
4988
4989
5002 @Override
5003 public List<Role> filterFindBySubtype(String subtype, int start, int end,
5004 OrderByComparator<Role> orderByComparator) {
5005 if (!InlineSQLHelperUtil.isEnabled()) {
5006 return findBySubtype(subtype, start, end, orderByComparator);
5007 }
5008
5009 StringBundler query = null;
5010
5011 if (orderByComparator != null) {
5012 query = new StringBundler(3 +
5013 (orderByComparator.getOrderByFields().length * 3));
5014 }
5015 else {
5016 query = new StringBundler(3);
5017 }
5018
5019 if (getDB().isSupportsInlineDistinct()) {
5020 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
5021 }
5022 else {
5023 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
5024 }
5025
5026 boolean bindSubtype = false;
5027
5028 if (subtype == null) {
5029 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
5030 }
5031 else if (subtype.equals(StringPool.BLANK)) {
5032 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
5033 }
5034 else {
5035 bindSubtype = true;
5036
5037 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
5038 }
5039
5040 if (!getDB().isSupportsInlineDistinct()) {
5041 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
5042 }
5043
5044 if (orderByComparator != null) {
5045 if (getDB().isSupportsInlineDistinct()) {
5046 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5047 orderByComparator, true);
5048 }
5049 else {
5050 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5051 orderByComparator, true);
5052 }
5053 }
5054 else {
5055 if (getDB().isSupportsInlineDistinct()) {
5056 query.append(RoleModelImpl.ORDER_BY_JPQL);
5057 }
5058 else {
5059 query.append(RoleModelImpl.ORDER_BY_SQL);
5060 }
5061 }
5062
5063 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5064 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
5065
5066 Session session = null;
5067
5068 try {
5069 session = openSession();
5070
5071 SQLQuery q = session.createSynchronizedSQLQuery(sql);
5072
5073 if (getDB().isSupportsInlineDistinct()) {
5074 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
5075 }
5076 else {
5077 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
5078 }
5079
5080 QueryPos qPos = QueryPos.getInstance(q);
5081
5082 if (bindSubtype) {
5083 qPos.add(subtype);
5084 }
5085
5086 return (List<Role>)QueryUtil.list(q, getDialect(), start, end);
5087 }
5088 catch (Exception e) {
5089 throw processException(e);
5090 }
5091 finally {
5092 closeSession(session);
5093 }
5094 }
5095
5096
5105 @Override
5106 public Role[] filterFindBySubtype_PrevAndNext(long roleId, String subtype,
5107 OrderByComparator<Role> orderByComparator) throws NoSuchRoleException {
5108 if (!InlineSQLHelperUtil.isEnabled()) {
5109 return findBySubtype_PrevAndNext(roleId, subtype, orderByComparator);
5110 }
5111
5112 Role role = findByPrimaryKey(roleId);
5113
5114 Session session = null;
5115
5116 try {
5117 session = openSession();
5118
5119 Role[] array = new RoleImpl[3];
5120
5121 array[0] = filterGetBySubtype_PrevAndNext(session, role, subtype,
5122 orderByComparator, true);
5123
5124 array[1] = role;
5125
5126 array[2] = filterGetBySubtype_PrevAndNext(session, role, subtype,
5127 orderByComparator, false);
5128
5129 return array;
5130 }
5131 catch (Exception e) {
5132 throw processException(e);
5133 }
5134 finally {
5135 closeSession(session);
5136 }
5137 }
5138
5139 protected Role filterGetBySubtype_PrevAndNext(Session session, Role role,
5140 String subtype, OrderByComparator<Role> orderByComparator,
5141 boolean previous) {
5142 StringBundler query = null;
5143
5144 if (orderByComparator != null) {
5145 query = new StringBundler(6 +
5146 (orderByComparator.getOrderByFields().length * 6));
5147 }
5148 else {
5149 query = new StringBundler(3);
5150 }
5151
5152 if (getDB().isSupportsInlineDistinct()) {
5153 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
5154 }
5155 else {
5156 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
5157 }
5158
5159 boolean bindSubtype = false;
5160
5161 if (subtype == null) {
5162 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
5163 }
5164 else if (subtype.equals(StringPool.BLANK)) {
5165 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
5166 }
5167 else {
5168 bindSubtype = true;
5169
5170 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
5171 }
5172
5173 if (!getDB().isSupportsInlineDistinct()) {
5174 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
5175 }
5176
5177 if (orderByComparator != null) {
5178 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5179
5180 if (orderByConditionFields.length > 0) {
5181 query.append(WHERE_AND);
5182 }
5183
5184 for (int i = 0; i < orderByConditionFields.length; i++) {
5185 if (getDB().isSupportsInlineDistinct()) {
5186 query.append(_ORDER_BY_ENTITY_ALIAS);
5187 }
5188 else {
5189 query.append(_ORDER_BY_ENTITY_TABLE);
5190 }
5191
5192 query.append(orderByConditionFields[i]);
5193
5194 if ((i + 1) < orderByConditionFields.length) {
5195 if (orderByComparator.isAscending() ^ previous) {
5196 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5197 }
5198 else {
5199 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5200 }
5201 }
5202 else {
5203 if (orderByComparator.isAscending() ^ previous) {
5204 query.append(WHERE_GREATER_THAN);
5205 }
5206 else {
5207 query.append(WHERE_LESSER_THAN);
5208 }
5209 }
5210 }
5211
5212 query.append(ORDER_BY_CLAUSE);
5213
5214 String[] orderByFields = orderByComparator.getOrderByFields();
5215
5216 for (int i = 0; i < orderByFields.length; i++) {
5217 if (getDB().isSupportsInlineDistinct()) {
5218 query.append(_ORDER_BY_ENTITY_ALIAS);
5219 }
5220 else {
5221 query.append(_ORDER_BY_ENTITY_TABLE);
5222 }
5223
5224 query.append(orderByFields[i]);
5225
5226 if ((i + 1) < orderByFields.length) {
5227 if (orderByComparator.isAscending() ^ previous) {
5228 query.append(ORDER_BY_ASC_HAS_NEXT);
5229 }
5230 else {
5231 query.append(ORDER_BY_DESC_HAS_NEXT);
5232 }
5233 }
5234 else {
5235 if (orderByComparator.isAscending() ^ previous) {
5236 query.append(ORDER_BY_ASC);
5237 }
5238 else {
5239 query.append(ORDER_BY_DESC);
5240 }
5241 }
5242 }
5243 }
5244 else {
5245 if (getDB().isSupportsInlineDistinct()) {
5246 query.append(RoleModelImpl.ORDER_BY_JPQL);
5247 }
5248 else {
5249 query.append(RoleModelImpl.ORDER_BY_SQL);
5250 }
5251 }
5252
5253 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5254 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
5255
5256 SQLQuery q = session.createSynchronizedSQLQuery(sql);
5257
5258 q.setFirstResult(0);
5259 q.setMaxResults(2);
5260
5261 if (getDB().isSupportsInlineDistinct()) {
5262 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
5263 }
5264 else {
5265 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
5266 }
5267
5268 QueryPos qPos = QueryPos.getInstance(q);
5269
5270 if (bindSubtype) {
5271 qPos.add(subtype);
5272 }
5273
5274 if (orderByComparator != null) {
5275 Object[] values = orderByComparator.getOrderByConditionValues(role);
5276
5277 for (Object value : values) {
5278 qPos.add(value);
5279 }
5280 }
5281
5282 List<Role> list = q.list();
5283
5284 if (list.size() == 2) {
5285 return list.get(1);
5286 }
5287 else {
5288 return null;
5289 }
5290 }
5291
5292
5297 @Override
5298 public void removeBySubtype(String subtype) {
5299 for (Role role : findBySubtype(subtype, QueryUtil.ALL_POS,
5300 QueryUtil.ALL_POS, null)) {
5301 remove(role);
5302 }
5303 }
5304
5305
5311 @Override
5312 public int countBySubtype(String subtype) {
5313 FinderPath finderPath = FINDER_PATH_COUNT_BY_SUBTYPE;
5314
5315 Object[] finderArgs = new Object[] { subtype };
5316
5317 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5318 this);
5319
5320 if (count == null) {
5321 StringBundler query = new StringBundler(2);
5322
5323 query.append(_SQL_COUNT_ROLE_WHERE);
5324
5325 boolean bindSubtype = false;
5326
5327 if (subtype == null) {
5328 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
5329 }
5330 else if (subtype.equals(StringPool.BLANK)) {
5331 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
5332 }
5333 else {
5334 bindSubtype = true;
5335
5336 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
5337 }
5338
5339 String sql = query.toString();
5340
5341 Session session = null;
5342
5343 try {
5344 session = openSession();
5345
5346 Query q = session.createQuery(sql);
5347
5348 QueryPos qPos = QueryPos.getInstance(q);
5349
5350 if (bindSubtype) {
5351 qPos.add(subtype);
5352 }
5353
5354 count = (Long)q.uniqueResult();
5355
5356 FinderCacheUtil.putResult(finderPath, finderArgs, count);
5357 }
5358 catch (Exception e) {
5359 FinderCacheUtil.removeResult(finderPath, finderArgs);
5360
5361 throw processException(e);
5362 }
5363 finally {
5364 closeSession(session);
5365 }
5366 }
5367
5368 return count.intValue();
5369 }
5370
5371
5377 @Override
5378 public int filterCountBySubtype(String subtype) {
5379 if (!InlineSQLHelperUtil.isEnabled()) {
5380 return countBySubtype(subtype);
5381 }
5382
5383 StringBundler query = new StringBundler(2);
5384
5385 query.append(_FILTER_SQL_COUNT_ROLE_WHERE);
5386
5387 boolean bindSubtype = false;
5388
5389 if (subtype == null) {
5390 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
5391 }
5392 else if (subtype.equals(StringPool.BLANK)) {
5393 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
5394 }
5395 else {
5396 bindSubtype = true;
5397
5398 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
5399 }
5400
5401 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5402 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
5403
5404 Session session = null;
5405
5406 try {
5407 session = openSession();
5408
5409 SQLQuery q = session.createSynchronizedSQLQuery(sql);
5410
5411 q.addScalar(COUNT_COLUMN_NAME,
5412 com.liferay.portal.kernel.dao.orm.Type.LONG);
5413
5414 QueryPos qPos = QueryPos.getInstance(q);
5415
5416 if (bindSubtype) {
5417 qPos.add(subtype);
5418 }
5419
5420 Long count = (Long)q.uniqueResult();
5421
5422 return count.intValue();
5423 }
5424 catch (Exception e) {
5425 throw processException(e);
5426 }
5427 finally {
5428 closeSession(session);
5429 }
5430 }
5431
5432 private static final String _FINDER_COLUMN_SUBTYPE_SUBTYPE_1 = "role.subtype IS NULL";
5433 private static final String _FINDER_COLUMN_SUBTYPE_SUBTYPE_2 = "role.subtype = ?";
5434 private static final String _FINDER_COLUMN_SUBTYPE_SUBTYPE_3 = "(role.subtype IS NULL OR role.subtype = '')";
5435 public static final FinderPath FINDER_PATH_FETCH_BY_C_N = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
5436 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
5437 FINDER_CLASS_NAME_ENTITY, "fetchByC_N",
5438 new String[] { Long.class.getName(), String.class.getName() },
5439 RoleModelImpl.COMPANYID_COLUMN_BITMASK |
5440 RoleModelImpl.NAME_COLUMN_BITMASK);
5441 public static final FinderPath FINDER_PATH_COUNT_BY_C_N = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
5442 RoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
5443 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_N",
5444 new String[] { Long.class.getName(), String.class.getName() });
5445
5446
5454 @Override
5455 public Role findByC_N(long companyId, String name)
5456 throws NoSuchRoleException {
5457 Role role = fetchByC_N(companyId, name);
5458
5459 if (role == null) {
5460 StringBundler msg = new StringBundler(6);
5461
5462 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5463
5464 msg.append("companyId=");
5465 msg.append(companyId);
5466
5467 msg.append(", name=");
5468 msg.append(name);
5469
5470 msg.append(StringPool.CLOSE_CURLY_BRACE);
5471
5472 if (_log.isWarnEnabled()) {
5473 _log.warn(msg.toString());
5474 }
5475
5476 throw new NoSuchRoleException(msg.toString());
5477 }
5478
5479 return role;
5480 }
5481
5482
5489 @Override
5490 public Role fetchByC_N(long companyId, String name) {
5491 return fetchByC_N(companyId, name, true);
5492 }
5493
5494
5502 @Override
5503 public Role fetchByC_N(long companyId, String name,
5504 boolean retrieveFromCache) {
5505 Object[] finderArgs = new Object[] { companyId, name };
5506
5507 Object result = null;
5508
5509 if (retrieveFromCache) {
5510 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_N,
5511 finderArgs, this);
5512 }
5513
5514 if (result instanceof Role) {
5515 Role role = (Role)result;
5516
5517 if ((companyId != role.getCompanyId()) ||
5518 !Validator.equals(name, role.getName())) {
5519 result = null;
5520 }
5521 }
5522
5523 if (result == null) {
5524 StringBundler query = new StringBundler(4);
5525
5526 query.append(_SQL_SELECT_ROLE_WHERE);
5527
5528 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
5529
5530 boolean bindName = false;
5531
5532 if (name == null) {
5533 query.append(_FINDER_COLUMN_C_N_NAME_1);
5534 }
5535 else if (name.equals(StringPool.BLANK)) {
5536 query.append(_FINDER_COLUMN_C_N_NAME_3);
5537 }
5538 else {
5539 bindName = true;
5540
5541 query.append(_FINDER_COLUMN_C_N_NAME_2);
5542 }
5543
5544 String sql = query.toString();
5545
5546 Session session = null;
5547
5548 try {
5549 session = openSession();
5550
5551 Query q = session.createQuery(sql);
5552
5553 QueryPos qPos = QueryPos.getInstance(q);
5554
5555 qPos.add(companyId);
5556
5557 if (bindName) {
5558 qPos.add(StringUtil.toLowerCase(name));
5559 }
5560
5561 List<Role> list = q.list();
5562
5563 if (list.isEmpty()) {
5564 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
5565 finderArgs, list);
5566 }
5567 else {
5568 Role role = list.get(0);
5569
5570 result = role;
5571
5572 cacheResult(role);
5573
5574 if ((role.getCompanyId() != companyId) ||
5575 (role.getName() == null) ||
5576 !role.getName().equals(name)) {
5577 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
5578 finderArgs, role);
5579 }
5580 }
5581 }
5582 catch (Exception e) {
5583 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
5584 finderArgs);
5585
5586 throw processException(e);
5587 }
5588 finally {
5589 closeSession(session);
5590 }
5591 }
5592
5593 if (result instanceof List<?>) {
5594 return null;
5595 }
5596 else {
5597 return (Role)result;
5598 }
5599 }
5600
5601
5608 @Override
5609 public Role removeByC_N(long companyId, String name)
5610 throws NoSuchRoleException {
5611 Role role = findByC_N(companyId, name);
5612
5613 return remove(role);
5614 }
5615
5616
5623 @Override
5624 public int countByC_N(long companyId, String name) {
5625 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_N;
5626
5627 Object[] finderArgs = new Object[] { companyId, name };
5628
5629 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5630 this);
5631
5632 if (count == null) {
5633 StringBundler query = new StringBundler(3);
5634
5635 query.append(_SQL_COUNT_ROLE_WHERE);
5636
5637 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
5638
5639 boolean bindName = false;
5640
5641 if (name == null) {
5642 query.append(_FINDER_COLUMN_C_N_NAME_1);
5643 }
5644 else if (name.equals(StringPool.BLANK)) {
5645 query.append(_FINDER_COLUMN_C_N_NAME_3);
5646 }
5647 else {
5648 bindName = true;
5649
5650 query.append(_FINDER_COLUMN_C_N_NAME_2);
5651 }
5652
5653 String sql = query.toString();
5654
5655 Session session = null;
5656
5657 try {
5658 session = openSession();
5659
5660 Query q = session.createQuery(sql);
5661
5662 QueryPos qPos = QueryPos.getInstance(q);
5663
5664 qPos.add(companyId);
5665
5666 if (bindName) {
5667 qPos.add(StringUtil.toLowerCase(name));
5668 }
5669
5670 count = (Long)q.uniqueResult();
5671
5672 FinderCacheUtil.putResult(finderPath, finderArgs, count);
5673 }
5674 catch (Exception e) {
5675 FinderCacheUtil.removeResult(finderPath, finderArgs);
5676
5677 throw processException(e);
5678 }
5679 finally {
5680 closeSession(session);
5681 }
5682 }
5683
5684 return count.intValue();
5685 }
5686
5687 private static final String _FINDER_COLUMN_C_N_COMPANYID_2 = "role.companyId = ? AND ";
5688 private static final String _FINDER_COLUMN_C_N_NAME_1 = "role.name IS NULL";
5689 private static final String _FINDER_COLUMN_C_N_NAME_2 = "lower(role.name) = ?";
5690 private static final String _FINDER_COLUMN_C_N_NAME_3 = "(role.name IS NULL OR role.name = '')";
5691 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_T = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
5692 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
5693 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_T",
5694 new String[] {
5695 Long.class.getName(), Integer.class.getName(),
5696
5697 Integer.class.getName(), Integer.class.getName(),
5698 OrderByComparator.class.getName()
5699 });
5700 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
5701 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
5702 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_T",
5703 new String[] { Long.class.getName(), Integer.class.getName() },
5704 RoleModelImpl.COMPANYID_COLUMN_BITMASK |
5705 RoleModelImpl.TYPE_COLUMN_BITMASK |
5706 RoleModelImpl.NAME_COLUMN_BITMASK);
5707 public static final FinderPath FINDER_PATH_COUNT_BY_C_T = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
5708 RoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
5709 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_T",
5710 new String[] { Long.class.getName(), Integer.class.getName() });
5711 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_T = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
5712 RoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
5713 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_T",
5714 new String[] { Long.class.getName(), Integer.class.getName() });
5715
5716
5723 @Override
5724 public List<Role> findByC_T(long companyId, int type) {
5725 return findByC_T(companyId, type, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
5726 null);
5727 }
5728
5729
5742 @Override
5743 public List<Role> findByC_T(long companyId, int type, int start, int end) {
5744 return findByC_T(companyId, type, start, end, null);
5745 }
5746
5747
5761 @Override
5762 public List<Role> findByC_T(long companyId, int type, int start, int end,
5763 OrderByComparator<Role> orderByComparator) {
5764 boolean pagination = true;
5765 FinderPath finderPath = null;
5766 Object[] finderArgs = null;
5767
5768 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5769 (orderByComparator == null)) {
5770 pagination = false;
5771 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T;
5772 finderArgs = new Object[] { companyId, type };
5773 }
5774 else {
5775 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_T;
5776 finderArgs = new Object[] {
5777 companyId, type,
5778
5779 start, end, orderByComparator
5780 };
5781 }
5782
5783 List<Role> list = (List<Role>)FinderCacheUtil.getResult(finderPath,
5784 finderArgs, this);
5785
5786 if ((list != null) && !list.isEmpty()) {
5787 for (Role role : list) {
5788 if ((companyId != role.getCompanyId()) ||
5789 (type != role.getType())) {
5790 list = null;
5791
5792 break;
5793 }
5794 }
5795 }
5796
5797 if (list == null) {
5798 StringBundler query = null;
5799
5800 if (orderByComparator != null) {
5801 query = new StringBundler(4 +
5802 (orderByComparator.getOrderByFields().length * 3));
5803 }
5804 else {
5805 query = new StringBundler(4);
5806 }
5807
5808 query.append(_SQL_SELECT_ROLE_WHERE);
5809
5810 query.append(_FINDER_COLUMN_C_T_COMPANYID_2);
5811
5812 query.append(_FINDER_COLUMN_C_T_TYPE_2);
5813
5814 if (orderByComparator != null) {
5815 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5816 orderByComparator);
5817 }
5818 else
5819 if (pagination) {
5820 query.append(RoleModelImpl.ORDER_BY_JPQL);
5821 }
5822
5823 String sql = query.toString();
5824
5825 Session session = null;
5826
5827 try {
5828 session = openSession();
5829
5830 Query q = session.createQuery(sql);
5831
5832 QueryPos qPos = QueryPos.getInstance(q);
5833
5834 qPos.add(companyId);
5835
5836 qPos.add(type);
5837
5838 if (!pagination) {
5839 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
5840 end, false);
5841
5842 Collections.sort(list);
5843
5844 list = Collections.unmodifiableList(list);
5845 }
5846 else {
5847 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
5848 end);
5849 }
5850
5851 cacheResult(list);
5852
5853 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5854 }
5855 catch (Exception e) {
5856 FinderCacheUtil.removeResult(finderPath, finderArgs);
5857
5858 throw processException(e);
5859 }
5860 finally {
5861 closeSession(session);
5862 }
5863 }
5864
5865 return list;
5866 }
5867
5868
5877 @Override
5878 public Role findByC_T_First(long companyId, int type,
5879 OrderByComparator<Role> orderByComparator) throws NoSuchRoleException {
5880 Role role = fetchByC_T_First(companyId, type, orderByComparator);
5881
5882 if (role != null) {
5883 return role;
5884 }
5885
5886 StringBundler msg = new StringBundler(6);
5887
5888 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5889
5890 msg.append("companyId=");
5891 msg.append(companyId);
5892
5893 msg.append(", type=");
5894 msg.append(type);
5895
5896 msg.append(StringPool.CLOSE_CURLY_BRACE);
5897
5898 throw new NoSuchRoleException(msg.toString());
5899 }
5900
5901
5909 @Override
5910 public Role fetchByC_T_First(long companyId, int type,
5911 OrderByComparator<Role> orderByComparator) {
5912 List<Role> list = findByC_T(companyId, type, 0, 1, orderByComparator);
5913
5914 if (!list.isEmpty()) {
5915 return list.get(0);
5916 }
5917
5918 return null;
5919 }
5920
5921
5930 @Override
5931 public Role findByC_T_Last(long companyId, int type,
5932 OrderByComparator<Role> orderByComparator) throws NoSuchRoleException {
5933 Role role = fetchByC_T_Last(companyId, type, orderByComparator);
5934
5935 if (role != null) {
5936 return role;
5937 }
5938
5939 StringBundler msg = new StringBundler(6);
5940
5941 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5942
5943 msg.append("companyId=");
5944 msg.append(companyId);
5945
5946 msg.append(", type=");
5947 msg.append(type);
5948
5949 msg.append(StringPool.CLOSE_CURLY_BRACE);
5950
5951 throw new NoSuchRoleException(msg.toString());
5952 }
5953
5954
5962 @Override
5963 public Role fetchByC_T_Last(long companyId, int type,
5964 OrderByComparator<Role> orderByComparator) {
5965 int count = countByC_T(companyId, type);
5966
5967 if (count == 0) {
5968 return null;
5969 }
5970
5971 List<Role> list = findByC_T(companyId, type, count - 1, count,
5972 orderByComparator);
5973
5974 if (!list.isEmpty()) {
5975 return list.get(0);
5976 }
5977
5978 return null;
5979 }
5980
5981
5991 @Override
5992 public Role[] findByC_T_PrevAndNext(long roleId, long companyId, int type,
5993 OrderByComparator<Role> orderByComparator) throws NoSuchRoleException {
5994 Role role = findByPrimaryKey(roleId);
5995
5996 Session session = null;
5997
5998 try {
5999 session = openSession();
6000
6001 Role[] array = new RoleImpl[3];
6002
6003 array[0] = getByC_T_PrevAndNext(session, role, companyId, type,
6004 orderByComparator, true);
6005
6006 array[1] = role;
6007
6008 array[2] = getByC_T_PrevAndNext(session, role, companyId, type,
6009 orderByComparator, false);
6010
6011 return array;
6012 }
6013 catch (Exception e) {
6014 throw processException(e);
6015 }
6016 finally {
6017 closeSession(session);
6018 }
6019 }
6020
6021 protected Role getByC_T_PrevAndNext(Session session, Role role,
6022 long companyId, int type, OrderByComparator<Role> orderByComparator,
6023 boolean previous) {
6024 StringBundler query = null;
6025
6026 if (orderByComparator != null) {
6027 query = new StringBundler(6 +
6028 (orderByComparator.getOrderByFields().length * 6));
6029 }
6030 else {
6031 query = new StringBundler(3);
6032 }
6033
6034 query.append(_SQL_SELECT_ROLE_WHERE);
6035
6036 query.append(_FINDER_COLUMN_C_T_COMPANYID_2);
6037
6038 query.append(_FINDER_COLUMN_C_T_TYPE_2);
6039
6040 if (orderByComparator != null) {
6041 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6042
6043 if (orderByConditionFields.length > 0) {
6044 query.append(WHERE_AND);
6045 }
6046
6047 for (int i = 0; i < orderByConditionFields.length; i++) {
6048 query.append(_ORDER_BY_ENTITY_ALIAS);
6049 query.append(orderByConditionFields[i]);
6050
6051 if ((i + 1) < orderByConditionFields.length) {
6052 if (orderByComparator.isAscending() ^ previous) {
6053 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6054 }
6055 else {
6056 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6057 }
6058 }
6059 else {
6060 if (orderByComparator.isAscending() ^ previous) {
6061 query.append(WHERE_GREATER_THAN);
6062 }
6063 else {
6064 query.append(WHERE_LESSER_THAN);
6065 }
6066 }
6067 }
6068
6069 query.append(ORDER_BY_CLAUSE);
6070
6071 String[] orderByFields = orderByComparator.getOrderByFields();
6072
6073 for (int i = 0; i < orderByFields.length; i++) {
6074 query.append(_ORDER_BY_ENTITY_ALIAS);
6075 query.append(orderByFields[i]);
6076
6077 if ((i + 1) < orderByFields.length) {
6078 if (orderByComparator.isAscending() ^ previous) {
6079 query.append(ORDER_BY_ASC_HAS_NEXT);
6080 }
6081 else {
6082 query.append(ORDER_BY_DESC_HAS_NEXT);
6083 }
6084 }
6085 else {
6086 if (orderByComparator.isAscending() ^ previous) {
6087 query.append(ORDER_BY_ASC);
6088 }
6089 else {
6090 query.append(ORDER_BY_DESC);
6091 }
6092 }
6093 }
6094 }
6095 else {
6096 query.append(RoleModelImpl.ORDER_BY_JPQL);
6097 }
6098
6099 String sql = query.toString();
6100
6101 Query q = session.createQuery(sql);
6102
6103 q.setFirstResult(0);
6104 q.setMaxResults(2);
6105
6106 QueryPos qPos = QueryPos.getInstance(q);
6107
6108 qPos.add(companyId);
6109
6110 qPos.add(type);
6111
6112 if (orderByComparator != null) {
6113 Object[] values = orderByComparator.getOrderByConditionValues(role);
6114
6115 for (Object value : values) {
6116 qPos.add(value);
6117 }
6118 }
6119
6120 List<Role> list = q.list();
6121
6122 if (list.size() == 2) {
6123 return list.get(1);
6124 }
6125 else {
6126 return null;
6127 }
6128 }
6129
6130
6137 @Override
6138 public List<Role> filterFindByC_T(long companyId, int type) {
6139 return filterFindByC_T(companyId, type, QueryUtil.ALL_POS,
6140 QueryUtil.ALL_POS, null);
6141 }
6142
6143
6156 @Override
6157 public List<Role> filterFindByC_T(long companyId, int type, int start,
6158 int end) {
6159 return filterFindByC_T(companyId, type, start, end, null);
6160 }
6161
6162
6176 @Override
6177 public List<Role> filterFindByC_T(long companyId, int type, int start,
6178 int end, OrderByComparator<Role> orderByComparator) {
6179 if (!InlineSQLHelperUtil.isEnabled()) {
6180 return findByC_T(companyId, type, start, end, orderByComparator);
6181 }
6182
6183 StringBundler query = null;
6184
6185 if (orderByComparator != null) {
6186 query = new StringBundler(4 +
6187 (orderByComparator.getOrderByFields().length * 3));
6188 }
6189 else {
6190 query = new StringBundler(4);
6191 }
6192
6193 if (getDB().isSupportsInlineDistinct()) {
6194 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
6195 }
6196 else {
6197 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
6198 }
6199
6200 query.append(_FINDER_COLUMN_C_T_COMPANYID_2);
6201
6202 query.append(_FINDER_COLUMN_C_T_TYPE_2_SQL);
6203
6204 if (!getDB().isSupportsInlineDistinct()) {
6205 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
6206 }
6207
6208 if (orderByComparator != null) {
6209 if (getDB().isSupportsInlineDistinct()) {
6210 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6211 orderByComparator, true);
6212 }
6213 else {
6214 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6215 orderByComparator, true);
6216 }
6217 }
6218 else {
6219 if (getDB().isSupportsInlineDistinct()) {
6220 query.append(RoleModelImpl.ORDER_BY_JPQL);
6221 }
6222 else {
6223 query.append(RoleModelImpl.ORDER_BY_SQL);
6224 }
6225 }
6226
6227 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6228 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
6229
6230 Session session = null;
6231
6232 try {
6233 session = openSession();
6234
6235 SQLQuery q = session.createSynchronizedSQLQuery(sql);
6236
6237 if (getDB().isSupportsInlineDistinct()) {
6238 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
6239 }
6240 else {
6241 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
6242 }
6243
6244 QueryPos qPos = QueryPos.getInstance(q);
6245
6246 qPos.add(companyId);
6247
6248 qPos.add(type);
6249
6250 return (List<Role>)QueryUtil.list(q, getDialect(), start, end);
6251 }
6252 catch (Exception e) {
6253 throw processException(e);
6254 }
6255 finally {
6256 closeSession(session);
6257 }
6258 }
6259
6260
6270 @Override
6271 public Role[] filterFindByC_T_PrevAndNext(long roleId, long companyId,
6272 int type, OrderByComparator<Role> orderByComparator)
6273 throws NoSuchRoleException {
6274 if (!InlineSQLHelperUtil.isEnabled()) {
6275 return findByC_T_PrevAndNext(roleId, companyId, type,
6276 orderByComparator);
6277 }
6278
6279 Role role = findByPrimaryKey(roleId);
6280
6281 Session session = null;
6282
6283 try {
6284 session = openSession();
6285
6286 Role[] array = new RoleImpl[3];
6287
6288 array[0] = filterGetByC_T_PrevAndNext(session, role, companyId,
6289 type, orderByComparator, true);
6290
6291 array[1] = role;
6292
6293 array[2] = filterGetByC_T_PrevAndNext(session, role, companyId,
6294 type, orderByComparator, false);
6295
6296 return array;
6297 }
6298 catch (Exception e) {
6299 throw processException(e);
6300 }
6301 finally {
6302 closeSession(session);
6303 }
6304 }
6305
6306 protected Role filterGetByC_T_PrevAndNext(Session session, Role role,
6307 long companyId, int type, OrderByComparator<Role> orderByComparator,
6308 boolean previous) {
6309 StringBundler query = null;
6310
6311 if (orderByComparator != null) {
6312 query = new StringBundler(6 +
6313 (orderByComparator.getOrderByFields().length * 6));
6314 }
6315 else {
6316 query = new StringBundler(3);
6317 }
6318
6319 if (getDB().isSupportsInlineDistinct()) {
6320 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
6321 }
6322 else {
6323 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
6324 }
6325
6326 query.append(_FINDER_COLUMN_C_T_COMPANYID_2);
6327
6328 query.append(_FINDER_COLUMN_C_T_TYPE_2_SQL);
6329
6330 if (!getDB().isSupportsInlineDistinct()) {
6331 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
6332 }
6333
6334 if (orderByComparator != null) {
6335 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6336
6337 if (orderByConditionFields.length > 0) {
6338 query.append(WHERE_AND);
6339 }
6340
6341 for (int i = 0; i < orderByConditionFields.length; i++) {
6342 if (getDB().isSupportsInlineDistinct()) {
6343 query.append(_ORDER_BY_ENTITY_ALIAS);
6344 }
6345 else {
6346 query.append(_ORDER_BY_ENTITY_TABLE);
6347 }
6348
6349 query.append(orderByConditionFields[i]);
6350
6351 if ((i + 1) < orderByConditionFields.length) {
6352 if (orderByComparator.isAscending() ^ previous) {
6353 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6354 }
6355 else {
6356 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6357 }
6358 }
6359 else {
6360 if (orderByComparator.isAscending() ^ previous) {
6361 query.append(WHERE_GREATER_THAN);
6362 }
6363 else {
6364 query.append(WHERE_LESSER_THAN);
6365 }
6366 }
6367 }
6368
6369 query.append(ORDER_BY_CLAUSE);
6370
6371 String[] orderByFields = orderByComparator.getOrderByFields();
6372
6373 for (int i = 0; i < orderByFields.length; i++) {
6374 if (getDB().isSupportsInlineDistinct()) {
6375 query.append(_ORDER_BY_ENTITY_ALIAS);
6376 }
6377 else {
6378 query.append(_ORDER_BY_ENTITY_TABLE);
6379 }
6380
6381 query.append(orderByFields[i]);
6382
6383 if ((i + 1) < orderByFields.length) {
6384 if (orderByComparator.isAscending() ^ previous) {
6385 query.append(ORDER_BY_ASC_HAS_NEXT);
6386 }
6387 else {
6388 query.append(ORDER_BY_DESC_HAS_NEXT);
6389 }
6390 }
6391 else {
6392 if (orderByComparator.isAscending() ^ previous) {
6393 query.append(ORDER_BY_ASC);
6394 }
6395 else {
6396 query.append(ORDER_BY_DESC);
6397 }
6398 }
6399 }
6400 }
6401 else {
6402 if (getDB().isSupportsInlineDistinct()) {
6403 query.append(RoleModelImpl.ORDER_BY_JPQL);
6404 }
6405 else {
6406 query.append(RoleModelImpl.ORDER_BY_SQL);
6407 }
6408 }
6409
6410 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6411 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
6412
6413 SQLQuery q = session.createSynchronizedSQLQuery(sql);
6414
6415 q.setFirstResult(0);
6416 q.setMaxResults(2);
6417
6418 if (getDB().isSupportsInlineDistinct()) {
6419 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
6420 }
6421 else {
6422 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
6423 }
6424
6425 QueryPos qPos = QueryPos.getInstance(q);
6426
6427 qPos.add(companyId);
6428
6429 qPos.add(type);
6430
6431 if (orderByComparator != null) {
6432 Object[] values = orderByComparator.getOrderByConditionValues(role);
6433
6434 for (Object value : values) {
6435 qPos.add(value);
6436 }
6437 }
6438
6439 List<Role> list = q.list();
6440
6441 if (list.size() == 2) {
6442 return list.get(1);
6443 }
6444 else {
6445 return null;
6446 }
6447 }
6448
6449
6456 @Override
6457 public List<Role> filterFindByC_T(long companyId, int[] types) {
6458 return filterFindByC_T(companyId, types, QueryUtil.ALL_POS,
6459 QueryUtil.ALL_POS, null);
6460 }
6461
6462
6475 @Override
6476 public List<Role> filterFindByC_T(long companyId, int[] types, int start,
6477 int end) {
6478 return filterFindByC_T(companyId, types, start, end, null);
6479 }
6480
6481
6495 @Override
6496 public List<Role> filterFindByC_T(long companyId, int[] types, int start,
6497 int end, OrderByComparator<Role> orderByComparator) {
6498 if (!InlineSQLHelperUtil.isEnabled()) {
6499 return findByC_T(companyId, types, start, end, orderByComparator);
6500 }
6501
6502 if (types == null) {
6503 types = new int[0];
6504 }
6505 else {
6506 types = ArrayUtil.unique(types);
6507 }
6508
6509 StringBundler query = new StringBundler();
6510
6511 if (getDB().isSupportsInlineDistinct()) {
6512 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
6513 }
6514 else {
6515 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
6516 }
6517
6518 query.append(_FINDER_COLUMN_C_T_COMPANYID_2);
6519
6520 if (types.length > 0) {
6521 query.append(StringPool.OPEN_PARENTHESIS);
6522
6523 query.append(_FINDER_COLUMN_C_T_TYPE_7_SQL);
6524
6525 query.append(StringUtil.merge(types));
6526
6527 query.append(StringPool.CLOSE_PARENTHESIS);
6528
6529 query.append(StringPool.CLOSE_PARENTHESIS);
6530 }
6531
6532 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
6533 query.index() - 1);
6534
6535 if (!getDB().isSupportsInlineDistinct()) {
6536 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
6537 }
6538
6539 if (orderByComparator != null) {
6540 if (getDB().isSupportsInlineDistinct()) {
6541 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6542 orderByComparator, true);
6543 }
6544 else {
6545 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6546 orderByComparator, true);
6547 }
6548 }
6549 else {
6550 if (getDB().isSupportsInlineDistinct()) {
6551 query.append(RoleModelImpl.ORDER_BY_JPQL);
6552 }
6553 else {
6554 query.append(RoleModelImpl.ORDER_BY_SQL);
6555 }
6556 }
6557
6558 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6559 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
6560
6561 Session session = null;
6562
6563 try {
6564 session = openSession();
6565
6566 SQLQuery q = session.createSynchronizedSQLQuery(sql);
6567
6568 if (getDB().isSupportsInlineDistinct()) {
6569 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
6570 }
6571 else {
6572 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
6573 }
6574
6575 QueryPos qPos = QueryPos.getInstance(q);
6576
6577 qPos.add(companyId);
6578
6579 return (List<Role>)QueryUtil.list(q, getDialect(), start, end);
6580 }
6581 catch (Exception e) {
6582 throw processException(e);
6583 }
6584 finally {
6585 closeSession(session);
6586 }
6587 }
6588
6589
6600 @Override
6601 public List<Role> findByC_T(long companyId, int[] types) {
6602 return findByC_T(companyId, types, QueryUtil.ALL_POS,
6603 QueryUtil.ALL_POS, null);
6604 }
6605
6606
6619 @Override
6620 public List<Role> findByC_T(long companyId, int[] types, int start, int end) {
6621 return findByC_T(companyId, types, start, end, null);
6622 }
6623
6624
6638 @Override
6639 public List<Role> findByC_T(long companyId, int[] types, int start,
6640 int end, OrderByComparator<Role> orderByComparator) {
6641 if (types == null) {
6642 types = new int[0];
6643 }
6644 else {
6645 types = ArrayUtil.unique(types);
6646 }
6647
6648 if (types.length == 1) {
6649 return findByC_T(companyId, types[0], start, end, orderByComparator);
6650 }
6651
6652 boolean pagination = true;
6653 Object[] finderArgs = null;
6654
6655 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6656 (orderByComparator == null)) {
6657 pagination = false;
6658 finderArgs = new Object[] { companyId, StringUtil.merge(types) };
6659 }
6660 else {
6661 finderArgs = new Object[] {
6662 companyId, StringUtil.merge(types),
6663
6664 start, end, orderByComparator
6665 };
6666 }
6667
6668 List<Role> list = (List<Role>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_C_T,
6669 finderArgs, this);
6670
6671 if ((list != null) && !list.isEmpty()) {
6672 for (Role role : list) {
6673 if ((companyId != role.getCompanyId()) ||
6674 !ArrayUtil.contains(types, role.getType())) {
6675 list = null;
6676
6677 break;
6678 }
6679 }
6680 }
6681
6682 if (list == null) {
6683 StringBundler query = new StringBundler();
6684
6685 query.append(_SQL_SELECT_ROLE_WHERE);
6686
6687 query.append(_FINDER_COLUMN_C_T_COMPANYID_2);
6688
6689 if (types.length > 0) {
6690 query.append(StringPool.OPEN_PARENTHESIS);
6691
6692 query.append(_FINDER_COLUMN_C_T_TYPE_7);
6693
6694 query.append(StringUtil.merge(types));
6695
6696 query.append(StringPool.CLOSE_PARENTHESIS);
6697
6698 query.append(StringPool.CLOSE_PARENTHESIS);
6699 }
6700
6701 query.setStringAt(removeConjunction(query.stringAt(query.index() -
6702 1)), query.index() - 1);
6703
6704 if (orderByComparator != null) {
6705 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6706 orderByComparator);
6707 }
6708 else
6709 if (pagination) {
6710 query.append(RoleModelImpl.ORDER_BY_JPQL);
6711 }
6712
6713 String sql = query.toString();
6714
6715 Session session = null;
6716
6717 try {
6718 session = openSession();
6719
6720 Query q = session.createQuery(sql);
6721
6722 QueryPos qPos = QueryPos.getInstance(q);
6723
6724 qPos.add(companyId);
6725
6726 if (!pagination) {
6727 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
6728 end, false);
6729
6730 Collections.sort(list);
6731
6732 list = Collections.unmodifiableList(list);
6733 }
6734 else {
6735 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
6736 end);
6737 }
6738
6739 cacheResult(list);
6740
6741 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_C_T,
6742 finderArgs, list);
6743 }
6744 catch (Exception e) {
6745 FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_C_T,
6746 finderArgs);
6747
6748 throw processException(e);
6749 }
6750 finally {
6751 closeSession(session);
6752 }
6753 }
6754
6755 return list;
6756 }
6757
6758
6764 @Override
6765 public void removeByC_T(long companyId, int type) {
6766 for (Role role : findByC_T(companyId, type, QueryUtil.ALL_POS,
6767 QueryUtil.ALL_POS, null)) {
6768 remove(role);
6769 }
6770 }
6771
6772
6779 @Override
6780 public int countByC_T(long companyId, int type) {
6781 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_T;
6782
6783 Object[] finderArgs = new Object[] { companyId, type };
6784
6785 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6786 this);
6787
6788 if (count == null) {
6789 StringBundler query = new StringBundler(3);
6790
6791 query.append(_SQL_COUNT_ROLE_WHERE);
6792
6793 query.append(_FINDER_COLUMN_C_T_COMPANYID_2);
6794
6795 query.append(_FINDER_COLUMN_C_T_TYPE_2);
6796
6797 String sql = query.toString();
6798
6799 Session session = null;
6800
6801 try {
6802 session = openSession();
6803
6804 Query q = session.createQuery(sql);
6805
6806 QueryPos qPos = QueryPos.getInstance(q);
6807
6808 qPos.add(companyId);
6809
6810 qPos.add(type);
6811
6812 count = (Long)q.uniqueResult();
6813
6814 FinderCacheUtil.putResult(finderPath, finderArgs, count);
6815 }
6816 catch (Exception e) {
6817 FinderCacheUtil.removeResult(finderPath, finderArgs);
6818
6819 throw processException(e);
6820 }
6821 finally {
6822 closeSession(session);
6823 }
6824 }
6825
6826 return count.intValue();
6827 }
6828
6829
6836 @Override
6837 public int countByC_T(long companyId, int[] types) {
6838 if (types == null) {
6839 types = new int[0];
6840 }
6841 else {
6842 types = ArrayUtil.unique(types);
6843 }
6844
6845 Object[] finderArgs = new Object[] { companyId, StringUtil.merge(types) };
6846
6847 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_T,
6848 finderArgs, this);
6849
6850 if (count == null) {
6851 StringBundler query = new StringBundler();
6852
6853 query.append(_SQL_COUNT_ROLE_WHERE);
6854
6855 query.append(_FINDER_COLUMN_C_T_COMPANYID_2);
6856
6857 if (types.length > 0) {
6858 query.append(StringPool.OPEN_PARENTHESIS);
6859
6860 query.append(_FINDER_COLUMN_C_T_TYPE_7);
6861
6862 query.append(StringUtil.merge(types));
6863
6864 query.append(StringPool.CLOSE_PARENTHESIS);
6865
6866 query.append(StringPool.CLOSE_PARENTHESIS);
6867 }
6868
6869 query.setStringAt(removeConjunction(query.stringAt(query.index() -
6870 1)), query.index() - 1);
6871
6872 String sql = query.toString();
6873
6874 Session session = null;
6875
6876 try {
6877 session = openSession();
6878
6879 Query q = session.createQuery(sql);
6880
6881 QueryPos qPos = QueryPos.getInstance(q);
6882
6883 qPos.add(companyId);
6884
6885 count = (Long)q.uniqueResult();
6886
6887 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_T,
6888 finderArgs, count);
6889 }
6890 catch (Exception e) {
6891 FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_T,
6892 finderArgs);
6893
6894 throw processException(e);
6895 }
6896 finally {
6897 closeSession(session);
6898 }
6899 }
6900
6901 return count.intValue();
6902 }
6903
6904
6911 @Override
6912 public int filterCountByC_T(long companyId, int type) {
6913 if (!InlineSQLHelperUtil.isEnabled()) {
6914 return countByC_T(companyId, type);
6915 }
6916
6917 StringBundler query = new StringBundler(3);
6918
6919 query.append(_FILTER_SQL_COUNT_ROLE_WHERE);
6920
6921 query.append(_FINDER_COLUMN_C_T_COMPANYID_2);
6922
6923 query.append(_FINDER_COLUMN_C_T_TYPE_2_SQL);
6924
6925 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6926 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
6927
6928 Session session = null;
6929
6930 try {
6931 session = openSession();
6932
6933 SQLQuery q = session.createSynchronizedSQLQuery(sql);
6934
6935 q.addScalar(COUNT_COLUMN_NAME,
6936 com.liferay.portal.kernel.dao.orm.Type.LONG);
6937
6938 QueryPos qPos = QueryPos.getInstance(q);
6939
6940 qPos.add(companyId);
6941
6942 qPos.add(type);
6943
6944 Long count = (Long)q.uniqueResult();
6945
6946 return count.intValue();
6947 }
6948 catch (Exception e) {
6949 throw processException(e);
6950 }
6951 finally {
6952 closeSession(session);
6953 }
6954 }
6955
6956
6963 @Override
6964 public int filterCountByC_T(long companyId, int[] types) {
6965 if (!InlineSQLHelperUtil.isEnabled()) {
6966 return countByC_T(companyId, types);
6967 }
6968
6969 if (types == null) {
6970 types = new int[0];
6971 }
6972 else {
6973 types = ArrayUtil.unique(types);
6974 }
6975
6976 StringBundler query = new StringBundler();
6977
6978 query.append(_FILTER_SQL_COUNT_ROLE_WHERE);
6979
6980 query.append(_FINDER_COLUMN_C_T_COMPANYID_2);
6981
6982 if (types.length > 0) {
6983 query.append(StringPool.OPEN_PARENTHESIS);
6984
6985 query.append(_FINDER_COLUMN_C_T_TYPE_7_SQL);
6986
6987 query.append(StringUtil.merge(types));
6988
6989 query.append(StringPool.CLOSE_PARENTHESIS);
6990
6991 query.append(StringPool.CLOSE_PARENTHESIS);
6992 }
6993
6994 query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
6995 query.index() - 1);
6996
6997 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6998 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
6999
7000 Session session = null;
7001
7002 try {
7003 session = openSession();
7004
7005 SQLQuery q = session.createSynchronizedSQLQuery(sql);
7006
7007 q.addScalar(COUNT_COLUMN_NAME,
7008 com.liferay.portal.kernel.dao.orm.Type.LONG);
7009
7010 QueryPos qPos = QueryPos.getInstance(q);
7011
7012 qPos.add(companyId);
7013
7014 Long count = (Long)q.uniqueResult();
7015
7016 return count.intValue();
7017 }
7018 catch (Exception e) {
7019 throw processException(e);
7020 }
7021 finally {
7022 closeSession(session);
7023 }
7024 }
7025
7026 private static final String _FINDER_COLUMN_C_T_COMPANYID_2 = "role.companyId = ? AND ";
7027 private static final String _FINDER_COLUMN_C_T_TYPE_2 = "role.type = ?";
7028 private static final String _FINDER_COLUMN_C_T_TYPE_7 = "role.type IN (";
7029 private static final String _FINDER_COLUMN_C_T_TYPE_2_SQL = "role.type_ = ?";
7030 private static final String _FINDER_COLUMN_C_T_TYPE_7_SQL = "role.type_ IN (";
7031 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_T_S = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
7032 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
7033 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByT_S",
7034 new String[] {
7035 Integer.class.getName(), String.class.getName(),
7036
7037 Integer.class.getName(), Integer.class.getName(),
7038 OrderByComparator.class.getName()
7039 });
7040 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
7041 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
7042 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByT_S",
7043 new String[] { Integer.class.getName(), String.class.getName() },
7044 RoleModelImpl.TYPE_COLUMN_BITMASK |
7045 RoleModelImpl.SUBTYPE_COLUMN_BITMASK |
7046 RoleModelImpl.NAME_COLUMN_BITMASK);
7047 public static final FinderPath FINDER_PATH_COUNT_BY_T_S = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
7048 RoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
7049 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByT_S",
7050 new String[] { Integer.class.getName(), String.class.getName() });
7051
7052
7059 @Override
7060 public List<Role> findByT_S(int type, String subtype) {
7061 return findByT_S(type, subtype, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
7062 null);
7063 }
7064
7065
7078 @Override
7079 public List<Role> findByT_S(int type, String subtype, int start, int end) {
7080 return findByT_S(type, subtype, start, end, null);
7081 }
7082
7083
7097 @Override
7098 public List<Role> findByT_S(int type, String subtype, int start, int end,
7099 OrderByComparator<Role> orderByComparator) {
7100 boolean pagination = true;
7101 FinderPath finderPath = null;
7102 Object[] finderArgs = null;
7103
7104 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7105 (orderByComparator == null)) {
7106 pagination = false;
7107 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S;
7108 finderArgs = new Object[] { type, subtype };
7109 }
7110 else {
7111 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_T_S;
7112 finderArgs = new Object[] {
7113 type, subtype,
7114
7115 start, end, orderByComparator
7116 };
7117 }
7118
7119 List<Role> list = (List<Role>)FinderCacheUtil.getResult(finderPath,
7120 finderArgs, this);
7121
7122 if ((list != null) && !list.isEmpty()) {
7123 for (Role role : list) {
7124 if ((type != role.getType()) ||
7125 !Validator.equals(subtype, role.getSubtype())) {
7126 list = null;
7127
7128 break;
7129 }
7130 }
7131 }
7132
7133 if (list == null) {
7134 StringBundler query = null;
7135
7136 if (orderByComparator != null) {
7137 query = new StringBundler(4 +
7138 (orderByComparator.getOrderByFields().length * 3));
7139 }
7140 else {
7141 query = new StringBundler(4);
7142 }
7143
7144 query.append(_SQL_SELECT_ROLE_WHERE);
7145
7146 query.append(_FINDER_COLUMN_T_S_TYPE_2);
7147
7148 boolean bindSubtype = false;
7149
7150 if (subtype == null) {
7151 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
7152 }
7153 else if (subtype.equals(StringPool.BLANK)) {
7154 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
7155 }
7156 else {
7157 bindSubtype = true;
7158
7159 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
7160 }
7161
7162 if (orderByComparator != null) {
7163 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7164 orderByComparator);
7165 }
7166 else
7167 if (pagination) {
7168 query.append(RoleModelImpl.ORDER_BY_JPQL);
7169 }
7170
7171 String sql = query.toString();
7172
7173 Session session = null;
7174
7175 try {
7176 session = openSession();
7177
7178 Query q = session.createQuery(sql);
7179
7180 QueryPos qPos = QueryPos.getInstance(q);
7181
7182 qPos.add(type);
7183
7184 if (bindSubtype) {
7185 qPos.add(subtype);
7186 }
7187
7188 if (!pagination) {
7189 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
7190 end, false);
7191
7192 Collections.sort(list);
7193
7194 list = Collections.unmodifiableList(list);
7195 }
7196 else {
7197 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
7198 end);
7199 }
7200
7201 cacheResult(list);
7202
7203 FinderCacheUtil.putResult(finderPath, finderArgs, list);
7204 }
7205 catch (Exception e) {
7206 FinderCacheUtil.removeResult(finderPath, finderArgs);
7207
7208 throw processException(e);
7209 }
7210 finally {
7211 closeSession(session);
7212 }
7213 }
7214
7215 return list;
7216 }
7217
7218
7227 @Override
7228 public Role findByT_S_First(int type, String subtype,
7229 OrderByComparator<Role> orderByComparator) throws NoSuchRoleException {
7230 Role role = fetchByT_S_First(type, subtype, orderByComparator);
7231
7232 if (role != null) {
7233 return role;
7234 }
7235
7236 StringBundler msg = new StringBundler(6);
7237
7238 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7239
7240 msg.append("type=");
7241 msg.append(type);
7242
7243 msg.append(", subtype=");
7244 msg.append(subtype);
7245
7246 msg.append(StringPool.CLOSE_CURLY_BRACE);
7247
7248 throw new NoSuchRoleException(msg.toString());
7249 }
7250
7251
7259 @Override
7260 public Role fetchByT_S_First(int type, String subtype,
7261 OrderByComparator<Role> orderByComparator) {
7262 List<Role> list = findByT_S(type, subtype, 0, 1, orderByComparator);
7263
7264 if (!list.isEmpty()) {
7265 return list.get(0);
7266 }
7267
7268 return null;
7269 }
7270
7271
7280 @Override
7281 public Role findByT_S_Last(int type, String subtype,
7282 OrderByComparator<Role> orderByComparator) throws NoSuchRoleException {
7283 Role role = fetchByT_S_Last(type, subtype, orderByComparator);
7284
7285 if (role != null) {
7286 return role;
7287 }
7288
7289 StringBundler msg = new StringBundler(6);
7290
7291 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7292
7293 msg.append("type=");
7294 msg.append(type);
7295
7296 msg.append(", subtype=");
7297 msg.append(subtype);
7298
7299 msg.append(StringPool.CLOSE_CURLY_BRACE);
7300
7301 throw new NoSuchRoleException(msg.toString());
7302 }
7303
7304
7312 @Override
7313 public Role fetchByT_S_Last(int type, String subtype,
7314 OrderByComparator<Role> orderByComparator) {
7315 int count = countByT_S(type, subtype);
7316
7317 if (count == 0) {
7318 return null;
7319 }
7320
7321 List<Role> list = findByT_S(type, subtype, count - 1, count,
7322 orderByComparator);
7323
7324 if (!list.isEmpty()) {
7325 return list.get(0);
7326 }
7327
7328 return null;
7329 }
7330
7331
7341 @Override
7342 public Role[] findByT_S_PrevAndNext(long roleId, int type, String subtype,
7343 OrderByComparator<Role> orderByComparator) throws NoSuchRoleException {
7344 Role role = findByPrimaryKey(roleId);
7345
7346 Session session = null;
7347
7348 try {
7349 session = openSession();
7350
7351 Role[] array = new RoleImpl[3];
7352
7353 array[0] = getByT_S_PrevAndNext(session, role, type, subtype,
7354 orderByComparator, true);
7355
7356 array[1] = role;
7357
7358 array[2] = getByT_S_PrevAndNext(session, role, type, subtype,
7359 orderByComparator, false);
7360
7361 return array;
7362 }
7363 catch (Exception e) {
7364 throw processException(e);
7365 }
7366 finally {
7367 closeSession(session);
7368 }
7369 }
7370
7371 protected Role getByT_S_PrevAndNext(Session session, Role role, int type,
7372 String subtype, OrderByComparator<Role> orderByComparator,
7373 boolean previous) {
7374 StringBundler query = null;
7375
7376 if (orderByComparator != null) {
7377 query = new StringBundler(6 +
7378 (orderByComparator.getOrderByFields().length * 6));
7379 }
7380 else {
7381 query = new StringBundler(3);
7382 }
7383
7384 query.append(_SQL_SELECT_ROLE_WHERE);
7385
7386 query.append(_FINDER_COLUMN_T_S_TYPE_2);
7387
7388 boolean bindSubtype = false;
7389
7390 if (subtype == null) {
7391 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
7392 }
7393 else if (subtype.equals(StringPool.BLANK)) {
7394 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
7395 }
7396 else {
7397 bindSubtype = true;
7398
7399 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
7400 }
7401
7402 if (orderByComparator != null) {
7403 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7404
7405 if (orderByConditionFields.length > 0) {
7406 query.append(WHERE_AND);
7407 }
7408
7409 for (int i = 0; i < orderByConditionFields.length; i++) {
7410 query.append(_ORDER_BY_ENTITY_ALIAS);
7411 query.append(orderByConditionFields[i]);
7412
7413 if ((i + 1) < orderByConditionFields.length) {
7414 if (orderByComparator.isAscending() ^ previous) {
7415 query.append(WHERE_GREATER_THAN_HAS_NEXT);
7416 }
7417 else {
7418 query.append(WHERE_LESSER_THAN_HAS_NEXT);
7419 }
7420 }
7421 else {
7422 if (orderByComparator.isAscending() ^ previous) {
7423 query.append(WHERE_GREATER_THAN);
7424 }
7425 else {
7426 query.append(WHERE_LESSER_THAN);
7427 }
7428 }
7429 }
7430
7431 query.append(ORDER_BY_CLAUSE);
7432
7433 String[] orderByFields = orderByComparator.getOrderByFields();
7434
7435 for (int i = 0; i < orderByFields.length; i++) {
7436 query.append(_ORDER_BY_ENTITY_ALIAS);
7437 query.append(orderByFields[i]);
7438
7439 if ((i + 1) < orderByFields.length) {
7440 if (orderByComparator.isAscending() ^ previous) {
7441 query.append(ORDER_BY_ASC_HAS_NEXT);
7442 }
7443 else {
7444 query.append(ORDER_BY_DESC_HAS_NEXT);
7445 }
7446 }
7447 else {
7448 if (orderByComparator.isAscending() ^ previous) {
7449 query.append(ORDER_BY_ASC);
7450 }
7451 else {
7452 query.append(ORDER_BY_DESC);
7453 }
7454 }
7455 }
7456 }
7457 else {
7458 query.append(RoleModelImpl.ORDER_BY_JPQL);
7459 }
7460
7461 String sql = query.toString();
7462
7463 Query q = session.createQuery(sql);
7464
7465 q.setFirstResult(0);
7466 q.setMaxResults(2);
7467
7468 QueryPos qPos = QueryPos.getInstance(q);
7469
7470 qPos.add(type);
7471
7472 if (bindSubtype) {
7473 qPos.add(subtype);
7474 }
7475
7476 if (orderByComparator != null) {
7477 Object[] values = orderByComparator.getOrderByConditionValues(role);
7478
7479 for (Object value : values) {
7480 qPos.add(value);
7481 }
7482 }
7483
7484 List<Role> list = q.list();
7485
7486 if (list.size() == 2) {
7487 return list.get(1);
7488 }
7489 else {
7490 return null;
7491 }
7492 }
7493
7494
7501 @Override
7502 public List<Role> filterFindByT_S(int type, String subtype) {
7503 return filterFindByT_S(type, subtype, QueryUtil.ALL_POS,
7504 QueryUtil.ALL_POS, null);
7505 }
7506
7507
7520 @Override
7521 public List<Role> filterFindByT_S(int type, String subtype, int start,
7522 int end) {
7523 return filterFindByT_S(type, subtype, start, end, null);
7524 }
7525
7526
7540 @Override
7541 public List<Role> filterFindByT_S(int type, String subtype, int start,
7542 int end, OrderByComparator<Role> orderByComparator) {
7543 if (!InlineSQLHelperUtil.isEnabled()) {
7544 return findByT_S(type, subtype, start, end, orderByComparator);
7545 }
7546
7547 StringBundler query = null;
7548
7549 if (orderByComparator != null) {
7550 query = new StringBundler(4 +
7551 (orderByComparator.getOrderByFields().length * 3));
7552 }
7553 else {
7554 query = new StringBundler(4);
7555 }
7556
7557 if (getDB().isSupportsInlineDistinct()) {
7558 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
7559 }
7560 else {
7561 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
7562 }
7563
7564 query.append(_FINDER_COLUMN_T_S_TYPE_2_SQL);
7565
7566 boolean bindSubtype = false;
7567
7568 if (subtype == null) {
7569 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
7570 }
7571 else if (subtype.equals(StringPool.BLANK)) {
7572 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
7573 }
7574 else {
7575 bindSubtype = true;
7576
7577 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
7578 }
7579
7580 if (!getDB().isSupportsInlineDistinct()) {
7581 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
7582 }
7583
7584 if (orderByComparator != null) {
7585 if (getDB().isSupportsInlineDistinct()) {
7586 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7587 orderByComparator, true);
7588 }
7589 else {
7590 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7591 orderByComparator, true);
7592 }
7593 }
7594 else {
7595 if (getDB().isSupportsInlineDistinct()) {
7596 query.append(RoleModelImpl.ORDER_BY_JPQL);
7597 }
7598 else {
7599 query.append(RoleModelImpl.ORDER_BY_SQL);
7600 }
7601 }
7602
7603 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7604 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
7605
7606 Session session = null;
7607
7608 try {
7609 session = openSession();
7610
7611 SQLQuery q = session.createSynchronizedSQLQuery(sql);
7612
7613 if (getDB().isSupportsInlineDistinct()) {
7614 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
7615 }
7616 else {
7617 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
7618 }
7619
7620 QueryPos qPos = QueryPos.getInstance(q);
7621
7622 qPos.add(type);
7623
7624 if (bindSubtype) {
7625 qPos.add(subtype);
7626 }
7627
7628 return (List<Role>)QueryUtil.list(q, getDialect(), start, end);
7629 }
7630 catch (Exception e) {
7631 throw processException(e);
7632 }
7633 finally {
7634 closeSession(session);
7635 }
7636 }
7637
7638
7648 @Override
7649 public Role[] filterFindByT_S_PrevAndNext(long roleId, int type,
7650 String subtype, OrderByComparator<Role> orderByComparator)
7651 throws NoSuchRoleException {
7652 if (!InlineSQLHelperUtil.isEnabled()) {
7653 return findByT_S_PrevAndNext(roleId, type, subtype,
7654 orderByComparator);
7655 }
7656
7657 Role role = findByPrimaryKey(roleId);
7658
7659 Session session = null;
7660
7661 try {
7662 session = openSession();
7663
7664 Role[] array = new RoleImpl[3];
7665
7666 array[0] = filterGetByT_S_PrevAndNext(session, role, type, subtype,
7667 orderByComparator, true);
7668
7669 array[1] = role;
7670
7671 array[2] = filterGetByT_S_PrevAndNext(session, role, type, subtype,
7672 orderByComparator, false);
7673
7674 return array;
7675 }
7676 catch (Exception e) {
7677 throw processException(e);
7678 }
7679 finally {
7680 closeSession(session);
7681 }
7682 }
7683
7684 protected Role filterGetByT_S_PrevAndNext(Session session, Role role,
7685 int type, String subtype, OrderByComparator<Role> orderByComparator,
7686 boolean previous) {
7687 StringBundler query = null;
7688
7689 if (orderByComparator != null) {
7690 query = new StringBundler(6 +
7691 (orderByComparator.getOrderByFields().length * 6));
7692 }
7693 else {
7694 query = new StringBundler(3);
7695 }
7696
7697 if (getDB().isSupportsInlineDistinct()) {
7698 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
7699 }
7700 else {
7701 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
7702 }
7703
7704 query.append(_FINDER_COLUMN_T_S_TYPE_2_SQL);
7705
7706 boolean bindSubtype = false;
7707
7708 if (subtype == null) {
7709 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
7710 }
7711 else if (subtype.equals(StringPool.BLANK)) {
7712 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
7713 }
7714 else {
7715 bindSubtype = true;
7716
7717 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
7718 }
7719
7720 if (!getDB().isSupportsInlineDistinct()) {
7721 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
7722 }
7723
7724 if (orderByComparator != null) {
7725 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7726
7727 if (orderByConditionFields.length > 0) {
7728 query.append(WHERE_AND);
7729 }
7730
7731 for (int i = 0; i < orderByConditionFields.length; i++) {
7732 if (getDB().isSupportsInlineDistinct()) {
7733 query.append(_ORDER_BY_ENTITY_ALIAS);
7734 }
7735 else {
7736 query.append(_ORDER_BY_ENTITY_TABLE);
7737 }
7738
7739 query.append(orderByConditionFields[i]);
7740
7741 if ((i + 1) < orderByConditionFields.length) {
7742 if (orderByComparator.isAscending() ^ previous) {
7743 query.append(WHERE_GREATER_THAN_HAS_NEXT);
7744 }
7745 else {
7746 query.append(WHERE_LESSER_THAN_HAS_NEXT);
7747 }
7748 }
7749 else {
7750 if (orderByComparator.isAscending() ^ previous) {
7751 query.append(WHERE_GREATER_THAN);
7752 }
7753 else {
7754 query.append(WHERE_LESSER_THAN);
7755 }
7756 }
7757 }
7758
7759 query.append(ORDER_BY_CLAUSE);
7760
7761 String[] orderByFields = orderByComparator.getOrderByFields();
7762
7763 for (int i = 0; i < orderByFields.length; i++) {
7764 if (getDB().isSupportsInlineDistinct()) {
7765 query.append(_ORDER_BY_ENTITY_ALIAS);
7766 }
7767 else {
7768 query.append(_ORDER_BY_ENTITY_TABLE);
7769 }
7770
7771 query.append(orderByFields[i]);
7772
7773 if ((i + 1) < orderByFields.length) {
7774 if (orderByComparator.isAscending() ^ previous) {
7775 query.append(ORDER_BY_ASC_HAS_NEXT);
7776 }
7777 else {
7778 query.append(ORDER_BY_DESC_HAS_NEXT);
7779 }
7780 }
7781 else {
7782 if (orderByComparator.isAscending() ^ previous) {
7783 query.append(ORDER_BY_ASC);
7784 }
7785 else {
7786 query.append(ORDER_BY_DESC);
7787 }
7788 }
7789 }
7790 }
7791 else {
7792 if (getDB().isSupportsInlineDistinct()) {
7793 query.append(RoleModelImpl.ORDER_BY_JPQL);
7794 }
7795 else {
7796 query.append(RoleModelImpl.ORDER_BY_SQL);
7797 }
7798 }
7799
7800 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7801 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
7802
7803 SQLQuery q = session.createSynchronizedSQLQuery(sql);
7804
7805 q.setFirstResult(0);
7806 q.setMaxResults(2);
7807
7808 if (getDB().isSupportsInlineDistinct()) {
7809 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
7810 }
7811 else {
7812 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
7813 }
7814
7815 QueryPos qPos = QueryPos.getInstance(q);
7816
7817 qPos.add(type);
7818
7819 if (bindSubtype) {
7820 qPos.add(subtype);
7821 }
7822
7823 if (orderByComparator != null) {
7824 Object[] values = orderByComparator.getOrderByConditionValues(role);
7825
7826 for (Object value : values) {
7827 qPos.add(value);
7828 }
7829 }
7830
7831 List<Role> list = q.list();
7832
7833 if (list.size() == 2) {
7834 return list.get(1);
7835 }
7836 else {
7837 return null;
7838 }
7839 }
7840
7841
7847 @Override
7848 public void removeByT_S(int type, String subtype) {
7849 for (Role role : findByT_S(type, subtype, QueryUtil.ALL_POS,
7850 QueryUtil.ALL_POS, null)) {
7851 remove(role);
7852 }
7853 }
7854
7855
7862 @Override
7863 public int countByT_S(int type, String subtype) {
7864 FinderPath finderPath = FINDER_PATH_COUNT_BY_T_S;
7865
7866 Object[] finderArgs = new Object[] { type, subtype };
7867
7868 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7869 this);
7870
7871 if (count == null) {
7872 StringBundler query = new StringBundler(3);
7873
7874 query.append(_SQL_COUNT_ROLE_WHERE);
7875
7876 query.append(_FINDER_COLUMN_T_S_TYPE_2);
7877
7878 boolean bindSubtype = false;
7879
7880 if (subtype == null) {
7881 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
7882 }
7883 else if (subtype.equals(StringPool.BLANK)) {
7884 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
7885 }
7886 else {
7887 bindSubtype = true;
7888
7889 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
7890 }
7891
7892 String sql = query.toString();
7893
7894 Session session = null;
7895
7896 try {
7897 session = openSession();
7898
7899 Query q = session.createQuery(sql);
7900
7901 QueryPos qPos = QueryPos.getInstance(q);
7902
7903 qPos.add(type);
7904
7905 if (bindSubtype) {
7906 qPos.add(subtype);
7907 }
7908
7909 count = (Long)q.uniqueResult();
7910
7911 FinderCacheUtil.putResult(finderPath, finderArgs, count);
7912 }
7913 catch (Exception e) {
7914 FinderCacheUtil.removeResult(finderPath, finderArgs);
7915
7916 throw processException(e);
7917 }
7918 finally {
7919 closeSession(session);
7920 }
7921 }
7922
7923 return count.intValue();
7924 }
7925
7926
7933 @Override
7934 public int filterCountByT_S(int type, String subtype) {
7935 if (!InlineSQLHelperUtil.isEnabled()) {
7936 return countByT_S(type, subtype);
7937 }
7938
7939 StringBundler query = new StringBundler(3);
7940
7941 query.append(_FILTER_SQL_COUNT_ROLE_WHERE);
7942
7943 query.append(_FINDER_COLUMN_T_S_TYPE_2_SQL);
7944
7945 boolean bindSubtype = false;
7946
7947 if (subtype == null) {
7948 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
7949 }
7950 else if (subtype.equals(StringPool.BLANK)) {
7951 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
7952 }
7953 else {
7954 bindSubtype = true;
7955
7956 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
7957 }
7958
7959 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7960 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
7961
7962 Session session = null;
7963
7964 try {
7965 session = openSession();
7966
7967 SQLQuery q = session.createSynchronizedSQLQuery(sql);
7968
7969 q.addScalar(COUNT_COLUMN_NAME,
7970 com.liferay.portal.kernel.dao.orm.Type.LONG);
7971
7972 QueryPos qPos = QueryPos.getInstance(q);
7973
7974 qPos.add(type);
7975
7976 if (bindSubtype) {
7977 qPos.add(subtype);
7978 }
7979
7980 Long count = (Long)q.uniqueResult();
7981
7982 return count.intValue();
7983 }
7984 catch (Exception e) {
7985 throw processException(e);
7986 }
7987 finally {
7988 closeSession(session);
7989 }
7990 }
7991
7992 private static final String _FINDER_COLUMN_T_S_TYPE_2 = "role.type = ? AND ";
7993 private static final String _FINDER_COLUMN_T_S_TYPE_2_SQL = "role.type_ = ? AND ";
7994 private static final String _FINDER_COLUMN_T_S_SUBTYPE_1 = "role.subtype IS NULL";
7995 private static final String _FINDER_COLUMN_T_S_SUBTYPE_2 = "role.subtype = ?";
7996 private static final String _FINDER_COLUMN_T_S_SUBTYPE_3 = "(role.subtype IS NULL OR role.subtype = '')";
7997 public static final FinderPath FINDER_PATH_FETCH_BY_C_C_C = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
7998 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
7999 FINDER_CLASS_NAME_ENTITY, "fetchByC_C_C",
8000 new String[] {
8001 Long.class.getName(), Long.class.getName(), Long.class.getName()
8002 },
8003 RoleModelImpl.COMPANYID_COLUMN_BITMASK |
8004 RoleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
8005 RoleModelImpl.CLASSPK_COLUMN_BITMASK);
8006 public static final FinderPath FINDER_PATH_COUNT_BY_C_C_C = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
8007 RoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
8008 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_C",
8009 new String[] {
8010 Long.class.getName(), Long.class.getName(), Long.class.getName()
8011 });
8012
8013
8022 @Override
8023 public Role findByC_C_C(long companyId, long classNameId, long classPK)
8024 throws NoSuchRoleException {
8025 Role role = fetchByC_C_C(companyId, classNameId, classPK);
8026
8027 if (role == null) {
8028 StringBundler msg = new StringBundler(8);
8029
8030 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8031
8032 msg.append("companyId=");
8033 msg.append(companyId);
8034
8035 msg.append(", classNameId=");
8036 msg.append(classNameId);
8037
8038 msg.append(", classPK=");
8039 msg.append(classPK);
8040
8041 msg.append(StringPool.CLOSE_CURLY_BRACE);
8042
8043 if (_log.isWarnEnabled()) {
8044 _log.warn(msg.toString());
8045 }
8046
8047 throw new NoSuchRoleException(msg.toString());
8048 }
8049
8050 return role;
8051 }
8052
8053
8061 @Override
8062 public Role fetchByC_C_C(long companyId, long classNameId, long classPK) {
8063 return fetchByC_C_C(companyId, classNameId, classPK, true);
8064 }
8065
8066
8075 @Override
8076 public Role fetchByC_C_C(long companyId, long classNameId, long classPK,
8077 boolean retrieveFromCache) {
8078 Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
8079
8080 Object result = null;
8081
8082 if (retrieveFromCache) {
8083 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C_C,
8084 finderArgs, this);
8085 }
8086
8087 if (result instanceof Role) {
8088 Role role = (Role)result;
8089
8090 if ((companyId != role.getCompanyId()) ||
8091 (classNameId != role.getClassNameId()) ||
8092 (classPK != role.getClassPK())) {
8093 result = null;
8094 }
8095 }
8096
8097 if (result == null) {
8098 StringBundler query = new StringBundler(5);
8099
8100 query.append(_SQL_SELECT_ROLE_WHERE);
8101
8102 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
8103
8104 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
8105
8106 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
8107
8108 String sql = query.toString();
8109
8110 Session session = null;
8111
8112 try {
8113 session = openSession();
8114
8115 Query q = session.createQuery(sql);
8116
8117 QueryPos qPos = QueryPos.getInstance(q);
8118
8119 qPos.add(companyId);
8120
8121 qPos.add(classNameId);
8122
8123 qPos.add(classPK);
8124
8125 List<Role> list = q.list();
8126
8127 if (list.isEmpty()) {
8128 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
8129 finderArgs, list);
8130 }
8131 else {
8132 Role role = list.get(0);
8133
8134 result = role;
8135
8136 cacheResult(role);
8137
8138 if ((role.getCompanyId() != companyId) ||
8139 (role.getClassNameId() != classNameId) ||
8140 (role.getClassPK() != classPK)) {
8141 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
8142 finderArgs, role);
8143 }
8144 }
8145 }
8146 catch (Exception e) {
8147 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C,
8148 finderArgs);
8149
8150 throw processException(e);
8151 }
8152 finally {
8153 closeSession(session);
8154 }
8155 }
8156
8157 if (result instanceof List<?>) {
8158 return null;
8159 }
8160 else {
8161 return (Role)result;
8162 }
8163 }
8164
8165
8173 @Override
8174 public Role removeByC_C_C(long companyId, long classNameId, long classPK)
8175 throws NoSuchRoleException {
8176 Role role = findByC_C_C(companyId, classNameId, classPK);
8177
8178 return remove(role);
8179 }
8180
8181
8189 @Override
8190 public int countByC_C_C(long companyId, long classNameId, long classPK) {
8191 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C_C;
8192
8193 Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
8194
8195 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8196 this);
8197
8198 if (count == null) {
8199 StringBundler query = new StringBundler(4);
8200
8201 query.append(_SQL_COUNT_ROLE_WHERE);
8202
8203 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
8204
8205 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
8206
8207 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
8208
8209 String sql = query.toString();
8210
8211 Session session = null;
8212
8213 try {
8214 session = openSession();
8215
8216 Query q = session.createQuery(sql);
8217
8218 QueryPos qPos = QueryPos.getInstance(q);
8219
8220 qPos.add(companyId);
8221
8222 qPos.add(classNameId);
8223
8224 qPos.add(classPK);
8225
8226 count = (Long)q.uniqueResult();
8227
8228 FinderCacheUtil.putResult(finderPath, finderArgs, count);
8229 }
8230 catch (Exception e) {
8231 FinderCacheUtil.removeResult(finderPath, finderArgs);
8232
8233 throw processException(e);
8234 }
8235 finally {
8236 closeSession(session);
8237 }
8238 }
8239
8240 return count.intValue();
8241 }
8242
8243 private static final String _FINDER_COLUMN_C_C_C_COMPANYID_2 = "role.companyId = ? AND ";
8244 private static final String _FINDER_COLUMN_C_C_C_CLASSNAMEID_2 = "role.classNameId = ? AND ";
8245 private static final String _FINDER_COLUMN_C_C_C_CLASSPK_2 = "role.classPK = ?";
8246
8247 public RolePersistenceImpl() {
8248 setModelClass(Role.class);
8249 }
8250
8251
8256 @Override
8257 public void cacheResult(Role role) {
8258 EntityCacheUtil.putResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
8259 RoleImpl.class, role.getPrimaryKey(), role);
8260
8261 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
8262 new Object[] { role.getCompanyId(), role.getName() }, role);
8263
8264 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
8265 new Object[] {
8266 role.getCompanyId(), role.getClassNameId(), role.getClassPK()
8267 }, role);
8268
8269 role.resetOriginalValues();
8270 }
8271
8272
8277 @Override
8278 public void cacheResult(List<Role> roles) {
8279 for (Role role : roles) {
8280 if (EntityCacheUtil.getResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
8281 RoleImpl.class, role.getPrimaryKey()) == null) {
8282 cacheResult(role);
8283 }
8284 else {
8285 role.resetOriginalValues();
8286 }
8287 }
8288 }
8289
8290
8297 @Override
8298 public void clearCache() {
8299 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
8300 CacheRegistryUtil.clear(RoleImpl.class.getName());
8301 }
8302
8303 EntityCacheUtil.clearCache(RoleImpl.class);
8304
8305 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
8306 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
8307 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
8308 }
8309
8310
8317 @Override
8318 public void clearCache(Role role) {
8319 EntityCacheUtil.removeResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
8320 RoleImpl.class, role.getPrimaryKey());
8321
8322 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
8323 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
8324
8325 clearUniqueFindersCache(role);
8326 }
8327
8328 @Override
8329 public void clearCache(List<Role> roles) {
8330 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
8331 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
8332
8333 for (Role role : roles) {
8334 EntityCacheUtil.removeResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
8335 RoleImpl.class, role.getPrimaryKey());
8336
8337 clearUniqueFindersCache(role);
8338 }
8339 }
8340
8341 protected void cacheUniqueFindersCache(Role role) {
8342 if (role.isNew()) {
8343 Object[] args = new Object[] { role.getCompanyId(), role.getName() };
8344
8345 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, args,
8346 Long.valueOf(1));
8347 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N, args, role);
8348
8349 args = new Object[] {
8350 role.getCompanyId(), role.getClassNameId(),
8351 role.getClassPK()
8352 };
8353
8354 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C, args,
8355 Long.valueOf(1));
8356 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C, args, role);
8357 }
8358 else {
8359 RoleModelImpl roleModelImpl = (RoleModelImpl)role;
8360
8361 if ((roleModelImpl.getColumnBitmask() &
8362 FINDER_PATH_FETCH_BY_C_N.getColumnBitmask()) != 0) {
8363 Object[] args = new Object[] { role.getCompanyId(), role.getName() };
8364
8365 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, args,
8366 Long.valueOf(1));
8367 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N, args, role);
8368 }
8369
8370 if ((roleModelImpl.getColumnBitmask() &
8371 FINDER_PATH_FETCH_BY_C_C_C.getColumnBitmask()) != 0) {
8372 Object[] args = new Object[] {
8373 role.getCompanyId(), role.getClassNameId(),
8374 role.getClassPK()
8375 };
8376
8377 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C, args,
8378 Long.valueOf(1));
8379 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C, args, role);
8380 }
8381 }
8382 }
8383
8384 protected void clearUniqueFindersCache(Role role) {
8385 RoleModelImpl roleModelImpl = (RoleModelImpl)role;
8386
8387 Object[] args = new Object[] { role.getCompanyId(), role.getName() };
8388
8389 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_N, args);
8390 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N, args);
8391
8392 if ((roleModelImpl.getColumnBitmask() &
8393 FINDER_PATH_FETCH_BY_C_N.getColumnBitmask()) != 0) {
8394 args = new Object[] {
8395 roleModelImpl.getOriginalCompanyId(),
8396 roleModelImpl.getOriginalName()
8397 };
8398
8399 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_N, args);
8400 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N, args);
8401 }
8402
8403 args = new Object[] {
8404 role.getCompanyId(), role.getClassNameId(), role.getClassPK()
8405 };
8406
8407 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
8408 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C, args);
8409
8410 if ((roleModelImpl.getColumnBitmask() &
8411 FINDER_PATH_FETCH_BY_C_C_C.getColumnBitmask()) != 0) {
8412 args = new Object[] {
8413 roleModelImpl.getOriginalCompanyId(),
8414 roleModelImpl.getOriginalClassNameId(),
8415 roleModelImpl.getOriginalClassPK()
8416 };
8417
8418 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
8419 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C, args);
8420 }
8421 }
8422
8423
8429 @Override
8430 public Role create(long roleId) {
8431 Role role = new RoleImpl();
8432
8433 role.setNew(true);
8434 role.setPrimaryKey(roleId);
8435
8436 String uuid = PortalUUIDUtil.generate();
8437
8438 role.setUuid(uuid);
8439
8440 return role;
8441 }
8442
8443
8450 @Override
8451 public Role remove(long roleId) throws NoSuchRoleException {
8452 return remove((Serializable)roleId);
8453 }
8454
8455
8462 @Override
8463 public Role remove(Serializable primaryKey) throws NoSuchRoleException {
8464 Session session = null;
8465
8466 try {
8467 session = openSession();
8468
8469 Role role = (Role)session.get(RoleImpl.class, primaryKey);
8470
8471 if (role == null) {
8472 if (_log.isWarnEnabled()) {
8473 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
8474 }
8475
8476 throw new NoSuchRoleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
8477 primaryKey);
8478 }
8479
8480 return remove(role);
8481 }
8482 catch (NoSuchRoleException nsee) {
8483 throw nsee;
8484 }
8485 catch (Exception e) {
8486 throw processException(e);
8487 }
8488 finally {
8489 closeSession(session);
8490 }
8491 }
8492
8493 @Override
8494 protected Role removeImpl(Role role) {
8495 role = toUnwrappedModel(role);
8496
8497 roleToGroupTableMapper.deleteLeftPrimaryKeyTableMappings(role.getPrimaryKey());
8498
8499 roleToUserTableMapper.deleteLeftPrimaryKeyTableMappings(role.getPrimaryKey());
8500
8501 Session session = null;
8502
8503 try {
8504 session = openSession();
8505
8506 if (!session.contains(role)) {
8507 role = (Role)session.get(RoleImpl.class, role.getPrimaryKeyObj());
8508 }
8509
8510 if (role != null) {
8511 session.delete(role);
8512 }
8513 }
8514 catch (Exception e) {
8515 throw processException(e);
8516 }
8517 finally {
8518 closeSession(session);
8519 }
8520
8521 if (role != null) {
8522 clearCache(role);
8523 }
8524
8525 return role;
8526 }
8527
8528 @Override
8529 public Role updateImpl(com.liferay.portal.model.Role role) {
8530 role = toUnwrappedModel(role);
8531
8532 boolean isNew = role.isNew();
8533
8534 RoleModelImpl roleModelImpl = (RoleModelImpl)role;
8535
8536 if (Validator.isNull(role.getUuid())) {
8537 String uuid = PortalUUIDUtil.generate();
8538
8539 role.setUuid(uuid);
8540 }
8541
8542 Session session = null;
8543
8544 try {
8545 session = openSession();
8546
8547 if (role.isNew()) {
8548 session.save(role);
8549
8550 role.setNew(false);
8551 }
8552 else {
8553 session.merge(role);
8554 }
8555 }
8556 catch (Exception e) {
8557 throw processException(e);
8558 }
8559 finally {
8560 closeSession(session);
8561 }
8562
8563 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
8564
8565 if (isNew || !RoleModelImpl.COLUMN_BITMASK_ENABLED) {
8566 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
8567 }
8568
8569 else {
8570 if ((roleModelImpl.getColumnBitmask() &
8571 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
8572 Object[] args = new Object[] { roleModelImpl.getOriginalUuid() };
8573
8574 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
8575 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
8576 args);
8577
8578 args = new Object[] { roleModelImpl.getUuid() };
8579
8580 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
8581 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
8582 args);
8583 }
8584
8585 if ((roleModelImpl.getColumnBitmask() &
8586 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
8587 Object[] args = new Object[] {
8588 roleModelImpl.getOriginalUuid(),
8589 roleModelImpl.getOriginalCompanyId()
8590 };
8591
8592 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
8593 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
8594 args);
8595
8596 args = new Object[] {
8597 roleModelImpl.getUuid(), roleModelImpl.getCompanyId()
8598 };
8599
8600 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
8601 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
8602 args);
8603 }
8604
8605 if ((roleModelImpl.getColumnBitmask() &
8606 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
8607 Object[] args = new Object[] {
8608 roleModelImpl.getOriginalCompanyId()
8609 };
8610
8611 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
8612 args);
8613 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
8614 args);
8615
8616 args = new Object[] { roleModelImpl.getCompanyId() };
8617
8618 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
8619 args);
8620 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
8621 args);
8622 }
8623
8624 if ((roleModelImpl.getColumnBitmask() &
8625 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NAME.getColumnBitmask()) != 0) {
8626 Object[] args = new Object[] { roleModelImpl.getOriginalName() };
8627
8628 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_NAME, args);
8629 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NAME,
8630 args);
8631
8632 args = new Object[] { roleModelImpl.getName() };
8633
8634 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_NAME, args);
8635 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NAME,
8636 args);
8637 }
8638
8639 if ((roleModelImpl.getColumnBitmask() &
8640 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYPE.getColumnBitmask()) != 0) {
8641 Object[] args = new Object[] { roleModelImpl.getOriginalType() };
8642
8643 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TYPE, args);
8644 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYPE,
8645 args);
8646
8647 args = new Object[] { roleModelImpl.getType() };
8648
8649 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TYPE, args);
8650 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYPE,
8651 args);
8652 }
8653
8654 if ((roleModelImpl.getColumnBitmask() &
8655 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SUBTYPE.getColumnBitmask()) != 0) {
8656 Object[] args = new Object[] { roleModelImpl.getOriginalSubtype() };
8657
8658 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SUBTYPE, args);
8659 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SUBTYPE,
8660 args);
8661
8662 args = new Object[] { roleModelImpl.getSubtype() };
8663
8664 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SUBTYPE, args);
8665 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SUBTYPE,
8666 args);
8667 }
8668
8669 if ((roleModelImpl.getColumnBitmask() &
8670 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T.getColumnBitmask()) != 0) {
8671 Object[] args = new Object[] {
8672 roleModelImpl.getOriginalCompanyId(),
8673 roleModelImpl.getOriginalType()
8674 };
8675
8676 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_T, args);
8677 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T,
8678 args);
8679
8680 args = new Object[] {
8681 roleModelImpl.getCompanyId(), roleModelImpl.getType()
8682 };
8683
8684 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_T, args);
8685 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T,
8686 args);
8687 }
8688
8689 if ((roleModelImpl.getColumnBitmask() &
8690 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S.getColumnBitmask()) != 0) {
8691 Object[] args = new Object[] {
8692 roleModelImpl.getOriginalType(),
8693 roleModelImpl.getOriginalSubtype()
8694 };
8695
8696 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_S, args);
8697 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S,
8698 args);
8699
8700 args = new Object[] {
8701 roleModelImpl.getType(), roleModelImpl.getSubtype()
8702 };
8703
8704 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_S, args);
8705 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S,
8706 args);
8707 }
8708 }
8709
8710 EntityCacheUtil.putResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
8711 RoleImpl.class, role.getPrimaryKey(), role, false);
8712
8713 clearUniqueFindersCache(role);
8714 cacheUniqueFindersCache(role);
8715
8716 role.resetOriginalValues();
8717
8718 return role;
8719 }
8720
8721 protected Role toUnwrappedModel(Role role) {
8722 if (role instanceof RoleImpl) {
8723 return role;
8724 }
8725
8726 RoleImpl roleImpl = new RoleImpl();
8727
8728 roleImpl.setNew(role.isNew());
8729 roleImpl.setPrimaryKey(role.getPrimaryKey());
8730
8731 roleImpl.setMvccVersion(role.getMvccVersion());
8732 roleImpl.setUuid(role.getUuid());
8733 roleImpl.setRoleId(role.getRoleId());
8734 roleImpl.setCompanyId(role.getCompanyId());
8735 roleImpl.setUserId(role.getUserId());
8736 roleImpl.setUserName(role.getUserName());
8737 roleImpl.setCreateDate(role.getCreateDate());
8738 roleImpl.setModifiedDate(role.getModifiedDate());
8739 roleImpl.setClassNameId(role.getClassNameId());
8740 roleImpl.setClassPK(role.getClassPK());
8741 roleImpl.setName(role.getName());
8742 roleImpl.setTitle(role.getTitle());
8743 roleImpl.setDescription(role.getDescription());
8744 roleImpl.setType(role.getType());
8745 roleImpl.setSubtype(role.getSubtype());
8746
8747 return roleImpl;
8748 }
8749
8750
8757 @Override
8758 public Role findByPrimaryKey(Serializable primaryKey)
8759 throws NoSuchRoleException {
8760 Role role = fetchByPrimaryKey(primaryKey);
8761
8762 if (role == null) {
8763 if (_log.isWarnEnabled()) {
8764 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
8765 }
8766
8767 throw new NoSuchRoleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
8768 primaryKey);
8769 }
8770
8771 return role;
8772 }
8773
8774
8781 @Override
8782 public Role findByPrimaryKey(long roleId) throws NoSuchRoleException {
8783 return findByPrimaryKey((Serializable)roleId);
8784 }
8785
8786
8792 @Override
8793 public Role fetchByPrimaryKey(Serializable primaryKey) {
8794 Role role = (Role)EntityCacheUtil.getResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
8795 RoleImpl.class, primaryKey);
8796
8797 if (role == _nullRole) {
8798 return null;
8799 }
8800
8801 if (role == null) {
8802 Session session = null;
8803
8804 try {
8805 session = openSession();
8806
8807 role = (Role)session.get(RoleImpl.class, primaryKey);
8808
8809 if (role != null) {
8810 cacheResult(role);
8811 }
8812 else {
8813 EntityCacheUtil.putResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
8814 RoleImpl.class, primaryKey, _nullRole);
8815 }
8816 }
8817 catch (Exception e) {
8818 EntityCacheUtil.removeResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
8819 RoleImpl.class, primaryKey);
8820
8821 throw processException(e);
8822 }
8823 finally {
8824 closeSession(session);
8825 }
8826 }
8827
8828 return role;
8829 }
8830
8831
8837 @Override
8838 public Role fetchByPrimaryKey(long roleId) {
8839 return fetchByPrimaryKey((Serializable)roleId);
8840 }
8841
8842 @Override
8843 public Map<Serializable, Role> fetchByPrimaryKeys(
8844 Set<Serializable> primaryKeys) {
8845 if (primaryKeys.isEmpty()) {
8846 return Collections.emptyMap();
8847 }
8848
8849 Map<Serializable, Role> map = new HashMap<Serializable, Role>();
8850
8851 if (primaryKeys.size() == 1) {
8852 Iterator<Serializable> iterator = primaryKeys.iterator();
8853
8854 Serializable primaryKey = iterator.next();
8855
8856 Role role = fetchByPrimaryKey(primaryKey);
8857
8858 if (role != null) {
8859 map.put(primaryKey, role);
8860 }
8861
8862 return map;
8863 }
8864
8865 Set<Serializable> uncachedPrimaryKeys = null;
8866
8867 for (Serializable primaryKey : primaryKeys) {
8868 Role role = (Role)EntityCacheUtil.getResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
8869 RoleImpl.class, primaryKey);
8870
8871 if (role == null) {
8872 if (uncachedPrimaryKeys == null) {
8873 uncachedPrimaryKeys = new HashSet<Serializable>();
8874 }
8875
8876 uncachedPrimaryKeys.add(primaryKey);
8877 }
8878 else {
8879 map.put(primaryKey, role);
8880 }
8881 }
8882
8883 if (uncachedPrimaryKeys == null) {
8884 return map;
8885 }
8886
8887 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
8888 1);
8889
8890 query.append(_SQL_SELECT_ROLE_WHERE_PKS_IN);
8891
8892 for (Serializable primaryKey : uncachedPrimaryKeys) {
8893 query.append(String.valueOf(primaryKey));
8894
8895 query.append(StringPool.COMMA);
8896 }
8897
8898 query.setIndex(query.index() - 1);
8899
8900 query.append(StringPool.CLOSE_PARENTHESIS);
8901
8902 String sql = query.toString();
8903
8904 Session session = null;
8905
8906 try {
8907 session = openSession();
8908
8909 Query q = session.createQuery(sql);
8910
8911 for (Role role : (List<Role>)q.list()) {
8912 map.put(role.getPrimaryKeyObj(), role);
8913
8914 cacheResult(role);
8915
8916 uncachedPrimaryKeys.remove(role.getPrimaryKeyObj());
8917 }
8918
8919 for (Serializable primaryKey : uncachedPrimaryKeys) {
8920 EntityCacheUtil.putResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
8921 RoleImpl.class, primaryKey, _nullRole);
8922 }
8923 }
8924 catch (Exception e) {
8925 throw processException(e);
8926 }
8927 finally {
8928 closeSession(session);
8929 }
8930
8931 return map;
8932 }
8933
8934
8939 @Override
8940 public List<Role> findAll() {
8941 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8942 }
8943
8944
8955 @Override
8956 public List<Role> findAll(int start, int end) {
8957 return findAll(start, end, null);
8958 }
8959
8960
8972 @Override
8973 public List<Role> findAll(int start, int end,
8974 OrderByComparator<Role> orderByComparator) {
8975 boolean pagination = true;
8976 FinderPath finderPath = null;
8977 Object[] finderArgs = null;
8978
8979 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8980 (orderByComparator == null)) {
8981 pagination = false;
8982 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
8983 finderArgs = FINDER_ARGS_EMPTY;
8984 }
8985 else {
8986 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
8987 finderArgs = new Object[] { start, end, orderByComparator };
8988 }
8989
8990 List<Role> list = (List<Role>)FinderCacheUtil.getResult(finderPath,
8991 finderArgs, this);
8992
8993 if (list == null) {
8994 StringBundler query = null;
8995 String sql = null;
8996
8997 if (orderByComparator != null) {
8998 query = new StringBundler(2 +
8999 (orderByComparator.getOrderByFields().length * 3));
9000
9001 query.append(_SQL_SELECT_ROLE);
9002
9003 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9004 orderByComparator);
9005
9006 sql = query.toString();
9007 }
9008 else {
9009 sql = _SQL_SELECT_ROLE;
9010
9011 if (pagination) {
9012 sql = sql.concat(RoleModelImpl.ORDER_BY_JPQL);
9013 }
9014 }
9015
9016 Session session = null;
9017
9018 try {
9019 session = openSession();
9020
9021 Query q = session.createQuery(sql);
9022
9023 if (!pagination) {
9024 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
9025 end, false);
9026
9027 Collections.sort(list);
9028
9029 list = Collections.unmodifiableList(list);
9030 }
9031 else {
9032 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
9033 end);
9034 }
9035
9036 cacheResult(list);
9037
9038 FinderCacheUtil.putResult(finderPath, finderArgs, list);
9039 }
9040 catch (Exception e) {
9041 FinderCacheUtil.removeResult(finderPath, finderArgs);
9042
9043 throw processException(e);
9044 }
9045 finally {
9046 closeSession(session);
9047 }
9048 }
9049
9050 return list;
9051 }
9052
9053
9057 @Override
9058 public void removeAll() {
9059 for (Role role : findAll()) {
9060 remove(role);
9061 }
9062 }
9063
9064
9069 @Override
9070 public int countAll() {
9071 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
9072 FINDER_ARGS_EMPTY, this);
9073
9074 if (count == null) {
9075 Session session = null;
9076
9077 try {
9078 session = openSession();
9079
9080 Query q = session.createQuery(_SQL_COUNT_ROLE);
9081
9082 count = (Long)q.uniqueResult();
9083
9084 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
9085 FINDER_ARGS_EMPTY, count);
9086 }
9087 catch (Exception e) {
9088 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
9089 FINDER_ARGS_EMPTY);
9090
9091 throw processException(e);
9092 }
9093 finally {
9094 closeSession(session);
9095 }
9096 }
9097
9098 return count.intValue();
9099 }
9100
9101
9107 @Override
9108 public long[] getGroupPrimaryKeys(long pk) {
9109 long[] pks = roleToGroupTableMapper.getRightPrimaryKeys(pk);
9110
9111 return pks.clone();
9112 }
9113
9114
9120 @Override
9121 public List<com.liferay.portal.model.Group> getGroups(long pk) {
9122 return getGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
9123 }
9124
9125
9137 @Override
9138 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
9139 int end) {
9140 return getGroups(pk, start, end, null);
9141 }
9142
9143
9156 @Override
9157 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
9158 int end,
9159 OrderByComparator<com.liferay.portal.model.Group> orderByComparator) {
9160 return roleToGroupTableMapper.getRightBaseModels(pk, start, end,
9161 orderByComparator);
9162 }
9163
9164
9170 @Override
9171 public int getGroupsSize(long pk) {
9172 long[] pks = roleToGroupTableMapper.getRightPrimaryKeys(pk);
9173
9174 return pks.length;
9175 }
9176
9177
9184 @Override
9185 public boolean containsGroup(long pk, long groupPK) {
9186 return roleToGroupTableMapper.containsTableMapping(pk, groupPK);
9187 }
9188
9189
9195 @Override
9196 public boolean containsGroups(long pk) {
9197 if (getGroupsSize(pk) > 0) {
9198 return true;
9199 }
9200 else {
9201 return false;
9202 }
9203 }
9204
9205
9211 @Override
9212 public void addGroup(long pk, long groupPK) {
9213 roleToGroupTableMapper.addTableMapping(pk, groupPK);
9214 }
9215
9216
9222 @Override
9223 public void addGroup(long pk, com.liferay.portal.model.Group group) {
9224 roleToGroupTableMapper.addTableMapping(pk, group.getPrimaryKey());
9225 }
9226
9227
9233 @Override
9234 public void addGroups(long pk, long[] groupPKs) {
9235 for (long groupPK : groupPKs) {
9236 roleToGroupTableMapper.addTableMapping(pk, groupPK);
9237 }
9238 }
9239
9240
9246 @Override
9247 public void addGroups(long pk, List<com.liferay.portal.model.Group> groups) {
9248 for (com.liferay.portal.model.Group group : groups) {
9249 roleToGroupTableMapper.addTableMapping(pk, group.getPrimaryKey());
9250 }
9251 }
9252
9253
9258 @Override
9259 public void clearGroups(long pk) {
9260 roleToGroupTableMapper.deleteLeftPrimaryKeyTableMappings(pk);
9261 }
9262
9263
9269 @Override
9270 public void removeGroup(long pk, long groupPK) {
9271 roleToGroupTableMapper.deleteTableMapping(pk, groupPK);
9272 }
9273
9274
9280 @Override
9281 public void removeGroup(long pk, com.liferay.portal.model.Group group) {
9282 roleToGroupTableMapper.deleteTableMapping(pk, group.getPrimaryKey());
9283 }
9284
9285
9291 @Override
9292 public void removeGroups(long pk, long[] groupPKs) {
9293 for (long groupPK : groupPKs) {
9294 roleToGroupTableMapper.deleteTableMapping(pk, groupPK);
9295 }
9296 }
9297
9298
9304 @Override
9305 public void removeGroups(long pk,
9306 List<com.liferay.portal.model.Group> groups) {
9307 for (com.liferay.portal.model.Group group : groups) {
9308 roleToGroupTableMapper.deleteTableMapping(pk, group.getPrimaryKey());
9309 }
9310 }
9311
9312
9318 @Override
9319 public void setGroups(long pk, long[] groupPKs) {
9320 Set<Long> newGroupPKsSet = SetUtil.fromArray(groupPKs);
9321 Set<Long> oldGroupPKsSet = SetUtil.fromArray(roleToGroupTableMapper.getRightPrimaryKeys(
9322 pk));
9323
9324 Set<Long> removeGroupPKsSet = new HashSet<Long>(oldGroupPKsSet);
9325
9326 removeGroupPKsSet.removeAll(newGroupPKsSet);
9327
9328 for (long removeGroupPK : removeGroupPKsSet) {
9329 roleToGroupTableMapper.deleteTableMapping(pk, removeGroupPK);
9330 }
9331
9332 newGroupPKsSet.removeAll(oldGroupPKsSet);
9333
9334 for (long newGroupPK : newGroupPKsSet) {
9335 roleToGroupTableMapper.addTableMapping(pk, newGroupPK);
9336 }
9337 }
9338
9339
9345 @Override
9346 public void setGroups(long pk, List<com.liferay.portal.model.Group> groups) {
9347 try {
9348 long[] groupPKs = new long[groups.size()];
9349
9350 for (int i = 0; i < groups.size(); i++) {
9351 com.liferay.portal.model.Group group = groups.get(i);
9352
9353 groupPKs[i] = group.getPrimaryKey();
9354 }
9355
9356 setGroups(pk, groupPKs);
9357 }
9358 catch (Exception e) {
9359 throw processException(e);
9360 }
9361 }
9362
9363
9369 @Override
9370 public long[] getUserPrimaryKeys(long pk) {
9371 long[] pks = roleToUserTableMapper.getRightPrimaryKeys(pk);
9372
9373 return pks.clone();
9374 }
9375
9376
9382 @Override
9383 public List<com.liferay.portal.model.User> getUsers(long pk) {
9384 return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
9385 }
9386
9387
9399 @Override
9400 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
9401 int end) {
9402 return getUsers(pk, start, end, null);
9403 }
9404
9405
9418 @Override
9419 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
9420 int end,
9421 OrderByComparator<com.liferay.portal.model.User> orderByComparator) {
9422 return roleToUserTableMapper.getRightBaseModels(pk, start, end,
9423 orderByComparator);
9424 }
9425
9426
9432 @Override
9433 public int getUsersSize(long pk) {
9434 long[] pks = roleToUserTableMapper.getRightPrimaryKeys(pk);
9435
9436 return pks.length;
9437 }
9438
9439
9446 @Override
9447 public boolean containsUser(long pk, long userPK) {
9448 return roleToUserTableMapper.containsTableMapping(pk, userPK);
9449 }
9450
9451
9457 @Override
9458 public boolean containsUsers(long pk) {
9459 if (getUsersSize(pk) > 0) {
9460 return true;
9461 }
9462 else {
9463 return false;
9464 }
9465 }
9466
9467
9473 @Override
9474 public void addUser(long pk, long userPK) {
9475 roleToUserTableMapper.addTableMapping(pk, userPK);
9476 }
9477
9478
9484 @Override
9485 public void addUser(long pk, com.liferay.portal.model.User user) {
9486 roleToUserTableMapper.addTableMapping(pk, user.getPrimaryKey());
9487 }
9488
9489
9495 @Override
9496 public void addUsers(long pk, long[] userPKs) {
9497 for (long userPK : userPKs) {
9498 roleToUserTableMapper.addTableMapping(pk, userPK);
9499 }
9500 }
9501
9502
9508 @Override
9509 public void addUsers(long pk, List<com.liferay.portal.model.User> users) {
9510 for (com.liferay.portal.model.User user : users) {
9511 roleToUserTableMapper.addTableMapping(pk, user.getPrimaryKey());
9512 }
9513 }
9514
9515
9520 @Override
9521 public void clearUsers(long pk) {
9522 roleToUserTableMapper.deleteLeftPrimaryKeyTableMappings(pk);
9523 }
9524
9525
9531 @Override
9532 public void removeUser(long pk, long userPK) {
9533 roleToUserTableMapper.deleteTableMapping(pk, userPK);
9534 }
9535
9536
9542 @Override
9543 public void removeUser(long pk, com.liferay.portal.model.User user) {
9544 roleToUserTableMapper.deleteTableMapping(pk, user.getPrimaryKey());
9545 }
9546
9547
9553 @Override
9554 public void removeUsers(long pk, long[] userPKs) {
9555 for (long userPK : userPKs) {
9556 roleToUserTableMapper.deleteTableMapping(pk, userPK);
9557 }
9558 }
9559
9560
9566 @Override
9567 public void removeUsers(long pk, List<com.liferay.portal.model.User> users) {
9568 for (com.liferay.portal.model.User user : users) {
9569 roleToUserTableMapper.deleteTableMapping(pk, user.getPrimaryKey());
9570 }
9571 }
9572
9573
9579 @Override
9580 public void setUsers(long pk, long[] userPKs) {
9581 Set<Long> newUserPKsSet = SetUtil.fromArray(userPKs);
9582 Set<Long> oldUserPKsSet = SetUtil.fromArray(roleToUserTableMapper.getRightPrimaryKeys(
9583 pk));
9584
9585 Set<Long> removeUserPKsSet = new HashSet<Long>(oldUserPKsSet);
9586
9587 removeUserPKsSet.removeAll(newUserPKsSet);
9588
9589 for (long removeUserPK : removeUserPKsSet) {
9590 roleToUserTableMapper.deleteTableMapping(pk, removeUserPK);
9591 }
9592
9593 newUserPKsSet.removeAll(oldUserPKsSet);
9594
9595 for (long newUserPK : newUserPKsSet) {
9596 roleToUserTableMapper.addTableMapping(pk, newUserPK);
9597 }
9598 }
9599
9600
9606 @Override
9607 public void setUsers(long pk, List<com.liferay.portal.model.User> users) {
9608 try {
9609 long[] userPKs = new long[users.size()];
9610
9611 for (int i = 0; i < users.size(); i++) {
9612 com.liferay.portal.model.User user = users.get(i);
9613
9614 userPKs[i] = user.getPrimaryKey();
9615 }
9616
9617 setUsers(pk, userPKs);
9618 }
9619 catch (Exception e) {
9620 throw processException(e);
9621 }
9622 }
9623
9624 @Override
9625 protected Set<String> getBadColumnNames() {
9626 return _badColumnNames;
9627 }
9628
9629
9632 public void afterPropertiesSet() {
9633 roleToGroupTableMapper = TableMapperFactory.getTableMapper("Groups_Roles",
9634 "roleId", "groupId", this, groupPersistence);
9635
9636 roleToUserTableMapper = TableMapperFactory.getTableMapper("Users_Roles",
9637 "roleId", "userId", this, userPersistence);
9638 }
9639
9640 public void destroy() {
9641 EntityCacheUtil.removeCache(RoleImpl.class.getName());
9642 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
9643 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
9644 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
9645
9646 TableMapperFactory.removeTableMapper("Groups_Roles");
9647 TableMapperFactory.removeTableMapper("Users_Roles");
9648 }
9649
9650 @BeanReference(type = GroupPersistence.class)
9651 protected GroupPersistence groupPersistence;
9652 protected TableMapper<Role, com.liferay.portal.model.Group> roleToGroupTableMapper;
9653 @BeanReference(type = UserPersistence.class)
9654 protected UserPersistence userPersistence;
9655 protected TableMapper<Role, com.liferay.portal.model.User> roleToUserTableMapper;
9656 private static final String _SQL_SELECT_ROLE = "SELECT role FROM Role role";
9657 private static final String _SQL_SELECT_ROLE_WHERE_PKS_IN = "SELECT role FROM Role role WHERE roleId IN (";
9658 private static final String _SQL_SELECT_ROLE_WHERE = "SELECT role FROM Role role WHERE ";
9659 private static final String _SQL_COUNT_ROLE = "SELECT COUNT(role) FROM Role role";
9660 private static final String _SQL_COUNT_ROLE_WHERE = "SELECT COUNT(role) FROM Role role WHERE ";
9661 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "role.roleId";
9662 private static final String _FILTER_SQL_SELECT_ROLE_WHERE = "SELECT DISTINCT {role.*} FROM Role_ role WHERE ";
9663 private static final String _FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1 =
9664 "SELECT {Role_.*} FROM (SELECT DISTINCT role.roleId FROM Role_ role WHERE ";
9665 private static final String _FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2 =
9666 ") TEMP_TABLE INNER JOIN Role_ ON TEMP_TABLE.roleId = Role_.roleId";
9667 private static final String _FILTER_SQL_COUNT_ROLE_WHERE = "SELECT COUNT(DISTINCT role.roleId) AS COUNT_VALUE FROM Role_ role WHERE ";
9668 private static final String _FILTER_ENTITY_ALIAS = "role";
9669 private static final String _FILTER_ENTITY_TABLE = "Role_";
9670 private static final String _ORDER_BY_ENTITY_ALIAS = "role.";
9671 private static final String _ORDER_BY_ENTITY_TABLE = "Role_.";
9672 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Role exists with the primary key ";
9673 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Role exists with the key {";
9674 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
9675 private static final Log _log = LogFactoryUtil.getLog(RolePersistenceImpl.class);
9676 private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
9677 "uuid", "type"
9678 });
9679 private static final Role _nullRole = new RoleImpl() {
9680 @Override
9681 public Object clone() {
9682 return this;
9683 }
9684
9685 @Override
9686 public CacheModel<Role> toCacheModel() {
9687 return _nullRoleCacheModel;
9688 }
9689 };
9690
9691 private static final CacheModel<Role> _nullRoleCacheModel = new NullCacheModel();
9692
9693 private static class NullCacheModel implements CacheModel<Role>, MVCCModel {
9694 @Override
9695 public long getMvccVersion() {
9696 return -1;
9697 }
9698
9699 @Override
9700 public void setMvccVersion(long mvccVersion) {
9701 }
9702
9703 @Override
9704 public Role toEntityModel() {
9705 return _nullRole;
9706 }
9707 }
9708 }