001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.NoSuchRoleException;
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
022 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
023 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
024 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
025 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
026 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
027 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
028 import com.liferay.portal.kernel.dao.orm.FinderPath;
029 import com.liferay.portal.kernel.dao.orm.Query;
030 import com.liferay.portal.kernel.dao.orm.QueryPos;
031 import com.liferay.portal.kernel.dao.orm.QueryUtil;
032 import com.liferay.portal.kernel.dao.orm.SQLQuery;
033 import com.liferay.portal.kernel.dao.orm.Session;
034 import com.liferay.portal.kernel.exception.SystemException;
035 import com.liferay.portal.kernel.log.Log;
036 import com.liferay.portal.kernel.log.LogFactoryUtil;
037 import com.liferay.portal.kernel.util.GetterUtil;
038 import com.liferay.portal.kernel.util.InstanceFactory;
039 import com.liferay.portal.kernel.util.OrderByComparator;
040 import com.liferay.portal.kernel.util.SetUtil;
041 import com.liferay.portal.kernel.util.StringBundler;
042 import com.liferay.portal.kernel.util.StringPool;
043 import com.liferay.portal.kernel.util.StringUtil;
044 import com.liferay.portal.model.CacheModel;
045 import com.liferay.portal.model.ModelListener;
046 import com.liferay.portal.model.Role;
047 import com.liferay.portal.model.impl.RoleImpl;
048 import com.liferay.portal.model.impl.RoleModelImpl;
049 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
050 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
051
052 import java.io.Serializable;
053
054 import java.util.ArrayList;
055 import java.util.Collections;
056 import java.util.List;
057 import java.util.Set;
058
059
071 public class RolePersistenceImpl extends BasePersistenceImpl<Role>
072 implements RolePersistence {
073
078 public static final String FINDER_CLASS_NAME_ENTITY = RoleImpl.class.getName();
079 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
080 ".List1";
081 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
082 ".List2";
083 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
084 new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
085 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
086 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
087 new String[] {
088 Long.class.getName(),
089
090 "java.lang.Integer", "java.lang.Integer",
091 "com.liferay.portal.kernel.util.OrderByComparator"
092 });
093 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
094 new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
095 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
096 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
097 new String[] { Long.class.getName() },
098 RoleModelImpl.COMPANYID_COLUMN_BITMASK);
099 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
100 RoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
101 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
102 new String[] { Long.class.getName() });
103 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_NAME = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
104 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
105 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByName",
106 new String[] {
107 String.class.getName(),
108
109 "java.lang.Integer", "java.lang.Integer",
110 "com.liferay.portal.kernel.util.OrderByComparator"
111 });
112 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NAME = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
113 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
114 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByName",
115 new String[] { String.class.getName() },
116 RoleModelImpl.NAME_COLUMN_BITMASK);
117 public static final FinderPath FINDER_PATH_COUNT_BY_NAME = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
118 RoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
119 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByName",
120 new String[] { String.class.getName() });
121 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_SUBTYPE = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
122 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
123 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findBySubtype",
124 new String[] {
125 String.class.getName(),
126
127 "java.lang.Integer", "java.lang.Integer",
128 "com.liferay.portal.kernel.util.OrderByComparator"
129 });
130 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SUBTYPE =
131 new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
132 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
133 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findBySubtype",
134 new String[] { String.class.getName() },
135 RoleModelImpl.SUBTYPE_COLUMN_BITMASK);
136 public static final FinderPath FINDER_PATH_COUNT_BY_SUBTYPE = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
137 RoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
138 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countBySubtype",
139 new String[] { String.class.getName() });
140 public static final FinderPath FINDER_PATH_FETCH_BY_C_N = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
141 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
142 FINDER_CLASS_NAME_ENTITY, "fetchByC_N",
143 new String[] { Long.class.getName(), String.class.getName() },
144 RoleModelImpl.COMPANYID_COLUMN_BITMASK |
145 RoleModelImpl.NAME_COLUMN_BITMASK);
146 public static final FinderPath FINDER_PATH_COUNT_BY_C_N = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
147 RoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
148 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_N",
149 new String[] { Long.class.getName(), String.class.getName() });
150 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_T_S = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
151 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
152 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByT_S",
153 new String[] {
154 Integer.class.getName(), String.class.getName(),
155
156 "java.lang.Integer", "java.lang.Integer",
157 "com.liferay.portal.kernel.util.OrderByComparator"
158 });
159 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
160 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
161 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByT_S",
162 new String[] { Integer.class.getName(), String.class.getName() },
163 RoleModelImpl.TYPE_COLUMN_BITMASK |
164 RoleModelImpl.SUBTYPE_COLUMN_BITMASK);
165 public static final FinderPath FINDER_PATH_COUNT_BY_T_S = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
166 RoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
167 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByT_S",
168 new String[] { Integer.class.getName(), String.class.getName() });
169 public static final FinderPath FINDER_PATH_FETCH_BY_C_C_C = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
170 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
171 FINDER_CLASS_NAME_ENTITY, "fetchByC_C_C",
172 new String[] {
173 Long.class.getName(), Long.class.getName(), Long.class.getName()
174 },
175 RoleModelImpl.COMPANYID_COLUMN_BITMASK |
176 RoleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
177 RoleModelImpl.CLASSPK_COLUMN_BITMASK);
178 public static final FinderPath FINDER_PATH_COUNT_BY_C_C_C = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
179 RoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
180 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_C",
181 new String[] {
182 Long.class.getName(), Long.class.getName(), Long.class.getName()
183 });
184 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
185 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
186 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
187 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
188 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
189 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
190 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
191 RoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
192 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
193
194
199 public void cacheResult(Role role) {
200 EntityCacheUtil.putResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
201 RoleImpl.class, role.getPrimaryKey(), role);
202
203 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
204 new Object[] { Long.valueOf(role.getCompanyId()), role.getName() },
205 role);
206
207 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
208 new Object[] {
209 Long.valueOf(role.getCompanyId()),
210 Long.valueOf(role.getClassNameId()),
211 Long.valueOf(role.getClassPK())
212 }, role);
213
214 role.resetOriginalValues();
215 }
216
217
222 public void cacheResult(List<Role> roles) {
223 for (Role role : roles) {
224 if (EntityCacheUtil.getResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
225 RoleImpl.class, role.getPrimaryKey()) == null) {
226 cacheResult(role);
227 }
228 else {
229 role.resetOriginalValues();
230 }
231 }
232 }
233
234
241 @Override
242 public void clearCache() {
243 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
244 CacheRegistryUtil.clear(RoleImpl.class.getName());
245 }
246
247 EntityCacheUtil.clearCache(RoleImpl.class.getName());
248
249 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
250 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
251 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
252 }
253
254
261 @Override
262 public void clearCache(Role role) {
263 EntityCacheUtil.removeResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
264 RoleImpl.class, role.getPrimaryKey());
265
266 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
267 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
268
269 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
270 new Object[] { Long.valueOf(role.getCompanyId()), role.getName() });
271
272 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C,
273 new Object[] {
274 Long.valueOf(role.getCompanyId()),
275 Long.valueOf(role.getClassNameId()),
276 Long.valueOf(role.getClassPK())
277 });
278 }
279
280
286 public Role create(long roleId) {
287 Role role = new RoleImpl();
288
289 role.setNew(true);
290 role.setPrimaryKey(roleId);
291
292 return role;
293 }
294
295
303 @Override
304 public Role remove(Serializable primaryKey)
305 throws NoSuchModelException, SystemException {
306 return remove(((Long)primaryKey).longValue());
307 }
308
309
317 public Role remove(long roleId) throws NoSuchRoleException, SystemException {
318 Session session = null;
319
320 try {
321 session = openSession();
322
323 Role role = (Role)session.get(RoleImpl.class, Long.valueOf(roleId));
324
325 if (role == null) {
326 if (_log.isWarnEnabled()) {
327 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + roleId);
328 }
329
330 throw new NoSuchRoleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
331 roleId);
332 }
333
334 return rolePersistence.remove(role);
335 }
336 catch (NoSuchRoleException nsee) {
337 throw nsee;
338 }
339 catch (Exception e) {
340 throw processException(e);
341 }
342 finally {
343 closeSession(session);
344 }
345 }
346
347
354 @Override
355 public Role remove(Role role) throws SystemException {
356 return super.remove(role);
357 }
358
359 @Override
360 protected Role removeImpl(Role role) throws SystemException {
361 role = toUnwrappedModel(role);
362
363 try {
364 clearGroups.clear(role.getPrimaryKey());
365 }
366 catch (Exception e) {
367 throw processException(e);
368 }
369 finally {
370 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
371 }
372
373 try {
374 clearPermissions.clear(role.getPrimaryKey());
375 }
376 catch (Exception e) {
377 throw processException(e);
378 }
379 finally {
380 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
381 }
382
383 try {
384 clearUsers.clear(role.getPrimaryKey());
385 }
386 catch (Exception e) {
387 throw processException(e);
388 }
389 finally {
390 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
391 }
392
393 Session session = null;
394
395 try {
396 session = openSession();
397
398 BatchSessionUtil.delete(session, role);
399 }
400 catch (Exception e) {
401 throw processException(e);
402 }
403 finally {
404 closeSession(session);
405 }
406
407 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
408 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
409
410 RoleModelImpl roleModelImpl = (RoleModelImpl)role;
411
412 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
413 new Object[] {
414 Long.valueOf(roleModelImpl.getCompanyId()),
415
416 roleModelImpl.getName()
417 });
418
419 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C,
420 new Object[] {
421 Long.valueOf(roleModelImpl.getCompanyId()),
422 Long.valueOf(roleModelImpl.getClassNameId()),
423 Long.valueOf(roleModelImpl.getClassPK())
424 });
425
426 EntityCacheUtil.removeResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
427 RoleImpl.class, role.getPrimaryKey());
428
429 return role;
430 }
431
432 @Override
433 public Role updateImpl(com.liferay.portal.model.Role role, boolean merge)
434 throws SystemException {
435 role = toUnwrappedModel(role);
436
437 boolean isNew = role.isNew();
438
439 RoleModelImpl roleModelImpl = (RoleModelImpl)role;
440
441 Session session = null;
442
443 try {
444 session = openSession();
445
446 BatchSessionUtil.update(session, role, merge);
447
448 role.setNew(false);
449 }
450 catch (Exception e) {
451 throw processException(e);
452 }
453 finally {
454 closeSession(session);
455 }
456
457 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
458
459 if (isNew || !RoleModelImpl.COLUMN_BITMASK_ENABLED) {
460 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
461 }
462
463 else {
464 if ((roleModelImpl.getColumnBitmask() &
465 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
466 Object[] args = new Object[] {
467 Long.valueOf(roleModelImpl.getOriginalCompanyId())
468 };
469
470 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
471 args);
472 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
473 args);
474
475 args = new Object[] { Long.valueOf(roleModelImpl.getCompanyId()) };
476
477 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
478 args);
479 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
480 args);
481 }
482
483 if ((roleModelImpl.getColumnBitmask() &
484 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NAME.getColumnBitmask()) != 0) {
485 Object[] args = new Object[] { roleModelImpl.getOriginalName() };
486
487 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_NAME, args);
488 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NAME,
489 args);
490
491 args = new Object[] { roleModelImpl.getName() };
492
493 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_NAME, args);
494 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NAME,
495 args);
496 }
497
498 if ((roleModelImpl.getColumnBitmask() &
499 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SUBTYPE.getColumnBitmask()) != 0) {
500 Object[] args = new Object[] { roleModelImpl.getOriginalSubtype() };
501
502 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SUBTYPE, args);
503 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SUBTYPE,
504 args);
505
506 args = new Object[] { roleModelImpl.getSubtype() };
507
508 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SUBTYPE, args);
509 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SUBTYPE,
510 args);
511 }
512
513 if ((roleModelImpl.getColumnBitmask() &
514 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S.getColumnBitmask()) != 0) {
515 Object[] args = new Object[] {
516 Integer.valueOf(roleModelImpl.getOriginalType()),
517
518 roleModelImpl.getOriginalSubtype()
519 };
520
521 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_S, args);
522 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S,
523 args);
524
525 args = new Object[] {
526 Integer.valueOf(roleModelImpl.getType()),
527
528 roleModelImpl.getSubtype()
529 };
530
531 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_S, args);
532 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S,
533 args);
534 }
535 }
536
537 EntityCacheUtil.putResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
538 RoleImpl.class, role.getPrimaryKey(), role);
539
540 if (isNew) {
541 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
542 new Object[] { Long.valueOf(role.getCompanyId()), role.getName() },
543 role);
544
545 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
546 new Object[] {
547 Long.valueOf(role.getCompanyId()),
548 Long.valueOf(role.getClassNameId()),
549 Long.valueOf(role.getClassPK())
550 }, role);
551 }
552 else {
553 if ((roleModelImpl.getColumnBitmask() &
554 FINDER_PATH_FETCH_BY_C_N.getColumnBitmask()) != 0) {
555 Object[] args = new Object[] {
556 Long.valueOf(roleModelImpl.getOriginalCompanyId()),
557
558 roleModelImpl.getOriginalName()
559 };
560
561 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_N, args);
562 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N, args);
563
564 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
565 new Object[] {
566 Long.valueOf(role.getCompanyId()),
567
568 role.getName()
569 }, role);
570 }
571
572 if ((roleModelImpl.getColumnBitmask() &
573 FINDER_PATH_FETCH_BY_C_C_C.getColumnBitmask()) != 0) {
574 Object[] args = new Object[] {
575 Long.valueOf(roleModelImpl.getOriginalCompanyId()),
576 Long.valueOf(roleModelImpl.getOriginalClassNameId()),
577 Long.valueOf(roleModelImpl.getOriginalClassPK())
578 };
579
580 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
581 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C, args);
582
583 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
584 new Object[] {
585 Long.valueOf(role.getCompanyId()),
586 Long.valueOf(role.getClassNameId()),
587 Long.valueOf(role.getClassPK())
588 }, role);
589 }
590 }
591
592 return role;
593 }
594
595 protected Role toUnwrappedModel(Role role) {
596 if (role instanceof RoleImpl) {
597 return role;
598 }
599
600 RoleImpl roleImpl = new RoleImpl();
601
602 roleImpl.setNew(role.isNew());
603 roleImpl.setPrimaryKey(role.getPrimaryKey());
604
605 roleImpl.setRoleId(role.getRoleId());
606 roleImpl.setCompanyId(role.getCompanyId());
607 roleImpl.setClassNameId(role.getClassNameId());
608 roleImpl.setClassPK(role.getClassPK());
609 roleImpl.setName(role.getName());
610 roleImpl.setTitle(role.getTitle());
611 roleImpl.setDescription(role.getDescription());
612 roleImpl.setType(role.getType());
613 roleImpl.setSubtype(role.getSubtype());
614
615 return roleImpl;
616 }
617
618
626 @Override
627 public Role findByPrimaryKey(Serializable primaryKey)
628 throws NoSuchModelException, SystemException {
629 return findByPrimaryKey(((Long)primaryKey).longValue());
630 }
631
632
640 public Role findByPrimaryKey(long roleId)
641 throws NoSuchRoleException, SystemException {
642 Role role = fetchByPrimaryKey(roleId);
643
644 if (role == null) {
645 if (_log.isWarnEnabled()) {
646 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + roleId);
647 }
648
649 throw new NoSuchRoleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
650 roleId);
651 }
652
653 return role;
654 }
655
656
663 @Override
664 public Role fetchByPrimaryKey(Serializable primaryKey)
665 throws SystemException {
666 return fetchByPrimaryKey(((Long)primaryKey).longValue());
667 }
668
669
676 public Role fetchByPrimaryKey(long roleId) throws SystemException {
677 Role role = (Role)EntityCacheUtil.getResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
678 RoleImpl.class, roleId);
679
680 if (role == _nullRole) {
681 return null;
682 }
683
684 if (role == null) {
685 Session session = null;
686
687 boolean hasException = false;
688
689 try {
690 session = openSession();
691
692 role = (Role)session.get(RoleImpl.class, Long.valueOf(roleId));
693 }
694 catch (Exception e) {
695 hasException = true;
696
697 throw processException(e);
698 }
699 finally {
700 if (role != null) {
701 cacheResult(role);
702 }
703 else if (!hasException) {
704 EntityCacheUtil.putResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
705 RoleImpl.class, roleId, _nullRole);
706 }
707
708 closeSession(session);
709 }
710 }
711
712 return role;
713 }
714
715
722 public List<Role> findByCompanyId(long companyId) throws SystemException {
723 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
724 null);
725 }
726
727
740 public List<Role> findByCompanyId(long companyId, int start, int end)
741 throws SystemException {
742 return findByCompanyId(companyId, start, end, null);
743 }
744
745
759 public List<Role> findByCompanyId(long companyId, int start, int end,
760 OrderByComparator orderByComparator) throws SystemException {
761 FinderPath finderPath = null;
762 Object[] finderArgs = null;
763
764 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
765 (orderByComparator == null)) {
766 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
767 finderArgs = new Object[] { companyId };
768 }
769 else {
770 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
771 finderArgs = new Object[] { companyId, start, end, orderByComparator };
772 }
773
774 List<Role> list = (List<Role>)FinderCacheUtil.getResult(finderPath,
775 finderArgs, this);
776
777 if (list == null) {
778 StringBundler query = null;
779
780 if (orderByComparator != null) {
781 query = new StringBundler(3 +
782 (orderByComparator.getOrderByFields().length * 3));
783 }
784 else {
785 query = new StringBundler(3);
786 }
787
788 query.append(_SQL_SELECT_ROLE_WHERE);
789
790 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
791
792 if (orderByComparator != null) {
793 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
794 orderByComparator);
795 }
796
797 else {
798 query.append(RoleModelImpl.ORDER_BY_JPQL);
799 }
800
801 String sql = query.toString();
802
803 Session session = null;
804
805 try {
806 session = openSession();
807
808 Query q = session.createQuery(sql);
809
810 QueryPos qPos = QueryPos.getInstance(q);
811
812 qPos.add(companyId);
813
814 list = (List<Role>)QueryUtil.list(q, getDialect(), start, end);
815 }
816 catch (Exception e) {
817 throw processException(e);
818 }
819 finally {
820 if (list == null) {
821 FinderCacheUtil.removeResult(finderPath, finderArgs);
822 }
823 else {
824 cacheResult(list);
825
826 FinderCacheUtil.putResult(finderPath, finderArgs, list);
827 }
828
829 closeSession(session);
830 }
831 }
832
833 return list;
834 }
835
836
849 public Role findByCompanyId_First(long companyId,
850 OrderByComparator orderByComparator)
851 throws NoSuchRoleException, SystemException {
852 List<Role> list = findByCompanyId(companyId, 0, 1, orderByComparator);
853
854 if (list.isEmpty()) {
855 StringBundler msg = new StringBundler(4);
856
857 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
858
859 msg.append("companyId=");
860 msg.append(companyId);
861
862 msg.append(StringPool.CLOSE_CURLY_BRACE);
863
864 throw new NoSuchRoleException(msg.toString());
865 }
866 else {
867 return list.get(0);
868 }
869 }
870
871
884 public Role findByCompanyId_Last(long companyId,
885 OrderByComparator orderByComparator)
886 throws NoSuchRoleException, SystemException {
887 int count = countByCompanyId(companyId);
888
889 List<Role> list = findByCompanyId(companyId, count - 1, count,
890 orderByComparator);
891
892 if (list.isEmpty()) {
893 StringBundler msg = new StringBundler(4);
894
895 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
896
897 msg.append("companyId=");
898 msg.append(companyId);
899
900 msg.append(StringPool.CLOSE_CURLY_BRACE);
901
902 throw new NoSuchRoleException(msg.toString());
903 }
904 else {
905 return list.get(0);
906 }
907 }
908
909
923 public Role[] findByCompanyId_PrevAndNext(long roleId, long companyId,
924 OrderByComparator orderByComparator)
925 throws NoSuchRoleException, SystemException {
926 Role role = findByPrimaryKey(roleId);
927
928 Session session = null;
929
930 try {
931 session = openSession();
932
933 Role[] array = new RoleImpl[3];
934
935 array[0] = getByCompanyId_PrevAndNext(session, role, companyId,
936 orderByComparator, true);
937
938 array[1] = role;
939
940 array[2] = getByCompanyId_PrevAndNext(session, role, companyId,
941 orderByComparator, false);
942
943 return array;
944 }
945 catch (Exception e) {
946 throw processException(e);
947 }
948 finally {
949 closeSession(session);
950 }
951 }
952
953 protected Role getByCompanyId_PrevAndNext(Session session, Role role,
954 long companyId, OrderByComparator orderByComparator, boolean previous) {
955 StringBundler query = null;
956
957 if (orderByComparator != null) {
958 query = new StringBundler(6 +
959 (orderByComparator.getOrderByFields().length * 6));
960 }
961 else {
962 query = new StringBundler(3);
963 }
964
965 query.append(_SQL_SELECT_ROLE_WHERE);
966
967 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
968
969 if (orderByComparator != null) {
970 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
971
972 if (orderByConditionFields.length > 0) {
973 query.append(WHERE_AND);
974 }
975
976 for (int i = 0; i < orderByConditionFields.length; i++) {
977 query.append(_ORDER_BY_ENTITY_ALIAS);
978 query.append(orderByConditionFields[i]);
979
980 if ((i + 1) < orderByConditionFields.length) {
981 if (orderByComparator.isAscending() ^ previous) {
982 query.append(WHERE_GREATER_THAN_HAS_NEXT);
983 }
984 else {
985 query.append(WHERE_LESSER_THAN_HAS_NEXT);
986 }
987 }
988 else {
989 if (orderByComparator.isAscending() ^ previous) {
990 query.append(WHERE_GREATER_THAN);
991 }
992 else {
993 query.append(WHERE_LESSER_THAN);
994 }
995 }
996 }
997
998 query.append(ORDER_BY_CLAUSE);
999
1000 String[] orderByFields = orderByComparator.getOrderByFields();
1001
1002 for (int i = 0; i < orderByFields.length; i++) {
1003 query.append(_ORDER_BY_ENTITY_ALIAS);
1004 query.append(orderByFields[i]);
1005
1006 if ((i + 1) < orderByFields.length) {
1007 if (orderByComparator.isAscending() ^ previous) {
1008 query.append(ORDER_BY_ASC_HAS_NEXT);
1009 }
1010 else {
1011 query.append(ORDER_BY_DESC_HAS_NEXT);
1012 }
1013 }
1014 else {
1015 if (orderByComparator.isAscending() ^ previous) {
1016 query.append(ORDER_BY_ASC);
1017 }
1018 else {
1019 query.append(ORDER_BY_DESC);
1020 }
1021 }
1022 }
1023 }
1024
1025 else {
1026 query.append(RoleModelImpl.ORDER_BY_JPQL);
1027 }
1028
1029 String sql = query.toString();
1030
1031 Query q = session.createQuery(sql);
1032
1033 q.setFirstResult(0);
1034 q.setMaxResults(2);
1035
1036 QueryPos qPos = QueryPos.getInstance(q);
1037
1038 qPos.add(companyId);
1039
1040 if (orderByComparator != null) {
1041 Object[] values = orderByComparator.getOrderByConditionValues(role);
1042
1043 for (Object value : values) {
1044 qPos.add(value);
1045 }
1046 }
1047
1048 List<Role> list = q.list();
1049
1050 if (list.size() == 2) {
1051 return list.get(1);
1052 }
1053 else {
1054 return null;
1055 }
1056 }
1057
1058
1065 public List<Role> filterFindByCompanyId(long companyId)
1066 throws SystemException {
1067 return filterFindByCompanyId(companyId, QueryUtil.ALL_POS,
1068 QueryUtil.ALL_POS, null);
1069 }
1070
1071
1084 public List<Role> filterFindByCompanyId(long companyId, int start, int end)
1085 throws SystemException {
1086 return filterFindByCompanyId(companyId, start, end, null);
1087 }
1088
1089
1103 public List<Role> filterFindByCompanyId(long companyId, int start, int end,
1104 OrderByComparator orderByComparator) throws SystemException {
1105 if (!InlineSQLHelperUtil.isEnabled()) {
1106 return findByCompanyId(companyId, start, end, orderByComparator);
1107 }
1108
1109 StringBundler query = null;
1110
1111 if (orderByComparator != null) {
1112 query = new StringBundler(3 +
1113 (orderByComparator.getOrderByFields().length * 3));
1114 }
1115 else {
1116 query = new StringBundler(3);
1117 }
1118
1119 if (getDB().isSupportsInlineDistinct()) {
1120 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
1121 }
1122 else {
1123 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
1124 }
1125
1126 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1127
1128 if (!getDB().isSupportsInlineDistinct()) {
1129 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
1130 }
1131
1132 if (orderByComparator != null) {
1133 if (getDB().isSupportsInlineDistinct()) {
1134 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1135 orderByComparator);
1136 }
1137 else {
1138 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1139 orderByComparator);
1140 }
1141 }
1142
1143 else {
1144 if (getDB().isSupportsInlineDistinct()) {
1145 query.append(RoleModelImpl.ORDER_BY_JPQL);
1146 }
1147 else {
1148 query.append(RoleModelImpl.ORDER_BY_SQL);
1149 }
1150 }
1151
1152 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1153 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1154
1155 Session session = null;
1156
1157 try {
1158 session = openSession();
1159
1160 SQLQuery q = session.createSQLQuery(sql);
1161
1162 if (getDB().isSupportsInlineDistinct()) {
1163 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
1164 }
1165 else {
1166 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
1167 }
1168
1169 QueryPos qPos = QueryPos.getInstance(q);
1170
1171 qPos.add(companyId);
1172
1173 return (List<Role>)QueryUtil.list(q, getDialect(), start, end);
1174 }
1175 catch (Exception e) {
1176 throw processException(e);
1177 }
1178 finally {
1179 closeSession(session);
1180 }
1181 }
1182
1183
1193 public Role[] filterFindByCompanyId_PrevAndNext(long roleId,
1194 long companyId, OrderByComparator orderByComparator)
1195 throws NoSuchRoleException, SystemException {
1196 if (!InlineSQLHelperUtil.isEnabled()) {
1197 return findByCompanyId_PrevAndNext(roleId, companyId,
1198 orderByComparator);
1199 }
1200
1201 Role role = findByPrimaryKey(roleId);
1202
1203 Session session = null;
1204
1205 try {
1206 session = openSession();
1207
1208 Role[] array = new RoleImpl[3];
1209
1210 array[0] = filterGetByCompanyId_PrevAndNext(session, role,
1211 companyId, orderByComparator, true);
1212
1213 array[1] = role;
1214
1215 array[2] = filterGetByCompanyId_PrevAndNext(session, role,
1216 companyId, orderByComparator, false);
1217
1218 return array;
1219 }
1220 catch (Exception e) {
1221 throw processException(e);
1222 }
1223 finally {
1224 closeSession(session);
1225 }
1226 }
1227
1228 protected Role filterGetByCompanyId_PrevAndNext(Session session, Role role,
1229 long companyId, OrderByComparator orderByComparator, boolean previous) {
1230 StringBundler query = null;
1231
1232 if (orderByComparator != null) {
1233 query = new StringBundler(6 +
1234 (orderByComparator.getOrderByFields().length * 6));
1235 }
1236 else {
1237 query = new StringBundler(3);
1238 }
1239
1240 if (getDB().isSupportsInlineDistinct()) {
1241 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
1242 }
1243 else {
1244 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
1245 }
1246
1247 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1248
1249 if (!getDB().isSupportsInlineDistinct()) {
1250 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
1251 }
1252
1253 if (orderByComparator != null) {
1254 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1255
1256 if (orderByConditionFields.length > 0) {
1257 query.append(WHERE_AND);
1258 }
1259
1260 for (int i = 0; i < orderByConditionFields.length; i++) {
1261 if (getDB().isSupportsInlineDistinct()) {
1262 query.append(_ORDER_BY_ENTITY_ALIAS);
1263 }
1264 else {
1265 query.append(_ORDER_BY_ENTITY_TABLE);
1266 }
1267
1268 query.append(orderByConditionFields[i]);
1269
1270 if ((i + 1) < orderByConditionFields.length) {
1271 if (orderByComparator.isAscending() ^ previous) {
1272 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1273 }
1274 else {
1275 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1276 }
1277 }
1278 else {
1279 if (orderByComparator.isAscending() ^ previous) {
1280 query.append(WHERE_GREATER_THAN);
1281 }
1282 else {
1283 query.append(WHERE_LESSER_THAN);
1284 }
1285 }
1286 }
1287
1288 query.append(ORDER_BY_CLAUSE);
1289
1290 String[] orderByFields = orderByComparator.getOrderByFields();
1291
1292 for (int i = 0; i < orderByFields.length; i++) {
1293 if (getDB().isSupportsInlineDistinct()) {
1294 query.append(_ORDER_BY_ENTITY_ALIAS);
1295 }
1296 else {
1297 query.append(_ORDER_BY_ENTITY_TABLE);
1298 }
1299
1300 query.append(orderByFields[i]);
1301
1302 if ((i + 1) < orderByFields.length) {
1303 if (orderByComparator.isAscending() ^ previous) {
1304 query.append(ORDER_BY_ASC_HAS_NEXT);
1305 }
1306 else {
1307 query.append(ORDER_BY_DESC_HAS_NEXT);
1308 }
1309 }
1310 else {
1311 if (orderByComparator.isAscending() ^ previous) {
1312 query.append(ORDER_BY_ASC);
1313 }
1314 else {
1315 query.append(ORDER_BY_DESC);
1316 }
1317 }
1318 }
1319 }
1320
1321 else {
1322 if (getDB().isSupportsInlineDistinct()) {
1323 query.append(RoleModelImpl.ORDER_BY_JPQL);
1324 }
1325 else {
1326 query.append(RoleModelImpl.ORDER_BY_SQL);
1327 }
1328 }
1329
1330 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1331 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1332
1333 SQLQuery q = session.createSQLQuery(sql);
1334
1335 q.setFirstResult(0);
1336 q.setMaxResults(2);
1337
1338 if (getDB().isSupportsInlineDistinct()) {
1339 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
1340 }
1341 else {
1342 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
1343 }
1344
1345 QueryPos qPos = QueryPos.getInstance(q);
1346
1347 qPos.add(companyId);
1348
1349 if (orderByComparator != null) {
1350 Object[] values = orderByComparator.getOrderByConditionValues(role);
1351
1352 for (Object value : values) {
1353 qPos.add(value);
1354 }
1355 }
1356
1357 List<Role> list = q.list();
1358
1359 if (list.size() == 2) {
1360 return list.get(1);
1361 }
1362 else {
1363 return null;
1364 }
1365 }
1366
1367
1374 public List<Role> findByName(String name) throws SystemException {
1375 return findByName(name, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1376 }
1377
1378
1391 public List<Role> findByName(String name, int start, int end)
1392 throws SystemException {
1393 return findByName(name, start, end, null);
1394 }
1395
1396
1410 public List<Role> findByName(String name, int start, int end,
1411 OrderByComparator orderByComparator) throws SystemException {
1412 FinderPath finderPath = null;
1413 Object[] finderArgs = null;
1414
1415 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1416 (orderByComparator == null)) {
1417 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NAME;
1418 finderArgs = new Object[] { name };
1419 }
1420 else {
1421 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_NAME;
1422 finderArgs = new Object[] { name, start, end, orderByComparator };
1423 }
1424
1425 List<Role> list = (List<Role>)FinderCacheUtil.getResult(finderPath,
1426 finderArgs, this);
1427
1428 if (list == null) {
1429 StringBundler query = null;
1430
1431 if (orderByComparator != null) {
1432 query = new StringBundler(3 +
1433 (orderByComparator.getOrderByFields().length * 3));
1434 }
1435 else {
1436 query = new StringBundler(3);
1437 }
1438
1439 query.append(_SQL_SELECT_ROLE_WHERE);
1440
1441 if (name == null) {
1442 query.append(_FINDER_COLUMN_NAME_NAME_1);
1443 }
1444 else {
1445 if (name.equals(StringPool.BLANK)) {
1446 query.append(_FINDER_COLUMN_NAME_NAME_3);
1447 }
1448 else {
1449 query.append(_FINDER_COLUMN_NAME_NAME_2);
1450 }
1451 }
1452
1453 if (orderByComparator != null) {
1454 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1455 orderByComparator);
1456 }
1457
1458 else {
1459 query.append(RoleModelImpl.ORDER_BY_JPQL);
1460 }
1461
1462 String sql = query.toString();
1463
1464 Session session = null;
1465
1466 try {
1467 session = openSession();
1468
1469 Query q = session.createQuery(sql);
1470
1471 QueryPos qPos = QueryPos.getInstance(q);
1472
1473 if (name != null) {
1474 qPos.add(name);
1475 }
1476
1477 list = (List<Role>)QueryUtil.list(q, getDialect(), start, end);
1478 }
1479 catch (Exception e) {
1480 throw processException(e);
1481 }
1482 finally {
1483 if (list == null) {
1484 FinderCacheUtil.removeResult(finderPath, finderArgs);
1485 }
1486 else {
1487 cacheResult(list);
1488
1489 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1490 }
1491
1492 closeSession(session);
1493 }
1494 }
1495
1496 return list;
1497 }
1498
1499
1512 public Role findByName_First(String name,
1513 OrderByComparator orderByComparator)
1514 throws NoSuchRoleException, SystemException {
1515 List<Role> list = findByName(name, 0, 1, orderByComparator);
1516
1517 if (list.isEmpty()) {
1518 StringBundler msg = new StringBundler(4);
1519
1520 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1521
1522 msg.append("name=");
1523 msg.append(name);
1524
1525 msg.append(StringPool.CLOSE_CURLY_BRACE);
1526
1527 throw new NoSuchRoleException(msg.toString());
1528 }
1529 else {
1530 return list.get(0);
1531 }
1532 }
1533
1534
1547 public Role findByName_Last(String name, OrderByComparator orderByComparator)
1548 throws NoSuchRoleException, SystemException {
1549 int count = countByName(name);
1550
1551 List<Role> list = findByName(name, count - 1, count, orderByComparator);
1552
1553 if (list.isEmpty()) {
1554 StringBundler msg = new StringBundler(4);
1555
1556 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1557
1558 msg.append("name=");
1559 msg.append(name);
1560
1561 msg.append(StringPool.CLOSE_CURLY_BRACE);
1562
1563 throw new NoSuchRoleException(msg.toString());
1564 }
1565 else {
1566 return list.get(0);
1567 }
1568 }
1569
1570
1584 public Role[] findByName_PrevAndNext(long roleId, String name,
1585 OrderByComparator orderByComparator)
1586 throws NoSuchRoleException, SystemException {
1587 Role role = findByPrimaryKey(roleId);
1588
1589 Session session = null;
1590
1591 try {
1592 session = openSession();
1593
1594 Role[] array = new RoleImpl[3];
1595
1596 array[0] = getByName_PrevAndNext(session, role, name,
1597 orderByComparator, true);
1598
1599 array[1] = role;
1600
1601 array[2] = getByName_PrevAndNext(session, role, name,
1602 orderByComparator, false);
1603
1604 return array;
1605 }
1606 catch (Exception e) {
1607 throw processException(e);
1608 }
1609 finally {
1610 closeSession(session);
1611 }
1612 }
1613
1614 protected Role getByName_PrevAndNext(Session session, Role role,
1615 String name, OrderByComparator orderByComparator, boolean previous) {
1616 StringBundler query = null;
1617
1618 if (orderByComparator != null) {
1619 query = new StringBundler(6 +
1620 (orderByComparator.getOrderByFields().length * 6));
1621 }
1622 else {
1623 query = new StringBundler(3);
1624 }
1625
1626 query.append(_SQL_SELECT_ROLE_WHERE);
1627
1628 if (name == null) {
1629 query.append(_FINDER_COLUMN_NAME_NAME_1);
1630 }
1631 else {
1632 if (name.equals(StringPool.BLANK)) {
1633 query.append(_FINDER_COLUMN_NAME_NAME_3);
1634 }
1635 else {
1636 query.append(_FINDER_COLUMN_NAME_NAME_2);
1637 }
1638 }
1639
1640 if (orderByComparator != null) {
1641 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1642
1643 if (orderByConditionFields.length > 0) {
1644 query.append(WHERE_AND);
1645 }
1646
1647 for (int i = 0; i < orderByConditionFields.length; i++) {
1648 query.append(_ORDER_BY_ENTITY_ALIAS);
1649 query.append(orderByConditionFields[i]);
1650
1651 if ((i + 1) < orderByConditionFields.length) {
1652 if (orderByComparator.isAscending() ^ previous) {
1653 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1654 }
1655 else {
1656 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1657 }
1658 }
1659 else {
1660 if (orderByComparator.isAscending() ^ previous) {
1661 query.append(WHERE_GREATER_THAN);
1662 }
1663 else {
1664 query.append(WHERE_LESSER_THAN);
1665 }
1666 }
1667 }
1668
1669 query.append(ORDER_BY_CLAUSE);
1670
1671 String[] orderByFields = orderByComparator.getOrderByFields();
1672
1673 for (int i = 0; i < orderByFields.length; i++) {
1674 query.append(_ORDER_BY_ENTITY_ALIAS);
1675 query.append(orderByFields[i]);
1676
1677 if ((i + 1) < orderByFields.length) {
1678 if (orderByComparator.isAscending() ^ previous) {
1679 query.append(ORDER_BY_ASC_HAS_NEXT);
1680 }
1681 else {
1682 query.append(ORDER_BY_DESC_HAS_NEXT);
1683 }
1684 }
1685 else {
1686 if (orderByComparator.isAscending() ^ previous) {
1687 query.append(ORDER_BY_ASC);
1688 }
1689 else {
1690 query.append(ORDER_BY_DESC);
1691 }
1692 }
1693 }
1694 }
1695
1696 else {
1697 query.append(RoleModelImpl.ORDER_BY_JPQL);
1698 }
1699
1700 String sql = query.toString();
1701
1702 Query q = session.createQuery(sql);
1703
1704 q.setFirstResult(0);
1705 q.setMaxResults(2);
1706
1707 QueryPos qPos = QueryPos.getInstance(q);
1708
1709 if (name != null) {
1710 qPos.add(name);
1711 }
1712
1713 if (orderByComparator != null) {
1714 Object[] values = orderByComparator.getOrderByConditionValues(role);
1715
1716 for (Object value : values) {
1717 qPos.add(value);
1718 }
1719 }
1720
1721 List<Role> list = q.list();
1722
1723 if (list.size() == 2) {
1724 return list.get(1);
1725 }
1726 else {
1727 return null;
1728 }
1729 }
1730
1731
1738 public List<Role> filterFindByName(String name) throws SystemException {
1739 return filterFindByName(name, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1740 }
1741
1742
1755 public List<Role> filterFindByName(String name, int start, int end)
1756 throws SystemException {
1757 return filterFindByName(name, start, end, null);
1758 }
1759
1760
1774 public List<Role> filterFindByName(String name, int start, int end,
1775 OrderByComparator orderByComparator) throws SystemException {
1776 if (!InlineSQLHelperUtil.isEnabled()) {
1777 return findByName(name, start, end, orderByComparator);
1778 }
1779
1780 StringBundler query = null;
1781
1782 if (orderByComparator != null) {
1783 query = new StringBundler(3 +
1784 (orderByComparator.getOrderByFields().length * 3));
1785 }
1786 else {
1787 query = new StringBundler(3);
1788 }
1789
1790 if (getDB().isSupportsInlineDistinct()) {
1791 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
1792 }
1793 else {
1794 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
1795 }
1796
1797 if (name == null) {
1798 query.append(_FINDER_COLUMN_NAME_NAME_1);
1799 }
1800 else {
1801 if (name.equals(StringPool.BLANK)) {
1802 query.append(_FINDER_COLUMN_NAME_NAME_3);
1803 }
1804 else {
1805 query.append(_FINDER_COLUMN_NAME_NAME_2);
1806 }
1807 }
1808
1809 if (!getDB().isSupportsInlineDistinct()) {
1810 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
1811 }
1812
1813 if (orderByComparator != null) {
1814 if (getDB().isSupportsInlineDistinct()) {
1815 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1816 orderByComparator);
1817 }
1818 else {
1819 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1820 orderByComparator);
1821 }
1822 }
1823
1824 else {
1825 if (getDB().isSupportsInlineDistinct()) {
1826 query.append(RoleModelImpl.ORDER_BY_JPQL);
1827 }
1828 else {
1829 query.append(RoleModelImpl.ORDER_BY_SQL);
1830 }
1831 }
1832
1833 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1834 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1835
1836 Session session = null;
1837
1838 try {
1839 session = openSession();
1840
1841 SQLQuery q = session.createSQLQuery(sql);
1842
1843 if (getDB().isSupportsInlineDistinct()) {
1844 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
1845 }
1846 else {
1847 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
1848 }
1849
1850 QueryPos qPos = QueryPos.getInstance(q);
1851
1852 if (name != null) {
1853 qPos.add(name);
1854 }
1855
1856 return (List<Role>)QueryUtil.list(q, getDialect(), start, end);
1857 }
1858 catch (Exception e) {
1859 throw processException(e);
1860 }
1861 finally {
1862 closeSession(session);
1863 }
1864 }
1865
1866
1876 public Role[] filterFindByName_PrevAndNext(long roleId, String name,
1877 OrderByComparator orderByComparator)
1878 throws NoSuchRoleException, SystemException {
1879 if (!InlineSQLHelperUtil.isEnabled()) {
1880 return findByName_PrevAndNext(roleId, name, orderByComparator);
1881 }
1882
1883 Role role = findByPrimaryKey(roleId);
1884
1885 Session session = null;
1886
1887 try {
1888 session = openSession();
1889
1890 Role[] array = new RoleImpl[3];
1891
1892 array[0] = filterGetByName_PrevAndNext(session, role, name,
1893 orderByComparator, true);
1894
1895 array[1] = role;
1896
1897 array[2] = filterGetByName_PrevAndNext(session, role, name,
1898 orderByComparator, false);
1899
1900 return array;
1901 }
1902 catch (Exception e) {
1903 throw processException(e);
1904 }
1905 finally {
1906 closeSession(session);
1907 }
1908 }
1909
1910 protected Role filterGetByName_PrevAndNext(Session session, Role role,
1911 String name, OrderByComparator orderByComparator, boolean previous) {
1912 StringBundler query = null;
1913
1914 if (orderByComparator != null) {
1915 query = new StringBundler(6 +
1916 (orderByComparator.getOrderByFields().length * 6));
1917 }
1918 else {
1919 query = new StringBundler(3);
1920 }
1921
1922 if (getDB().isSupportsInlineDistinct()) {
1923 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
1924 }
1925 else {
1926 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
1927 }
1928
1929 if (name == null) {
1930 query.append(_FINDER_COLUMN_NAME_NAME_1);
1931 }
1932 else {
1933 if (name.equals(StringPool.BLANK)) {
1934 query.append(_FINDER_COLUMN_NAME_NAME_3);
1935 }
1936 else {
1937 query.append(_FINDER_COLUMN_NAME_NAME_2);
1938 }
1939 }
1940
1941 if (!getDB().isSupportsInlineDistinct()) {
1942 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
1943 }
1944
1945 if (orderByComparator != null) {
1946 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1947
1948 if (orderByConditionFields.length > 0) {
1949 query.append(WHERE_AND);
1950 }
1951
1952 for (int i = 0; i < orderByConditionFields.length; i++) {
1953 if (getDB().isSupportsInlineDistinct()) {
1954 query.append(_ORDER_BY_ENTITY_ALIAS);
1955 }
1956 else {
1957 query.append(_ORDER_BY_ENTITY_TABLE);
1958 }
1959
1960 query.append(orderByConditionFields[i]);
1961
1962 if ((i + 1) < orderByConditionFields.length) {
1963 if (orderByComparator.isAscending() ^ previous) {
1964 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1965 }
1966 else {
1967 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1968 }
1969 }
1970 else {
1971 if (orderByComparator.isAscending() ^ previous) {
1972 query.append(WHERE_GREATER_THAN);
1973 }
1974 else {
1975 query.append(WHERE_LESSER_THAN);
1976 }
1977 }
1978 }
1979
1980 query.append(ORDER_BY_CLAUSE);
1981
1982 String[] orderByFields = orderByComparator.getOrderByFields();
1983
1984 for (int i = 0; i < orderByFields.length; i++) {
1985 if (getDB().isSupportsInlineDistinct()) {
1986 query.append(_ORDER_BY_ENTITY_ALIAS);
1987 }
1988 else {
1989 query.append(_ORDER_BY_ENTITY_TABLE);
1990 }
1991
1992 query.append(orderByFields[i]);
1993
1994 if ((i + 1) < orderByFields.length) {
1995 if (orderByComparator.isAscending() ^ previous) {
1996 query.append(ORDER_BY_ASC_HAS_NEXT);
1997 }
1998 else {
1999 query.append(ORDER_BY_DESC_HAS_NEXT);
2000 }
2001 }
2002 else {
2003 if (orderByComparator.isAscending() ^ previous) {
2004 query.append(ORDER_BY_ASC);
2005 }
2006 else {
2007 query.append(ORDER_BY_DESC);
2008 }
2009 }
2010 }
2011 }
2012
2013 else {
2014 if (getDB().isSupportsInlineDistinct()) {
2015 query.append(RoleModelImpl.ORDER_BY_JPQL);
2016 }
2017 else {
2018 query.append(RoleModelImpl.ORDER_BY_SQL);
2019 }
2020 }
2021
2022 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2023 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2024
2025 SQLQuery q = session.createSQLQuery(sql);
2026
2027 q.setFirstResult(0);
2028 q.setMaxResults(2);
2029
2030 if (getDB().isSupportsInlineDistinct()) {
2031 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
2032 }
2033 else {
2034 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
2035 }
2036
2037 QueryPos qPos = QueryPos.getInstance(q);
2038
2039 if (name != null) {
2040 qPos.add(name);
2041 }
2042
2043 if (orderByComparator != null) {
2044 Object[] values = orderByComparator.getOrderByConditionValues(role);
2045
2046 for (Object value : values) {
2047 qPos.add(value);
2048 }
2049 }
2050
2051 List<Role> list = q.list();
2052
2053 if (list.size() == 2) {
2054 return list.get(1);
2055 }
2056 else {
2057 return null;
2058 }
2059 }
2060
2061
2068 public List<Role> findBySubtype(String subtype) throws SystemException {
2069 return findBySubtype(subtype, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2070 }
2071
2072
2085 public List<Role> findBySubtype(String subtype, int start, int end)
2086 throws SystemException {
2087 return findBySubtype(subtype, start, end, null);
2088 }
2089
2090
2104 public List<Role> findBySubtype(String subtype, int start, int end,
2105 OrderByComparator orderByComparator) throws SystemException {
2106 FinderPath finderPath = null;
2107 Object[] finderArgs = null;
2108
2109 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2110 (orderByComparator == null)) {
2111 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SUBTYPE;
2112 finderArgs = new Object[] { subtype };
2113 }
2114 else {
2115 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SUBTYPE;
2116 finderArgs = new Object[] { subtype, start, end, orderByComparator };
2117 }
2118
2119 List<Role> list = (List<Role>)FinderCacheUtil.getResult(finderPath,
2120 finderArgs, this);
2121
2122 if (list == null) {
2123 StringBundler query = null;
2124
2125 if (orderByComparator != null) {
2126 query = new StringBundler(3 +
2127 (orderByComparator.getOrderByFields().length * 3));
2128 }
2129 else {
2130 query = new StringBundler(3);
2131 }
2132
2133 query.append(_SQL_SELECT_ROLE_WHERE);
2134
2135 if (subtype == null) {
2136 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
2137 }
2138 else {
2139 if (subtype.equals(StringPool.BLANK)) {
2140 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
2141 }
2142 else {
2143 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
2144 }
2145 }
2146
2147 if (orderByComparator != null) {
2148 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2149 orderByComparator);
2150 }
2151
2152 else {
2153 query.append(RoleModelImpl.ORDER_BY_JPQL);
2154 }
2155
2156 String sql = query.toString();
2157
2158 Session session = null;
2159
2160 try {
2161 session = openSession();
2162
2163 Query q = session.createQuery(sql);
2164
2165 QueryPos qPos = QueryPos.getInstance(q);
2166
2167 if (subtype != null) {
2168 qPos.add(subtype);
2169 }
2170
2171 list = (List<Role>)QueryUtil.list(q, getDialect(), start, end);
2172 }
2173 catch (Exception e) {
2174 throw processException(e);
2175 }
2176 finally {
2177 if (list == null) {
2178 FinderCacheUtil.removeResult(finderPath, finderArgs);
2179 }
2180 else {
2181 cacheResult(list);
2182
2183 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2184 }
2185
2186 closeSession(session);
2187 }
2188 }
2189
2190 return list;
2191 }
2192
2193
2206 public Role findBySubtype_First(String subtype,
2207 OrderByComparator orderByComparator)
2208 throws NoSuchRoleException, SystemException {
2209 List<Role> list = findBySubtype(subtype, 0, 1, orderByComparator);
2210
2211 if (list.isEmpty()) {
2212 StringBundler msg = new StringBundler(4);
2213
2214 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2215
2216 msg.append("subtype=");
2217 msg.append(subtype);
2218
2219 msg.append(StringPool.CLOSE_CURLY_BRACE);
2220
2221 throw new NoSuchRoleException(msg.toString());
2222 }
2223 else {
2224 return list.get(0);
2225 }
2226 }
2227
2228
2241 public Role findBySubtype_Last(String subtype,
2242 OrderByComparator orderByComparator)
2243 throws NoSuchRoleException, SystemException {
2244 int count = countBySubtype(subtype);
2245
2246 List<Role> list = findBySubtype(subtype, count - 1, count,
2247 orderByComparator);
2248
2249 if (list.isEmpty()) {
2250 StringBundler msg = new StringBundler(4);
2251
2252 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2253
2254 msg.append("subtype=");
2255 msg.append(subtype);
2256
2257 msg.append(StringPool.CLOSE_CURLY_BRACE);
2258
2259 throw new NoSuchRoleException(msg.toString());
2260 }
2261 else {
2262 return list.get(0);
2263 }
2264 }
2265
2266
2280 public Role[] findBySubtype_PrevAndNext(long roleId, String subtype,
2281 OrderByComparator orderByComparator)
2282 throws NoSuchRoleException, SystemException {
2283 Role role = findByPrimaryKey(roleId);
2284
2285 Session session = null;
2286
2287 try {
2288 session = openSession();
2289
2290 Role[] array = new RoleImpl[3];
2291
2292 array[0] = getBySubtype_PrevAndNext(session, role, subtype,
2293 orderByComparator, true);
2294
2295 array[1] = role;
2296
2297 array[2] = getBySubtype_PrevAndNext(session, role, subtype,
2298 orderByComparator, false);
2299
2300 return array;
2301 }
2302 catch (Exception e) {
2303 throw processException(e);
2304 }
2305 finally {
2306 closeSession(session);
2307 }
2308 }
2309
2310 protected Role getBySubtype_PrevAndNext(Session session, Role role,
2311 String subtype, OrderByComparator orderByComparator, boolean previous) {
2312 StringBundler query = null;
2313
2314 if (orderByComparator != null) {
2315 query = new StringBundler(6 +
2316 (orderByComparator.getOrderByFields().length * 6));
2317 }
2318 else {
2319 query = new StringBundler(3);
2320 }
2321
2322 query.append(_SQL_SELECT_ROLE_WHERE);
2323
2324 if (subtype == null) {
2325 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
2326 }
2327 else {
2328 if (subtype.equals(StringPool.BLANK)) {
2329 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
2330 }
2331 else {
2332 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
2333 }
2334 }
2335
2336 if (orderByComparator != null) {
2337 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2338
2339 if (orderByConditionFields.length > 0) {
2340 query.append(WHERE_AND);
2341 }
2342
2343 for (int i = 0; i < orderByConditionFields.length; i++) {
2344 query.append(_ORDER_BY_ENTITY_ALIAS);
2345 query.append(orderByConditionFields[i]);
2346
2347 if ((i + 1) < orderByConditionFields.length) {
2348 if (orderByComparator.isAscending() ^ previous) {
2349 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2350 }
2351 else {
2352 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2353 }
2354 }
2355 else {
2356 if (orderByComparator.isAscending() ^ previous) {
2357 query.append(WHERE_GREATER_THAN);
2358 }
2359 else {
2360 query.append(WHERE_LESSER_THAN);
2361 }
2362 }
2363 }
2364
2365 query.append(ORDER_BY_CLAUSE);
2366
2367 String[] orderByFields = orderByComparator.getOrderByFields();
2368
2369 for (int i = 0; i < orderByFields.length; i++) {
2370 query.append(_ORDER_BY_ENTITY_ALIAS);
2371 query.append(orderByFields[i]);
2372
2373 if ((i + 1) < orderByFields.length) {
2374 if (orderByComparator.isAscending() ^ previous) {
2375 query.append(ORDER_BY_ASC_HAS_NEXT);
2376 }
2377 else {
2378 query.append(ORDER_BY_DESC_HAS_NEXT);
2379 }
2380 }
2381 else {
2382 if (orderByComparator.isAscending() ^ previous) {
2383 query.append(ORDER_BY_ASC);
2384 }
2385 else {
2386 query.append(ORDER_BY_DESC);
2387 }
2388 }
2389 }
2390 }
2391
2392 else {
2393 query.append(RoleModelImpl.ORDER_BY_JPQL);
2394 }
2395
2396 String sql = query.toString();
2397
2398 Query q = session.createQuery(sql);
2399
2400 q.setFirstResult(0);
2401 q.setMaxResults(2);
2402
2403 QueryPos qPos = QueryPos.getInstance(q);
2404
2405 if (subtype != null) {
2406 qPos.add(subtype);
2407 }
2408
2409 if (orderByComparator != null) {
2410 Object[] values = orderByComparator.getOrderByConditionValues(role);
2411
2412 for (Object value : values) {
2413 qPos.add(value);
2414 }
2415 }
2416
2417 List<Role> list = q.list();
2418
2419 if (list.size() == 2) {
2420 return list.get(1);
2421 }
2422 else {
2423 return null;
2424 }
2425 }
2426
2427
2434 public List<Role> filterFindBySubtype(String subtype)
2435 throws SystemException {
2436 return filterFindBySubtype(subtype, QueryUtil.ALL_POS,
2437 QueryUtil.ALL_POS, null);
2438 }
2439
2440
2453 public List<Role> filterFindBySubtype(String subtype, int start, int end)
2454 throws SystemException {
2455 return filterFindBySubtype(subtype, start, end, null);
2456 }
2457
2458
2472 public List<Role> filterFindBySubtype(String subtype, int start, int end,
2473 OrderByComparator orderByComparator) throws SystemException {
2474 if (!InlineSQLHelperUtil.isEnabled()) {
2475 return findBySubtype(subtype, start, end, orderByComparator);
2476 }
2477
2478 StringBundler query = null;
2479
2480 if (orderByComparator != null) {
2481 query = new StringBundler(3 +
2482 (orderByComparator.getOrderByFields().length * 3));
2483 }
2484 else {
2485 query = new StringBundler(3);
2486 }
2487
2488 if (getDB().isSupportsInlineDistinct()) {
2489 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
2490 }
2491 else {
2492 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
2493 }
2494
2495 if (subtype == null) {
2496 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
2497 }
2498 else {
2499 if (subtype.equals(StringPool.BLANK)) {
2500 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
2501 }
2502 else {
2503 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
2504 }
2505 }
2506
2507 if (!getDB().isSupportsInlineDistinct()) {
2508 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
2509 }
2510
2511 if (orderByComparator != null) {
2512 if (getDB().isSupportsInlineDistinct()) {
2513 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2514 orderByComparator);
2515 }
2516 else {
2517 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2518 orderByComparator);
2519 }
2520 }
2521
2522 else {
2523 if (getDB().isSupportsInlineDistinct()) {
2524 query.append(RoleModelImpl.ORDER_BY_JPQL);
2525 }
2526 else {
2527 query.append(RoleModelImpl.ORDER_BY_SQL);
2528 }
2529 }
2530
2531 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2532 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2533
2534 Session session = null;
2535
2536 try {
2537 session = openSession();
2538
2539 SQLQuery q = session.createSQLQuery(sql);
2540
2541 if (getDB().isSupportsInlineDistinct()) {
2542 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
2543 }
2544 else {
2545 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
2546 }
2547
2548 QueryPos qPos = QueryPos.getInstance(q);
2549
2550 if (subtype != null) {
2551 qPos.add(subtype);
2552 }
2553
2554 return (List<Role>)QueryUtil.list(q, getDialect(), start, end);
2555 }
2556 catch (Exception e) {
2557 throw processException(e);
2558 }
2559 finally {
2560 closeSession(session);
2561 }
2562 }
2563
2564
2574 public Role[] filterFindBySubtype_PrevAndNext(long roleId, String subtype,
2575 OrderByComparator orderByComparator)
2576 throws NoSuchRoleException, SystemException {
2577 if (!InlineSQLHelperUtil.isEnabled()) {
2578 return findBySubtype_PrevAndNext(roleId, subtype, orderByComparator);
2579 }
2580
2581 Role role = findByPrimaryKey(roleId);
2582
2583 Session session = null;
2584
2585 try {
2586 session = openSession();
2587
2588 Role[] array = new RoleImpl[3];
2589
2590 array[0] = filterGetBySubtype_PrevAndNext(session, role, subtype,
2591 orderByComparator, true);
2592
2593 array[1] = role;
2594
2595 array[2] = filterGetBySubtype_PrevAndNext(session, role, subtype,
2596 orderByComparator, false);
2597
2598 return array;
2599 }
2600 catch (Exception e) {
2601 throw processException(e);
2602 }
2603 finally {
2604 closeSession(session);
2605 }
2606 }
2607
2608 protected Role filterGetBySubtype_PrevAndNext(Session session, Role role,
2609 String subtype, OrderByComparator orderByComparator, boolean previous) {
2610 StringBundler query = null;
2611
2612 if (orderByComparator != null) {
2613 query = new StringBundler(6 +
2614 (orderByComparator.getOrderByFields().length * 6));
2615 }
2616 else {
2617 query = new StringBundler(3);
2618 }
2619
2620 if (getDB().isSupportsInlineDistinct()) {
2621 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
2622 }
2623 else {
2624 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
2625 }
2626
2627 if (subtype == null) {
2628 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
2629 }
2630 else {
2631 if (subtype.equals(StringPool.BLANK)) {
2632 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
2633 }
2634 else {
2635 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
2636 }
2637 }
2638
2639 if (!getDB().isSupportsInlineDistinct()) {
2640 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
2641 }
2642
2643 if (orderByComparator != null) {
2644 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2645
2646 if (orderByConditionFields.length > 0) {
2647 query.append(WHERE_AND);
2648 }
2649
2650 for (int i = 0; i < orderByConditionFields.length; i++) {
2651 if (getDB().isSupportsInlineDistinct()) {
2652 query.append(_ORDER_BY_ENTITY_ALIAS);
2653 }
2654 else {
2655 query.append(_ORDER_BY_ENTITY_TABLE);
2656 }
2657
2658 query.append(orderByConditionFields[i]);
2659
2660 if ((i + 1) < orderByConditionFields.length) {
2661 if (orderByComparator.isAscending() ^ previous) {
2662 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2663 }
2664 else {
2665 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2666 }
2667 }
2668 else {
2669 if (orderByComparator.isAscending() ^ previous) {
2670 query.append(WHERE_GREATER_THAN);
2671 }
2672 else {
2673 query.append(WHERE_LESSER_THAN);
2674 }
2675 }
2676 }
2677
2678 query.append(ORDER_BY_CLAUSE);
2679
2680 String[] orderByFields = orderByComparator.getOrderByFields();
2681
2682 for (int i = 0; i < orderByFields.length; i++) {
2683 if (getDB().isSupportsInlineDistinct()) {
2684 query.append(_ORDER_BY_ENTITY_ALIAS);
2685 }
2686 else {
2687 query.append(_ORDER_BY_ENTITY_TABLE);
2688 }
2689
2690 query.append(orderByFields[i]);
2691
2692 if ((i + 1) < orderByFields.length) {
2693 if (orderByComparator.isAscending() ^ previous) {
2694 query.append(ORDER_BY_ASC_HAS_NEXT);
2695 }
2696 else {
2697 query.append(ORDER_BY_DESC_HAS_NEXT);
2698 }
2699 }
2700 else {
2701 if (orderByComparator.isAscending() ^ previous) {
2702 query.append(ORDER_BY_ASC);
2703 }
2704 else {
2705 query.append(ORDER_BY_DESC);
2706 }
2707 }
2708 }
2709 }
2710
2711 else {
2712 if (getDB().isSupportsInlineDistinct()) {
2713 query.append(RoleModelImpl.ORDER_BY_JPQL);
2714 }
2715 else {
2716 query.append(RoleModelImpl.ORDER_BY_SQL);
2717 }
2718 }
2719
2720 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2721 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2722
2723 SQLQuery q = session.createSQLQuery(sql);
2724
2725 q.setFirstResult(0);
2726 q.setMaxResults(2);
2727
2728 if (getDB().isSupportsInlineDistinct()) {
2729 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
2730 }
2731 else {
2732 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
2733 }
2734
2735 QueryPos qPos = QueryPos.getInstance(q);
2736
2737 if (subtype != null) {
2738 qPos.add(subtype);
2739 }
2740
2741 if (orderByComparator != null) {
2742 Object[] values = orderByComparator.getOrderByConditionValues(role);
2743
2744 for (Object value : values) {
2745 qPos.add(value);
2746 }
2747 }
2748
2749 List<Role> list = q.list();
2750
2751 if (list.size() == 2) {
2752 return list.get(1);
2753 }
2754 else {
2755 return null;
2756 }
2757 }
2758
2759
2768 public Role findByC_N(long companyId, String name)
2769 throws NoSuchRoleException, SystemException {
2770 Role role = fetchByC_N(companyId, name);
2771
2772 if (role == null) {
2773 StringBundler msg = new StringBundler(6);
2774
2775 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2776
2777 msg.append("companyId=");
2778 msg.append(companyId);
2779
2780 msg.append(", name=");
2781 msg.append(name);
2782
2783 msg.append(StringPool.CLOSE_CURLY_BRACE);
2784
2785 if (_log.isWarnEnabled()) {
2786 _log.warn(msg.toString());
2787 }
2788
2789 throw new NoSuchRoleException(msg.toString());
2790 }
2791
2792 return role;
2793 }
2794
2795
2803 public Role fetchByC_N(long companyId, String name)
2804 throws SystemException {
2805 return fetchByC_N(companyId, name, true);
2806 }
2807
2808
2817 public Role fetchByC_N(long companyId, String name,
2818 boolean retrieveFromCache) throws SystemException {
2819 Object[] finderArgs = new Object[] { companyId, name };
2820
2821 Object result = null;
2822
2823 if (retrieveFromCache) {
2824 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_N,
2825 finderArgs, this);
2826 }
2827
2828 if (result == null) {
2829 StringBundler query = new StringBundler(4);
2830
2831 query.append(_SQL_SELECT_ROLE_WHERE);
2832
2833 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
2834
2835 if (name == null) {
2836 query.append(_FINDER_COLUMN_C_N_NAME_1);
2837 }
2838 else {
2839 if (name.equals(StringPool.BLANK)) {
2840 query.append(_FINDER_COLUMN_C_N_NAME_3);
2841 }
2842 else {
2843 query.append(_FINDER_COLUMN_C_N_NAME_2);
2844 }
2845 }
2846
2847 query.append(RoleModelImpl.ORDER_BY_JPQL);
2848
2849 String sql = query.toString();
2850
2851 Session session = null;
2852
2853 try {
2854 session = openSession();
2855
2856 Query q = session.createQuery(sql);
2857
2858 QueryPos qPos = QueryPos.getInstance(q);
2859
2860 qPos.add(companyId);
2861
2862 if (name != null) {
2863 qPos.add(name);
2864 }
2865
2866 List<Role> list = q.list();
2867
2868 result = list;
2869
2870 Role role = null;
2871
2872 if (list.isEmpty()) {
2873 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
2874 finderArgs, list);
2875 }
2876 else {
2877 role = list.get(0);
2878
2879 cacheResult(role);
2880
2881 if ((role.getCompanyId() != companyId) ||
2882 (role.getName() == null) ||
2883 !role.getName().equals(name)) {
2884 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
2885 finderArgs, role);
2886 }
2887 }
2888
2889 return role;
2890 }
2891 catch (Exception e) {
2892 throw processException(e);
2893 }
2894 finally {
2895 if (result == null) {
2896 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
2897 finderArgs);
2898 }
2899
2900 closeSession(session);
2901 }
2902 }
2903 else {
2904 if (result instanceof List<?>) {
2905 return null;
2906 }
2907 else {
2908 return (Role)result;
2909 }
2910 }
2911 }
2912
2913
2921 public List<Role> findByT_S(int type, String subtype)
2922 throws SystemException {
2923 return findByT_S(type, subtype, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2924 null);
2925 }
2926
2927
2941 public List<Role> findByT_S(int type, String subtype, int start, int end)
2942 throws SystemException {
2943 return findByT_S(type, subtype, start, end, null);
2944 }
2945
2946
2961 public List<Role> findByT_S(int type, String subtype, int start, int end,
2962 OrderByComparator orderByComparator) throws SystemException {
2963 FinderPath finderPath = null;
2964 Object[] finderArgs = null;
2965
2966 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2967 (orderByComparator == null)) {
2968 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S;
2969 finderArgs = new Object[] { type, subtype };
2970 }
2971 else {
2972 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_T_S;
2973 finderArgs = new Object[] {
2974 type, subtype,
2975
2976 start, end, orderByComparator
2977 };
2978 }
2979
2980 List<Role> list = (List<Role>)FinderCacheUtil.getResult(finderPath,
2981 finderArgs, this);
2982
2983 if (list == null) {
2984 StringBundler query = null;
2985
2986 if (orderByComparator != null) {
2987 query = new StringBundler(4 +
2988 (orderByComparator.getOrderByFields().length * 3));
2989 }
2990 else {
2991 query = new StringBundler(4);
2992 }
2993
2994 query.append(_SQL_SELECT_ROLE_WHERE);
2995
2996 query.append(_FINDER_COLUMN_T_S_TYPE_2);
2997
2998 if (subtype == null) {
2999 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
3000 }
3001 else {
3002 if (subtype.equals(StringPool.BLANK)) {
3003 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
3004 }
3005 else {
3006 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
3007 }
3008 }
3009
3010 if (orderByComparator != null) {
3011 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3012 orderByComparator);
3013 }
3014
3015 else {
3016 query.append(RoleModelImpl.ORDER_BY_JPQL);
3017 }
3018
3019 String sql = query.toString();
3020
3021 Session session = null;
3022
3023 try {
3024 session = openSession();
3025
3026 Query q = session.createQuery(sql);
3027
3028 QueryPos qPos = QueryPos.getInstance(q);
3029
3030 qPos.add(type);
3031
3032 if (subtype != null) {
3033 qPos.add(subtype);
3034 }
3035
3036 list = (List<Role>)QueryUtil.list(q, getDialect(), start, end);
3037 }
3038 catch (Exception e) {
3039 throw processException(e);
3040 }
3041 finally {
3042 if (list == null) {
3043 FinderCacheUtil.removeResult(finderPath, finderArgs);
3044 }
3045 else {
3046 cacheResult(list);
3047
3048 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3049 }
3050
3051 closeSession(session);
3052 }
3053 }
3054
3055 return list;
3056 }
3057
3058
3072 public Role findByT_S_First(int type, String subtype,
3073 OrderByComparator orderByComparator)
3074 throws NoSuchRoleException, SystemException {
3075 List<Role> list = findByT_S(type, subtype, 0, 1, orderByComparator);
3076
3077 if (list.isEmpty()) {
3078 StringBundler msg = new StringBundler(6);
3079
3080 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3081
3082 msg.append("type=");
3083 msg.append(type);
3084
3085 msg.append(", subtype=");
3086 msg.append(subtype);
3087
3088 msg.append(StringPool.CLOSE_CURLY_BRACE);
3089
3090 throw new NoSuchRoleException(msg.toString());
3091 }
3092 else {
3093 return list.get(0);
3094 }
3095 }
3096
3097
3111 public Role findByT_S_Last(int type, String subtype,
3112 OrderByComparator orderByComparator)
3113 throws NoSuchRoleException, SystemException {
3114 int count = countByT_S(type, subtype);
3115
3116 List<Role> list = findByT_S(type, subtype, count - 1, count,
3117 orderByComparator);
3118
3119 if (list.isEmpty()) {
3120 StringBundler msg = new StringBundler(6);
3121
3122 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3123
3124 msg.append("type=");
3125 msg.append(type);
3126
3127 msg.append(", subtype=");
3128 msg.append(subtype);
3129
3130 msg.append(StringPool.CLOSE_CURLY_BRACE);
3131
3132 throw new NoSuchRoleException(msg.toString());
3133 }
3134 else {
3135 return list.get(0);
3136 }
3137 }
3138
3139
3154 public Role[] findByT_S_PrevAndNext(long roleId, int type, String subtype,
3155 OrderByComparator orderByComparator)
3156 throws NoSuchRoleException, SystemException {
3157 Role role = findByPrimaryKey(roleId);
3158
3159 Session session = null;
3160
3161 try {
3162 session = openSession();
3163
3164 Role[] array = new RoleImpl[3];
3165
3166 array[0] = getByT_S_PrevAndNext(session, role, type, subtype,
3167 orderByComparator, true);
3168
3169 array[1] = role;
3170
3171 array[2] = getByT_S_PrevAndNext(session, role, type, subtype,
3172 orderByComparator, false);
3173
3174 return array;
3175 }
3176 catch (Exception e) {
3177 throw processException(e);
3178 }
3179 finally {
3180 closeSession(session);
3181 }
3182 }
3183
3184 protected Role getByT_S_PrevAndNext(Session session, Role role, int type,
3185 String subtype, OrderByComparator orderByComparator, boolean previous) {
3186 StringBundler query = null;
3187
3188 if (orderByComparator != null) {
3189 query = new StringBundler(6 +
3190 (orderByComparator.getOrderByFields().length * 6));
3191 }
3192 else {
3193 query = new StringBundler(3);
3194 }
3195
3196 query.append(_SQL_SELECT_ROLE_WHERE);
3197
3198 query.append(_FINDER_COLUMN_T_S_TYPE_2);
3199
3200 if (subtype == null) {
3201 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
3202 }
3203 else {
3204 if (subtype.equals(StringPool.BLANK)) {
3205 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
3206 }
3207 else {
3208 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
3209 }
3210 }
3211
3212 if (orderByComparator != null) {
3213 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3214
3215 if (orderByConditionFields.length > 0) {
3216 query.append(WHERE_AND);
3217 }
3218
3219 for (int i = 0; i < orderByConditionFields.length; i++) {
3220 query.append(_ORDER_BY_ENTITY_ALIAS);
3221 query.append(orderByConditionFields[i]);
3222
3223 if ((i + 1) < orderByConditionFields.length) {
3224 if (orderByComparator.isAscending() ^ previous) {
3225 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3226 }
3227 else {
3228 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3229 }
3230 }
3231 else {
3232 if (orderByComparator.isAscending() ^ previous) {
3233 query.append(WHERE_GREATER_THAN);
3234 }
3235 else {
3236 query.append(WHERE_LESSER_THAN);
3237 }
3238 }
3239 }
3240
3241 query.append(ORDER_BY_CLAUSE);
3242
3243 String[] orderByFields = orderByComparator.getOrderByFields();
3244
3245 for (int i = 0; i < orderByFields.length; i++) {
3246 query.append(_ORDER_BY_ENTITY_ALIAS);
3247 query.append(orderByFields[i]);
3248
3249 if ((i + 1) < orderByFields.length) {
3250 if (orderByComparator.isAscending() ^ previous) {
3251 query.append(ORDER_BY_ASC_HAS_NEXT);
3252 }
3253 else {
3254 query.append(ORDER_BY_DESC_HAS_NEXT);
3255 }
3256 }
3257 else {
3258 if (orderByComparator.isAscending() ^ previous) {
3259 query.append(ORDER_BY_ASC);
3260 }
3261 else {
3262 query.append(ORDER_BY_DESC);
3263 }
3264 }
3265 }
3266 }
3267
3268 else {
3269 query.append(RoleModelImpl.ORDER_BY_JPQL);
3270 }
3271
3272 String sql = query.toString();
3273
3274 Query q = session.createQuery(sql);
3275
3276 q.setFirstResult(0);
3277 q.setMaxResults(2);
3278
3279 QueryPos qPos = QueryPos.getInstance(q);
3280
3281 qPos.add(type);
3282
3283 if (subtype != null) {
3284 qPos.add(subtype);
3285 }
3286
3287 if (orderByComparator != null) {
3288 Object[] values = orderByComparator.getOrderByConditionValues(role);
3289
3290 for (Object value : values) {
3291 qPos.add(value);
3292 }
3293 }
3294
3295 List<Role> list = q.list();
3296
3297 if (list.size() == 2) {
3298 return list.get(1);
3299 }
3300 else {
3301 return null;
3302 }
3303 }
3304
3305
3313 public List<Role> filterFindByT_S(int type, String subtype)
3314 throws SystemException {
3315 return filterFindByT_S(type, subtype, QueryUtil.ALL_POS,
3316 QueryUtil.ALL_POS, null);
3317 }
3318
3319
3333 public List<Role> filterFindByT_S(int type, String subtype, int start,
3334 int end) throws SystemException {
3335 return filterFindByT_S(type, subtype, start, end, null);
3336 }
3337
3338
3353 public List<Role> filterFindByT_S(int type, String subtype, int start,
3354 int end, OrderByComparator orderByComparator) throws SystemException {
3355 if (!InlineSQLHelperUtil.isEnabled()) {
3356 return findByT_S(type, subtype, start, end, orderByComparator);
3357 }
3358
3359 StringBundler query = null;
3360
3361 if (orderByComparator != null) {
3362 query = new StringBundler(4 +
3363 (orderByComparator.getOrderByFields().length * 3));
3364 }
3365 else {
3366 query = new StringBundler(4);
3367 }
3368
3369 if (getDB().isSupportsInlineDistinct()) {
3370 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
3371 }
3372 else {
3373 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
3374 }
3375
3376 query.append(_FINDER_COLUMN_T_S_TYPE_2);
3377
3378 if (subtype == null) {
3379 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
3380 }
3381 else {
3382 if (subtype.equals(StringPool.BLANK)) {
3383 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
3384 }
3385 else {
3386 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
3387 }
3388 }
3389
3390 if (!getDB().isSupportsInlineDistinct()) {
3391 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
3392 }
3393
3394 if (orderByComparator != null) {
3395 if (getDB().isSupportsInlineDistinct()) {
3396 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3397 orderByComparator);
3398 }
3399 else {
3400 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3401 orderByComparator);
3402 }
3403 }
3404
3405 else {
3406 if (getDB().isSupportsInlineDistinct()) {
3407 query.append(RoleModelImpl.ORDER_BY_JPQL);
3408 }
3409 else {
3410 query.append(RoleModelImpl.ORDER_BY_SQL);
3411 }
3412 }
3413
3414 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3415 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3416
3417 Session session = null;
3418
3419 try {
3420 session = openSession();
3421
3422 SQLQuery q = session.createSQLQuery(sql);
3423
3424 if (getDB().isSupportsInlineDistinct()) {
3425 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
3426 }
3427 else {
3428 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
3429 }
3430
3431 QueryPos qPos = QueryPos.getInstance(q);
3432
3433 qPos.add(type);
3434
3435 if (subtype != null) {
3436 qPos.add(subtype);
3437 }
3438
3439 return (List<Role>)QueryUtil.list(q, getDialect(), start, end);
3440 }
3441 catch (Exception e) {
3442 throw processException(e);
3443 }
3444 finally {
3445 closeSession(session);
3446 }
3447 }
3448
3449
3460 public Role[] filterFindByT_S_PrevAndNext(long roleId, int type,
3461 String subtype, OrderByComparator orderByComparator)
3462 throws NoSuchRoleException, SystemException {
3463 if (!InlineSQLHelperUtil.isEnabled()) {
3464 return findByT_S_PrevAndNext(roleId, type, subtype,
3465 orderByComparator);
3466 }
3467
3468 Role role = findByPrimaryKey(roleId);
3469
3470 Session session = null;
3471
3472 try {
3473 session = openSession();
3474
3475 Role[] array = new RoleImpl[3];
3476
3477 array[0] = filterGetByT_S_PrevAndNext(session, role, type, subtype,
3478 orderByComparator, true);
3479
3480 array[1] = role;
3481
3482 array[2] = filterGetByT_S_PrevAndNext(session, role, type, subtype,
3483 orderByComparator, false);
3484
3485 return array;
3486 }
3487 catch (Exception e) {
3488 throw processException(e);
3489 }
3490 finally {
3491 closeSession(session);
3492 }
3493 }
3494
3495 protected Role filterGetByT_S_PrevAndNext(Session session, Role role,
3496 int type, String subtype, OrderByComparator orderByComparator,
3497 boolean previous) {
3498 StringBundler query = null;
3499
3500 if (orderByComparator != null) {
3501 query = new StringBundler(6 +
3502 (orderByComparator.getOrderByFields().length * 6));
3503 }
3504 else {
3505 query = new StringBundler(3);
3506 }
3507
3508 if (getDB().isSupportsInlineDistinct()) {
3509 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
3510 }
3511 else {
3512 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
3513 }
3514
3515 query.append(_FINDER_COLUMN_T_S_TYPE_2);
3516
3517 if (subtype == null) {
3518 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
3519 }
3520 else {
3521 if (subtype.equals(StringPool.BLANK)) {
3522 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
3523 }
3524 else {
3525 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
3526 }
3527 }
3528
3529 if (!getDB().isSupportsInlineDistinct()) {
3530 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
3531 }
3532
3533 if (orderByComparator != null) {
3534 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3535
3536 if (orderByConditionFields.length > 0) {
3537 query.append(WHERE_AND);
3538 }
3539
3540 for (int i = 0; i < orderByConditionFields.length; i++) {
3541 if (getDB().isSupportsInlineDistinct()) {
3542 query.append(_ORDER_BY_ENTITY_ALIAS);
3543 }
3544 else {
3545 query.append(_ORDER_BY_ENTITY_TABLE);
3546 }
3547
3548 query.append(orderByConditionFields[i]);
3549
3550 if ((i + 1) < orderByConditionFields.length) {
3551 if (orderByComparator.isAscending() ^ previous) {
3552 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3553 }
3554 else {
3555 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3556 }
3557 }
3558 else {
3559 if (orderByComparator.isAscending() ^ previous) {
3560 query.append(WHERE_GREATER_THAN);
3561 }
3562 else {
3563 query.append(WHERE_LESSER_THAN);
3564 }
3565 }
3566 }
3567
3568 query.append(ORDER_BY_CLAUSE);
3569
3570 String[] orderByFields = orderByComparator.getOrderByFields();
3571
3572 for (int i = 0; i < orderByFields.length; i++) {
3573 if (getDB().isSupportsInlineDistinct()) {
3574 query.append(_ORDER_BY_ENTITY_ALIAS);
3575 }
3576 else {
3577 query.append(_ORDER_BY_ENTITY_TABLE);
3578 }
3579
3580 query.append(orderByFields[i]);
3581
3582 if ((i + 1) < orderByFields.length) {
3583 if (orderByComparator.isAscending() ^ previous) {
3584 query.append(ORDER_BY_ASC_HAS_NEXT);
3585 }
3586 else {
3587 query.append(ORDER_BY_DESC_HAS_NEXT);
3588 }
3589 }
3590 else {
3591 if (orderByComparator.isAscending() ^ previous) {
3592 query.append(ORDER_BY_ASC);
3593 }
3594 else {
3595 query.append(ORDER_BY_DESC);
3596 }
3597 }
3598 }
3599 }
3600
3601 else {
3602 if (getDB().isSupportsInlineDistinct()) {
3603 query.append(RoleModelImpl.ORDER_BY_JPQL);
3604 }
3605 else {
3606 query.append(RoleModelImpl.ORDER_BY_SQL);
3607 }
3608 }
3609
3610 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3611 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3612
3613 SQLQuery q = session.createSQLQuery(sql);
3614
3615 q.setFirstResult(0);
3616 q.setMaxResults(2);
3617
3618 if (getDB().isSupportsInlineDistinct()) {
3619 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
3620 }
3621 else {
3622 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
3623 }
3624
3625 QueryPos qPos = QueryPos.getInstance(q);
3626
3627 qPos.add(type);
3628
3629 if (subtype != null) {
3630 qPos.add(subtype);
3631 }
3632
3633 if (orderByComparator != null) {
3634 Object[] values = orderByComparator.getOrderByConditionValues(role);
3635
3636 for (Object value : values) {
3637 qPos.add(value);
3638 }
3639 }
3640
3641 List<Role> list = q.list();
3642
3643 if (list.size() == 2) {
3644 return list.get(1);
3645 }
3646 else {
3647 return null;
3648 }
3649 }
3650
3651
3661 public Role findByC_C_C(long companyId, long classNameId, long classPK)
3662 throws NoSuchRoleException, SystemException {
3663 Role role = fetchByC_C_C(companyId, classNameId, classPK);
3664
3665 if (role == null) {
3666 StringBundler msg = new StringBundler(8);
3667
3668 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3669
3670 msg.append("companyId=");
3671 msg.append(companyId);
3672
3673 msg.append(", classNameId=");
3674 msg.append(classNameId);
3675
3676 msg.append(", classPK=");
3677 msg.append(classPK);
3678
3679 msg.append(StringPool.CLOSE_CURLY_BRACE);
3680
3681 if (_log.isWarnEnabled()) {
3682 _log.warn(msg.toString());
3683 }
3684
3685 throw new NoSuchRoleException(msg.toString());
3686 }
3687
3688 return role;
3689 }
3690
3691
3700 public Role fetchByC_C_C(long companyId, long classNameId, long classPK)
3701 throws SystemException {
3702 return fetchByC_C_C(companyId, classNameId, classPK, true);
3703 }
3704
3705
3715 public Role fetchByC_C_C(long companyId, long classNameId, long classPK,
3716 boolean retrieveFromCache) throws SystemException {
3717 Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
3718
3719 Object result = null;
3720
3721 if (retrieveFromCache) {
3722 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C_C,
3723 finderArgs, this);
3724 }
3725
3726 if (result == null) {
3727 StringBundler query = new StringBundler(5);
3728
3729 query.append(_SQL_SELECT_ROLE_WHERE);
3730
3731 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
3732
3733 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
3734
3735 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
3736
3737 query.append(RoleModelImpl.ORDER_BY_JPQL);
3738
3739 String sql = query.toString();
3740
3741 Session session = null;
3742
3743 try {
3744 session = openSession();
3745
3746 Query q = session.createQuery(sql);
3747
3748 QueryPos qPos = QueryPos.getInstance(q);
3749
3750 qPos.add(companyId);
3751
3752 qPos.add(classNameId);
3753
3754 qPos.add(classPK);
3755
3756 List<Role> list = q.list();
3757
3758 result = list;
3759
3760 Role role = null;
3761
3762 if (list.isEmpty()) {
3763 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
3764 finderArgs, list);
3765 }
3766 else {
3767 role = list.get(0);
3768
3769 cacheResult(role);
3770
3771 if ((role.getCompanyId() != companyId) ||
3772 (role.getClassNameId() != classNameId) ||
3773 (role.getClassPK() != classPK)) {
3774 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
3775 finderArgs, role);
3776 }
3777 }
3778
3779 return role;
3780 }
3781 catch (Exception e) {
3782 throw processException(e);
3783 }
3784 finally {
3785 if (result == null) {
3786 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C,
3787 finderArgs);
3788 }
3789
3790 closeSession(session);
3791 }
3792 }
3793 else {
3794 if (result instanceof List<?>) {
3795 return null;
3796 }
3797 else {
3798 return (Role)result;
3799 }
3800 }
3801 }
3802
3803
3809 public List<Role> findAll() throws SystemException {
3810 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3811 }
3812
3813
3825 public List<Role> findAll(int start, int end) throws SystemException {
3826 return findAll(start, end, null);
3827 }
3828
3829
3842 public List<Role> findAll(int start, int end,
3843 OrderByComparator orderByComparator) throws SystemException {
3844 FinderPath finderPath = null;
3845 Object[] finderArgs = new Object[] { start, end, orderByComparator };
3846
3847 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3848 (orderByComparator == null)) {
3849 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3850 finderArgs = FINDER_ARGS_EMPTY;
3851 }
3852 else {
3853 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3854 finderArgs = new Object[] { start, end, orderByComparator };
3855 }
3856
3857 List<Role> list = (List<Role>)FinderCacheUtil.getResult(finderPath,
3858 finderArgs, this);
3859
3860 if (list == null) {
3861 StringBundler query = null;
3862 String sql = null;
3863
3864 if (orderByComparator != null) {
3865 query = new StringBundler(2 +
3866 (orderByComparator.getOrderByFields().length * 3));
3867
3868 query.append(_SQL_SELECT_ROLE);
3869
3870 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3871 orderByComparator);
3872
3873 sql = query.toString();
3874 }
3875 else {
3876 sql = _SQL_SELECT_ROLE.concat(RoleModelImpl.ORDER_BY_JPQL);
3877 }
3878
3879 Session session = null;
3880
3881 try {
3882 session = openSession();
3883
3884 Query q = session.createQuery(sql);
3885
3886 if (orderByComparator == null) {
3887 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
3888 end, false);
3889
3890 Collections.sort(list);
3891 }
3892 else {
3893 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
3894 end);
3895 }
3896 }
3897 catch (Exception e) {
3898 throw processException(e);
3899 }
3900 finally {
3901 if (list == null) {
3902 FinderCacheUtil.removeResult(finderPath, finderArgs);
3903 }
3904 else {
3905 cacheResult(list);
3906
3907 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3908 }
3909
3910 closeSession(session);
3911 }
3912 }
3913
3914 return list;
3915 }
3916
3917
3923 public void removeByCompanyId(long companyId) throws SystemException {
3924 for (Role role : findByCompanyId(companyId)) {
3925 rolePersistence.remove(role);
3926 }
3927 }
3928
3929
3935 public void removeByName(String name) throws SystemException {
3936 for (Role role : findByName(name)) {
3937 rolePersistence.remove(role);
3938 }
3939 }
3940
3941
3947 public void removeBySubtype(String subtype) throws SystemException {
3948 for (Role role : findBySubtype(subtype)) {
3949 rolePersistence.remove(role);
3950 }
3951 }
3952
3953
3960 public void removeByC_N(long companyId, String name)
3961 throws NoSuchRoleException, SystemException {
3962 Role role = findByC_N(companyId, name);
3963
3964 rolePersistence.remove(role);
3965 }
3966
3967
3974 public void removeByT_S(int type, String subtype) throws SystemException {
3975 for (Role role : findByT_S(type, subtype)) {
3976 rolePersistence.remove(role);
3977 }
3978 }
3979
3980
3988 public void removeByC_C_C(long companyId, long classNameId, long classPK)
3989 throws NoSuchRoleException, SystemException {
3990 Role role = findByC_C_C(companyId, classNameId, classPK);
3991
3992 rolePersistence.remove(role);
3993 }
3994
3995
4000 public void removeAll() throws SystemException {
4001 for (Role role : findAll()) {
4002 rolePersistence.remove(role);
4003 }
4004 }
4005
4006
4013 public int countByCompanyId(long companyId) throws SystemException {
4014 Object[] finderArgs = new Object[] { companyId };
4015
4016 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
4017 finderArgs, this);
4018
4019 if (count == null) {
4020 StringBundler query = new StringBundler(2);
4021
4022 query.append(_SQL_COUNT_ROLE_WHERE);
4023
4024 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
4025
4026 String sql = query.toString();
4027
4028 Session session = null;
4029
4030 try {
4031 session = openSession();
4032
4033 Query q = session.createQuery(sql);
4034
4035 QueryPos qPos = QueryPos.getInstance(q);
4036
4037 qPos.add(companyId);
4038
4039 count = (Long)q.uniqueResult();
4040 }
4041 catch (Exception e) {
4042 throw processException(e);
4043 }
4044 finally {
4045 if (count == null) {
4046 count = Long.valueOf(0);
4047 }
4048
4049 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
4050 finderArgs, count);
4051
4052 closeSession(session);
4053 }
4054 }
4055
4056 return count.intValue();
4057 }
4058
4059
4066 public int filterCountByCompanyId(long companyId) throws SystemException {
4067 if (!InlineSQLHelperUtil.isEnabled()) {
4068 return countByCompanyId(companyId);
4069 }
4070
4071 StringBundler query = new StringBundler(2);
4072
4073 query.append(_FILTER_SQL_COUNT_ROLE_WHERE);
4074
4075 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
4076
4077 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4078 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4079
4080 Session session = null;
4081
4082 try {
4083 session = openSession();
4084
4085 SQLQuery q = session.createSQLQuery(sql);
4086
4087 q.addScalar(COUNT_COLUMN_NAME,
4088 com.liferay.portal.kernel.dao.orm.Type.LONG);
4089
4090 QueryPos qPos = QueryPos.getInstance(q);
4091
4092 qPos.add(companyId);
4093
4094 Long count = (Long)q.uniqueResult();
4095
4096 return count.intValue();
4097 }
4098 catch (Exception e) {
4099 throw processException(e);
4100 }
4101 finally {
4102 closeSession(session);
4103 }
4104 }
4105
4106
4113 public int countByName(String name) throws SystemException {
4114 Object[] finderArgs = new Object[] { name };
4115
4116 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_NAME,
4117 finderArgs, this);
4118
4119 if (count == null) {
4120 StringBundler query = new StringBundler(2);
4121
4122 query.append(_SQL_COUNT_ROLE_WHERE);
4123
4124 if (name == null) {
4125 query.append(_FINDER_COLUMN_NAME_NAME_1);
4126 }
4127 else {
4128 if (name.equals(StringPool.BLANK)) {
4129 query.append(_FINDER_COLUMN_NAME_NAME_3);
4130 }
4131 else {
4132 query.append(_FINDER_COLUMN_NAME_NAME_2);
4133 }
4134 }
4135
4136 String sql = query.toString();
4137
4138 Session session = null;
4139
4140 try {
4141 session = openSession();
4142
4143 Query q = session.createQuery(sql);
4144
4145 QueryPos qPos = QueryPos.getInstance(q);
4146
4147 if (name != null) {
4148 qPos.add(name);
4149 }
4150
4151 count = (Long)q.uniqueResult();
4152 }
4153 catch (Exception e) {
4154 throw processException(e);
4155 }
4156 finally {
4157 if (count == null) {
4158 count = Long.valueOf(0);
4159 }
4160
4161 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_NAME,
4162 finderArgs, count);
4163
4164 closeSession(session);
4165 }
4166 }
4167
4168 return count.intValue();
4169 }
4170
4171
4178 public int filterCountByName(String name) throws SystemException {
4179 if (!InlineSQLHelperUtil.isEnabled()) {
4180 return countByName(name);
4181 }
4182
4183 StringBundler query = new StringBundler(2);
4184
4185 query.append(_FILTER_SQL_COUNT_ROLE_WHERE);
4186
4187 if (name == null) {
4188 query.append(_FINDER_COLUMN_NAME_NAME_1);
4189 }
4190 else {
4191 if (name.equals(StringPool.BLANK)) {
4192 query.append(_FINDER_COLUMN_NAME_NAME_3);
4193 }
4194 else {
4195 query.append(_FINDER_COLUMN_NAME_NAME_2);
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.createSQLQuery(sql);
4208
4209 q.addScalar(COUNT_COLUMN_NAME,
4210 com.liferay.portal.kernel.dao.orm.Type.LONG);
4211
4212 QueryPos qPos = QueryPos.getInstance(q);
4213
4214 if (name != null) {
4215 qPos.add(name);
4216 }
4217
4218 Long count = (Long)q.uniqueResult();
4219
4220 return count.intValue();
4221 }
4222 catch (Exception e) {
4223 throw processException(e);
4224 }
4225 finally {
4226 closeSession(session);
4227 }
4228 }
4229
4230
4237 public int countBySubtype(String subtype) throws SystemException {
4238 Object[] finderArgs = new Object[] { subtype };
4239
4240 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SUBTYPE,
4241 finderArgs, this);
4242
4243 if (count == null) {
4244 StringBundler query = new StringBundler(2);
4245
4246 query.append(_SQL_COUNT_ROLE_WHERE);
4247
4248 if (subtype == null) {
4249 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
4250 }
4251 else {
4252 if (subtype.equals(StringPool.BLANK)) {
4253 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
4254 }
4255 else {
4256 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
4257 }
4258 }
4259
4260 String sql = query.toString();
4261
4262 Session session = null;
4263
4264 try {
4265 session = openSession();
4266
4267 Query q = session.createQuery(sql);
4268
4269 QueryPos qPos = QueryPos.getInstance(q);
4270
4271 if (subtype != null) {
4272 qPos.add(subtype);
4273 }
4274
4275 count = (Long)q.uniqueResult();
4276 }
4277 catch (Exception e) {
4278 throw processException(e);
4279 }
4280 finally {
4281 if (count == null) {
4282 count = Long.valueOf(0);
4283 }
4284
4285 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SUBTYPE,
4286 finderArgs, count);
4287
4288 closeSession(session);
4289 }
4290 }
4291
4292 return count.intValue();
4293 }
4294
4295
4302 public int filterCountBySubtype(String subtype) throws SystemException {
4303 if (!InlineSQLHelperUtil.isEnabled()) {
4304 return countBySubtype(subtype);
4305 }
4306
4307 StringBundler query = new StringBundler(2);
4308
4309 query.append(_FILTER_SQL_COUNT_ROLE_WHERE);
4310
4311 if (subtype == null) {
4312 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
4313 }
4314 else {
4315 if (subtype.equals(StringPool.BLANK)) {
4316 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
4317 }
4318 else {
4319 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
4320 }
4321 }
4322
4323 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4324 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4325
4326 Session session = null;
4327
4328 try {
4329 session = openSession();
4330
4331 SQLQuery q = session.createSQLQuery(sql);
4332
4333 q.addScalar(COUNT_COLUMN_NAME,
4334 com.liferay.portal.kernel.dao.orm.Type.LONG);
4335
4336 QueryPos qPos = QueryPos.getInstance(q);
4337
4338 if (subtype != null) {
4339 qPos.add(subtype);
4340 }
4341
4342 Long count = (Long)q.uniqueResult();
4343
4344 return count.intValue();
4345 }
4346 catch (Exception e) {
4347 throw processException(e);
4348 }
4349 finally {
4350 closeSession(session);
4351 }
4352 }
4353
4354
4362 public int countByC_N(long companyId, String name)
4363 throws SystemException {
4364 Object[] finderArgs = new Object[] { companyId, name };
4365
4366 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_N,
4367 finderArgs, this);
4368
4369 if (count == null) {
4370 StringBundler query = new StringBundler(3);
4371
4372 query.append(_SQL_COUNT_ROLE_WHERE);
4373
4374 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
4375
4376 if (name == null) {
4377 query.append(_FINDER_COLUMN_C_N_NAME_1);
4378 }
4379 else {
4380 if (name.equals(StringPool.BLANK)) {
4381 query.append(_FINDER_COLUMN_C_N_NAME_3);
4382 }
4383 else {
4384 query.append(_FINDER_COLUMN_C_N_NAME_2);
4385 }
4386 }
4387
4388 String sql = query.toString();
4389
4390 Session session = null;
4391
4392 try {
4393 session = openSession();
4394
4395 Query q = session.createQuery(sql);
4396
4397 QueryPos qPos = QueryPos.getInstance(q);
4398
4399 qPos.add(companyId);
4400
4401 if (name != null) {
4402 qPos.add(name);
4403 }
4404
4405 count = (Long)q.uniqueResult();
4406 }
4407 catch (Exception e) {
4408 throw processException(e);
4409 }
4410 finally {
4411 if (count == null) {
4412 count = Long.valueOf(0);
4413 }
4414
4415 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, finderArgs,
4416 count);
4417
4418 closeSession(session);
4419 }
4420 }
4421
4422 return count.intValue();
4423 }
4424
4425
4433 public int countByT_S(int type, String subtype) throws SystemException {
4434 Object[] finderArgs = new Object[] { type, subtype };
4435
4436 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_T_S,
4437 finderArgs, this);
4438
4439 if (count == null) {
4440 StringBundler query = new StringBundler(3);
4441
4442 query.append(_SQL_COUNT_ROLE_WHERE);
4443
4444 query.append(_FINDER_COLUMN_T_S_TYPE_2);
4445
4446 if (subtype == null) {
4447 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
4448 }
4449 else {
4450 if (subtype.equals(StringPool.BLANK)) {
4451 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
4452 }
4453 else {
4454 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
4455 }
4456 }
4457
4458 String sql = query.toString();
4459
4460 Session session = null;
4461
4462 try {
4463 session = openSession();
4464
4465 Query q = session.createQuery(sql);
4466
4467 QueryPos qPos = QueryPos.getInstance(q);
4468
4469 qPos.add(type);
4470
4471 if (subtype != null) {
4472 qPos.add(subtype);
4473 }
4474
4475 count = (Long)q.uniqueResult();
4476 }
4477 catch (Exception e) {
4478 throw processException(e);
4479 }
4480 finally {
4481 if (count == null) {
4482 count = Long.valueOf(0);
4483 }
4484
4485 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_S, finderArgs,
4486 count);
4487
4488 closeSession(session);
4489 }
4490 }
4491
4492 return count.intValue();
4493 }
4494
4495
4503 public int filterCountByT_S(int type, String subtype)
4504 throws SystemException {
4505 if (!InlineSQLHelperUtil.isEnabled()) {
4506 return countByT_S(type, subtype);
4507 }
4508
4509 StringBundler query = new StringBundler(3);
4510
4511 query.append(_FILTER_SQL_COUNT_ROLE_WHERE);
4512
4513 query.append(_FINDER_COLUMN_T_S_TYPE_2);
4514
4515 if (subtype == null) {
4516 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
4517 }
4518 else {
4519 if (subtype.equals(StringPool.BLANK)) {
4520 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
4521 }
4522 else {
4523 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
4524 }
4525 }
4526
4527 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4528 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4529
4530 Session session = null;
4531
4532 try {
4533 session = openSession();
4534
4535 SQLQuery q = session.createSQLQuery(sql);
4536
4537 q.addScalar(COUNT_COLUMN_NAME,
4538 com.liferay.portal.kernel.dao.orm.Type.LONG);
4539
4540 QueryPos qPos = QueryPos.getInstance(q);
4541
4542 qPos.add(type);
4543
4544 if (subtype != null) {
4545 qPos.add(subtype);
4546 }
4547
4548 Long count = (Long)q.uniqueResult();
4549
4550 return count.intValue();
4551 }
4552 catch (Exception e) {
4553 throw processException(e);
4554 }
4555 finally {
4556 closeSession(session);
4557 }
4558 }
4559
4560
4569 public int countByC_C_C(long companyId, long classNameId, long classPK)
4570 throws SystemException {
4571 Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
4572
4573 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_C,
4574 finderArgs, this);
4575
4576 if (count == null) {
4577 StringBundler query = new StringBundler(4);
4578
4579 query.append(_SQL_COUNT_ROLE_WHERE);
4580
4581 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
4582
4583 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
4584
4585 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
4586
4587 String sql = query.toString();
4588
4589 Session session = null;
4590
4591 try {
4592 session = openSession();
4593
4594 Query q = session.createQuery(sql);
4595
4596 QueryPos qPos = QueryPos.getInstance(q);
4597
4598 qPos.add(companyId);
4599
4600 qPos.add(classNameId);
4601
4602 qPos.add(classPK);
4603
4604 count = (Long)q.uniqueResult();
4605 }
4606 catch (Exception e) {
4607 throw processException(e);
4608 }
4609 finally {
4610 if (count == null) {
4611 count = Long.valueOf(0);
4612 }
4613
4614 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C,
4615 finderArgs, count);
4616
4617 closeSession(session);
4618 }
4619 }
4620
4621 return count.intValue();
4622 }
4623
4624
4630 public int countAll() throws SystemException {
4631 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4632 FINDER_ARGS_EMPTY, this);
4633
4634 if (count == null) {
4635 Session session = null;
4636
4637 try {
4638 session = openSession();
4639
4640 Query q = session.createQuery(_SQL_COUNT_ROLE);
4641
4642 count = (Long)q.uniqueResult();
4643 }
4644 catch (Exception e) {
4645 throw processException(e);
4646 }
4647 finally {
4648 if (count == null) {
4649 count = Long.valueOf(0);
4650 }
4651
4652 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
4653 FINDER_ARGS_EMPTY, count);
4654
4655 closeSession(session);
4656 }
4657 }
4658
4659 return count.intValue();
4660 }
4661
4662
4669 public List<com.liferay.portal.model.Group> getGroups(long pk)
4670 throws SystemException {
4671 return getGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
4672 }
4673
4674
4687 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
4688 int end) throws SystemException {
4689 return getGroups(pk, start, end, null);
4690 }
4691
4692 public static final FinderPath FINDER_PATH_GET_GROUPS = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
4693 RoleModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES,
4694 com.liferay.portal.model.impl.GroupImpl.class,
4695 RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "getGroups",
4696 new String[] {
4697 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
4698 "com.liferay.portal.kernel.util.OrderByComparator"
4699 });
4700
4701
4715 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
4716 int end, OrderByComparator orderByComparator) throws SystemException {
4717 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
4718
4719 List<com.liferay.portal.model.Group> list = (List<com.liferay.portal.model.Group>)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS,
4720 finderArgs, this);
4721
4722 if (list == null) {
4723 Session session = null;
4724
4725 try {
4726 session = openSession();
4727
4728 String sql = null;
4729
4730 if (orderByComparator != null) {
4731 sql = _SQL_GETGROUPS.concat(ORDER_BY_CLAUSE)
4732 .concat(orderByComparator.getOrderBy());
4733 }
4734 else {
4735 sql = _SQL_GETGROUPS.concat(com.liferay.portal.model.impl.GroupModelImpl.ORDER_BY_SQL);
4736 }
4737
4738 SQLQuery q = session.createSQLQuery(sql);
4739
4740 q.addEntity("Group_",
4741 com.liferay.portal.model.impl.GroupImpl.class);
4742
4743 QueryPos qPos = QueryPos.getInstance(q);
4744
4745 qPos.add(pk);
4746
4747 list = (List<com.liferay.portal.model.Group>)QueryUtil.list(q,
4748 getDialect(), start, end);
4749 }
4750 catch (Exception e) {
4751 throw processException(e);
4752 }
4753 finally {
4754 if (list == null) {
4755 FinderCacheUtil.removeResult(FINDER_PATH_GET_GROUPS,
4756 finderArgs);
4757 }
4758 else {
4759 groupPersistence.cacheResult(list);
4760
4761 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS,
4762 finderArgs, list);
4763 }
4764
4765 closeSession(session);
4766 }
4767 }
4768
4769 return list;
4770 }
4771
4772 public static final FinderPath FINDER_PATH_GET_GROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
4773 RoleModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES, Long.class,
4774 RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "getGroupsSize",
4775 new String[] { Long.class.getName() });
4776
4777
4784 public int getGroupsSize(long pk) throws SystemException {
4785 Object[] finderArgs = new Object[] { pk };
4786
4787 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS_SIZE,
4788 finderArgs, this);
4789
4790 if (count == null) {
4791 Session session = null;
4792
4793 try {
4794 session = openSession();
4795
4796 SQLQuery q = session.createSQLQuery(_SQL_GETGROUPSSIZE);
4797
4798 q.addScalar(COUNT_COLUMN_NAME,
4799 com.liferay.portal.kernel.dao.orm.Type.LONG);
4800
4801 QueryPos qPos = QueryPos.getInstance(q);
4802
4803 qPos.add(pk);
4804
4805 count = (Long)q.uniqueResult();
4806 }
4807 catch (Exception e) {
4808 throw processException(e);
4809 }
4810 finally {
4811 if (count == null) {
4812 count = Long.valueOf(0);
4813 }
4814
4815 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS_SIZE,
4816 finderArgs, count);
4817
4818 closeSession(session);
4819 }
4820 }
4821
4822 return count.intValue();
4823 }
4824
4825 public static final FinderPath FINDER_PATH_CONTAINS_GROUP = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
4826 RoleModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES, Boolean.class,
4827 RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "containsGroup",
4828 new String[] { Long.class.getName(), Long.class.getName() });
4829
4830
4838 public boolean containsGroup(long pk, long groupPK)
4839 throws SystemException {
4840 Object[] finderArgs = new Object[] { pk, groupPK };
4841
4842 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_GROUP,
4843 finderArgs, this);
4844
4845 if (value == null) {
4846 try {
4847 value = Boolean.valueOf(containsGroup.contains(pk, groupPK));
4848 }
4849 catch (Exception e) {
4850 throw processException(e);
4851 }
4852 finally {
4853 if (value == null) {
4854 value = Boolean.FALSE;
4855 }
4856
4857 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_GROUP,
4858 finderArgs, value);
4859 }
4860 }
4861
4862 return value.booleanValue();
4863 }
4864
4865
4872 public boolean containsGroups(long pk) throws SystemException {
4873 if (getGroupsSize(pk) > 0) {
4874 return true;
4875 }
4876 else {
4877 return false;
4878 }
4879 }
4880
4881
4888 public void addGroup(long pk, long groupPK) throws SystemException {
4889 try {
4890 addGroup.add(pk, groupPK);
4891 }
4892 catch (Exception e) {
4893 throw processException(e);
4894 }
4895 finally {
4896 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4897 }
4898 }
4899
4900
4907 public void addGroup(long pk, com.liferay.portal.model.Group group)
4908 throws SystemException {
4909 try {
4910 addGroup.add(pk, group.getPrimaryKey());
4911 }
4912 catch (Exception e) {
4913 throw processException(e);
4914 }
4915 finally {
4916 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4917 }
4918 }
4919
4920
4927 public void addGroups(long pk, long[] groupPKs) throws SystemException {
4928 try {
4929 for (long groupPK : groupPKs) {
4930 addGroup.add(pk, groupPK);
4931 }
4932 }
4933 catch (Exception e) {
4934 throw processException(e);
4935 }
4936 finally {
4937 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4938 }
4939 }
4940
4941
4948 public void addGroups(long pk, List<com.liferay.portal.model.Group> groups)
4949 throws SystemException {
4950 try {
4951 for (com.liferay.portal.model.Group group : groups) {
4952 addGroup.add(pk, group.getPrimaryKey());
4953 }
4954 }
4955 catch (Exception e) {
4956 throw processException(e);
4957 }
4958 finally {
4959 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4960 }
4961 }
4962
4963
4969 public void clearGroups(long pk) throws SystemException {
4970 try {
4971 clearGroups.clear(pk);
4972 }
4973 catch (Exception e) {
4974 throw processException(e);
4975 }
4976 finally {
4977 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4978 }
4979 }
4980
4981
4988 public void removeGroup(long pk, long groupPK) throws SystemException {
4989 try {
4990 removeGroup.remove(pk, groupPK);
4991 }
4992 catch (Exception e) {
4993 throw processException(e);
4994 }
4995 finally {
4996 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4997 }
4998 }
4999
5000
5007 public void removeGroup(long pk, com.liferay.portal.model.Group group)
5008 throws SystemException {
5009 try {
5010 removeGroup.remove(pk, group.getPrimaryKey());
5011 }
5012 catch (Exception e) {
5013 throw processException(e);
5014 }
5015 finally {
5016 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5017 }
5018 }
5019
5020
5027 public void removeGroups(long pk, long[] groupPKs)
5028 throws SystemException {
5029 try {
5030 for (long groupPK : groupPKs) {
5031 removeGroup.remove(pk, groupPK);
5032 }
5033 }
5034 catch (Exception e) {
5035 throw processException(e);
5036 }
5037 finally {
5038 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5039 }
5040 }
5041
5042
5049 public void removeGroups(long pk,
5050 List<com.liferay.portal.model.Group> groups) throws SystemException {
5051 try {
5052 for (com.liferay.portal.model.Group group : groups) {
5053 removeGroup.remove(pk, group.getPrimaryKey());
5054 }
5055 }
5056 catch (Exception e) {
5057 throw processException(e);
5058 }
5059 finally {
5060 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5061 }
5062 }
5063
5064
5071 public void setGroups(long pk, long[] groupPKs) throws SystemException {
5072 try {
5073 Set<Long> groupPKSet = SetUtil.fromArray(groupPKs);
5074
5075 List<com.liferay.portal.model.Group> groups = getGroups(pk);
5076
5077 for (com.liferay.portal.model.Group group : groups) {
5078 if (!groupPKSet.remove(group.getPrimaryKey())) {
5079 removeGroup.remove(pk, group.getPrimaryKey());
5080 }
5081 }
5082
5083 for (Long groupPK : groupPKSet) {
5084 addGroup.add(pk, groupPK);
5085 }
5086 }
5087 catch (Exception e) {
5088 throw processException(e);
5089 }
5090 finally {
5091 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5092 }
5093 }
5094
5095
5102 public void setGroups(long pk, List<com.liferay.portal.model.Group> groups)
5103 throws SystemException {
5104 try {
5105 long[] groupPKs = new long[groups.size()];
5106
5107 for (int i = 0; i < groups.size(); i++) {
5108 com.liferay.portal.model.Group group = groups.get(i);
5109
5110 groupPKs[i] = group.getPrimaryKey();
5111 }
5112
5113 setGroups(pk, groupPKs);
5114 }
5115 catch (Exception e) {
5116 throw processException(e);
5117 }
5118 finally {
5119 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5120 }
5121 }
5122
5123
5130 public List<com.liferay.portal.model.Permission> getPermissions(long pk)
5131 throws SystemException {
5132 return getPermissions(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
5133 }
5134
5135
5148 public List<com.liferay.portal.model.Permission> getPermissions(long pk,
5149 int start, int end) throws SystemException {
5150 return getPermissions(pk, start, end, null);
5151 }
5152
5153 public static final FinderPath FINDER_PATH_GET_PERMISSIONS = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
5154 RoleModelImpl.FINDER_CACHE_ENABLED_ROLES_PERMISSIONS,
5155 com.liferay.portal.model.impl.PermissionImpl.class,
5156 RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME,
5157 "getPermissions",
5158 new String[] {
5159 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
5160 "com.liferay.portal.kernel.util.OrderByComparator"
5161 });
5162
5163
5177 public List<com.liferay.portal.model.Permission> getPermissions(long pk,
5178 int start, int end, OrderByComparator orderByComparator)
5179 throws SystemException {
5180 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
5181
5182 List<com.liferay.portal.model.Permission> list = (List<com.liferay.portal.model.Permission>)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS,
5183 finderArgs, this);
5184
5185 if (list == null) {
5186 Session session = null;
5187
5188 try {
5189 session = openSession();
5190
5191 String sql = null;
5192
5193 if (orderByComparator != null) {
5194 sql = _SQL_GETPERMISSIONS.concat(ORDER_BY_CLAUSE)
5195 .concat(orderByComparator.getOrderBy());
5196 }
5197 else {
5198 sql = _SQL_GETPERMISSIONS;
5199 }
5200
5201 SQLQuery q = session.createSQLQuery(sql);
5202
5203 q.addEntity("Permission_",
5204 com.liferay.portal.model.impl.PermissionImpl.class);
5205
5206 QueryPos qPos = QueryPos.getInstance(q);
5207
5208 qPos.add(pk);
5209
5210 list = (List<com.liferay.portal.model.Permission>)QueryUtil.list(q,
5211 getDialect(), start, end);
5212 }
5213 catch (Exception e) {
5214 throw processException(e);
5215 }
5216 finally {
5217 if (list == null) {
5218 FinderCacheUtil.removeResult(FINDER_PATH_GET_PERMISSIONS,
5219 finderArgs);
5220 }
5221 else {
5222 permissionPersistence.cacheResult(list);
5223
5224 FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS,
5225 finderArgs, list);
5226 }
5227
5228 closeSession(session);
5229 }
5230 }
5231
5232 return list;
5233 }
5234
5235 public static final FinderPath FINDER_PATH_GET_PERMISSIONS_SIZE = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
5236 RoleModelImpl.FINDER_CACHE_ENABLED_ROLES_PERMISSIONS, Long.class,
5237 RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME,
5238 "getPermissionsSize", new String[] { Long.class.getName() });
5239
5240
5247 public int getPermissionsSize(long pk) throws SystemException {
5248 Object[] finderArgs = new Object[] { pk };
5249
5250 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
5251 finderArgs, this);
5252
5253 if (count == null) {
5254 Session session = null;
5255
5256 try {
5257 session = openSession();
5258
5259 SQLQuery q = session.createSQLQuery(_SQL_GETPERMISSIONSSIZE);
5260
5261 q.addScalar(COUNT_COLUMN_NAME,
5262 com.liferay.portal.kernel.dao.orm.Type.LONG);
5263
5264 QueryPos qPos = QueryPos.getInstance(q);
5265
5266 qPos.add(pk);
5267
5268 count = (Long)q.uniqueResult();
5269 }
5270 catch (Exception e) {
5271 throw processException(e);
5272 }
5273 finally {
5274 if (count == null) {
5275 count = Long.valueOf(0);
5276 }
5277
5278 FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
5279 finderArgs, count);
5280
5281 closeSession(session);
5282 }
5283 }
5284
5285 return count.intValue();
5286 }
5287
5288 public static final FinderPath FINDER_PATH_CONTAINS_PERMISSION = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
5289 RoleModelImpl.FINDER_CACHE_ENABLED_ROLES_PERMISSIONS,
5290 Boolean.class, RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME,
5291 "containsPermission",
5292 new String[] { Long.class.getName(), Long.class.getName() });
5293
5294
5302 public boolean containsPermission(long pk, long permissionPK)
5303 throws SystemException {
5304 Object[] finderArgs = new Object[] { pk, permissionPK };
5305
5306 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_PERMISSION,
5307 finderArgs, this);
5308
5309 if (value == null) {
5310 try {
5311 value = Boolean.valueOf(containsPermission.contains(pk,
5312 permissionPK));
5313 }
5314 catch (Exception e) {
5315 throw processException(e);
5316 }
5317 finally {
5318 if (value == null) {
5319 value = Boolean.FALSE;
5320 }
5321
5322 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_PERMISSION,
5323 finderArgs, value);
5324 }
5325 }
5326
5327 return value.booleanValue();
5328 }
5329
5330
5337 public boolean containsPermissions(long pk) throws SystemException {
5338 if (getPermissionsSize(pk) > 0) {
5339 return true;
5340 }
5341 else {
5342 return false;
5343 }
5344 }
5345
5346
5353 public void addPermission(long pk, long permissionPK)
5354 throws SystemException {
5355 try {
5356 addPermission.add(pk, permissionPK);
5357 }
5358 catch (Exception e) {
5359 throw processException(e);
5360 }
5361 finally {
5362 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5363 }
5364 }
5365
5366
5373 public void addPermission(long pk,
5374 com.liferay.portal.model.Permission permission)
5375 throws SystemException {
5376 try {
5377 addPermission.add(pk, permission.getPrimaryKey());
5378 }
5379 catch (Exception e) {
5380 throw processException(e);
5381 }
5382 finally {
5383 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5384 }
5385 }
5386
5387
5394 public void addPermissions(long pk, long[] permissionPKs)
5395 throws SystemException {
5396 try {
5397 for (long permissionPK : permissionPKs) {
5398 addPermission.add(pk, permissionPK);
5399 }
5400 }
5401 catch (Exception e) {
5402 throw processException(e);
5403 }
5404 finally {
5405 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5406 }
5407 }
5408
5409
5416 public void addPermissions(long pk,
5417 List<com.liferay.portal.model.Permission> permissions)
5418 throws SystemException {
5419 try {
5420 for (com.liferay.portal.model.Permission permission : permissions) {
5421 addPermission.add(pk, permission.getPrimaryKey());
5422 }
5423 }
5424 catch (Exception e) {
5425 throw processException(e);
5426 }
5427 finally {
5428 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5429 }
5430 }
5431
5432
5438 public void clearPermissions(long pk) throws SystemException {
5439 try {
5440 clearPermissions.clear(pk);
5441 }
5442 catch (Exception e) {
5443 throw processException(e);
5444 }
5445 finally {
5446 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5447 }
5448 }
5449
5450
5457 public void removePermission(long pk, long permissionPK)
5458 throws SystemException {
5459 try {
5460 removePermission.remove(pk, permissionPK);
5461 }
5462 catch (Exception e) {
5463 throw processException(e);
5464 }
5465 finally {
5466 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5467 }
5468 }
5469
5470
5477 public void removePermission(long pk,
5478 com.liferay.portal.model.Permission permission)
5479 throws SystemException {
5480 try {
5481 removePermission.remove(pk, permission.getPrimaryKey());
5482 }
5483 catch (Exception e) {
5484 throw processException(e);
5485 }
5486 finally {
5487 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5488 }
5489 }
5490
5491
5498 public void removePermissions(long pk, long[] permissionPKs)
5499 throws SystemException {
5500 try {
5501 for (long permissionPK : permissionPKs) {
5502 removePermission.remove(pk, permissionPK);
5503 }
5504 }
5505 catch (Exception e) {
5506 throw processException(e);
5507 }
5508 finally {
5509 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5510 }
5511 }
5512
5513
5520 public void removePermissions(long pk,
5521 List<com.liferay.portal.model.Permission> permissions)
5522 throws SystemException {
5523 try {
5524 for (com.liferay.portal.model.Permission permission : permissions) {
5525 removePermission.remove(pk, permission.getPrimaryKey());
5526 }
5527 }
5528 catch (Exception e) {
5529 throw processException(e);
5530 }
5531 finally {
5532 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5533 }
5534 }
5535
5536
5543 public void setPermissions(long pk, long[] permissionPKs)
5544 throws SystemException {
5545 try {
5546 Set<Long> permissionPKSet = SetUtil.fromArray(permissionPKs);
5547
5548 List<com.liferay.portal.model.Permission> permissions = getPermissions(pk);
5549
5550 for (com.liferay.portal.model.Permission permission : permissions) {
5551 if (!permissionPKSet.remove(permission.getPrimaryKey())) {
5552 removePermission.remove(pk, permission.getPrimaryKey());
5553 }
5554 }
5555
5556 for (Long permissionPK : permissionPKSet) {
5557 addPermission.add(pk, permissionPK);
5558 }
5559 }
5560 catch (Exception e) {
5561 throw processException(e);
5562 }
5563 finally {
5564 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5565 }
5566 }
5567
5568
5575 public void setPermissions(long pk,
5576 List<com.liferay.portal.model.Permission> permissions)
5577 throws SystemException {
5578 try {
5579 long[] permissionPKs = new long[permissions.size()];
5580
5581 for (int i = 0; i < permissions.size(); i++) {
5582 com.liferay.portal.model.Permission permission = permissions.get(i);
5583
5584 permissionPKs[i] = permission.getPrimaryKey();
5585 }
5586
5587 setPermissions(pk, permissionPKs);
5588 }
5589 catch (Exception e) {
5590 throw processException(e);
5591 }
5592 finally {
5593 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5594 }
5595 }
5596
5597
5604 public List<com.liferay.portal.model.User> getUsers(long pk)
5605 throws SystemException {
5606 return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
5607 }
5608
5609
5622 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
5623 int end) throws SystemException {
5624 return getUsers(pk, start, end, null);
5625 }
5626
5627 public static final FinderPath FINDER_PATH_GET_USERS = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
5628 RoleModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES,
5629 com.liferay.portal.model.impl.UserImpl.class,
5630 RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "getUsers",
5631 new String[] {
5632 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
5633 "com.liferay.portal.kernel.util.OrderByComparator"
5634 });
5635
5636
5650 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
5651 int end, OrderByComparator orderByComparator) throws SystemException {
5652 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
5653
5654 List<com.liferay.portal.model.User> list = (List<com.liferay.portal.model.User>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS,
5655 finderArgs, this);
5656
5657 if (list == null) {
5658 Session session = null;
5659
5660 try {
5661 session = openSession();
5662
5663 String sql = null;
5664
5665 if (orderByComparator != null) {
5666 sql = _SQL_GETUSERS.concat(ORDER_BY_CLAUSE)
5667 .concat(orderByComparator.getOrderBy());
5668 }
5669 else {
5670 sql = _SQL_GETUSERS;
5671 }
5672
5673 SQLQuery q = session.createSQLQuery(sql);
5674
5675 q.addEntity("User_",
5676 com.liferay.portal.model.impl.UserImpl.class);
5677
5678 QueryPos qPos = QueryPos.getInstance(q);
5679
5680 qPos.add(pk);
5681
5682 list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
5683 getDialect(), start, end);
5684 }
5685 catch (Exception e) {
5686 throw processException(e);
5687 }
5688 finally {
5689 if (list == null) {
5690 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERS,
5691 finderArgs);
5692 }
5693 else {
5694 userPersistence.cacheResult(list);
5695
5696 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS,
5697 finderArgs, list);
5698 }
5699
5700 closeSession(session);
5701 }
5702 }
5703
5704 return list;
5705 }
5706
5707 public static final FinderPath FINDER_PATH_GET_USERS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
5708 RoleModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES, Long.class,
5709 RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "getUsersSize",
5710 new String[] { Long.class.getName() });
5711
5712
5719 public int getUsersSize(long pk) throws SystemException {
5720 Object[] finderArgs = new Object[] { pk };
5721
5722 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS_SIZE,
5723 finderArgs, this);
5724
5725 if (count == null) {
5726 Session session = null;
5727
5728 try {
5729 session = openSession();
5730
5731 SQLQuery q = session.createSQLQuery(_SQL_GETUSERSSIZE);
5732
5733 q.addScalar(COUNT_COLUMN_NAME,
5734 com.liferay.portal.kernel.dao.orm.Type.LONG);
5735
5736 QueryPos qPos = QueryPos.getInstance(q);
5737
5738 qPos.add(pk);
5739
5740 count = (Long)q.uniqueResult();
5741 }
5742 catch (Exception e) {
5743 throw processException(e);
5744 }
5745 finally {
5746 if (count == null) {
5747 count = Long.valueOf(0);
5748 }
5749
5750 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS_SIZE,
5751 finderArgs, count);
5752
5753 closeSession(session);
5754 }
5755 }
5756
5757 return count.intValue();
5758 }
5759
5760 public static final FinderPath FINDER_PATH_CONTAINS_USER = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
5761 RoleModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES, Boolean.class,
5762 RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "containsUser",
5763 new String[] { Long.class.getName(), Long.class.getName() });
5764
5765
5773 public boolean containsUser(long pk, long userPK) throws SystemException {
5774 Object[] finderArgs = new Object[] { pk, userPK };
5775
5776 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USER,
5777 finderArgs, this);
5778
5779 if (value == null) {
5780 try {
5781 value = Boolean.valueOf(containsUser.contains(pk, userPK));
5782 }
5783 catch (Exception e) {
5784 throw processException(e);
5785 }
5786 finally {
5787 if (value == null) {
5788 value = Boolean.FALSE;
5789 }
5790
5791 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USER,
5792 finderArgs, value);
5793 }
5794 }
5795
5796 return value.booleanValue();
5797 }
5798
5799
5806 public boolean containsUsers(long pk) throws SystemException {
5807 if (getUsersSize(pk) > 0) {
5808 return true;
5809 }
5810 else {
5811 return false;
5812 }
5813 }
5814
5815
5822 public void addUser(long pk, long userPK) throws SystemException {
5823 try {
5824 addUser.add(pk, userPK);
5825 }
5826 catch (Exception e) {
5827 throw processException(e);
5828 }
5829 finally {
5830 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
5831 }
5832 }
5833
5834
5841 public void addUser(long pk, com.liferay.portal.model.User user)
5842 throws SystemException {
5843 try {
5844 addUser.add(pk, user.getPrimaryKey());
5845 }
5846 catch (Exception e) {
5847 throw processException(e);
5848 }
5849 finally {
5850 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
5851 }
5852 }
5853
5854
5861 public void addUsers(long pk, long[] userPKs) throws SystemException {
5862 try {
5863 for (long userPK : userPKs) {
5864 addUser.add(pk, userPK);
5865 }
5866 }
5867 catch (Exception e) {
5868 throw processException(e);
5869 }
5870 finally {
5871 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
5872 }
5873 }
5874
5875
5882 public void addUsers(long pk, List<com.liferay.portal.model.User> users)
5883 throws SystemException {
5884 try {
5885 for (com.liferay.portal.model.User user : users) {
5886 addUser.add(pk, user.getPrimaryKey());
5887 }
5888 }
5889 catch (Exception e) {
5890 throw processException(e);
5891 }
5892 finally {
5893 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
5894 }
5895 }
5896
5897
5903 public void clearUsers(long pk) throws SystemException {
5904 try {
5905 clearUsers.clear(pk);
5906 }
5907 catch (Exception e) {
5908 throw processException(e);
5909 }
5910 finally {
5911 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
5912 }
5913 }
5914
5915
5922 public void removeUser(long pk, long userPK) throws SystemException {
5923 try {
5924 removeUser.remove(pk, userPK);
5925 }
5926 catch (Exception e) {
5927 throw processException(e);
5928 }
5929 finally {
5930 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
5931 }
5932 }
5933
5934
5941 public void removeUser(long pk, com.liferay.portal.model.User user)
5942 throws SystemException {
5943 try {
5944 removeUser.remove(pk, user.getPrimaryKey());
5945 }
5946 catch (Exception e) {
5947 throw processException(e);
5948 }
5949 finally {
5950 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
5951 }
5952 }
5953
5954
5961 public void removeUsers(long pk, long[] userPKs) throws SystemException {
5962 try {
5963 for (long userPK : userPKs) {
5964 removeUser.remove(pk, userPK);
5965 }
5966 }
5967 catch (Exception e) {
5968 throw processException(e);
5969 }
5970 finally {
5971 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
5972 }
5973 }
5974
5975
5982 public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
5983 throws SystemException {
5984 try {
5985 for (com.liferay.portal.model.User user : users) {
5986 removeUser.remove(pk, user.getPrimaryKey());
5987 }
5988 }
5989 catch (Exception e) {
5990 throw processException(e);
5991 }
5992 finally {
5993 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
5994 }
5995 }
5996
5997
6004 public void setUsers(long pk, long[] userPKs) throws SystemException {
6005 try {
6006 Set<Long> userPKSet = SetUtil.fromArray(userPKs);
6007
6008 List<com.liferay.portal.model.User> users = getUsers(pk);
6009
6010 for (com.liferay.portal.model.User user : users) {
6011 if (!userPKSet.remove(user.getPrimaryKey())) {
6012 removeUser.remove(pk, user.getPrimaryKey());
6013 }
6014 }
6015
6016 for (Long userPK : userPKSet) {
6017 addUser.add(pk, userPK);
6018 }
6019 }
6020 catch (Exception e) {
6021 throw processException(e);
6022 }
6023 finally {
6024 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6025 }
6026 }
6027
6028
6035 public void setUsers(long pk, List<com.liferay.portal.model.User> users)
6036 throws SystemException {
6037 try {
6038 long[] userPKs = new long[users.size()];
6039
6040 for (int i = 0; i < users.size(); i++) {
6041 com.liferay.portal.model.User user = users.get(i);
6042
6043 userPKs[i] = user.getPrimaryKey();
6044 }
6045
6046 setUsers(pk, userPKs);
6047 }
6048 catch (Exception e) {
6049 throw processException(e);
6050 }
6051 finally {
6052 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6053 }
6054 }
6055
6056
6059 public void afterPropertiesSet() {
6060 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
6061 com.liferay.portal.util.PropsUtil.get(
6062 "value.object.listener.com.liferay.portal.model.Role")));
6063
6064 if (listenerClassNames.length > 0) {
6065 try {
6066 List<ModelListener<Role>> listenersList = new ArrayList<ModelListener<Role>>();
6067
6068 for (String listenerClassName : listenerClassNames) {
6069 listenersList.add((ModelListener<Role>)InstanceFactory.newInstance(
6070 listenerClassName));
6071 }
6072
6073 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
6074 }
6075 catch (Exception e) {
6076 _log.error(e);
6077 }
6078 }
6079
6080 containsGroup = new ContainsGroup(this);
6081
6082 addGroup = new AddGroup(this);
6083 clearGroups = new ClearGroups(this);
6084 removeGroup = new RemoveGroup(this);
6085
6086 containsPermission = new ContainsPermission(this);
6087
6088 addPermission = new AddPermission(this);
6089 clearPermissions = new ClearPermissions(this);
6090 removePermission = new RemovePermission(this);
6091
6092 containsUser = new ContainsUser(this);
6093
6094 addUser = new AddUser(this);
6095 clearUsers = new ClearUsers(this);
6096 removeUser = new RemoveUser(this);
6097 }
6098
6099 public void destroy() {
6100 EntityCacheUtil.removeCache(RoleImpl.class.getName());
6101 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
6102 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6103 }
6104
6105 @BeanReference(type = AccountPersistence.class)
6106 protected AccountPersistence accountPersistence;
6107 @BeanReference(type = AddressPersistence.class)
6108 protected AddressPersistence addressPersistence;
6109 @BeanReference(type = BrowserTrackerPersistence.class)
6110 protected BrowserTrackerPersistence browserTrackerPersistence;
6111 @BeanReference(type = ClassNamePersistence.class)
6112 protected ClassNamePersistence classNamePersistence;
6113 @BeanReference(type = ClusterGroupPersistence.class)
6114 protected ClusterGroupPersistence clusterGroupPersistence;
6115 @BeanReference(type = CompanyPersistence.class)
6116 protected CompanyPersistence companyPersistence;
6117 @BeanReference(type = ContactPersistence.class)
6118 protected ContactPersistence contactPersistence;
6119 @BeanReference(type = CountryPersistence.class)
6120 protected CountryPersistence countryPersistence;
6121 @BeanReference(type = EmailAddressPersistence.class)
6122 protected EmailAddressPersistence emailAddressPersistence;
6123 @BeanReference(type = GroupPersistence.class)
6124 protected GroupPersistence groupPersistence;
6125 @BeanReference(type = ImagePersistence.class)
6126 protected ImagePersistence imagePersistence;
6127 @BeanReference(type = LayoutPersistence.class)
6128 protected LayoutPersistence layoutPersistence;
6129 @BeanReference(type = LayoutBranchPersistence.class)
6130 protected LayoutBranchPersistence layoutBranchPersistence;
6131 @BeanReference(type = LayoutPrototypePersistence.class)
6132 protected LayoutPrototypePersistence layoutPrototypePersistence;
6133 @BeanReference(type = LayoutRevisionPersistence.class)
6134 protected LayoutRevisionPersistence layoutRevisionPersistence;
6135 @BeanReference(type = LayoutSetPersistence.class)
6136 protected LayoutSetPersistence layoutSetPersistence;
6137 @BeanReference(type = LayoutSetBranchPersistence.class)
6138 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
6139 @BeanReference(type = LayoutSetPrototypePersistence.class)
6140 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
6141 @BeanReference(type = ListTypePersistence.class)
6142 protected ListTypePersistence listTypePersistence;
6143 @BeanReference(type = LockPersistence.class)
6144 protected LockPersistence lockPersistence;
6145 @BeanReference(type = MembershipRequestPersistence.class)
6146 protected MembershipRequestPersistence membershipRequestPersistence;
6147 @BeanReference(type = OrganizationPersistence.class)
6148 protected OrganizationPersistence organizationPersistence;
6149 @BeanReference(type = OrgGroupPermissionPersistence.class)
6150 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
6151 @BeanReference(type = OrgGroupRolePersistence.class)
6152 protected OrgGroupRolePersistence orgGroupRolePersistence;
6153 @BeanReference(type = OrgLaborPersistence.class)
6154 protected OrgLaborPersistence orgLaborPersistence;
6155 @BeanReference(type = PasswordPolicyPersistence.class)
6156 protected PasswordPolicyPersistence passwordPolicyPersistence;
6157 @BeanReference(type = PasswordPolicyRelPersistence.class)
6158 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
6159 @BeanReference(type = PasswordTrackerPersistence.class)
6160 protected PasswordTrackerPersistence passwordTrackerPersistence;
6161 @BeanReference(type = PermissionPersistence.class)
6162 protected PermissionPersistence permissionPersistence;
6163 @BeanReference(type = PhonePersistence.class)
6164 protected PhonePersistence phonePersistence;
6165 @BeanReference(type = PluginSettingPersistence.class)
6166 protected PluginSettingPersistence pluginSettingPersistence;
6167 @BeanReference(type = PortalPreferencesPersistence.class)
6168 protected PortalPreferencesPersistence portalPreferencesPersistence;
6169 @BeanReference(type = PortletPersistence.class)
6170 protected PortletPersistence portletPersistence;
6171 @BeanReference(type = PortletItemPersistence.class)
6172 protected PortletItemPersistence portletItemPersistence;
6173 @BeanReference(type = PortletPreferencesPersistence.class)
6174 protected PortletPreferencesPersistence portletPreferencesPersistence;
6175 @BeanReference(type = RegionPersistence.class)
6176 protected RegionPersistence regionPersistence;
6177 @BeanReference(type = ReleasePersistence.class)
6178 protected ReleasePersistence releasePersistence;
6179 @BeanReference(type = RepositoryPersistence.class)
6180 protected RepositoryPersistence repositoryPersistence;
6181 @BeanReference(type = RepositoryEntryPersistence.class)
6182 protected RepositoryEntryPersistence repositoryEntryPersistence;
6183 @BeanReference(type = ResourcePersistence.class)
6184 protected ResourcePersistence resourcePersistence;
6185 @BeanReference(type = ResourceActionPersistence.class)
6186 protected ResourceActionPersistence resourceActionPersistence;
6187 @BeanReference(type = ResourceBlockPersistence.class)
6188 protected ResourceBlockPersistence resourceBlockPersistence;
6189 @BeanReference(type = ResourceBlockPermissionPersistence.class)
6190 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
6191 @BeanReference(type = ResourceCodePersistence.class)
6192 protected ResourceCodePersistence resourceCodePersistence;
6193 @BeanReference(type = ResourcePermissionPersistence.class)
6194 protected ResourcePermissionPersistence resourcePermissionPersistence;
6195 @BeanReference(type = ResourceTypePermissionPersistence.class)
6196 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
6197 @BeanReference(type = RolePersistence.class)
6198 protected RolePersistence rolePersistence;
6199 @BeanReference(type = ServiceComponentPersistence.class)
6200 protected ServiceComponentPersistence serviceComponentPersistence;
6201 @BeanReference(type = ShardPersistence.class)
6202 protected ShardPersistence shardPersistence;
6203 @BeanReference(type = SubscriptionPersistence.class)
6204 protected SubscriptionPersistence subscriptionPersistence;
6205 @BeanReference(type = TeamPersistence.class)
6206 protected TeamPersistence teamPersistence;
6207 @BeanReference(type = TicketPersistence.class)
6208 protected TicketPersistence ticketPersistence;
6209 @BeanReference(type = UserPersistence.class)
6210 protected UserPersistence userPersistence;
6211 @BeanReference(type = UserGroupPersistence.class)
6212 protected UserGroupPersistence userGroupPersistence;
6213 @BeanReference(type = UserGroupGroupRolePersistence.class)
6214 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
6215 @BeanReference(type = UserGroupRolePersistence.class)
6216 protected UserGroupRolePersistence userGroupRolePersistence;
6217 @BeanReference(type = UserIdMapperPersistence.class)
6218 protected UserIdMapperPersistence userIdMapperPersistence;
6219 @BeanReference(type = UserNotificationEventPersistence.class)
6220 protected UserNotificationEventPersistence userNotificationEventPersistence;
6221 @BeanReference(type = UserTrackerPersistence.class)
6222 protected UserTrackerPersistence userTrackerPersistence;
6223 @BeanReference(type = UserTrackerPathPersistence.class)
6224 protected UserTrackerPathPersistence userTrackerPathPersistence;
6225 @BeanReference(type = VirtualHostPersistence.class)
6226 protected VirtualHostPersistence virtualHostPersistence;
6227 @BeanReference(type = WebDAVPropsPersistence.class)
6228 protected WebDAVPropsPersistence webDAVPropsPersistence;
6229 @BeanReference(type = WebsitePersistence.class)
6230 protected WebsitePersistence websitePersistence;
6231 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
6232 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
6233 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
6234 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
6235 protected ContainsGroup containsGroup;
6236 protected AddGroup addGroup;
6237 protected ClearGroups clearGroups;
6238 protected RemoveGroup removeGroup;
6239 protected ContainsPermission containsPermission;
6240 protected AddPermission addPermission;
6241 protected ClearPermissions clearPermissions;
6242 protected RemovePermission removePermission;
6243 protected ContainsUser containsUser;
6244 protected AddUser addUser;
6245 protected ClearUsers clearUsers;
6246 protected RemoveUser removeUser;
6247
6248 protected class ContainsGroup {
6249 protected ContainsGroup(RolePersistenceImpl persistenceImpl) {
6250 super();
6251
6252 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6253 _SQL_CONTAINSGROUP,
6254 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6255 RowMapper.COUNT);
6256 }
6257
6258 protected boolean contains(long roleId, long groupId) {
6259 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6260 new Long(roleId), new Long(groupId)
6261 });
6262
6263 if (results.size() > 0) {
6264 Integer count = results.get(0);
6265
6266 if (count.intValue() > 0) {
6267 return true;
6268 }
6269 }
6270
6271 return false;
6272 }
6273
6274 private MappingSqlQuery<Integer> _mappingSqlQuery;
6275 }
6276
6277 protected class AddGroup {
6278 protected AddGroup(RolePersistenceImpl persistenceImpl) {
6279 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6280 "INSERT INTO Groups_Roles (roleId, groupId) VALUES (?, ?)",
6281 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6282 _persistenceImpl = persistenceImpl;
6283 }
6284
6285 protected void add(long roleId, long groupId) throws SystemException {
6286 if (!_persistenceImpl.containsGroup.contains(roleId, groupId)) {
6287 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
6288
6289 for (ModelListener<Role> listener : listeners) {
6290 listener.onBeforeAddAssociation(roleId,
6291 com.liferay.portal.model.Group.class.getName(), groupId);
6292 }
6293
6294 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
6295 listener.onBeforeAddAssociation(groupId,
6296 Role.class.getName(), roleId);
6297 }
6298
6299 _sqlUpdate.update(new Object[] {
6300 new Long(roleId), new Long(groupId)
6301 });
6302
6303 for (ModelListener<Role> listener : listeners) {
6304 listener.onAfterAddAssociation(roleId,
6305 com.liferay.portal.model.Group.class.getName(), groupId);
6306 }
6307
6308 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
6309 listener.onAfterAddAssociation(groupId,
6310 Role.class.getName(), roleId);
6311 }
6312 }
6313 }
6314
6315 private SqlUpdate _sqlUpdate;
6316 private RolePersistenceImpl _persistenceImpl;
6317 }
6318
6319 protected class ClearGroups {
6320 protected ClearGroups(RolePersistenceImpl persistenceImpl) {
6321 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6322 "DELETE FROM Groups_Roles WHERE roleId = ?",
6323 new int[] { java.sql.Types.BIGINT });
6324 }
6325
6326 protected void clear(long roleId) throws SystemException {
6327 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
6328
6329 List<com.liferay.portal.model.Group> groups = null;
6330
6331 if ((listeners.length > 0) || (groupListeners.length > 0)) {
6332 groups = getGroups(roleId);
6333
6334 for (com.liferay.portal.model.Group group : groups) {
6335 for (ModelListener<Role> listener : listeners) {
6336 listener.onBeforeRemoveAssociation(roleId,
6337 com.liferay.portal.model.Group.class.getName(),
6338 group.getPrimaryKey());
6339 }
6340
6341 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
6342 listener.onBeforeRemoveAssociation(group.getPrimaryKey(),
6343 Role.class.getName(), roleId);
6344 }
6345 }
6346 }
6347
6348 _sqlUpdate.update(new Object[] { new Long(roleId) });
6349
6350 if ((listeners.length > 0) || (groupListeners.length > 0)) {
6351 for (com.liferay.portal.model.Group group : groups) {
6352 for (ModelListener<Role> listener : listeners) {
6353 listener.onAfterRemoveAssociation(roleId,
6354 com.liferay.portal.model.Group.class.getName(),
6355 group.getPrimaryKey());
6356 }
6357
6358 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
6359 listener.onAfterRemoveAssociation(group.getPrimaryKey(),
6360 Role.class.getName(), roleId);
6361 }
6362 }
6363 }
6364 }
6365
6366 private SqlUpdate _sqlUpdate;
6367 }
6368
6369 protected class RemoveGroup {
6370 protected RemoveGroup(RolePersistenceImpl persistenceImpl) {
6371 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6372 "DELETE FROM Groups_Roles WHERE roleId = ? AND groupId = ?",
6373 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6374 _persistenceImpl = persistenceImpl;
6375 }
6376
6377 protected void remove(long roleId, long groupId)
6378 throws SystemException {
6379 if (_persistenceImpl.containsGroup.contains(roleId, groupId)) {
6380 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
6381
6382 for (ModelListener<Role> listener : listeners) {
6383 listener.onBeforeRemoveAssociation(roleId,
6384 com.liferay.portal.model.Group.class.getName(), groupId);
6385 }
6386
6387 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
6388 listener.onBeforeRemoveAssociation(groupId,
6389 Role.class.getName(), roleId);
6390 }
6391
6392 _sqlUpdate.update(new Object[] {
6393 new Long(roleId), new Long(groupId)
6394 });
6395
6396 for (ModelListener<Role> listener : listeners) {
6397 listener.onAfterRemoveAssociation(roleId,
6398 com.liferay.portal.model.Group.class.getName(), groupId);
6399 }
6400
6401 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
6402 listener.onAfterRemoveAssociation(groupId,
6403 Role.class.getName(), roleId);
6404 }
6405 }
6406 }
6407
6408 private SqlUpdate _sqlUpdate;
6409 private RolePersistenceImpl _persistenceImpl;
6410 }
6411
6412 protected class ContainsPermission {
6413 protected ContainsPermission(RolePersistenceImpl persistenceImpl) {
6414 super();
6415
6416 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6417 _SQL_CONTAINSPERMISSION,
6418 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6419 RowMapper.COUNT);
6420 }
6421
6422 protected boolean contains(long roleId, long permissionId) {
6423 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6424 new Long(roleId), new Long(permissionId)
6425 });
6426
6427 if (results.size() > 0) {
6428 Integer count = results.get(0);
6429
6430 if (count.intValue() > 0) {
6431 return true;
6432 }
6433 }
6434
6435 return false;
6436 }
6437
6438 private MappingSqlQuery<Integer> _mappingSqlQuery;
6439 }
6440
6441 protected class AddPermission {
6442 protected AddPermission(RolePersistenceImpl persistenceImpl) {
6443 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6444 "INSERT INTO Roles_Permissions (roleId, permissionId) VALUES (?, ?)",
6445 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6446 _persistenceImpl = persistenceImpl;
6447 }
6448
6449 protected void add(long roleId, long permissionId)
6450 throws SystemException {
6451 if (!_persistenceImpl.containsPermission.contains(roleId,
6452 permissionId)) {
6453 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
6454 permissionPersistence.getListeners();
6455
6456 for (ModelListener<Role> listener : listeners) {
6457 listener.onBeforeAddAssociation(roleId,
6458 com.liferay.portal.model.Permission.class.getName(),
6459 permissionId);
6460 }
6461
6462 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6463 listener.onBeforeAddAssociation(permissionId,
6464 Role.class.getName(), roleId);
6465 }
6466
6467 _sqlUpdate.update(new Object[] {
6468 new Long(roleId), new Long(permissionId)
6469 });
6470
6471 for (ModelListener<Role> listener : listeners) {
6472 listener.onAfterAddAssociation(roleId,
6473 com.liferay.portal.model.Permission.class.getName(),
6474 permissionId);
6475 }
6476
6477 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6478 listener.onAfterAddAssociation(permissionId,
6479 Role.class.getName(), roleId);
6480 }
6481 }
6482 }
6483
6484 private SqlUpdate _sqlUpdate;
6485 private RolePersistenceImpl _persistenceImpl;
6486 }
6487
6488 protected class ClearPermissions {
6489 protected ClearPermissions(RolePersistenceImpl persistenceImpl) {
6490 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6491 "DELETE FROM Roles_Permissions WHERE roleId = ?",
6492 new int[] { java.sql.Types.BIGINT });
6493 }
6494
6495 protected void clear(long roleId) throws SystemException {
6496 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
6497 permissionPersistence.getListeners();
6498
6499 List<com.liferay.portal.model.Permission> permissions = null;
6500
6501 if ((listeners.length > 0) || (permissionListeners.length > 0)) {
6502 permissions = getPermissions(roleId);
6503
6504 for (com.liferay.portal.model.Permission permission : permissions) {
6505 for (ModelListener<Role> listener : listeners) {
6506 listener.onBeforeRemoveAssociation(roleId,
6507 com.liferay.portal.model.Permission.class.getName(),
6508 permission.getPrimaryKey());
6509 }
6510
6511 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6512 listener.onBeforeRemoveAssociation(permission.getPrimaryKey(),
6513 Role.class.getName(), roleId);
6514 }
6515 }
6516 }
6517
6518 _sqlUpdate.update(new Object[] { new Long(roleId) });
6519
6520 if ((listeners.length > 0) || (permissionListeners.length > 0)) {
6521 for (com.liferay.portal.model.Permission permission : permissions) {
6522 for (ModelListener<Role> listener : listeners) {
6523 listener.onAfterRemoveAssociation(roleId,
6524 com.liferay.portal.model.Permission.class.getName(),
6525 permission.getPrimaryKey());
6526 }
6527
6528 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6529 listener.onAfterRemoveAssociation(permission.getPrimaryKey(),
6530 Role.class.getName(), roleId);
6531 }
6532 }
6533 }
6534 }
6535
6536 private SqlUpdate _sqlUpdate;
6537 }
6538
6539 protected class RemovePermission {
6540 protected RemovePermission(RolePersistenceImpl persistenceImpl) {
6541 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6542 "DELETE FROM Roles_Permissions WHERE roleId = ? AND permissionId = ?",
6543 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6544 _persistenceImpl = persistenceImpl;
6545 }
6546
6547 protected void remove(long roleId, long permissionId)
6548 throws SystemException {
6549 if (_persistenceImpl.containsPermission.contains(roleId,
6550 permissionId)) {
6551 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
6552 permissionPersistence.getListeners();
6553
6554 for (ModelListener<Role> listener : listeners) {
6555 listener.onBeforeRemoveAssociation(roleId,
6556 com.liferay.portal.model.Permission.class.getName(),
6557 permissionId);
6558 }
6559
6560 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6561 listener.onBeforeRemoveAssociation(permissionId,
6562 Role.class.getName(), roleId);
6563 }
6564
6565 _sqlUpdate.update(new Object[] {
6566 new Long(roleId), new Long(permissionId)
6567 });
6568
6569 for (ModelListener<Role> listener : listeners) {
6570 listener.onAfterRemoveAssociation(roleId,
6571 com.liferay.portal.model.Permission.class.getName(),
6572 permissionId);
6573 }
6574
6575 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6576 listener.onAfterRemoveAssociation(permissionId,
6577 Role.class.getName(), roleId);
6578 }
6579 }
6580 }
6581
6582 private SqlUpdate _sqlUpdate;
6583 private RolePersistenceImpl _persistenceImpl;
6584 }
6585
6586 protected class ContainsUser {
6587 protected ContainsUser(RolePersistenceImpl persistenceImpl) {
6588 super();
6589
6590 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6591 _SQL_CONTAINSUSER,
6592 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6593 RowMapper.COUNT);
6594 }
6595
6596 protected boolean contains(long roleId, long userId) {
6597 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6598 new Long(roleId), new Long(userId)
6599 });
6600
6601 if (results.size() > 0) {
6602 Integer count = results.get(0);
6603
6604 if (count.intValue() > 0) {
6605 return true;
6606 }
6607 }
6608
6609 return false;
6610 }
6611
6612 private MappingSqlQuery<Integer> _mappingSqlQuery;
6613 }
6614
6615 protected class AddUser {
6616 protected AddUser(RolePersistenceImpl persistenceImpl) {
6617 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6618 "INSERT INTO Users_Roles (roleId, userId) VALUES (?, ?)",
6619 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6620 _persistenceImpl = persistenceImpl;
6621 }
6622
6623 protected void add(long roleId, long userId) throws SystemException {
6624 if (!_persistenceImpl.containsUser.contains(roleId, userId)) {
6625 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
6626
6627 for (ModelListener<Role> listener : listeners) {
6628 listener.onBeforeAddAssociation(roleId,
6629 com.liferay.portal.model.User.class.getName(), userId);
6630 }
6631
6632 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6633 listener.onBeforeAddAssociation(userId,
6634 Role.class.getName(), roleId);
6635 }
6636
6637 _sqlUpdate.update(new Object[] {
6638 new Long(roleId), new Long(userId)
6639 });
6640
6641 for (ModelListener<Role> listener : listeners) {
6642 listener.onAfterAddAssociation(roleId,
6643 com.liferay.portal.model.User.class.getName(), userId);
6644 }
6645
6646 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6647 listener.onAfterAddAssociation(userId,
6648 Role.class.getName(), roleId);
6649 }
6650 }
6651 }
6652
6653 private SqlUpdate _sqlUpdate;
6654 private RolePersistenceImpl _persistenceImpl;
6655 }
6656
6657 protected class ClearUsers {
6658 protected ClearUsers(RolePersistenceImpl persistenceImpl) {
6659 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6660 "DELETE FROM Users_Roles WHERE roleId = ?",
6661 new int[] { java.sql.Types.BIGINT });
6662 }
6663
6664 protected void clear(long roleId) throws SystemException {
6665 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
6666
6667 List<com.liferay.portal.model.User> users = null;
6668
6669 if ((listeners.length > 0) || (userListeners.length > 0)) {
6670 users = getUsers(roleId);
6671
6672 for (com.liferay.portal.model.User user : users) {
6673 for (ModelListener<Role> listener : listeners) {
6674 listener.onBeforeRemoveAssociation(roleId,
6675 com.liferay.portal.model.User.class.getName(),
6676 user.getPrimaryKey());
6677 }
6678
6679 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6680 listener.onBeforeRemoveAssociation(user.getPrimaryKey(),
6681 Role.class.getName(), roleId);
6682 }
6683 }
6684 }
6685
6686 _sqlUpdate.update(new Object[] { new Long(roleId) });
6687
6688 if ((listeners.length > 0) || (userListeners.length > 0)) {
6689 for (com.liferay.portal.model.User user : users) {
6690 for (ModelListener<Role> listener : listeners) {
6691 listener.onAfterRemoveAssociation(roleId,
6692 com.liferay.portal.model.User.class.getName(),
6693 user.getPrimaryKey());
6694 }
6695
6696 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6697 listener.onAfterRemoveAssociation(user.getPrimaryKey(),
6698 Role.class.getName(), roleId);
6699 }
6700 }
6701 }
6702 }
6703
6704 private SqlUpdate _sqlUpdate;
6705 }
6706
6707 protected class RemoveUser {
6708 protected RemoveUser(RolePersistenceImpl persistenceImpl) {
6709 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6710 "DELETE FROM Users_Roles WHERE roleId = ? AND userId = ?",
6711 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6712 _persistenceImpl = persistenceImpl;
6713 }
6714
6715 protected void remove(long roleId, long userId)
6716 throws SystemException {
6717 if (_persistenceImpl.containsUser.contains(roleId, userId)) {
6718 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
6719
6720 for (ModelListener<Role> listener : listeners) {
6721 listener.onBeforeRemoveAssociation(roleId,
6722 com.liferay.portal.model.User.class.getName(), userId);
6723 }
6724
6725 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6726 listener.onBeforeRemoveAssociation(userId,
6727 Role.class.getName(), roleId);
6728 }
6729
6730 _sqlUpdate.update(new Object[] {
6731 new Long(roleId), new Long(userId)
6732 });
6733
6734 for (ModelListener<Role> listener : listeners) {
6735 listener.onAfterRemoveAssociation(roleId,
6736 com.liferay.portal.model.User.class.getName(), userId);
6737 }
6738
6739 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6740 listener.onAfterRemoveAssociation(userId,
6741 Role.class.getName(), roleId);
6742 }
6743 }
6744 }
6745
6746 private SqlUpdate _sqlUpdate;
6747 private RolePersistenceImpl _persistenceImpl;
6748 }
6749
6750 private static final String _SQL_SELECT_ROLE = "SELECT role FROM Role role";
6751 private static final String _SQL_SELECT_ROLE_WHERE = "SELECT role FROM Role role WHERE ";
6752 private static final String _SQL_COUNT_ROLE = "SELECT COUNT(role) FROM Role role";
6753 private static final String _SQL_COUNT_ROLE_WHERE = "SELECT COUNT(role) FROM Role role WHERE ";
6754 private static final String _SQL_GETGROUPS = "SELECT {Group_.*} FROM Group_ INNER JOIN Groups_Roles ON (Groups_Roles.groupId = Group_.groupId) WHERE (Groups_Roles.roleId = ?)";
6755 private static final String _SQL_GETGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Roles WHERE roleId = ?";
6756 private static final String _SQL_CONTAINSGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Roles WHERE roleId = ? AND groupId = ?";
6757 private static final String _SQL_GETPERMISSIONS = "SELECT {Permission_.*} FROM Permission_ INNER JOIN Roles_Permissions ON (Roles_Permissions.permissionId = Permission_.permissionId) WHERE (Roles_Permissions.roleId = ?)";
6758 private static final String _SQL_GETPERMISSIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Roles_Permissions WHERE roleId = ?";
6759 private static final String _SQL_CONTAINSPERMISSION = "SELECT COUNT(*) AS COUNT_VALUE FROM Roles_Permissions WHERE roleId = ? AND permissionId = ?";
6760 private static final String _SQL_GETUSERS = "SELECT {User_.*} FROM User_ INNER JOIN Users_Roles ON (Users_Roles.userId = User_.userId) WHERE (Users_Roles.roleId = ?)";
6761 private static final String _SQL_GETUSERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Roles WHERE roleId = ?";
6762 private static final String _SQL_CONTAINSUSER = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Roles WHERE roleId = ? AND userId = ?";
6763 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "role.companyId = ?";
6764 private static final String _FINDER_COLUMN_NAME_NAME_1 = "role.name IS NULL";
6765 private static final String _FINDER_COLUMN_NAME_NAME_2 = "role.name = ?";
6766 private static final String _FINDER_COLUMN_NAME_NAME_3 = "(role.name IS NULL OR role.name = ?)";
6767 private static final String _FINDER_COLUMN_SUBTYPE_SUBTYPE_1 = "role.subtype IS NULL";
6768 private static final String _FINDER_COLUMN_SUBTYPE_SUBTYPE_2 = "role.subtype = ?";
6769 private static final String _FINDER_COLUMN_SUBTYPE_SUBTYPE_3 = "(role.subtype IS NULL OR role.subtype = ?)";
6770 private static final String _FINDER_COLUMN_C_N_COMPANYID_2 = "role.companyId = ? AND ";
6771 private static final String _FINDER_COLUMN_C_N_NAME_1 = "role.name IS NULL";
6772 private static final String _FINDER_COLUMN_C_N_NAME_2 = "lower(role.name) = lower(CAST_TEXT(?))";
6773 private static final String _FINDER_COLUMN_C_N_NAME_3 = "(role.name IS NULL OR lower(role.name) = lower(CAST_TEXT(?)))";
6774 private static final String _FINDER_COLUMN_T_S_TYPE_2 = "role.type = ? AND ";
6775 private static final String _FINDER_COLUMN_T_S_SUBTYPE_1 = "role.subtype IS NULL";
6776 private static final String _FINDER_COLUMN_T_S_SUBTYPE_2 = "role.subtype = ?";
6777 private static final String _FINDER_COLUMN_T_S_SUBTYPE_3 = "(role.subtype IS NULL OR role.subtype = ?)";
6778 private static final String _FINDER_COLUMN_C_C_C_COMPANYID_2 = "role.companyId = ? AND ";
6779 private static final String _FINDER_COLUMN_C_C_C_CLASSNAMEID_2 = "role.classNameId = ? AND ";
6780 private static final String _FINDER_COLUMN_C_C_C_CLASSPK_2 = "role.classPK = ?";
6781 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "role.roleId";
6782 private static final String _FILTER_SQL_SELECT_ROLE_WHERE = "SELECT DISTINCT {role.*} FROM Role_ role WHERE ";
6783 private static final String _FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1 =
6784 "SELECT {Role_.*} FROM (SELECT DISTINCT role.roleId FROM Role_ role WHERE ";
6785 private static final String _FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2 =
6786 ") TEMP_TABLE INNER JOIN Role_ ON TEMP_TABLE.roleId = Role_.roleId";
6787 private static final String _FILTER_SQL_COUNT_ROLE_WHERE = "SELECT COUNT(DISTINCT role.roleId) AS COUNT_VALUE FROM Role_ role WHERE ";
6788 private static final String _FILTER_ENTITY_ALIAS = "role";
6789 private static final String _FILTER_ENTITY_TABLE = "Role_";
6790 private static final String _ORDER_BY_ENTITY_ALIAS = "role.";
6791 private static final String _ORDER_BY_ENTITY_TABLE = "Role_.";
6792 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Role exists with the primary key ";
6793 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Role exists with the key {";
6794 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
6795 private static Log _log = LogFactoryUtil.getLog(RolePersistenceImpl.class);
6796 private static Role _nullRole = new RoleImpl() {
6797 @Override
6798 public Object clone() {
6799 return this;
6800 }
6801
6802 @Override
6803 public CacheModel<Role> toCacheModel() {
6804 return _nullRoleCacheModel;
6805 }
6806 };
6807
6808 private static CacheModel<Role> _nullRoleCacheModel = new CacheModel<Role>() {
6809 public Role toEntityModel() {
6810 return _nullRole;
6811 }
6812 };
6813 }