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.kernel.util.Validator;
045 import com.liferay.portal.model.CacheModel;
046 import com.liferay.portal.model.ModelListener;
047 import com.liferay.portal.model.Role;
048 import com.liferay.portal.model.impl.RoleImpl;
049 import com.liferay.portal.model.impl.RoleModelImpl;
050 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
051 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
052
053 import java.io.Serializable;
054
055 import java.util.ArrayList;
056 import java.util.Collections;
057 import java.util.List;
058 import java.util.Set;
059
060
072 public class RolePersistenceImpl extends BasePersistenceImpl<Role>
073 implements RolePersistence {
074
079 public static final String FINDER_CLASS_NAME_ENTITY = RoleImpl.class.getName();
080 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
081 ".List1";
082 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
083 ".List2";
084 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
085 new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
086 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
087 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
088 new String[] {
089 Long.class.getName(),
090
091 "java.lang.Integer", "java.lang.Integer",
092 "com.liferay.portal.kernel.util.OrderByComparator"
093 });
094 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
095 new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
096 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
097 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
098 new String[] { Long.class.getName() },
099 RoleModelImpl.COMPANYID_COLUMN_BITMASK);
100 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
101 RoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
102 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
103 new String[] { Long.class.getName() });
104 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_NAME = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
105 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
106 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByName",
107 new String[] {
108 String.class.getName(),
109
110 "java.lang.Integer", "java.lang.Integer",
111 "com.liferay.portal.kernel.util.OrderByComparator"
112 });
113 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NAME = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
114 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
115 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByName",
116 new String[] { String.class.getName() },
117 RoleModelImpl.NAME_COLUMN_BITMASK);
118 public static final FinderPath FINDER_PATH_COUNT_BY_NAME = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
119 RoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
120 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByName",
121 new String[] { String.class.getName() });
122 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_SUBTYPE = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
123 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
124 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findBySubtype",
125 new String[] {
126 String.class.getName(),
127
128 "java.lang.Integer", "java.lang.Integer",
129 "com.liferay.portal.kernel.util.OrderByComparator"
130 });
131 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SUBTYPE =
132 new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
133 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
134 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findBySubtype",
135 new String[] { String.class.getName() },
136 RoleModelImpl.SUBTYPE_COLUMN_BITMASK);
137 public static final FinderPath FINDER_PATH_COUNT_BY_SUBTYPE = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
138 RoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
139 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countBySubtype",
140 new String[] { String.class.getName() });
141 public static final FinderPath FINDER_PATH_FETCH_BY_C_N = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
142 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
143 FINDER_CLASS_NAME_ENTITY, "fetchByC_N",
144 new String[] { Long.class.getName(), String.class.getName() },
145 RoleModelImpl.COMPANYID_COLUMN_BITMASK |
146 RoleModelImpl.NAME_COLUMN_BITMASK);
147 public static final FinderPath FINDER_PATH_COUNT_BY_C_N = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
148 RoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
149 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_N",
150 new String[] { Long.class.getName(), String.class.getName() });
151 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_T_S = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
152 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
153 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByT_S",
154 new String[] {
155 Integer.class.getName(), String.class.getName(),
156
157 "java.lang.Integer", "java.lang.Integer",
158 "com.liferay.portal.kernel.util.OrderByComparator"
159 });
160 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
161 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
162 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByT_S",
163 new String[] { Integer.class.getName(), String.class.getName() },
164 RoleModelImpl.TYPE_COLUMN_BITMASK |
165 RoleModelImpl.SUBTYPE_COLUMN_BITMASK);
166 public static final FinderPath FINDER_PATH_COUNT_BY_T_S = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
167 RoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
168 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByT_S",
169 new String[] { Integer.class.getName(), String.class.getName() });
170 public static final FinderPath FINDER_PATH_FETCH_BY_C_C_C = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
171 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
172 FINDER_CLASS_NAME_ENTITY, "fetchByC_C_C",
173 new String[] {
174 Long.class.getName(), Long.class.getName(), Long.class.getName()
175 },
176 RoleModelImpl.COMPANYID_COLUMN_BITMASK |
177 RoleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
178 RoleModelImpl.CLASSPK_COLUMN_BITMASK);
179 public static final FinderPath FINDER_PATH_COUNT_BY_C_C_C = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
180 RoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
181 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_C",
182 new String[] {
183 Long.class.getName(), Long.class.getName(), Long.class.getName()
184 });
185 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
186 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
187 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
188 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
189 RoleModelImpl.FINDER_CACHE_ENABLED, RoleImpl.class,
190 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
191 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
192 RoleModelImpl.FINDER_CACHE_ENABLED, Long.class,
193 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
194
195
200 public void cacheResult(Role role) {
201 EntityCacheUtil.putResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
202 RoleImpl.class, role.getPrimaryKey(), role);
203
204 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
205 new Object[] { Long.valueOf(role.getCompanyId()), role.getName() },
206 role);
207
208 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
209 new Object[] {
210 Long.valueOf(role.getCompanyId()),
211 Long.valueOf(role.getClassNameId()),
212 Long.valueOf(role.getClassPK())
213 }, role);
214
215 role.resetOriginalValues();
216 }
217
218
223 public void cacheResult(List<Role> roles) {
224 for (Role role : roles) {
225 if (EntityCacheUtil.getResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
226 RoleImpl.class, role.getPrimaryKey()) == null) {
227 cacheResult(role);
228 }
229 else {
230 role.resetOriginalValues();
231 }
232 }
233 }
234
235
242 @Override
243 public void clearCache() {
244 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
245 CacheRegistryUtil.clear(RoleImpl.class.getName());
246 }
247
248 EntityCacheUtil.clearCache(RoleImpl.class.getName());
249
250 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
251 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
252 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
253 }
254
255
262 @Override
263 public void clearCache(Role role) {
264 EntityCacheUtil.removeResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
265 RoleImpl.class, role.getPrimaryKey());
266
267 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
268 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
269
270 clearUniqueFindersCache(role);
271 }
272
273 @Override
274 public void clearCache(List<Role> roles) {
275 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
276 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
277
278 for (Role role : roles) {
279 EntityCacheUtil.removeResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
280 RoleImpl.class, role.getPrimaryKey());
281
282 clearUniqueFindersCache(role);
283 }
284 }
285
286 protected void clearUniqueFindersCache(Role role) {
287 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
288 new Object[] { Long.valueOf(role.getCompanyId()), role.getName() });
289
290 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C,
291 new Object[] {
292 Long.valueOf(role.getCompanyId()),
293 Long.valueOf(role.getClassNameId()),
294 Long.valueOf(role.getClassPK())
295 });
296 }
297
298
304 public Role create(long roleId) {
305 Role role = new RoleImpl();
306
307 role.setNew(true);
308 role.setPrimaryKey(roleId);
309
310 return role;
311 }
312
313
321 public Role remove(long roleId) throws NoSuchRoleException, SystemException {
322 return remove(Long.valueOf(roleId));
323 }
324
325
333 @Override
334 public Role remove(Serializable primaryKey)
335 throws NoSuchRoleException, SystemException {
336 Session session = null;
337
338 try {
339 session = openSession();
340
341 Role role = (Role)session.get(RoleImpl.class, primaryKey);
342
343 if (role == null) {
344 if (_log.isWarnEnabled()) {
345 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
346 }
347
348 throw new NoSuchRoleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
349 primaryKey);
350 }
351
352 return remove(role);
353 }
354 catch (NoSuchRoleException nsee) {
355 throw nsee;
356 }
357 catch (Exception e) {
358 throw processException(e);
359 }
360 finally {
361 closeSession(session);
362 }
363 }
364
365 @Override
366 protected Role removeImpl(Role role) throws SystemException {
367 role = toUnwrappedModel(role);
368
369 try {
370 clearGroups.clear(role.getPrimaryKey());
371 }
372 catch (Exception e) {
373 throw processException(e);
374 }
375 finally {
376 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
377 }
378
379 try {
380 clearPermissions.clear(role.getPrimaryKey());
381 }
382 catch (Exception e) {
383 throw processException(e);
384 }
385 finally {
386 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
387 }
388
389 try {
390 clearUsers.clear(role.getPrimaryKey());
391 }
392 catch (Exception e) {
393 throw processException(e);
394 }
395 finally {
396 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
397 }
398
399 Session session = null;
400
401 try {
402 session = openSession();
403
404 BatchSessionUtil.delete(session, role);
405 }
406 catch (Exception e) {
407 throw processException(e);
408 }
409 finally {
410 closeSession(session);
411 }
412
413 clearCache(role);
414
415 return role;
416 }
417
418 @Override
419 public Role updateImpl(com.liferay.portal.model.Role role, boolean merge)
420 throws SystemException {
421 role = toUnwrappedModel(role);
422
423 boolean isNew = role.isNew();
424
425 RoleModelImpl roleModelImpl = (RoleModelImpl)role;
426
427 Session session = null;
428
429 try {
430 session = openSession();
431
432 BatchSessionUtil.update(session, role, merge);
433
434 role.setNew(false);
435 }
436 catch (Exception e) {
437 throw processException(e);
438 }
439 finally {
440 closeSession(session);
441 }
442
443 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
444
445 if (isNew || !RoleModelImpl.COLUMN_BITMASK_ENABLED) {
446 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
447 }
448 else {
449 if ((roleModelImpl.getColumnBitmask() &
450 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
451 Object[] args = new Object[] {
452 Long.valueOf(roleModelImpl.getOriginalCompanyId())
453 };
454
455 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
456 args);
457 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
458 args);
459
460 args = new Object[] { Long.valueOf(roleModelImpl.getCompanyId()) };
461
462 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
463 args);
464 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
465 args);
466 }
467
468 if ((roleModelImpl.getColumnBitmask() &
469 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NAME.getColumnBitmask()) != 0) {
470 Object[] args = new Object[] { roleModelImpl.getOriginalName() };
471
472 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_NAME, args);
473 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NAME,
474 args);
475
476 args = new Object[] { roleModelImpl.getName() };
477
478 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_NAME, args);
479 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NAME,
480 args);
481 }
482
483 if ((roleModelImpl.getColumnBitmask() &
484 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SUBTYPE.getColumnBitmask()) != 0) {
485 Object[] args = new Object[] { roleModelImpl.getOriginalSubtype() };
486
487 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SUBTYPE, args);
488 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SUBTYPE,
489 args);
490
491 args = new Object[] { roleModelImpl.getSubtype() };
492
493 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SUBTYPE, args);
494 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SUBTYPE,
495 args);
496 }
497
498 if ((roleModelImpl.getColumnBitmask() &
499 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S.getColumnBitmask()) != 0) {
500 Object[] args = new Object[] {
501 Integer.valueOf(roleModelImpl.getOriginalType()),
502
503 roleModelImpl.getOriginalSubtype()
504 };
505
506 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_S, args);
507 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S,
508 args);
509
510 args = new Object[] {
511 Integer.valueOf(roleModelImpl.getType()),
512
513 roleModelImpl.getSubtype()
514 };
515
516 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_S, args);
517 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S,
518 args);
519 }
520 }
521
522 EntityCacheUtil.putResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
523 RoleImpl.class, role.getPrimaryKey(), role);
524
525 if (isNew) {
526 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
527 new Object[] { Long.valueOf(role.getCompanyId()), role.getName() },
528 role);
529
530 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
531 new Object[] {
532 Long.valueOf(role.getCompanyId()),
533 Long.valueOf(role.getClassNameId()),
534 Long.valueOf(role.getClassPK())
535 }, role);
536 }
537 else {
538 if ((roleModelImpl.getColumnBitmask() &
539 FINDER_PATH_FETCH_BY_C_N.getColumnBitmask()) != 0) {
540 Object[] args = new Object[] {
541 Long.valueOf(roleModelImpl.getOriginalCompanyId()),
542
543 roleModelImpl.getOriginalName()
544 };
545
546 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_N, args);
547 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N, args);
548
549 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
550 new Object[] {
551 Long.valueOf(role.getCompanyId()),
552
553 role.getName()
554 }, role);
555 }
556
557 if ((roleModelImpl.getColumnBitmask() &
558 FINDER_PATH_FETCH_BY_C_C_C.getColumnBitmask()) != 0) {
559 Object[] args = new Object[] {
560 Long.valueOf(roleModelImpl.getOriginalCompanyId()),
561 Long.valueOf(roleModelImpl.getOriginalClassNameId()),
562 Long.valueOf(roleModelImpl.getOriginalClassPK())
563 };
564
565 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
566 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C, args);
567
568 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
569 new Object[] {
570 Long.valueOf(role.getCompanyId()),
571 Long.valueOf(role.getClassNameId()),
572 Long.valueOf(role.getClassPK())
573 }, role);
574 }
575 }
576
577 return role;
578 }
579
580 protected Role toUnwrappedModel(Role role) {
581 if (role instanceof RoleImpl) {
582 return role;
583 }
584
585 RoleImpl roleImpl = new RoleImpl();
586
587 roleImpl.setNew(role.isNew());
588 roleImpl.setPrimaryKey(role.getPrimaryKey());
589
590 roleImpl.setRoleId(role.getRoleId());
591 roleImpl.setCompanyId(role.getCompanyId());
592 roleImpl.setClassNameId(role.getClassNameId());
593 roleImpl.setClassPK(role.getClassPK());
594 roleImpl.setName(role.getName());
595 roleImpl.setTitle(role.getTitle());
596 roleImpl.setDescription(role.getDescription());
597 roleImpl.setType(role.getType());
598 roleImpl.setSubtype(role.getSubtype());
599
600 return roleImpl;
601 }
602
603
611 @Override
612 public Role findByPrimaryKey(Serializable primaryKey)
613 throws NoSuchModelException, SystemException {
614 return findByPrimaryKey(((Long)primaryKey).longValue());
615 }
616
617
625 public Role findByPrimaryKey(long roleId)
626 throws NoSuchRoleException, SystemException {
627 Role role = fetchByPrimaryKey(roleId);
628
629 if (role == null) {
630 if (_log.isWarnEnabled()) {
631 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + roleId);
632 }
633
634 throw new NoSuchRoleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
635 roleId);
636 }
637
638 return role;
639 }
640
641
648 @Override
649 public Role fetchByPrimaryKey(Serializable primaryKey)
650 throws SystemException {
651 return fetchByPrimaryKey(((Long)primaryKey).longValue());
652 }
653
654
661 public Role fetchByPrimaryKey(long roleId) throws SystemException {
662 Role role = (Role)EntityCacheUtil.getResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
663 RoleImpl.class, roleId);
664
665 if (role == _nullRole) {
666 return null;
667 }
668
669 if (role == null) {
670 Session session = null;
671
672 boolean hasException = false;
673
674 try {
675 session = openSession();
676
677 role = (Role)session.get(RoleImpl.class, Long.valueOf(roleId));
678 }
679 catch (Exception e) {
680 hasException = true;
681
682 throw processException(e);
683 }
684 finally {
685 if (role != null) {
686 cacheResult(role);
687 }
688 else if (!hasException) {
689 EntityCacheUtil.putResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
690 RoleImpl.class, roleId, _nullRole);
691 }
692
693 closeSession(session);
694 }
695 }
696
697 return role;
698 }
699
700
707 public List<Role> findByCompanyId(long companyId) throws SystemException {
708 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
709 null);
710 }
711
712
725 public List<Role> findByCompanyId(long companyId, int start, int end)
726 throws SystemException {
727 return findByCompanyId(companyId, start, end, null);
728 }
729
730
744 public List<Role> findByCompanyId(long companyId, int start, int end,
745 OrderByComparator orderByComparator) throws SystemException {
746 FinderPath finderPath = null;
747 Object[] finderArgs = null;
748
749 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
750 (orderByComparator == null)) {
751 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
752 finderArgs = new Object[] { companyId };
753 }
754 else {
755 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
756 finderArgs = new Object[] { companyId, start, end, orderByComparator };
757 }
758
759 List<Role> list = (List<Role>)FinderCacheUtil.getResult(finderPath,
760 finderArgs, this);
761
762 if ((list != null) && !list.isEmpty()) {
763 for (Role role : list) {
764 if ((companyId != role.getCompanyId())) {
765 list = null;
766
767 break;
768 }
769 }
770 }
771
772 if (list == null) {
773 StringBundler query = null;
774
775 if (orderByComparator != null) {
776 query = new StringBundler(3 +
777 (orderByComparator.getOrderByFields().length * 3));
778 }
779 else {
780 query = new StringBundler(3);
781 }
782
783 query.append(_SQL_SELECT_ROLE_WHERE);
784
785 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
786
787 if (orderByComparator != null) {
788 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
789 orderByComparator);
790 }
791
792 else {
793 query.append(RoleModelImpl.ORDER_BY_JPQL);
794 }
795
796 String sql = query.toString();
797
798 Session session = null;
799
800 try {
801 session = openSession();
802
803 Query q = session.createQuery(sql);
804
805 QueryPos qPos = QueryPos.getInstance(q);
806
807 qPos.add(companyId);
808
809 list = (List<Role>)QueryUtil.list(q, getDialect(), start, end);
810 }
811 catch (Exception e) {
812 throw processException(e);
813 }
814 finally {
815 if (list == null) {
816 FinderCacheUtil.removeResult(finderPath, finderArgs);
817 }
818 else {
819 cacheResult(list);
820
821 FinderCacheUtil.putResult(finderPath, finderArgs, list);
822 }
823
824 closeSession(session);
825 }
826 }
827
828 return list;
829 }
830
831
844 public Role findByCompanyId_First(long companyId,
845 OrderByComparator orderByComparator)
846 throws NoSuchRoleException, SystemException {
847 List<Role> list = findByCompanyId(companyId, 0, 1, orderByComparator);
848
849 if (list.isEmpty()) {
850 StringBundler msg = new StringBundler(4);
851
852 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
853
854 msg.append("companyId=");
855 msg.append(companyId);
856
857 msg.append(StringPool.CLOSE_CURLY_BRACE);
858
859 throw new NoSuchRoleException(msg.toString());
860 }
861 else {
862 return list.get(0);
863 }
864 }
865
866
879 public Role findByCompanyId_Last(long companyId,
880 OrderByComparator orderByComparator)
881 throws NoSuchRoleException, SystemException {
882 int count = countByCompanyId(companyId);
883
884 List<Role> list = findByCompanyId(companyId, count - 1, count,
885 orderByComparator);
886
887 if (list.isEmpty()) {
888 StringBundler msg = new StringBundler(4);
889
890 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
891
892 msg.append("companyId=");
893 msg.append(companyId);
894
895 msg.append(StringPool.CLOSE_CURLY_BRACE);
896
897 throw new NoSuchRoleException(msg.toString());
898 }
899 else {
900 return list.get(0);
901 }
902 }
903
904
918 public Role[] findByCompanyId_PrevAndNext(long roleId, long companyId,
919 OrderByComparator orderByComparator)
920 throws NoSuchRoleException, SystemException {
921 Role role = findByPrimaryKey(roleId);
922
923 Session session = null;
924
925 try {
926 session = openSession();
927
928 Role[] array = new RoleImpl[3];
929
930 array[0] = getByCompanyId_PrevAndNext(session, role, companyId,
931 orderByComparator, true);
932
933 array[1] = role;
934
935 array[2] = getByCompanyId_PrevAndNext(session, role, companyId,
936 orderByComparator, false);
937
938 return array;
939 }
940 catch (Exception e) {
941 throw processException(e);
942 }
943 finally {
944 closeSession(session);
945 }
946 }
947
948 protected Role getByCompanyId_PrevAndNext(Session session, Role role,
949 long companyId, OrderByComparator orderByComparator, boolean previous) {
950 StringBundler query = null;
951
952 if (orderByComparator != null) {
953 query = new StringBundler(6 +
954 (orderByComparator.getOrderByFields().length * 6));
955 }
956 else {
957 query = new StringBundler(3);
958 }
959
960 query.append(_SQL_SELECT_ROLE_WHERE);
961
962 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
963
964 if (orderByComparator != null) {
965 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
966
967 if (orderByConditionFields.length > 0) {
968 query.append(WHERE_AND);
969 }
970
971 for (int i = 0; i < orderByConditionFields.length; i++) {
972 query.append(_ORDER_BY_ENTITY_ALIAS);
973 query.append(orderByConditionFields[i]);
974
975 if ((i + 1) < orderByConditionFields.length) {
976 if (orderByComparator.isAscending() ^ previous) {
977 query.append(WHERE_GREATER_THAN_HAS_NEXT);
978 }
979 else {
980 query.append(WHERE_LESSER_THAN_HAS_NEXT);
981 }
982 }
983 else {
984 if (orderByComparator.isAscending() ^ previous) {
985 query.append(WHERE_GREATER_THAN);
986 }
987 else {
988 query.append(WHERE_LESSER_THAN);
989 }
990 }
991 }
992
993 query.append(ORDER_BY_CLAUSE);
994
995 String[] orderByFields = orderByComparator.getOrderByFields();
996
997 for (int i = 0; i < orderByFields.length; i++) {
998 query.append(_ORDER_BY_ENTITY_ALIAS);
999 query.append(orderByFields[i]);
1000
1001 if ((i + 1) < orderByFields.length) {
1002 if (orderByComparator.isAscending() ^ previous) {
1003 query.append(ORDER_BY_ASC_HAS_NEXT);
1004 }
1005 else {
1006 query.append(ORDER_BY_DESC_HAS_NEXT);
1007 }
1008 }
1009 else {
1010 if (orderByComparator.isAscending() ^ previous) {
1011 query.append(ORDER_BY_ASC);
1012 }
1013 else {
1014 query.append(ORDER_BY_DESC);
1015 }
1016 }
1017 }
1018 }
1019
1020 else {
1021 query.append(RoleModelImpl.ORDER_BY_JPQL);
1022 }
1023
1024 String sql = query.toString();
1025
1026 Query q = session.createQuery(sql);
1027
1028 q.setFirstResult(0);
1029 q.setMaxResults(2);
1030
1031 QueryPos qPos = QueryPos.getInstance(q);
1032
1033 qPos.add(companyId);
1034
1035 if (orderByComparator != null) {
1036 Object[] values = orderByComparator.getOrderByConditionValues(role);
1037
1038 for (Object value : values) {
1039 qPos.add(value);
1040 }
1041 }
1042
1043 List<Role> list = q.list();
1044
1045 if (list.size() == 2) {
1046 return list.get(1);
1047 }
1048 else {
1049 return null;
1050 }
1051 }
1052
1053
1060 public List<Role> filterFindByCompanyId(long companyId)
1061 throws SystemException {
1062 return filterFindByCompanyId(companyId, QueryUtil.ALL_POS,
1063 QueryUtil.ALL_POS, null);
1064 }
1065
1066
1079 public List<Role> filterFindByCompanyId(long companyId, int start, int end)
1080 throws SystemException {
1081 return filterFindByCompanyId(companyId, start, end, null);
1082 }
1083
1084
1098 public List<Role> filterFindByCompanyId(long companyId, int start, int end,
1099 OrderByComparator orderByComparator) throws SystemException {
1100 if (!InlineSQLHelperUtil.isEnabled()) {
1101 return findByCompanyId(companyId, start, end, orderByComparator);
1102 }
1103
1104 StringBundler query = null;
1105
1106 if (orderByComparator != null) {
1107 query = new StringBundler(3 +
1108 (orderByComparator.getOrderByFields().length * 3));
1109 }
1110 else {
1111 query = new StringBundler(3);
1112 }
1113
1114 if (getDB().isSupportsInlineDistinct()) {
1115 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
1116 }
1117 else {
1118 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
1119 }
1120
1121 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1122
1123 if (!getDB().isSupportsInlineDistinct()) {
1124 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
1125 }
1126
1127 if (orderByComparator != null) {
1128 if (getDB().isSupportsInlineDistinct()) {
1129 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1130 orderByComparator);
1131 }
1132 else {
1133 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1134 orderByComparator);
1135 }
1136 }
1137
1138 else {
1139 if (getDB().isSupportsInlineDistinct()) {
1140 query.append(RoleModelImpl.ORDER_BY_JPQL);
1141 }
1142 else {
1143 query.append(RoleModelImpl.ORDER_BY_SQL);
1144 }
1145 }
1146
1147 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1148 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1149
1150 Session session = null;
1151
1152 try {
1153 session = openSession();
1154
1155 SQLQuery q = session.createSQLQuery(sql);
1156
1157 if (getDB().isSupportsInlineDistinct()) {
1158 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
1159 }
1160 else {
1161 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
1162 }
1163
1164 QueryPos qPos = QueryPos.getInstance(q);
1165
1166 qPos.add(companyId);
1167
1168 return (List<Role>)QueryUtil.list(q, getDialect(), start, end);
1169 }
1170 catch (Exception e) {
1171 throw processException(e);
1172 }
1173 finally {
1174 closeSession(session);
1175 }
1176 }
1177
1178
1188 public Role[] filterFindByCompanyId_PrevAndNext(long roleId,
1189 long companyId, OrderByComparator orderByComparator)
1190 throws NoSuchRoleException, SystemException {
1191 if (!InlineSQLHelperUtil.isEnabled()) {
1192 return findByCompanyId_PrevAndNext(roleId, companyId,
1193 orderByComparator);
1194 }
1195
1196 Role role = findByPrimaryKey(roleId);
1197
1198 Session session = null;
1199
1200 try {
1201 session = openSession();
1202
1203 Role[] array = new RoleImpl[3];
1204
1205 array[0] = filterGetByCompanyId_PrevAndNext(session, role,
1206 companyId, orderByComparator, true);
1207
1208 array[1] = role;
1209
1210 array[2] = filterGetByCompanyId_PrevAndNext(session, role,
1211 companyId, orderByComparator, false);
1212
1213 return array;
1214 }
1215 catch (Exception e) {
1216 throw processException(e);
1217 }
1218 finally {
1219 closeSession(session);
1220 }
1221 }
1222
1223 protected Role filterGetByCompanyId_PrevAndNext(Session session, Role role,
1224 long companyId, OrderByComparator orderByComparator, boolean previous) {
1225 StringBundler query = null;
1226
1227 if (orderByComparator != null) {
1228 query = new StringBundler(6 +
1229 (orderByComparator.getOrderByFields().length * 6));
1230 }
1231 else {
1232 query = new StringBundler(3);
1233 }
1234
1235 if (getDB().isSupportsInlineDistinct()) {
1236 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
1237 }
1238 else {
1239 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
1240 }
1241
1242 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1243
1244 if (!getDB().isSupportsInlineDistinct()) {
1245 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
1246 }
1247
1248 if (orderByComparator != null) {
1249 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1250
1251 if (orderByConditionFields.length > 0) {
1252 query.append(WHERE_AND);
1253 }
1254
1255 for (int i = 0; i < orderByConditionFields.length; i++) {
1256 if (getDB().isSupportsInlineDistinct()) {
1257 query.append(_ORDER_BY_ENTITY_ALIAS);
1258 }
1259 else {
1260 query.append(_ORDER_BY_ENTITY_TABLE);
1261 }
1262
1263 query.append(orderByConditionFields[i]);
1264
1265 if ((i + 1) < orderByConditionFields.length) {
1266 if (orderByComparator.isAscending() ^ previous) {
1267 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1268 }
1269 else {
1270 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1271 }
1272 }
1273 else {
1274 if (orderByComparator.isAscending() ^ previous) {
1275 query.append(WHERE_GREATER_THAN);
1276 }
1277 else {
1278 query.append(WHERE_LESSER_THAN);
1279 }
1280 }
1281 }
1282
1283 query.append(ORDER_BY_CLAUSE);
1284
1285 String[] orderByFields = orderByComparator.getOrderByFields();
1286
1287 for (int i = 0; i < orderByFields.length; i++) {
1288 if (getDB().isSupportsInlineDistinct()) {
1289 query.append(_ORDER_BY_ENTITY_ALIAS);
1290 }
1291 else {
1292 query.append(_ORDER_BY_ENTITY_TABLE);
1293 }
1294
1295 query.append(orderByFields[i]);
1296
1297 if ((i + 1) < orderByFields.length) {
1298 if (orderByComparator.isAscending() ^ previous) {
1299 query.append(ORDER_BY_ASC_HAS_NEXT);
1300 }
1301 else {
1302 query.append(ORDER_BY_DESC_HAS_NEXT);
1303 }
1304 }
1305 else {
1306 if (orderByComparator.isAscending() ^ previous) {
1307 query.append(ORDER_BY_ASC);
1308 }
1309 else {
1310 query.append(ORDER_BY_DESC);
1311 }
1312 }
1313 }
1314 }
1315
1316 else {
1317 if (getDB().isSupportsInlineDistinct()) {
1318 query.append(RoleModelImpl.ORDER_BY_JPQL);
1319 }
1320 else {
1321 query.append(RoleModelImpl.ORDER_BY_SQL);
1322 }
1323 }
1324
1325 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1326 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1327
1328 SQLQuery q = session.createSQLQuery(sql);
1329
1330 q.setFirstResult(0);
1331 q.setMaxResults(2);
1332
1333 if (getDB().isSupportsInlineDistinct()) {
1334 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
1335 }
1336 else {
1337 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
1338 }
1339
1340 QueryPos qPos = QueryPos.getInstance(q);
1341
1342 qPos.add(companyId);
1343
1344 if (orderByComparator != null) {
1345 Object[] values = orderByComparator.getOrderByConditionValues(role);
1346
1347 for (Object value : values) {
1348 qPos.add(value);
1349 }
1350 }
1351
1352 List<Role> list = q.list();
1353
1354 if (list.size() == 2) {
1355 return list.get(1);
1356 }
1357 else {
1358 return null;
1359 }
1360 }
1361
1362
1369 public List<Role> findByName(String name) throws SystemException {
1370 return findByName(name, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1371 }
1372
1373
1386 public List<Role> findByName(String name, int start, int end)
1387 throws SystemException {
1388 return findByName(name, start, end, null);
1389 }
1390
1391
1405 public List<Role> findByName(String name, int start, int end,
1406 OrderByComparator orderByComparator) throws SystemException {
1407 FinderPath finderPath = null;
1408 Object[] finderArgs = null;
1409
1410 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1411 (orderByComparator == null)) {
1412 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NAME;
1413 finderArgs = new Object[] { name };
1414 }
1415 else {
1416 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_NAME;
1417 finderArgs = new Object[] { name, start, end, orderByComparator };
1418 }
1419
1420 List<Role> list = (List<Role>)FinderCacheUtil.getResult(finderPath,
1421 finderArgs, this);
1422
1423 if ((list != null) && !list.isEmpty()) {
1424 for (Role role : list) {
1425 if (!Validator.equals(name, role.getName())) {
1426 list = null;
1427
1428 break;
1429 }
1430 }
1431 }
1432
1433 if (list == null) {
1434 StringBundler query = null;
1435
1436 if (orderByComparator != null) {
1437 query = new StringBundler(3 +
1438 (orderByComparator.getOrderByFields().length * 3));
1439 }
1440 else {
1441 query = new StringBundler(3);
1442 }
1443
1444 query.append(_SQL_SELECT_ROLE_WHERE);
1445
1446 if (name == null) {
1447 query.append(_FINDER_COLUMN_NAME_NAME_1);
1448 }
1449 else {
1450 if (name.equals(StringPool.BLANK)) {
1451 query.append(_FINDER_COLUMN_NAME_NAME_3);
1452 }
1453 else {
1454 query.append(_FINDER_COLUMN_NAME_NAME_2);
1455 }
1456 }
1457
1458 if (orderByComparator != null) {
1459 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1460 orderByComparator);
1461 }
1462
1463 else {
1464 query.append(RoleModelImpl.ORDER_BY_JPQL);
1465 }
1466
1467 String sql = query.toString();
1468
1469 Session session = null;
1470
1471 try {
1472 session = openSession();
1473
1474 Query q = session.createQuery(sql);
1475
1476 QueryPos qPos = QueryPos.getInstance(q);
1477
1478 if (name != null) {
1479 qPos.add(name);
1480 }
1481
1482 list = (List<Role>)QueryUtil.list(q, getDialect(), start, end);
1483 }
1484 catch (Exception e) {
1485 throw processException(e);
1486 }
1487 finally {
1488 if (list == null) {
1489 FinderCacheUtil.removeResult(finderPath, finderArgs);
1490 }
1491 else {
1492 cacheResult(list);
1493
1494 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1495 }
1496
1497 closeSession(session);
1498 }
1499 }
1500
1501 return list;
1502 }
1503
1504
1517 public Role findByName_First(String name,
1518 OrderByComparator orderByComparator)
1519 throws NoSuchRoleException, SystemException {
1520 List<Role> list = findByName(name, 0, 1, orderByComparator);
1521
1522 if (list.isEmpty()) {
1523 StringBundler msg = new StringBundler(4);
1524
1525 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1526
1527 msg.append("name=");
1528 msg.append(name);
1529
1530 msg.append(StringPool.CLOSE_CURLY_BRACE);
1531
1532 throw new NoSuchRoleException(msg.toString());
1533 }
1534 else {
1535 return list.get(0);
1536 }
1537 }
1538
1539
1552 public Role findByName_Last(String name, OrderByComparator orderByComparator)
1553 throws NoSuchRoleException, SystemException {
1554 int count = countByName(name);
1555
1556 List<Role> list = findByName(name, count - 1, count, orderByComparator);
1557
1558 if (list.isEmpty()) {
1559 StringBundler msg = new StringBundler(4);
1560
1561 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1562
1563 msg.append("name=");
1564 msg.append(name);
1565
1566 msg.append(StringPool.CLOSE_CURLY_BRACE);
1567
1568 throw new NoSuchRoleException(msg.toString());
1569 }
1570 else {
1571 return list.get(0);
1572 }
1573 }
1574
1575
1589 public Role[] findByName_PrevAndNext(long roleId, String name,
1590 OrderByComparator orderByComparator)
1591 throws NoSuchRoleException, SystemException {
1592 Role role = findByPrimaryKey(roleId);
1593
1594 Session session = null;
1595
1596 try {
1597 session = openSession();
1598
1599 Role[] array = new RoleImpl[3];
1600
1601 array[0] = getByName_PrevAndNext(session, role, name,
1602 orderByComparator, true);
1603
1604 array[1] = role;
1605
1606 array[2] = getByName_PrevAndNext(session, role, name,
1607 orderByComparator, false);
1608
1609 return array;
1610 }
1611 catch (Exception e) {
1612 throw processException(e);
1613 }
1614 finally {
1615 closeSession(session);
1616 }
1617 }
1618
1619 protected Role getByName_PrevAndNext(Session session, Role role,
1620 String name, OrderByComparator orderByComparator, boolean previous) {
1621 StringBundler query = null;
1622
1623 if (orderByComparator != null) {
1624 query = new StringBundler(6 +
1625 (orderByComparator.getOrderByFields().length * 6));
1626 }
1627 else {
1628 query = new StringBundler(3);
1629 }
1630
1631 query.append(_SQL_SELECT_ROLE_WHERE);
1632
1633 if (name == null) {
1634 query.append(_FINDER_COLUMN_NAME_NAME_1);
1635 }
1636 else {
1637 if (name.equals(StringPool.BLANK)) {
1638 query.append(_FINDER_COLUMN_NAME_NAME_3);
1639 }
1640 else {
1641 query.append(_FINDER_COLUMN_NAME_NAME_2);
1642 }
1643 }
1644
1645 if (orderByComparator != null) {
1646 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1647
1648 if (orderByConditionFields.length > 0) {
1649 query.append(WHERE_AND);
1650 }
1651
1652 for (int i = 0; i < orderByConditionFields.length; i++) {
1653 query.append(_ORDER_BY_ENTITY_ALIAS);
1654 query.append(orderByConditionFields[i]);
1655
1656 if ((i + 1) < orderByConditionFields.length) {
1657 if (orderByComparator.isAscending() ^ previous) {
1658 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1659 }
1660 else {
1661 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1662 }
1663 }
1664 else {
1665 if (orderByComparator.isAscending() ^ previous) {
1666 query.append(WHERE_GREATER_THAN);
1667 }
1668 else {
1669 query.append(WHERE_LESSER_THAN);
1670 }
1671 }
1672 }
1673
1674 query.append(ORDER_BY_CLAUSE);
1675
1676 String[] orderByFields = orderByComparator.getOrderByFields();
1677
1678 for (int i = 0; i < orderByFields.length; i++) {
1679 query.append(_ORDER_BY_ENTITY_ALIAS);
1680 query.append(orderByFields[i]);
1681
1682 if ((i + 1) < orderByFields.length) {
1683 if (orderByComparator.isAscending() ^ previous) {
1684 query.append(ORDER_BY_ASC_HAS_NEXT);
1685 }
1686 else {
1687 query.append(ORDER_BY_DESC_HAS_NEXT);
1688 }
1689 }
1690 else {
1691 if (orderByComparator.isAscending() ^ previous) {
1692 query.append(ORDER_BY_ASC);
1693 }
1694 else {
1695 query.append(ORDER_BY_DESC);
1696 }
1697 }
1698 }
1699 }
1700
1701 else {
1702 query.append(RoleModelImpl.ORDER_BY_JPQL);
1703 }
1704
1705 String sql = query.toString();
1706
1707 Query q = session.createQuery(sql);
1708
1709 q.setFirstResult(0);
1710 q.setMaxResults(2);
1711
1712 QueryPos qPos = QueryPos.getInstance(q);
1713
1714 if (name != null) {
1715 qPos.add(name);
1716 }
1717
1718 if (orderByComparator != null) {
1719 Object[] values = orderByComparator.getOrderByConditionValues(role);
1720
1721 for (Object value : values) {
1722 qPos.add(value);
1723 }
1724 }
1725
1726 List<Role> list = q.list();
1727
1728 if (list.size() == 2) {
1729 return list.get(1);
1730 }
1731 else {
1732 return null;
1733 }
1734 }
1735
1736
1743 public List<Role> filterFindByName(String name) throws SystemException {
1744 return filterFindByName(name, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1745 }
1746
1747
1760 public List<Role> filterFindByName(String name, int start, int end)
1761 throws SystemException {
1762 return filterFindByName(name, start, end, null);
1763 }
1764
1765
1779 public List<Role> filterFindByName(String name, int start, int end,
1780 OrderByComparator orderByComparator) throws SystemException {
1781 if (!InlineSQLHelperUtil.isEnabled()) {
1782 return findByName(name, start, end, orderByComparator);
1783 }
1784
1785 StringBundler query = null;
1786
1787 if (orderByComparator != null) {
1788 query = new StringBundler(3 +
1789 (orderByComparator.getOrderByFields().length * 3));
1790 }
1791 else {
1792 query = new StringBundler(3);
1793 }
1794
1795 if (getDB().isSupportsInlineDistinct()) {
1796 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
1797 }
1798 else {
1799 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
1800 }
1801
1802 if (name == null) {
1803 query.append(_FINDER_COLUMN_NAME_NAME_1);
1804 }
1805 else {
1806 if (name.equals(StringPool.BLANK)) {
1807 query.append(_FINDER_COLUMN_NAME_NAME_3);
1808 }
1809 else {
1810 query.append(_FINDER_COLUMN_NAME_NAME_2);
1811 }
1812 }
1813
1814 if (!getDB().isSupportsInlineDistinct()) {
1815 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
1816 }
1817
1818 if (orderByComparator != null) {
1819 if (getDB().isSupportsInlineDistinct()) {
1820 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1821 orderByComparator);
1822 }
1823 else {
1824 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1825 orderByComparator);
1826 }
1827 }
1828
1829 else {
1830 if (getDB().isSupportsInlineDistinct()) {
1831 query.append(RoleModelImpl.ORDER_BY_JPQL);
1832 }
1833 else {
1834 query.append(RoleModelImpl.ORDER_BY_SQL);
1835 }
1836 }
1837
1838 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1839 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1840
1841 Session session = null;
1842
1843 try {
1844 session = openSession();
1845
1846 SQLQuery q = session.createSQLQuery(sql);
1847
1848 if (getDB().isSupportsInlineDistinct()) {
1849 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
1850 }
1851 else {
1852 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
1853 }
1854
1855 QueryPos qPos = QueryPos.getInstance(q);
1856
1857 if (name != null) {
1858 qPos.add(name);
1859 }
1860
1861 return (List<Role>)QueryUtil.list(q, getDialect(), start, end);
1862 }
1863 catch (Exception e) {
1864 throw processException(e);
1865 }
1866 finally {
1867 closeSession(session);
1868 }
1869 }
1870
1871
1881 public Role[] filterFindByName_PrevAndNext(long roleId, String name,
1882 OrderByComparator orderByComparator)
1883 throws NoSuchRoleException, SystemException {
1884 if (!InlineSQLHelperUtil.isEnabled()) {
1885 return findByName_PrevAndNext(roleId, name, orderByComparator);
1886 }
1887
1888 Role role = findByPrimaryKey(roleId);
1889
1890 Session session = null;
1891
1892 try {
1893 session = openSession();
1894
1895 Role[] array = new RoleImpl[3];
1896
1897 array[0] = filterGetByName_PrevAndNext(session, role, name,
1898 orderByComparator, true);
1899
1900 array[1] = role;
1901
1902 array[2] = filterGetByName_PrevAndNext(session, role, name,
1903 orderByComparator, false);
1904
1905 return array;
1906 }
1907 catch (Exception e) {
1908 throw processException(e);
1909 }
1910 finally {
1911 closeSession(session);
1912 }
1913 }
1914
1915 protected Role filterGetByName_PrevAndNext(Session session, Role role,
1916 String name, OrderByComparator orderByComparator, boolean previous) {
1917 StringBundler query = null;
1918
1919 if (orderByComparator != null) {
1920 query = new StringBundler(6 +
1921 (orderByComparator.getOrderByFields().length * 6));
1922 }
1923 else {
1924 query = new StringBundler(3);
1925 }
1926
1927 if (getDB().isSupportsInlineDistinct()) {
1928 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
1929 }
1930 else {
1931 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
1932 }
1933
1934 if (name == null) {
1935 query.append(_FINDER_COLUMN_NAME_NAME_1);
1936 }
1937 else {
1938 if (name.equals(StringPool.BLANK)) {
1939 query.append(_FINDER_COLUMN_NAME_NAME_3);
1940 }
1941 else {
1942 query.append(_FINDER_COLUMN_NAME_NAME_2);
1943 }
1944 }
1945
1946 if (!getDB().isSupportsInlineDistinct()) {
1947 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
1948 }
1949
1950 if (orderByComparator != null) {
1951 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1952
1953 if (orderByConditionFields.length > 0) {
1954 query.append(WHERE_AND);
1955 }
1956
1957 for (int i = 0; i < orderByConditionFields.length; i++) {
1958 if (getDB().isSupportsInlineDistinct()) {
1959 query.append(_ORDER_BY_ENTITY_ALIAS);
1960 }
1961 else {
1962 query.append(_ORDER_BY_ENTITY_TABLE);
1963 }
1964
1965 query.append(orderByConditionFields[i]);
1966
1967 if ((i + 1) < orderByConditionFields.length) {
1968 if (orderByComparator.isAscending() ^ previous) {
1969 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1970 }
1971 else {
1972 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1973 }
1974 }
1975 else {
1976 if (orderByComparator.isAscending() ^ previous) {
1977 query.append(WHERE_GREATER_THAN);
1978 }
1979 else {
1980 query.append(WHERE_LESSER_THAN);
1981 }
1982 }
1983 }
1984
1985 query.append(ORDER_BY_CLAUSE);
1986
1987 String[] orderByFields = orderByComparator.getOrderByFields();
1988
1989 for (int i = 0; i < orderByFields.length; i++) {
1990 if (getDB().isSupportsInlineDistinct()) {
1991 query.append(_ORDER_BY_ENTITY_ALIAS);
1992 }
1993 else {
1994 query.append(_ORDER_BY_ENTITY_TABLE);
1995 }
1996
1997 query.append(orderByFields[i]);
1998
1999 if ((i + 1) < orderByFields.length) {
2000 if (orderByComparator.isAscending() ^ previous) {
2001 query.append(ORDER_BY_ASC_HAS_NEXT);
2002 }
2003 else {
2004 query.append(ORDER_BY_DESC_HAS_NEXT);
2005 }
2006 }
2007 else {
2008 if (orderByComparator.isAscending() ^ previous) {
2009 query.append(ORDER_BY_ASC);
2010 }
2011 else {
2012 query.append(ORDER_BY_DESC);
2013 }
2014 }
2015 }
2016 }
2017
2018 else {
2019 if (getDB().isSupportsInlineDistinct()) {
2020 query.append(RoleModelImpl.ORDER_BY_JPQL);
2021 }
2022 else {
2023 query.append(RoleModelImpl.ORDER_BY_SQL);
2024 }
2025 }
2026
2027 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2028 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2029
2030 SQLQuery q = session.createSQLQuery(sql);
2031
2032 q.setFirstResult(0);
2033 q.setMaxResults(2);
2034
2035 if (getDB().isSupportsInlineDistinct()) {
2036 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
2037 }
2038 else {
2039 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
2040 }
2041
2042 QueryPos qPos = QueryPos.getInstance(q);
2043
2044 if (name != null) {
2045 qPos.add(name);
2046 }
2047
2048 if (orderByComparator != null) {
2049 Object[] values = orderByComparator.getOrderByConditionValues(role);
2050
2051 for (Object value : values) {
2052 qPos.add(value);
2053 }
2054 }
2055
2056 List<Role> list = q.list();
2057
2058 if (list.size() == 2) {
2059 return list.get(1);
2060 }
2061 else {
2062 return null;
2063 }
2064 }
2065
2066
2073 public List<Role> findBySubtype(String subtype) throws SystemException {
2074 return findBySubtype(subtype, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2075 }
2076
2077
2090 public List<Role> findBySubtype(String subtype, int start, int end)
2091 throws SystemException {
2092 return findBySubtype(subtype, start, end, null);
2093 }
2094
2095
2109 public List<Role> findBySubtype(String subtype, int start, int end,
2110 OrderByComparator orderByComparator) throws SystemException {
2111 FinderPath finderPath = null;
2112 Object[] finderArgs = null;
2113
2114 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2115 (orderByComparator == null)) {
2116 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SUBTYPE;
2117 finderArgs = new Object[] { subtype };
2118 }
2119 else {
2120 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SUBTYPE;
2121 finderArgs = new Object[] { subtype, start, end, orderByComparator };
2122 }
2123
2124 List<Role> list = (List<Role>)FinderCacheUtil.getResult(finderPath,
2125 finderArgs, this);
2126
2127 if ((list != null) && !list.isEmpty()) {
2128 for (Role role : list) {
2129 if (!Validator.equals(subtype, role.getSubtype())) {
2130 list = null;
2131
2132 break;
2133 }
2134 }
2135 }
2136
2137 if (list == null) {
2138 StringBundler query = null;
2139
2140 if (orderByComparator != null) {
2141 query = new StringBundler(3 +
2142 (orderByComparator.getOrderByFields().length * 3));
2143 }
2144 else {
2145 query = new StringBundler(3);
2146 }
2147
2148 query.append(_SQL_SELECT_ROLE_WHERE);
2149
2150 if (subtype == null) {
2151 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
2152 }
2153 else {
2154 if (subtype.equals(StringPool.BLANK)) {
2155 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
2156 }
2157 else {
2158 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
2159 }
2160 }
2161
2162 if (orderByComparator != null) {
2163 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2164 orderByComparator);
2165 }
2166
2167 else {
2168 query.append(RoleModelImpl.ORDER_BY_JPQL);
2169 }
2170
2171 String sql = query.toString();
2172
2173 Session session = null;
2174
2175 try {
2176 session = openSession();
2177
2178 Query q = session.createQuery(sql);
2179
2180 QueryPos qPos = QueryPos.getInstance(q);
2181
2182 if (subtype != null) {
2183 qPos.add(subtype);
2184 }
2185
2186 list = (List<Role>)QueryUtil.list(q, getDialect(), start, end);
2187 }
2188 catch (Exception e) {
2189 throw processException(e);
2190 }
2191 finally {
2192 if (list == null) {
2193 FinderCacheUtil.removeResult(finderPath, finderArgs);
2194 }
2195 else {
2196 cacheResult(list);
2197
2198 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2199 }
2200
2201 closeSession(session);
2202 }
2203 }
2204
2205 return list;
2206 }
2207
2208
2221 public Role findBySubtype_First(String subtype,
2222 OrderByComparator orderByComparator)
2223 throws NoSuchRoleException, SystemException {
2224 List<Role> list = findBySubtype(subtype, 0, 1, orderByComparator);
2225
2226 if (list.isEmpty()) {
2227 StringBundler msg = new StringBundler(4);
2228
2229 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2230
2231 msg.append("subtype=");
2232 msg.append(subtype);
2233
2234 msg.append(StringPool.CLOSE_CURLY_BRACE);
2235
2236 throw new NoSuchRoleException(msg.toString());
2237 }
2238 else {
2239 return list.get(0);
2240 }
2241 }
2242
2243
2256 public Role findBySubtype_Last(String subtype,
2257 OrderByComparator orderByComparator)
2258 throws NoSuchRoleException, SystemException {
2259 int count = countBySubtype(subtype);
2260
2261 List<Role> list = findBySubtype(subtype, count - 1, count,
2262 orderByComparator);
2263
2264 if (list.isEmpty()) {
2265 StringBundler msg = new StringBundler(4);
2266
2267 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2268
2269 msg.append("subtype=");
2270 msg.append(subtype);
2271
2272 msg.append(StringPool.CLOSE_CURLY_BRACE);
2273
2274 throw new NoSuchRoleException(msg.toString());
2275 }
2276 else {
2277 return list.get(0);
2278 }
2279 }
2280
2281
2295 public Role[] findBySubtype_PrevAndNext(long roleId, String subtype,
2296 OrderByComparator orderByComparator)
2297 throws NoSuchRoleException, SystemException {
2298 Role role = findByPrimaryKey(roleId);
2299
2300 Session session = null;
2301
2302 try {
2303 session = openSession();
2304
2305 Role[] array = new RoleImpl[3];
2306
2307 array[0] = getBySubtype_PrevAndNext(session, role, subtype,
2308 orderByComparator, true);
2309
2310 array[1] = role;
2311
2312 array[2] = getBySubtype_PrevAndNext(session, role, subtype,
2313 orderByComparator, false);
2314
2315 return array;
2316 }
2317 catch (Exception e) {
2318 throw processException(e);
2319 }
2320 finally {
2321 closeSession(session);
2322 }
2323 }
2324
2325 protected Role getBySubtype_PrevAndNext(Session session, Role role,
2326 String subtype, OrderByComparator orderByComparator, boolean previous) {
2327 StringBundler query = null;
2328
2329 if (orderByComparator != null) {
2330 query = new StringBundler(6 +
2331 (orderByComparator.getOrderByFields().length * 6));
2332 }
2333 else {
2334 query = new StringBundler(3);
2335 }
2336
2337 query.append(_SQL_SELECT_ROLE_WHERE);
2338
2339 if (subtype == null) {
2340 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
2341 }
2342 else {
2343 if (subtype.equals(StringPool.BLANK)) {
2344 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
2345 }
2346 else {
2347 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
2348 }
2349 }
2350
2351 if (orderByComparator != null) {
2352 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2353
2354 if (orderByConditionFields.length > 0) {
2355 query.append(WHERE_AND);
2356 }
2357
2358 for (int i = 0; i < orderByConditionFields.length; i++) {
2359 query.append(_ORDER_BY_ENTITY_ALIAS);
2360 query.append(orderByConditionFields[i]);
2361
2362 if ((i + 1) < orderByConditionFields.length) {
2363 if (orderByComparator.isAscending() ^ previous) {
2364 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2365 }
2366 else {
2367 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2368 }
2369 }
2370 else {
2371 if (orderByComparator.isAscending() ^ previous) {
2372 query.append(WHERE_GREATER_THAN);
2373 }
2374 else {
2375 query.append(WHERE_LESSER_THAN);
2376 }
2377 }
2378 }
2379
2380 query.append(ORDER_BY_CLAUSE);
2381
2382 String[] orderByFields = orderByComparator.getOrderByFields();
2383
2384 for (int i = 0; i < orderByFields.length; i++) {
2385 query.append(_ORDER_BY_ENTITY_ALIAS);
2386 query.append(orderByFields[i]);
2387
2388 if ((i + 1) < orderByFields.length) {
2389 if (orderByComparator.isAscending() ^ previous) {
2390 query.append(ORDER_BY_ASC_HAS_NEXT);
2391 }
2392 else {
2393 query.append(ORDER_BY_DESC_HAS_NEXT);
2394 }
2395 }
2396 else {
2397 if (orderByComparator.isAscending() ^ previous) {
2398 query.append(ORDER_BY_ASC);
2399 }
2400 else {
2401 query.append(ORDER_BY_DESC);
2402 }
2403 }
2404 }
2405 }
2406
2407 else {
2408 query.append(RoleModelImpl.ORDER_BY_JPQL);
2409 }
2410
2411 String sql = query.toString();
2412
2413 Query q = session.createQuery(sql);
2414
2415 q.setFirstResult(0);
2416 q.setMaxResults(2);
2417
2418 QueryPos qPos = QueryPos.getInstance(q);
2419
2420 if (subtype != null) {
2421 qPos.add(subtype);
2422 }
2423
2424 if (orderByComparator != null) {
2425 Object[] values = orderByComparator.getOrderByConditionValues(role);
2426
2427 for (Object value : values) {
2428 qPos.add(value);
2429 }
2430 }
2431
2432 List<Role> list = q.list();
2433
2434 if (list.size() == 2) {
2435 return list.get(1);
2436 }
2437 else {
2438 return null;
2439 }
2440 }
2441
2442
2449 public List<Role> filterFindBySubtype(String subtype)
2450 throws SystemException {
2451 return filterFindBySubtype(subtype, QueryUtil.ALL_POS,
2452 QueryUtil.ALL_POS, null);
2453 }
2454
2455
2468 public List<Role> filterFindBySubtype(String subtype, int start, int end)
2469 throws SystemException {
2470 return filterFindBySubtype(subtype, start, end, null);
2471 }
2472
2473
2487 public List<Role> filterFindBySubtype(String subtype, int start, int end,
2488 OrderByComparator orderByComparator) throws SystemException {
2489 if (!InlineSQLHelperUtil.isEnabled()) {
2490 return findBySubtype(subtype, start, end, orderByComparator);
2491 }
2492
2493 StringBundler query = null;
2494
2495 if (orderByComparator != null) {
2496 query = new StringBundler(3 +
2497 (orderByComparator.getOrderByFields().length * 3));
2498 }
2499 else {
2500 query = new StringBundler(3);
2501 }
2502
2503 if (getDB().isSupportsInlineDistinct()) {
2504 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
2505 }
2506 else {
2507 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
2508 }
2509
2510 if (subtype == null) {
2511 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
2512 }
2513 else {
2514 if (subtype.equals(StringPool.BLANK)) {
2515 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
2516 }
2517 else {
2518 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
2519 }
2520 }
2521
2522 if (!getDB().isSupportsInlineDistinct()) {
2523 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
2524 }
2525
2526 if (orderByComparator != null) {
2527 if (getDB().isSupportsInlineDistinct()) {
2528 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2529 orderByComparator);
2530 }
2531 else {
2532 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2533 orderByComparator);
2534 }
2535 }
2536
2537 else {
2538 if (getDB().isSupportsInlineDistinct()) {
2539 query.append(RoleModelImpl.ORDER_BY_JPQL);
2540 }
2541 else {
2542 query.append(RoleModelImpl.ORDER_BY_SQL);
2543 }
2544 }
2545
2546 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2547 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2548
2549 Session session = null;
2550
2551 try {
2552 session = openSession();
2553
2554 SQLQuery q = session.createSQLQuery(sql);
2555
2556 if (getDB().isSupportsInlineDistinct()) {
2557 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
2558 }
2559 else {
2560 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
2561 }
2562
2563 QueryPos qPos = QueryPos.getInstance(q);
2564
2565 if (subtype != null) {
2566 qPos.add(subtype);
2567 }
2568
2569 return (List<Role>)QueryUtil.list(q, getDialect(), start, end);
2570 }
2571 catch (Exception e) {
2572 throw processException(e);
2573 }
2574 finally {
2575 closeSession(session);
2576 }
2577 }
2578
2579
2589 public Role[] filterFindBySubtype_PrevAndNext(long roleId, String subtype,
2590 OrderByComparator orderByComparator)
2591 throws NoSuchRoleException, SystemException {
2592 if (!InlineSQLHelperUtil.isEnabled()) {
2593 return findBySubtype_PrevAndNext(roleId, subtype, orderByComparator);
2594 }
2595
2596 Role role = findByPrimaryKey(roleId);
2597
2598 Session session = null;
2599
2600 try {
2601 session = openSession();
2602
2603 Role[] array = new RoleImpl[3];
2604
2605 array[0] = filterGetBySubtype_PrevAndNext(session, role, subtype,
2606 orderByComparator, true);
2607
2608 array[1] = role;
2609
2610 array[2] = filterGetBySubtype_PrevAndNext(session, role, subtype,
2611 orderByComparator, false);
2612
2613 return array;
2614 }
2615 catch (Exception e) {
2616 throw processException(e);
2617 }
2618 finally {
2619 closeSession(session);
2620 }
2621 }
2622
2623 protected Role filterGetBySubtype_PrevAndNext(Session session, Role role,
2624 String subtype, OrderByComparator orderByComparator, boolean previous) {
2625 StringBundler query = null;
2626
2627 if (orderByComparator != null) {
2628 query = new StringBundler(6 +
2629 (orderByComparator.getOrderByFields().length * 6));
2630 }
2631 else {
2632 query = new StringBundler(3);
2633 }
2634
2635 if (getDB().isSupportsInlineDistinct()) {
2636 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
2637 }
2638 else {
2639 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
2640 }
2641
2642 if (subtype == null) {
2643 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
2644 }
2645 else {
2646 if (subtype.equals(StringPool.BLANK)) {
2647 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
2648 }
2649 else {
2650 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
2651 }
2652 }
2653
2654 if (!getDB().isSupportsInlineDistinct()) {
2655 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
2656 }
2657
2658 if (orderByComparator != null) {
2659 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2660
2661 if (orderByConditionFields.length > 0) {
2662 query.append(WHERE_AND);
2663 }
2664
2665 for (int i = 0; i < orderByConditionFields.length; i++) {
2666 if (getDB().isSupportsInlineDistinct()) {
2667 query.append(_ORDER_BY_ENTITY_ALIAS);
2668 }
2669 else {
2670 query.append(_ORDER_BY_ENTITY_TABLE);
2671 }
2672
2673 query.append(orderByConditionFields[i]);
2674
2675 if ((i + 1) < orderByConditionFields.length) {
2676 if (orderByComparator.isAscending() ^ previous) {
2677 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2678 }
2679 else {
2680 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2681 }
2682 }
2683 else {
2684 if (orderByComparator.isAscending() ^ previous) {
2685 query.append(WHERE_GREATER_THAN);
2686 }
2687 else {
2688 query.append(WHERE_LESSER_THAN);
2689 }
2690 }
2691 }
2692
2693 query.append(ORDER_BY_CLAUSE);
2694
2695 String[] orderByFields = orderByComparator.getOrderByFields();
2696
2697 for (int i = 0; i < orderByFields.length; i++) {
2698 if (getDB().isSupportsInlineDistinct()) {
2699 query.append(_ORDER_BY_ENTITY_ALIAS);
2700 }
2701 else {
2702 query.append(_ORDER_BY_ENTITY_TABLE);
2703 }
2704
2705 query.append(orderByFields[i]);
2706
2707 if ((i + 1) < orderByFields.length) {
2708 if (orderByComparator.isAscending() ^ previous) {
2709 query.append(ORDER_BY_ASC_HAS_NEXT);
2710 }
2711 else {
2712 query.append(ORDER_BY_DESC_HAS_NEXT);
2713 }
2714 }
2715 else {
2716 if (orderByComparator.isAscending() ^ previous) {
2717 query.append(ORDER_BY_ASC);
2718 }
2719 else {
2720 query.append(ORDER_BY_DESC);
2721 }
2722 }
2723 }
2724 }
2725
2726 else {
2727 if (getDB().isSupportsInlineDistinct()) {
2728 query.append(RoleModelImpl.ORDER_BY_JPQL);
2729 }
2730 else {
2731 query.append(RoleModelImpl.ORDER_BY_SQL);
2732 }
2733 }
2734
2735 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2736 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2737
2738 SQLQuery q = session.createSQLQuery(sql);
2739
2740 q.setFirstResult(0);
2741 q.setMaxResults(2);
2742
2743 if (getDB().isSupportsInlineDistinct()) {
2744 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
2745 }
2746 else {
2747 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
2748 }
2749
2750 QueryPos qPos = QueryPos.getInstance(q);
2751
2752 if (subtype != null) {
2753 qPos.add(subtype);
2754 }
2755
2756 if (orderByComparator != null) {
2757 Object[] values = orderByComparator.getOrderByConditionValues(role);
2758
2759 for (Object value : values) {
2760 qPos.add(value);
2761 }
2762 }
2763
2764 List<Role> list = q.list();
2765
2766 if (list.size() == 2) {
2767 return list.get(1);
2768 }
2769 else {
2770 return null;
2771 }
2772 }
2773
2774
2783 public Role findByC_N(long companyId, String name)
2784 throws NoSuchRoleException, SystemException {
2785 Role role = fetchByC_N(companyId, name);
2786
2787 if (role == null) {
2788 StringBundler msg = new StringBundler(6);
2789
2790 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2791
2792 msg.append("companyId=");
2793 msg.append(companyId);
2794
2795 msg.append(", name=");
2796 msg.append(name);
2797
2798 msg.append(StringPool.CLOSE_CURLY_BRACE);
2799
2800 if (_log.isWarnEnabled()) {
2801 _log.warn(msg.toString());
2802 }
2803
2804 throw new NoSuchRoleException(msg.toString());
2805 }
2806
2807 return role;
2808 }
2809
2810
2818 public Role fetchByC_N(long companyId, String name)
2819 throws SystemException {
2820 return fetchByC_N(companyId, name, true);
2821 }
2822
2823
2832 public Role fetchByC_N(long companyId, String name,
2833 boolean retrieveFromCache) throws SystemException {
2834 Object[] finderArgs = new Object[] { companyId, name };
2835
2836 Object result = null;
2837
2838 if (retrieveFromCache) {
2839 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_N,
2840 finderArgs, this);
2841 }
2842
2843 if (result instanceof Role) {
2844 Role role = (Role)result;
2845
2846 if ((companyId != role.getCompanyId()) ||
2847 !Validator.equals(name, role.getName())) {
2848 result = null;
2849 }
2850 }
2851
2852 if (result == null) {
2853 StringBundler query = new StringBundler(4);
2854
2855 query.append(_SQL_SELECT_ROLE_WHERE);
2856
2857 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
2858
2859 if (name == null) {
2860 query.append(_FINDER_COLUMN_C_N_NAME_1);
2861 }
2862 else {
2863 if (name.equals(StringPool.BLANK)) {
2864 query.append(_FINDER_COLUMN_C_N_NAME_3);
2865 }
2866 else {
2867 query.append(_FINDER_COLUMN_C_N_NAME_2);
2868 }
2869 }
2870
2871 query.append(RoleModelImpl.ORDER_BY_JPQL);
2872
2873 String sql = query.toString();
2874
2875 Session session = null;
2876
2877 try {
2878 session = openSession();
2879
2880 Query q = session.createQuery(sql);
2881
2882 QueryPos qPos = QueryPos.getInstance(q);
2883
2884 qPos.add(companyId);
2885
2886 if (name != null) {
2887 qPos.add(name);
2888 }
2889
2890 List<Role> list = q.list();
2891
2892 result = list;
2893
2894 Role role = null;
2895
2896 if (list.isEmpty()) {
2897 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
2898 finderArgs, list);
2899 }
2900 else {
2901 role = list.get(0);
2902
2903 cacheResult(role);
2904
2905 if ((role.getCompanyId() != companyId) ||
2906 (role.getName() == null) ||
2907 !role.getName().equals(name)) {
2908 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
2909 finderArgs, role);
2910 }
2911 }
2912
2913 return role;
2914 }
2915 catch (Exception e) {
2916 throw processException(e);
2917 }
2918 finally {
2919 if (result == null) {
2920 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
2921 finderArgs);
2922 }
2923
2924 closeSession(session);
2925 }
2926 }
2927 else {
2928 if (result instanceof List<?>) {
2929 return null;
2930 }
2931 else {
2932 return (Role)result;
2933 }
2934 }
2935 }
2936
2937
2945 public List<Role> findByT_S(int type, String subtype)
2946 throws SystemException {
2947 return findByT_S(type, subtype, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2948 null);
2949 }
2950
2951
2965 public List<Role> findByT_S(int type, String subtype, int start, int end)
2966 throws SystemException {
2967 return findByT_S(type, subtype, start, end, null);
2968 }
2969
2970
2985 public List<Role> findByT_S(int type, String subtype, int start, int end,
2986 OrderByComparator orderByComparator) throws SystemException {
2987 FinderPath finderPath = null;
2988 Object[] finderArgs = null;
2989
2990 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2991 (orderByComparator == null)) {
2992 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S;
2993 finderArgs = new Object[] { type, subtype };
2994 }
2995 else {
2996 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_T_S;
2997 finderArgs = new Object[] {
2998 type, subtype,
2999
3000 start, end, orderByComparator
3001 };
3002 }
3003
3004 List<Role> list = (List<Role>)FinderCacheUtil.getResult(finderPath,
3005 finderArgs, this);
3006
3007 if ((list != null) && !list.isEmpty()) {
3008 for (Role role : list) {
3009 if ((type != role.getType()) ||
3010 !Validator.equals(subtype, role.getSubtype())) {
3011 list = null;
3012
3013 break;
3014 }
3015 }
3016 }
3017
3018 if (list == null) {
3019 StringBundler query = null;
3020
3021 if (orderByComparator != null) {
3022 query = new StringBundler(4 +
3023 (orderByComparator.getOrderByFields().length * 3));
3024 }
3025 else {
3026 query = new StringBundler(4);
3027 }
3028
3029 query.append(_SQL_SELECT_ROLE_WHERE);
3030
3031 query.append(_FINDER_COLUMN_T_S_TYPE_2);
3032
3033 if (subtype == null) {
3034 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
3035 }
3036 else {
3037 if (subtype.equals(StringPool.BLANK)) {
3038 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
3039 }
3040 else {
3041 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
3042 }
3043 }
3044
3045 if (orderByComparator != null) {
3046 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3047 orderByComparator);
3048 }
3049
3050 else {
3051 query.append(RoleModelImpl.ORDER_BY_JPQL);
3052 }
3053
3054 String sql = query.toString();
3055
3056 Session session = null;
3057
3058 try {
3059 session = openSession();
3060
3061 Query q = session.createQuery(sql);
3062
3063 QueryPos qPos = QueryPos.getInstance(q);
3064
3065 qPos.add(type);
3066
3067 if (subtype != null) {
3068 qPos.add(subtype);
3069 }
3070
3071 list = (List<Role>)QueryUtil.list(q, getDialect(), start, end);
3072 }
3073 catch (Exception e) {
3074 throw processException(e);
3075 }
3076 finally {
3077 if (list == null) {
3078 FinderCacheUtil.removeResult(finderPath, finderArgs);
3079 }
3080 else {
3081 cacheResult(list);
3082
3083 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3084 }
3085
3086 closeSession(session);
3087 }
3088 }
3089
3090 return list;
3091 }
3092
3093
3107 public Role findByT_S_First(int type, String subtype,
3108 OrderByComparator orderByComparator)
3109 throws NoSuchRoleException, SystemException {
3110 List<Role> list = findByT_S(type, subtype, 0, 1, orderByComparator);
3111
3112 if (list.isEmpty()) {
3113 StringBundler msg = new StringBundler(6);
3114
3115 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3116
3117 msg.append("type=");
3118 msg.append(type);
3119
3120 msg.append(", subtype=");
3121 msg.append(subtype);
3122
3123 msg.append(StringPool.CLOSE_CURLY_BRACE);
3124
3125 throw new NoSuchRoleException(msg.toString());
3126 }
3127 else {
3128 return list.get(0);
3129 }
3130 }
3131
3132
3146 public Role findByT_S_Last(int type, String subtype,
3147 OrderByComparator orderByComparator)
3148 throws NoSuchRoleException, SystemException {
3149 int count = countByT_S(type, subtype);
3150
3151 List<Role> list = findByT_S(type, subtype, count - 1, count,
3152 orderByComparator);
3153
3154 if (list.isEmpty()) {
3155 StringBundler msg = new StringBundler(6);
3156
3157 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3158
3159 msg.append("type=");
3160 msg.append(type);
3161
3162 msg.append(", subtype=");
3163 msg.append(subtype);
3164
3165 msg.append(StringPool.CLOSE_CURLY_BRACE);
3166
3167 throw new NoSuchRoleException(msg.toString());
3168 }
3169 else {
3170 return list.get(0);
3171 }
3172 }
3173
3174
3189 public Role[] findByT_S_PrevAndNext(long roleId, int type, String subtype,
3190 OrderByComparator orderByComparator)
3191 throws NoSuchRoleException, SystemException {
3192 Role role = findByPrimaryKey(roleId);
3193
3194 Session session = null;
3195
3196 try {
3197 session = openSession();
3198
3199 Role[] array = new RoleImpl[3];
3200
3201 array[0] = getByT_S_PrevAndNext(session, role, type, subtype,
3202 orderByComparator, true);
3203
3204 array[1] = role;
3205
3206 array[2] = getByT_S_PrevAndNext(session, role, type, subtype,
3207 orderByComparator, false);
3208
3209 return array;
3210 }
3211 catch (Exception e) {
3212 throw processException(e);
3213 }
3214 finally {
3215 closeSession(session);
3216 }
3217 }
3218
3219 protected Role getByT_S_PrevAndNext(Session session, Role role, int type,
3220 String subtype, OrderByComparator orderByComparator, boolean previous) {
3221 StringBundler query = null;
3222
3223 if (orderByComparator != null) {
3224 query = new StringBundler(6 +
3225 (orderByComparator.getOrderByFields().length * 6));
3226 }
3227 else {
3228 query = new StringBundler(3);
3229 }
3230
3231 query.append(_SQL_SELECT_ROLE_WHERE);
3232
3233 query.append(_FINDER_COLUMN_T_S_TYPE_2);
3234
3235 if (subtype == null) {
3236 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
3237 }
3238 else {
3239 if (subtype.equals(StringPool.BLANK)) {
3240 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
3241 }
3242 else {
3243 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
3244 }
3245 }
3246
3247 if (orderByComparator != null) {
3248 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3249
3250 if (orderByConditionFields.length > 0) {
3251 query.append(WHERE_AND);
3252 }
3253
3254 for (int i = 0; i < orderByConditionFields.length; i++) {
3255 query.append(_ORDER_BY_ENTITY_ALIAS);
3256 query.append(orderByConditionFields[i]);
3257
3258 if ((i + 1) < orderByConditionFields.length) {
3259 if (orderByComparator.isAscending() ^ previous) {
3260 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3261 }
3262 else {
3263 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3264 }
3265 }
3266 else {
3267 if (orderByComparator.isAscending() ^ previous) {
3268 query.append(WHERE_GREATER_THAN);
3269 }
3270 else {
3271 query.append(WHERE_LESSER_THAN);
3272 }
3273 }
3274 }
3275
3276 query.append(ORDER_BY_CLAUSE);
3277
3278 String[] orderByFields = orderByComparator.getOrderByFields();
3279
3280 for (int i = 0; i < orderByFields.length; i++) {
3281 query.append(_ORDER_BY_ENTITY_ALIAS);
3282 query.append(orderByFields[i]);
3283
3284 if ((i + 1) < orderByFields.length) {
3285 if (orderByComparator.isAscending() ^ previous) {
3286 query.append(ORDER_BY_ASC_HAS_NEXT);
3287 }
3288 else {
3289 query.append(ORDER_BY_DESC_HAS_NEXT);
3290 }
3291 }
3292 else {
3293 if (orderByComparator.isAscending() ^ previous) {
3294 query.append(ORDER_BY_ASC);
3295 }
3296 else {
3297 query.append(ORDER_BY_DESC);
3298 }
3299 }
3300 }
3301 }
3302
3303 else {
3304 query.append(RoleModelImpl.ORDER_BY_JPQL);
3305 }
3306
3307 String sql = query.toString();
3308
3309 Query q = session.createQuery(sql);
3310
3311 q.setFirstResult(0);
3312 q.setMaxResults(2);
3313
3314 QueryPos qPos = QueryPos.getInstance(q);
3315
3316 qPos.add(type);
3317
3318 if (subtype != null) {
3319 qPos.add(subtype);
3320 }
3321
3322 if (orderByComparator != null) {
3323 Object[] values = orderByComparator.getOrderByConditionValues(role);
3324
3325 for (Object value : values) {
3326 qPos.add(value);
3327 }
3328 }
3329
3330 List<Role> list = q.list();
3331
3332 if (list.size() == 2) {
3333 return list.get(1);
3334 }
3335 else {
3336 return null;
3337 }
3338 }
3339
3340
3348 public List<Role> filterFindByT_S(int type, String subtype)
3349 throws SystemException {
3350 return filterFindByT_S(type, subtype, QueryUtil.ALL_POS,
3351 QueryUtil.ALL_POS, null);
3352 }
3353
3354
3368 public List<Role> filterFindByT_S(int type, String subtype, int start,
3369 int end) throws SystemException {
3370 return filterFindByT_S(type, subtype, start, end, null);
3371 }
3372
3373
3388 public List<Role> filterFindByT_S(int type, String subtype, int start,
3389 int end, OrderByComparator orderByComparator) throws SystemException {
3390 if (!InlineSQLHelperUtil.isEnabled()) {
3391 return findByT_S(type, subtype, start, end, orderByComparator);
3392 }
3393
3394 StringBundler query = null;
3395
3396 if (orderByComparator != null) {
3397 query = new StringBundler(4 +
3398 (orderByComparator.getOrderByFields().length * 3));
3399 }
3400 else {
3401 query = new StringBundler(4);
3402 }
3403
3404 if (getDB().isSupportsInlineDistinct()) {
3405 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
3406 }
3407 else {
3408 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
3409 }
3410
3411 query.append(_FINDER_COLUMN_T_S_TYPE_2);
3412
3413 if (subtype == null) {
3414 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
3415 }
3416 else {
3417 if (subtype.equals(StringPool.BLANK)) {
3418 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
3419 }
3420 else {
3421 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
3422 }
3423 }
3424
3425 if (!getDB().isSupportsInlineDistinct()) {
3426 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
3427 }
3428
3429 if (orderByComparator != null) {
3430 if (getDB().isSupportsInlineDistinct()) {
3431 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3432 orderByComparator);
3433 }
3434 else {
3435 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3436 orderByComparator);
3437 }
3438 }
3439
3440 else {
3441 if (getDB().isSupportsInlineDistinct()) {
3442 query.append(RoleModelImpl.ORDER_BY_JPQL);
3443 }
3444 else {
3445 query.append(RoleModelImpl.ORDER_BY_SQL);
3446 }
3447 }
3448
3449 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3450 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3451
3452 Session session = null;
3453
3454 try {
3455 session = openSession();
3456
3457 SQLQuery q = session.createSQLQuery(sql);
3458
3459 if (getDB().isSupportsInlineDistinct()) {
3460 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
3461 }
3462 else {
3463 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
3464 }
3465
3466 QueryPos qPos = QueryPos.getInstance(q);
3467
3468 qPos.add(type);
3469
3470 if (subtype != null) {
3471 qPos.add(subtype);
3472 }
3473
3474 return (List<Role>)QueryUtil.list(q, getDialect(), start, end);
3475 }
3476 catch (Exception e) {
3477 throw processException(e);
3478 }
3479 finally {
3480 closeSession(session);
3481 }
3482 }
3483
3484
3495 public Role[] filterFindByT_S_PrevAndNext(long roleId, int type,
3496 String subtype, OrderByComparator orderByComparator)
3497 throws NoSuchRoleException, SystemException {
3498 if (!InlineSQLHelperUtil.isEnabled()) {
3499 return findByT_S_PrevAndNext(roleId, type, subtype,
3500 orderByComparator);
3501 }
3502
3503 Role role = findByPrimaryKey(roleId);
3504
3505 Session session = null;
3506
3507 try {
3508 session = openSession();
3509
3510 Role[] array = new RoleImpl[3];
3511
3512 array[0] = filterGetByT_S_PrevAndNext(session, role, type, subtype,
3513 orderByComparator, true);
3514
3515 array[1] = role;
3516
3517 array[2] = filterGetByT_S_PrevAndNext(session, role, type, subtype,
3518 orderByComparator, false);
3519
3520 return array;
3521 }
3522 catch (Exception e) {
3523 throw processException(e);
3524 }
3525 finally {
3526 closeSession(session);
3527 }
3528 }
3529
3530 protected Role filterGetByT_S_PrevAndNext(Session session, Role role,
3531 int type, String subtype, OrderByComparator orderByComparator,
3532 boolean previous) {
3533 StringBundler query = null;
3534
3535 if (orderByComparator != null) {
3536 query = new StringBundler(6 +
3537 (orderByComparator.getOrderByFields().length * 6));
3538 }
3539 else {
3540 query = new StringBundler(3);
3541 }
3542
3543 if (getDB().isSupportsInlineDistinct()) {
3544 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
3545 }
3546 else {
3547 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
3548 }
3549
3550 query.append(_FINDER_COLUMN_T_S_TYPE_2);
3551
3552 if (subtype == null) {
3553 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
3554 }
3555 else {
3556 if (subtype.equals(StringPool.BLANK)) {
3557 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
3558 }
3559 else {
3560 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
3561 }
3562 }
3563
3564 if (!getDB().isSupportsInlineDistinct()) {
3565 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
3566 }
3567
3568 if (orderByComparator != null) {
3569 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3570
3571 if (orderByConditionFields.length > 0) {
3572 query.append(WHERE_AND);
3573 }
3574
3575 for (int i = 0; i < orderByConditionFields.length; i++) {
3576 if (getDB().isSupportsInlineDistinct()) {
3577 query.append(_ORDER_BY_ENTITY_ALIAS);
3578 }
3579 else {
3580 query.append(_ORDER_BY_ENTITY_TABLE);
3581 }
3582
3583 query.append(orderByConditionFields[i]);
3584
3585 if ((i + 1) < orderByConditionFields.length) {
3586 if (orderByComparator.isAscending() ^ previous) {
3587 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3588 }
3589 else {
3590 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3591 }
3592 }
3593 else {
3594 if (orderByComparator.isAscending() ^ previous) {
3595 query.append(WHERE_GREATER_THAN);
3596 }
3597 else {
3598 query.append(WHERE_LESSER_THAN);
3599 }
3600 }
3601 }
3602
3603 query.append(ORDER_BY_CLAUSE);
3604
3605 String[] orderByFields = orderByComparator.getOrderByFields();
3606
3607 for (int i = 0; i < orderByFields.length; i++) {
3608 if (getDB().isSupportsInlineDistinct()) {
3609 query.append(_ORDER_BY_ENTITY_ALIAS);
3610 }
3611 else {
3612 query.append(_ORDER_BY_ENTITY_TABLE);
3613 }
3614
3615 query.append(orderByFields[i]);
3616
3617 if ((i + 1) < orderByFields.length) {
3618 if (orderByComparator.isAscending() ^ previous) {
3619 query.append(ORDER_BY_ASC_HAS_NEXT);
3620 }
3621 else {
3622 query.append(ORDER_BY_DESC_HAS_NEXT);
3623 }
3624 }
3625 else {
3626 if (orderByComparator.isAscending() ^ previous) {
3627 query.append(ORDER_BY_ASC);
3628 }
3629 else {
3630 query.append(ORDER_BY_DESC);
3631 }
3632 }
3633 }
3634 }
3635
3636 else {
3637 if (getDB().isSupportsInlineDistinct()) {
3638 query.append(RoleModelImpl.ORDER_BY_JPQL);
3639 }
3640 else {
3641 query.append(RoleModelImpl.ORDER_BY_SQL);
3642 }
3643 }
3644
3645 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3646 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3647
3648 SQLQuery q = session.createSQLQuery(sql);
3649
3650 q.setFirstResult(0);
3651 q.setMaxResults(2);
3652
3653 if (getDB().isSupportsInlineDistinct()) {
3654 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
3655 }
3656 else {
3657 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
3658 }
3659
3660 QueryPos qPos = QueryPos.getInstance(q);
3661
3662 qPos.add(type);
3663
3664 if (subtype != null) {
3665 qPos.add(subtype);
3666 }
3667
3668 if (orderByComparator != null) {
3669 Object[] values = orderByComparator.getOrderByConditionValues(role);
3670
3671 for (Object value : values) {
3672 qPos.add(value);
3673 }
3674 }
3675
3676 List<Role> list = q.list();
3677
3678 if (list.size() == 2) {
3679 return list.get(1);
3680 }
3681 else {
3682 return null;
3683 }
3684 }
3685
3686
3696 public Role findByC_C_C(long companyId, long classNameId, long classPK)
3697 throws NoSuchRoleException, SystemException {
3698 Role role = fetchByC_C_C(companyId, classNameId, classPK);
3699
3700 if (role == null) {
3701 StringBundler msg = new StringBundler(8);
3702
3703 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3704
3705 msg.append("companyId=");
3706 msg.append(companyId);
3707
3708 msg.append(", classNameId=");
3709 msg.append(classNameId);
3710
3711 msg.append(", classPK=");
3712 msg.append(classPK);
3713
3714 msg.append(StringPool.CLOSE_CURLY_BRACE);
3715
3716 if (_log.isWarnEnabled()) {
3717 _log.warn(msg.toString());
3718 }
3719
3720 throw new NoSuchRoleException(msg.toString());
3721 }
3722
3723 return role;
3724 }
3725
3726
3735 public Role fetchByC_C_C(long companyId, long classNameId, long classPK)
3736 throws SystemException {
3737 return fetchByC_C_C(companyId, classNameId, classPK, true);
3738 }
3739
3740
3750 public Role fetchByC_C_C(long companyId, long classNameId, long classPK,
3751 boolean retrieveFromCache) throws SystemException {
3752 Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
3753
3754 Object result = null;
3755
3756 if (retrieveFromCache) {
3757 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C_C,
3758 finderArgs, this);
3759 }
3760
3761 if (result instanceof Role) {
3762 Role role = (Role)result;
3763
3764 if ((companyId != role.getCompanyId()) ||
3765 (classNameId != role.getClassNameId()) ||
3766 (classPK != role.getClassPK())) {
3767 result = null;
3768 }
3769 }
3770
3771 if (result == null) {
3772 StringBundler query = new StringBundler(5);
3773
3774 query.append(_SQL_SELECT_ROLE_WHERE);
3775
3776 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
3777
3778 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
3779
3780 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
3781
3782 query.append(RoleModelImpl.ORDER_BY_JPQL);
3783
3784 String sql = query.toString();
3785
3786 Session session = null;
3787
3788 try {
3789 session = openSession();
3790
3791 Query q = session.createQuery(sql);
3792
3793 QueryPos qPos = QueryPos.getInstance(q);
3794
3795 qPos.add(companyId);
3796
3797 qPos.add(classNameId);
3798
3799 qPos.add(classPK);
3800
3801 List<Role> list = q.list();
3802
3803 result = list;
3804
3805 Role role = null;
3806
3807 if (list.isEmpty()) {
3808 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
3809 finderArgs, list);
3810 }
3811 else {
3812 role = list.get(0);
3813
3814 cacheResult(role);
3815
3816 if ((role.getCompanyId() != companyId) ||
3817 (role.getClassNameId() != classNameId) ||
3818 (role.getClassPK() != classPK)) {
3819 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
3820 finderArgs, role);
3821 }
3822 }
3823
3824 return role;
3825 }
3826 catch (Exception e) {
3827 throw processException(e);
3828 }
3829 finally {
3830 if (result == null) {
3831 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C,
3832 finderArgs);
3833 }
3834
3835 closeSession(session);
3836 }
3837 }
3838 else {
3839 if (result instanceof List<?>) {
3840 return null;
3841 }
3842 else {
3843 return (Role)result;
3844 }
3845 }
3846 }
3847
3848
3854 public List<Role> findAll() throws SystemException {
3855 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3856 }
3857
3858
3870 public List<Role> findAll(int start, int end) throws SystemException {
3871 return findAll(start, end, null);
3872 }
3873
3874
3887 public List<Role> findAll(int start, int end,
3888 OrderByComparator orderByComparator) throws SystemException {
3889 FinderPath finderPath = null;
3890 Object[] finderArgs = new Object[] { start, end, orderByComparator };
3891
3892 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3893 (orderByComparator == null)) {
3894 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3895 finderArgs = FINDER_ARGS_EMPTY;
3896 }
3897 else {
3898 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3899 finderArgs = new Object[] { start, end, orderByComparator };
3900 }
3901
3902 List<Role> list = (List<Role>)FinderCacheUtil.getResult(finderPath,
3903 finderArgs, this);
3904
3905 if (list == null) {
3906 StringBundler query = null;
3907 String sql = null;
3908
3909 if (orderByComparator != null) {
3910 query = new StringBundler(2 +
3911 (orderByComparator.getOrderByFields().length * 3));
3912
3913 query.append(_SQL_SELECT_ROLE);
3914
3915 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3916 orderByComparator);
3917
3918 sql = query.toString();
3919 }
3920 else {
3921 sql = _SQL_SELECT_ROLE.concat(RoleModelImpl.ORDER_BY_JPQL);
3922 }
3923
3924 Session session = null;
3925
3926 try {
3927 session = openSession();
3928
3929 Query q = session.createQuery(sql);
3930
3931 if (orderByComparator == null) {
3932 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
3933 end, false);
3934
3935 Collections.sort(list);
3936 }
3937 else {
3938 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
3939 end);
3940 }
3941 }
3942 catch (Exception e) {
3943 throw processException(e);
3944 }
3945 finally {
3946 if (list == null) {
3947 FinderCacheUtil.removeResult(finderPath, finderArgs);
3948 }
3949 else {
3950 cacheResult(list);
3951
3952 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3953 }
3954
3955 closeSession(session);
3956 }
3957 }
3958
3959 return list;
3960 }
3961
3962
3968 public void removeByCompanyId(long companyId) throws SystemException {
3969 for (Role role : findByCompanyId(companyId)) {
3970 remove(role);
3971 }
3972 }
3973
3974
3980 public void removeByName(String name) throws SystemException {
3981 for (Role role : findByName(name)) {
3982 remove(role);
3983 }
3984 }
3985
3986
3992 public void removeBySubtype(String subtype) throws SystemException {
3993 for (Role role : findBySubtype(subtype)) {
3994 remove(role);
3995 }
3996 }
3997
3998
4005 public void removeByC_N(long companyId, String name)
4006 throws NoSuchRoleException, SystemException {
4007 Role role = findByC_N(companyId, name);
4008
4009 remove(role);
4010 }
4011
4012
4019 public void removeByT_S(int type, String subtype) throws SystemException {
4020 for (Role role : findByT_S(type, subtype)) {
4021 remove(role);
4022 }
4023 }
4024
4025
4033 public void removeByC_C_C(long companyId, long classNameId, long classPK)
4034 throws NoSuchRoleException, SystemException {
4035 Role role = findByC_C_C(companyId, classNameId, classPK);
4036
4037 remove(role);
4038 }
4039
4040
4045 public void removeAll() throws SystemException {
4046 for (Role role : findAll()) {
4047 remove(role);
4048 }
4049 }
4050
4051
4058 public int countByCompanyId(long companyId) throws SystemException {
4059 Object[] finderArgs = new Object[] { companyId };
4060
4061 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
4062 finderArgs, this);
4063
4064 if (count == null) {
4065 StringBundler query = new StringBundler(2);
4066
4067 query.append(_SQL_COUNT_ROLE_WHERE);
4068
4069 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
4070
4071 String sql = query.toString();
4072
4073 Session session = null;
4074
4075 try {
4076 session = openSession();
4077
4078 Query q = session.createQuery(sql);
4079
4080 QueryPos qPos = QueryPos.getInstance(q);
4081
4082 qPos.add(companyId);
4083
4084 count = (Long)q.uniqueResult();
4085 }
4086 catch (Exception e) {
4087 throw processException(e);
4088 }
4089 finally {
4090 if (count == null) {
4091 count = Long.valueOf(0);
4092 }
4093
4094 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
4095 finderArgs, count);
4096
4097 closeSession(session);
4098 }
4099 }
4100
4101 return count.intValue();
4102 }
4103
4104
4111 public int filterCountByCompanyId(long companyId) throws SystemException {
4112 if (!InlineSQLHelperUtil.isEnabled()) {
4113 return countByCompanyId(companyId);
4114 }
4115
4116 StringBundler query = new StringBundler(2);
4117
4118 query.append(_FILTER_SQL_COUNT_ROLE_WHERE);
4119
4120 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
4121
4122 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4123 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4124
4125 Session session = null;
4126
4127 try {
4128 session = openSession();
4129
4130 SQLQuery q = session.createSQLQuery(sql);
4131
4132 q.addScalar(COUNT_COLUMN_NAME,
4133 com.liferay.portal.kernel.dao.orm.Type.LONG);
4134
4135 QueryPos qPos = QueryPos.getInstance(q);
4136
4137 qPos.add(companyId);
4138
4139 Long count = (Long)q.uniqueResult();
4140
4141 return count.intValue();
4142 }
4143 catch (Exception e) {
4144 throw processException(e);
4145 }
4146 finally {
4147 closeSession(session);
4148 }
4149 }
4150
4151
4158 public int countByName(String name) throws SystemException {
4159 Object[] finderArgs = new Object[] { name };
4160
4161 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_NAME,
4162 finderArgs, this);
4163
4164 if (count == null) {
4165 StringBundler query = new StringBundler(2);
4166
4167 query.append(_SQL_COUNT_ROLE_WHERE);
4168
4169 if (name == null) {
4170 query.append(_FINDER_COLUMN_NAME_NAME_1);
4171 }
4172 else {
4173 if (name.equals(StringPool.BLANK)) {
4174 query.append(_FINDER_COLUMN_NAME_NAME_3);
4175 }
4176 else {
4177 query.append(_FINDER_COLUMN_NAME_NAME_2);
4178 }
4179 }
4180
4181 String sql = query.toString();
4182
4183 Session session = null;
4184
4185 try {
4186 session = openSession();
4187
4188 Query q = session.createQuery(sql);
4189
4190 QueryPos qPos = QueryPos.getInstance(q);
4191
4192 if (name != null) {
4193 qPos.add(name);
4194 }
4195
4196 count = (Long)q.uniqueResult();
4197 }
4198 catch (Exception e) {
4199 throw processException(e);
4200 }
4201 finally {
4202 if (count == null) {
4203 count = Long.valueOf(0);
4204 }
4205
4206 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_NAME,
4207 finderArgs, count);
4208
4209 closeSession(session);
4210 }
4211 }
4212
4213 return count.intValue();
4214 }
4215
4216
4223 public int filterCountByName(String name) throws SystemException {
4224 if (!InlineSQLHelperUtil.isEnabled()) {
4225 return countByName(name);
4226 }
4227
4228 StringBundler query = new StringBundler(2);
4229
4230 query.append(_FILTER_SQL_COUNT_ROLE_WHERE);
4231
4232 if (name == null) {
4233 query.append(_FINDER_COLUMN_NAME_NAME_1);
4234 }
4235 else {
4236 if (name.equals(StringPool.BLANK)) {
4237 query.append(_FINDER_COLUMN_NAME_NAME_3);
4238 }
4239 else {
4240 query.append(_FINDER_COLUMN_NAME_NAME_2);
4241 }
4242 }
4243
4244 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4245 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4246
4247 Session session = null;
4248
4249 try {
4250 session = openSession();
4251
4252 SQLQuery q = session.createSQLQuery(sql);
4253
4254 q.addScalar(COUNT_COLUMN_NAME,
4255 com.liferay.portal.kernel.dao.orm.Type.LONG);
4256
4257 QueryPos qPos = QueryPos.getInstance(q);
4258
4259 if (name != null) {
4260 qPos.add(name);
4261 }
4262
4263 Long count = (Long)q.uniqueResult();
4264
4265 return count.intValue();
4266 }
4267 catch (Exception e) {
4268 throw processException(e);
4269 }
4270 finally {
4271 closeSession(session);
4272 }
4273 }
4274
4275
4282 public int countBySubtype(String subtype) throws SystemException {
4283 Object[] finderArgs = new Object[] { subtype };
4284
4285 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SUBTYPE,
4286 finderArgs, this);
4287
4288 if (count == null) {
4289 StringBundler query = new StringBundler(2);
4290
4291 query.append(_SQL_COUNT_ROLE_WHERE);
4292
4293 if (subtype == null) {
4294 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
4295 }
4296 else {
4297 if (subtype.equals(StringPool.BLANK)) {
4298 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
4299 }
4300 else {
4301 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
4302 }
4303 }
4304
4305 String sql = query.toString();
4306
4307 Session session = null;
4308
4309 try {
4310 session = openSession();
4311
4312 Query q = session.createQuery(sql);
4313
4314 QueryPos qPos = QueryPos.getInstance(q);
4315
4316 if (subtype != null) {
4317 qPos.add(subtype);
4318 }
4319
4320 count = (Long)q.uniqueResult();
4321 }
4322 catch (Exception e) {
4323 throw processException(e);
4324 }
4325 finally {
4326 if (count == null) {
4327 count = Long.valueOf(0);
4328 }
4329
4330 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SUBTYPE,
4331 finderArgs, count);
4332
4333 closeSession(session);
4334 }
4335 }
4336
4337 return count.intValue();
4338 }
4339
4340
4347 public int filterCountBySubtype(String subtype) throws SystemException {
4348 if (!InlineSQLHelperUtil.isEnabled()) {
4349 return countBySubtype(subtype);
4350 }
4351
4352 StringBundler query = new StringBundler(2);
4353
4354 query.append(_FILTER_SQL_COUNT_ROLE_WHERE);
4355
4356 if (subtype == null) {
4357 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
4358 }
4359 else {
4360 if (subtype.equals(StringPool.BLANK)) {
4361 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
4362 }
4363 else {
4364 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
4365 }
4366 }
4367
4368 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4369 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4370
4371 Session session = null;
4372
4373 try {
4374 session = openSession();
4375
4376 SQLQuery q = session.createSQLQuery(sql);
4377
4378 q.addScalar(COUNT_COLUMN_NAME,
4379 com.liferay.portal.kernel.dao.orm.Type.LONG);
4380
4381 QueryPos qPos = QueryPos.getInstance(q);
4382
4383 if (subtype != null) {
4384 qPos.add(subtype);
4385 }
4386
4387 Long count = (Long)q.uniqueResult();
4388
4389 return count.intValue();
4390 }
4391 catch (Exception e) {
4392 throw processException(e);
4393 }
4394 finally {
4395 closeSession(session);
4396 }
4397 }
4398
4399
4407 public int countByC_N(long companyId, String name)
4408 throws SystemException {
4409 Object[] finderArgs = new Object[] { companyId, name };
4410
4411 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_N,
4412 finderArgs, this);
4413
4414 if (count == null) {
4415 StringBundler query = new StringBundler(3);
4416
4417 query.append(_SQL_COUNT_ROLE_WHERE);
4418
4419 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
4420
4421 if (name == null) {
4422 query.append(_FINDER_COLUMN_C_N_NAME_1);
4423 }
4424 else {
4425 if (name.equals(StringPool.BLANK)) {
4426 query.append(_FINDER_COLUMN_C_N_NAME_3);
4427 }
4428 else {
4429 query.append(_FINDER_COLUMN_C_N_NAME_2);
4430 }
4431 }
4432
4433 String sql = query.toString();
4434
4435 Session session = null;
4436
4437 try {
4438 session = openSession();
4439
4440 Query q = session.createQuery(sql);
4441
4442 QueryPos qPos = QueryPos.getInstance(q);
4443
4444 qPos.add(companyId);
4445
4446 if (name != null) {
4447 qPos.add(name);
4448 }
4449
4450 count = (Long)q.uniqueResult();
4451 }
4452 catch (Exception e) {
4453 throw processException(e);
4454 }
4455 finally {
4456 if (count == null) {
4457 count = Long.valueOf(0);
4458 }
4459
4460 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, finderArgs,
4461 count);
4462
4463 closeSession(session);
4464 }
4465 }
4466
4467 return count.intValue();
4468 }
4469
4470
4478 public int countByT_S(int type, String subtype) throws SystemException {
4479 Object[] finderArgs = new Object[] { type, subtype };
4480
4481 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_T_S,
4482 finderArgs, this);
4483
4484 if (count == null) {
4485 StringBundler query = new StringBundler(3);
4486
4487 query.append(_SQL_COUNT_ROLE_WHERE);
4488
4489 query.append(_FINDER_COLUMN_T_S_TYPE_2);
4490
4491 if (subtype == null) {
4492 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
4493 }
4494 else {
4495 if (subtype.equals(StringPool.BLANK)) {
4496 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
4497 }
4498 else {
4499 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
4500 }
4501 }
4502
4503 String sql = query.toString();
4504
4505 Session session = null;
4506
4507 try {
4508 session = openSession();
4509
4510 Query q = session.createQuery(sql);
4511
4512 QueryPos qPos = QueryPos.getInstance(q);
4513
4514 qPos.add(type);
4515
4516 if (subtype != null) {
4517 qPos.add(subtype);
4518 }
4519
4520 count = (Long)q.uniqueResult();
4521 }
4522 catch (Exception e) {
4523 throw processException(e);
4524 }
4525 finally {
4526 if (count == null) {
4527 count = Long.valueOf(0);
4528 }
4529
4530 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_S, finderArgs,
4531 count);
4532
4533 closeSession(session);
4534 }
4535 }
4536
4537 return count.intValue();
4538 }
4539
4540
4548 public int filterCountByT_S(int type, String subtype)
4549 throws SystemException {
4550 if (!InlineSQLHelperUtil.isEnabled()) {
4551 return countByT_S(type, subtype);
4552 }
4553
4554 StringBundler query = new StringBundler(3);
4555
4556 query.append(_FILTER_SQL_COUNT_ROLE_WHERE);
4557
4558 query.append(_FINDER_COLUMN_T_S_TYPE_2);
4559
4560 if (subtype == null) {
4561 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
4562 }
4563 else {
4564 if (subtype.equals(StringPool.BLANK)) {
4565 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
4566 }
4567 else {
4568 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
4569 }
4570 }
4571
4572 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4573 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4574
4575 Session session = null;
4576
4577 try {
4578 session = openSession();
4579
4580 SQLQuery q = session.createSQLQuery(sql);
4581
4582 q.addScalar(COUNT_COLUMN_NAME,
4583 com.liferay.portal.kernel.dao.orm.Type.LONG);
4584
4585 QueryPos qPos = QueryPos.getInstance(q);
4586
4587 qPos.add(type);
4588
4589 if (subtype != null) {
4590 qPos.add(subtype);
4591 }
4592
4593 Long count = (Long)q.uniqueResult();
4594
4595 return count.intValue();
4596 }
4597 catch (Exception e) {
4598 throw processException(e);
4599 }
4600 finally {
4601 closeSession(session);
4602 }
4603 }
4604
4605
4614 public int countByC_C_C(long companyId, long classNameId, long classPK)
4615 throws SystemException {
4616 Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
4617
4618 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_C,
4619 finderArgs, this);
4620
4621 if (count == null) {
4622 StringBundler query = new StringBundler(4);
4623
4624 query.append(_SQL_COUNT_ROLE_WHERE);
4625
4626 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
4627
4628 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
4629
4630 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
4631
4632 String sql = query.toString();
4633
4634 Session session = null;
4635
4636 try {
4637 session = openSession();
4638
4639 Query q = session.createQuery(sql);
4640
4641 QueryPos qPos = QueryPos.getInstance(q);
4642
4643 qPos.add(companyId);
4644
4645 qPos.add(classNameId);
4646
4647 qPos.add(classPK);
4648
4649 count = (Long)q.uniqueResult();
4650 }
4651 catch (Exception e) {
4652 throw processException(e);
4653 }
4654 finally {
4655 if (count == null) {
4656 count = Long.valueOf(0);
4657 }
4658
4659 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C,
4660 finderArgs, count);
4661
4662 closeSession(session);
4663 }
4664 }
4665
4666 return count.intValue();
4667 }
4668
4669
4675 public int countAll() throws SystemException {
4676 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4677 FINDER_ARGS_EMPTY, this);
4678
4679 if (count == null) {
4680 Session session = null;
4681
4682 try {
4683 session = openSession();
4684
4685 Query q = session.createQuery(_SQL_COUNT_ROLE);
4686
4687 count = (Long)q.uniqueResult();
4688 }
4689 catch (Exception e) {
4690 throw processException(e);
4691 }
4692 finally {
4693 if (count == null) {
4694 count = Long.valueOf(0);
4695 }
4696
4697 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
4698 FINDER_ARGS_EMPTY, count);
4699
4700 closeSession(session);
4701 }
4702 }
4703
4704 return count.intValue();
4705 }
4706
4707
4714 public List<com.liferay.portal.model.Group> getGroups(long pk)
4715 throws SystemException {
4716 return getGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
4717 }
4718
4719
4732 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
4733 int end) throws SystemException {
4734 return getGroups(pk, start, end, null);
4735 }
4736
4737 public static final FinderPath FINDER_PATH_GET_GROUPS = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
4738 RoleModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES,
4739 com.liferay.portal.model.impl.GroupImpl.class,
4740 RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "getGroups",
4741 new String[] {
4742 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
4743 "com.liferay.portal.kernel.util.OrderByComparator"
4744 });
4745
4746 static {
4747 FINDER_PATH_GET_GROUPS.setCacheKeyGeneratorCacheName(null);
4748 }
4749
4750
4764 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
4765 int end, OrderByComparator orderByComparator) throws SystemException {
4766 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
4767
4768 List<com.liferay.portal.model.Group> list = (List<com.liferay.portal.model.Group>)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS,
4769 finderArgs, this);
4770
4771 if (list == null) {
4772 Session session = null;
4773
4774 try {
4775 session = openSession();
4776
4777 String sql = null;
4778
4779 if (orderByComparator != null) {
4780 sql = _SQL_GETGROUPS.concat(ORDER_BY_CLAUSE)
4781 .concat(orderByComparator.getOrderBy());
4782 }
4783 else {
4784 sql = _SQL_GETGROUPS.concat(com.liferay.portal.model.impl.GroupModelImpl.ORDER_BY_SQL);
4785 }
4786
4787 SQLQuery q = session.createSQLQuery(sql);
4788
4789 q.addEntity("Group_",
4790 com.liferay.portal.model.impl.GroupImpl.class);
4791
4792 QueryPos qPos = QueryPos.getInstance(q);
4793
4794 qPos.add(pk);
4795
4796 list = (List<com.liferay.portal.model.Group>)QueryUtil.list(q,
4797 getDialect(), start, end);
4798 }
4799 catch (Exception e) {
4800 throw processException(e);
4801 }
4802 finally {
4803 if (list == null) {
4804 FinderCacheUtil.removeResult(FINDER_PATH_GET_GROUPS,
4805 finderArgs);
4806 }
4807 else {
4808 groupPersistence.cacheResult(list);
4809
4810 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS,
4811 finderArgs, list);
4812 }
4813
4814 closeSession(session);
4815 }
4816 }
4817
4818 return list;
4819 }
4820
4821 public static final FinderPath FINDER_PATH_GET_GROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
4822 RoleModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES, Long.class,
4823 RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "getGroupsSize",
4824 new String[] { Long.class.getName() });
4825
4826 static {
4827 FINDER_PATH_GET_GROUPS_SIZE.setCacheKeyGeneratorCacheName(null);
4828 }
4829
4830
4837 public int getGroupsSize(long pk) throws SystemException {
4838 Object[] finderArgs = new Object[] { pk };
4839
4840 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS_SIZE,
4841 finderArgs, this);
4842
4843 if (count == null) {
4844 Session session = null;
4845
4846 try {
4847 session = openSession();
4848
4849 SQLQuery q = session.createSQLQuery(_SQL_GETGROUPSSIZE);
4850
4851 q.addScalar(COUNT_COLUMN_NAME,
4852 com.liferay.portal.kernel.dao.orm.Type.LONG);
4853
4854 QueryPos qPos = QueryPos.getInstance(q);
4855
4856 qPos.add(pk);
4857
4858 count = (Long)q.uniqueResult();
4859 }
4860 catch (Exception e) {
4861 throw processException(e);
4862 }
4863 finally {
4864 if (count == null) {
4865 count = Long.valueOf(0);
4866 }
4867
4868 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS_SIZE,
4869 finderArgs, count);
4870
4871 closeSession(session);
4872 }
4873 }
4874
4875 return count.intValue();
4876 }
4877
4878 public static final FinderPath FINDER_PATH_CONTAINS_GROUP = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
4879 RoleModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES, Boolean.class,
4880 RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "containsGroup",
4881 new String[] { Long.class.getName(), Long.class.getName() });
4882
4883
4891 public boolean containsGroup(long pk, long groupPK)
4892 throws SystemException {
4893 Object[] finderArgs = new Object[] { pk, groupPK };
4894
4895 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_GROUP,
4896 finderArgs, this);
4897
4898 if (value == null) {
4899 try {
4900 value = Boolean.valueOf(containsGroup.contains(pk, groupPK));
4901 }
4902 catch (Exception e) {
4903 throw processException(e);
4904 }
4905 finally {
4906 if (value == null) {
4907 value = Boolean.FALSE;
4908 }
4909
4910 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_GROUP,
4911 finderArgs, value);
4912 }
4913 }
4914
4915 return value.booleanValue();
4916 }
4917
4918
4925 public boolean containsGroups(long pk) throws SystemException {
4926 if (getGroupsSize(pk) > 0) {
4927 return true;
4928 }
4929 else {
4930 return false;
4931 }
4932 }
4933
4934
4941 public void addGroup(long pk, long groupPK) throws SystemException {
4942 try {
4943 addGroup.add(pk, groupPK);
4944 }
4945 catch (Exception e) {
4946 throw processException(e);
4947 }
4948 finally {
4949 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4950 }
4951 }
4952
4953
4960 public void addGroup(long pk, com.liferay.portal.model.Group group)
4961 throws SystemException {
4962 try {
4963 addGroup.add(pk, group.getPrimaryKey());
4964 }
4965 catch (Exception e) {
4966 throw processException(e);
4967 }
4968 finally {
4969 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4970 }
4971 }
4972
4973
4980 public void addGroups(long pk, long[] groupPKs) throws SystemException {
4981 try {
4982 for (long groupPK : groupPKs) {
4983 addGroup.add(pk, groupPK);
4984 }
4985 }
4986 catch (Exception e) {
4987 throw processException(e);
4988 }
4989 finally {
4990 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4991 }
4992 }
4993
4994
5001 public void addGroups(long pk, List<com.liferay.portal.model.Group> groups)
5002 throws SystemException {
5003 try {
5004 for (com.liferay.portal.model.Group group : groups) {
5005 addGroup.add(pk, group.getPrimaryKey());
5006 }
5007 }
5008 catch (Exception e) {
5009 throw processException(e);
5010 }
5011 finally {
5012 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5013 }
5014 }
5015
5016
5022 public void clearGroups(long pk) throws SystemException {
5023 try {
5024 clearGroups.clear(pk);
5025 }
5026 catch (Exception e) {
5027 throw processException(e);
5028 }
5029 finally {
5030 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5031 }
5032 }
5033
5034
5041 public void removeGroup(long pk, long groupPK) throws SystemException {
5042 try {
5043 removeGroup.remove(pk, groupPK);
5044 }
5045 catch (Exception e) {
5046 throw processException(e);
5047 }
5048 finally {
5049 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5050 }
5051 }
5052
5053
5060 public void removeGroup(long pk, com.liferay.portal.model.Group group)
5061 throws SystemException {
5062 try {
5063 removeGroup.remove(pk, group.getPrimaryKey());
5064 }
5065 catch (Exception e) {
5066 throw processException(e);
5067 }
5068 finally {
5069 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5070 }
5071 }
5072
5073
5080 public void removeGroups(long pk, long[] groupPKs)
5081 throws SystemException {
5082 try {
5083 for (long groupPK : groupPKs) {
5084 removeGroup.remove(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 removeGroups(long pk,
5103 List<com.liferay.portal.model.Group> groups) throws SystemException {
5104 try {
5105 for (com.liferay.portal.model.Group group : groups) {
5106 removeGroup.remove(pk, group.getPrimaryKey());
5107 }
5108 }
5109 catch (Exception e) {
5110 throw processException(e);
5111 }
5112 finally {
5113 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5114 }
5115 }
5116
5117
5124 public void setGroups(long pk, long[] groupPKs) throws SystemException {
5125 try {
5126 Set<Long> groupPKSet = SetUtil.fromArray(groupPKs);
5127
5128 List<com.liferay.portal.model.Group> groups = getGroups(pk);
5129
5130 for (com.liferay.portal.model.Group group : groups) {
5131 if (!groupPKSet.remove(group.getPrimaryKey())) {
5132 removeGroup.remove(pk, group.getPrimaryKey());
5133 }
5134 }
5135
5136 for (Long groupPK : groupPKSet) {
5137 addGroup.add(pk, groupPK);
5138 }
5139 }
5140 catch (Exception e) {
5141 throw processException(e);
5142 }
5143 finally {
5144 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5145 }
5146 }
5147
5148
5155 public void setGroups(long pk, List<com.liferay.portal.model.Group> groups)
5156 throws SystemException {
5157 try {
5158 long[] groupPKs = new long[groups.size()];
5159
5160 for (int i = 0; i < groups.size(); i++) {
5161 com.liferay.portal.model.Group group = groups.get(i);
5162
5163 groupPKs[i] = group.getPrimaryKey();
5164 }
5165
5166 setGroups(pk, groupPKs);
5167 }
5168 catch (Exception e) {
5169 throw processException(e);
5170 }
5171 finally {
5172 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5173 }
5174 }
5175
5176
5183 public List<com.liferay.portal.model.Permission> getPermissions(long pk)
5184 throws SystemException {
5185 return getPermissions(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
5186 }
5187
5188
5201 public List<com.liferay.portal.model.Permission> getPermissions(long pk,
5202 int start, int end) throws SystemException {
5203 return getPermissions(pk, start, end, null);
5204 }
5205
5206 public static final FinderPath FINDER_PATH_GET_PERMISSIONS = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
5207 RoleModelImpl.FINDER_CACHE_ENABLED_ROLES_PERMISSIONS,
5208 com.liferay.portal.model.impl.PermissionImpl.class,
5209 RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME,
5210 "getPermissions",
5211 new String[] {
5212 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
5213 "com.liferay.portal.kernel.util.OrderByComparator"
5214 });
5215
5216 static {
5217 FINDER_PATH_GET_PERMISSIONS.setCacheKeyGeneratorCacheName(null);
5218 }
5219
5220
5234 public List<com.liferay.portal.model.Permission> getPermissions(long pk,
5235 int start, int end, OrderByComparator orderByComparator)
5236 throws SystemException {
5237 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
5238
5239 List<com.liferay.portal.model.Permission> list = (List<com.liferay.portal.model.Permission>)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS,
5240 finderArgs, this);
5241
5242 if (list == null) {
5243 Session session = null;
5244
5245 try {
5246 session = openSession();
5247
5248 String sql = null;
5249
5250 if (orderByComparator != null) {
5251 sql = _SQL_GETPERMISSIONS.concat(ORDER_BY_CLAUSE)
5252 .concat(orderByComparator.getOrderBy());
5253 }
5254 else {
5255 sql = _SQL_GETPERMISSIONS;
5256 }
5257
5258 SQLQuery q = session.createSQLQuery(sql);
5259
5260 q.addEntity("Permission_",
5261 com.liferay.portal.model.impl.PermissionImpl.class);
5262
5263 QueryPos qPos = QueryPos.getInstance(q);
5264
5265 qPos.add(pk);
5266
5267 list = (List<com.liferay.portal.model.Permission>)QueryUtil.list(q,
5268 getDialect(), start, end);
5269 }
5270 catch (Exception e) {
5271 throw processException(e);
5272 }
5273 finally {
5274 if (list == null) {
5275 FinderCacheUtil.removeResult(FINDER_PATH_GET_PERMISSIONS,
5276 finderArgs);
5277 }
5278 else {
5279 permissionPersistence.cacheResult(list);
5280
5281 FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS,
5282 finderArgs, list);
5283 }
5284
5285 closeSession(session);
5286 }
5287 }
5288
5289 return list;
5290 }
5291
5292 public static final FinderPath FINDER_PATH_GET_PERMISSIONS_SIZE = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
5293 RoleModelImpl.FINDER_CACHE_ENABLED_ROLES_PERMISSIONS, Long.class,
5294 RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME,
5295 "getPermissionsSize", new String[] { Long.class.getName() });
5296
5297 static {
5298 FINDER_PATH_GET_PERMISSIONS_SIZE.setCacheKeyGeneratorCacheName(null);
5299 }
5300
5301
5308 public int getPermissionsSize(long pk) throws SystemException {
5309 Object[] finderArgs = new Object[] { pk };
5310
5311 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
5312 finderArgs, this);
5313
5314 if (count == null) {
5315 Session session = null;
5316
5317 try {
5318 session = openSession();
5319
5320 SQLQuery q = session.createSQLQuery(_SQL_GETPERMISSIONSSIZE);
5321
5322 q.addScalar(COUNT_COLUMN_NAME,
5323 com.liferay.portal.kernel.dao.orm.Type.LONG);
5324
5325 QueryPos qPos = QueryPos.getInstance(q);
5326
5327 qPos.add(pk);
5328
5329 count = (Long)q.uniqueResult();
5330 }
5331 catch (Exception e) {
5332 throw processException(e);
5333 }
5334 finally {
5335 if (count == null) {
5336 count = Long.valueOf(0);
5337 }
5338
5339 FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
5340 finderArgs, count);
5341
5342 closeSession(session);
5343 }
5344 }
5345
5346 return count.intValue();
5347 }
5348
5349 public static final FinderPath FINDER_PATH_CONTAINS_PERMISSION = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
5350 RoleModelImpl.FINDER_CACHE_ENABLED_ROLES_PERMISSIONS,
5351 Boolean.class, RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME,
5352 "containsPermission",
5353 new String[] { Long.class.getName(), Long.class.getName() });
5354
5355
5363 public boolean containsPermission(long pk, long permissionPK)
5364 throws SystemException {
5365 Object[] finderArgs = new Object[] { pk, permissionPK };
5366
5367 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_PERMISSION,
5368 finderArgs, this);
5369
5370 if (value == null) {
5371 try {
5372 value = Boolean.valueOf(containsPermission.contains(pk,
5373 permissionPK));
5374 }
5375 catch (Exception e) {
5376 throw processException(e);
5377 }
5378 finally {
5379 if (value == null) {
5380 value = Boolean.FALSE;
5381 }
5382
5383 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_PERMISSION,
5384 finderArgs, value);
5385 }
5386 }
5387
5388 return value.booleanValue();
5389 }
5390
5391
5398 public boolean containsPermissions(long pk) throws SystemException {
5399 if (getPermissionsSize(pk) > 0) {
5400 return true;
5401 }
5402 else {
5403 return false;
5404 }
5405 }
5406
5407
5414 public void addPermission(long pk, long permissionPK)
5415 throws SystemException {
5416 try {
5417 addPermission.add(pk, permissionPK);
5418 }
5419 catch (Exception e) {
5420 throw processException(e);
5421 }
5422 finally {
5423 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5424 }
5425 }
5426
5427
5434 public void addPermission(long pk,
5435 com.liferay.portal.model.Permission permission)
5436 throws SystemException {
5437 try {
5438 addPermission.add(pk, permission.getPrimaryKey());
5439 }
5440 catch (Exception e) {
5441 throw processException(e);
5442 }
5443 finally {
5444 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5445 }
5446 }
5447
5448
5455 public void addPermissions(long pk, long[] permissionPKs)
5456 throws SystemException {
5457 try {
5458 for (long permissionPK : permissionPKs) {
5459 addPermission.add(pk, permissionPK);
5460 }
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 addPermissions(long pk,
5478 List<com.liferay.portal.model.Permission> permissions)
5479 throws SystemException {
5480 try {
5481 for (com.liferay.portal.model.Permission permission : permissions) {
5482 addPermission.add(pk, permission.getPrimaryKey());
5483 }
5484 }
5485 catch (Exception e) {
5486 throw processException(e);
5487 }
5488 finally {
5489 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5490 }
5491 }
5492
5493
5499 public void clearPermissions(long pk) throws SystemException {
5500 try {
5501 clearPermissions.clear(pk);
5502 }
5503 catch (Exception e) {
5504 throw processException(e);
5505 }
5506 finally {
5507 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5508 }
5509 }
5510
5511
5518 public void removePermission(long pk, long permissionPK)
5519 throws SystemException {
5520 try {
5521 removePermission.remove(pk, permissionPK);
5522 }
5523 catch (Exception e) {
5524 throw processException(e);
5525 }
5526 finally {
5527 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5528 }
5529 }
5530
5531
5538 public void removePermission(long pk,
5539 com.liferay.portal.model.Permission permission)
5540 throws SystemException {
5541 try {
5542 removePermission.remove(pk, permission.getPrimaryKey());
5543 }
5544 catch (Exception e) {
5545 throw processException(e);
5546 }
5547 finally {
5548 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5549 }
5550 }
5551
5552
5559 public void removePermissions(long pk, long[] permissionPKs)
5560 throws SystemException {
5561 try {
5562 for (long permissionPK : permissionPKs) {
5563 removePermission.remove(pk, permissionPK);
5564 }
5565 }
5566 catch (Exception e) {
5567 throw processException(e);
5568 }
5569 finally {
5570 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5571 }
5572 }
5573
5574
5581 public void removePermissions(long pk,
5582 List<com.liferay.portal.model.Permission> permissions)
5583 throws SystemException {
5584 try {
5585 for (com.liferay.portal.model.Permission permission : permissions) {
5586 removePermission.remove(pk, permission.getPrimaryKey());
5587 }
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 void setPermissions(long pk, long[] permissionPKs)
5605 throws SystemException {
5606 try {
5607 Set<Long> permissionPKSet = SetUtil.fromArray(permissionPKs);
5608
5609 List<com.liferay.portal.model.Permission> permissions = getPermissions(pk);
5610
5611 for (com.liferay.portal.model.Permission permission : permissions) {
5612 if (!permissionPKSet.remove(permission.getPrimaryKey())) {
5613 removePermission.remove(pk, permission.getPrimaryKey());
5614 }
5615 }
5616
5617 for (Long permissionPK : permissionPKSet) {
5618 addPermission.add(pk, permissionPK);
5619 }
5620 }
5621 catch (Exception e) {
5622 throw processException(e);
5623 }
5624 finally {
5625 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5626 }
5627 }
5628
5629
5636 public void setPermissions(long pk,
5637 List<com.liferay.portal.model.Permission> permissions)
5638 throws SystemException {
5639 try {
5640 long[] permissionPKs = new long[permissions.size()];
5641
5642 for (int i = 0; i < permissions.size(); i++) {
5643 com.liferay.portal.model.Permission permission = permissions.get(i);
5644
5645 permissionPKs[i] = permission.getPrimaryKey();
5646 }
5647
5648 setPermissions(pk, permissionPKs);
5649 }
5650 catch (Exception e) {
5651 throw processException(e);
5652 }
5653 finally {
5654 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5655 }
5656 }
5657
5658
5665 public List<com.liferay.portal.model.User> getUsers(long pk)
5666 throws SystemException {
5667 return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
5668 }
5669
5670
5683 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
5684 int end) throws SystemException {
5685 return getUsers(pk, start, end, null);
5686 }
5687
5688 public static final FinderPath FINDER_PATH_GET_USERS = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
5689 RoleModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES,
5690 com.liferay.portal.model.impl.UserImpl.class,
5691 RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "getUsers",
5692 new String[] {
5693 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
5694 "com.liferay.portal.kernel.util.OrderByComparator"
5695 });
5696
5697 static {
5698 FINDER_PATH_GET_USERS.setCacheKeyGeneratorCacheName(null);
5699 }
5700
5701
5715 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
5716 int end, OrderByComparator orderByComparator) throws SystemException {
5717 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
5718
5719 List<com.liferay.portal.model.User> list = (List<com.liferay.portal.model.User>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS,
5720 finderArgs, this);
5721
5722 if (list == null) {
5723 Session session = null;
5724
5725 try {
5726 session = openSession();
5727
5728 String sql = null;
5729
5730 if (orderByComparator != null) {
5731 sql = _SQL_GETUSERS.concat(ORDER_BY_CLAUSE)
5732 .concat(orderByComparator.getOrderBy());
5733 }
5734 else {
5735 sql = _SQL_GETUSERS;
5736 }
5737
5738 SQLQuery q = session.createSQLQuery(sql);
5739
5740 q.addEntity("User_",
5741 com.liferay.portal.model.impl.UserImpl.class);
5742
5743 QueryPos qPos = QueryPos.getInstance(q);
5744
5745 qPos.add(pk);
5746
5747 list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
5748 getDialect(), start, end);
5749 }
5750 catch (Exception e) {
5751 throw processException(e);
5752 }
5753 finally {
5754 if (list == null) {
5755 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERS,
5756 finderArgs);
5757 }
5758 else {
5759 userPersistence.cacheResult(list);
5760
5761 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS,
5762 finderArgs, list);
5763 }
5764
5765 closeSession(session);
5766 }
5767 }
5768
5769 return list;
5770 }
5771
5772 public static final FinderPath FINDER_PATH_GET_USERS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
5773 RoleModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES, Long.class,
5774 RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "getUsersSize",
5775 new String[] { Long.class.getName() });
5776
5777 static {
5778 FINDER_PATH_GET_USERS_SIZE.setCacheKeyGeneratorCacheName(null);
5779 }
5780
5781
5788 public int getUsersSize(long pk) throws SystemException {
5789 Object[] finderArgs = new Object[] { pk };
5790
5791 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS_SIZE,
5792 finderArgs, this);
5793
5794 if (count == null) {
5795 Session session = null;
5796
5797 try {
5798 session = openSession();
5799
5800 SQLQuery q = session.createSQLQuery(_SQL_GETUSERSSIZE);
5801
5802 q.addScalar(COUNT_COLUMN_NAME,
5803 com.liferay.portal.kernel.dao.orm.Type.LONG);
5804
5805 QueryPos qPos = QueryPos.getInstance(q);
5806
5807 qPos.add(pk);
5808
5809 count = (Long)q.uniqueResult();
5810 }
5811 catch (Exception e) {
5812 throw processException(e);
5813 }
5814 finally {
5815 if (count == null) {
5816 count = Long.valueOf(0);
5817 }
5818
5819 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS_SIZE,
5820 finderArgs, count);
5821
5822 closeSession(session);
5823 }
5824 }
5825
5826 return count.intValue();
5827 }
5828
5829 public static final FinderPath FINDER_PATH_CONTAINS_USER = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
5830 RoleModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES, Boolean.class,
5831 RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "containsUser",
5832 new String[] { Long.class.getName(), Long.class.getName() });
5833
5834
5842 public boolean containsUser(long pk, long userPK) throws SystemException {
5843 Object[] finderArgs = new Object[] { pk, userPK };
5844
5845 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USER,
5846 finderArgs, this);
5847
5848 if (value == null) {
5849 try {
5850 value = Boolean.valueOf(containsUser.contains(pk, userPK));
5851 }
5852 catch (Exception e) {
5853 throw processException(e);
5854 }
5855 finally {
5856 if (value == null) {
5857 value = Boolean.FALSE;
5858 }
5859
5860 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USER,
5861 finderArgs, value);
5862 }
5863 }
5864
5865 return value.booleanValue();
5866 }
5867
5868
5875 public boolean containsUsers(long pk) throws SystemException {
5876 if (getUsersSize(pk) > 0) {
5877 return true;
5878 }
5879 else {
5880 return false;
5881 }
5882 }
5883
5884
5891 public void addUser(long pk, long userPK) throws SystemException {
5892 try {
5893 addUser.add(pk, userPK);
5894 }
5895 catch (Exception e) {
5896 throw processException(e);
5897 }
5898 finally {
5899 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
5900 }
5901 }
5902
5903
5910 public void addUser(long pk, com.liferay.portal.model.User user)
5911 throws SystemException {
5912 try {
5913 addUser.add(pk, user.getPrimaryKey());
5914 }
5915 catch (Exception e) {
5916 throw processException(e);
5917 }
5918 finally {
5919 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
5920 }
5921 }
5922
5923
5930 public void addUsers(long pk, long[] userPKs) throws SystemException {
5931 try {
5932 for (long userPK : userPKs) {
5933 addUser.add(pk, userPK);
5934 }
5935 }
5936 catch (Exception e) {
5937 throw processException(e);
5938 }
5939 finally {
5940 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
5941 }
5942 }
5943
5944
5951 public void addUsers(long pk, List<com.liferay.portal.model.User> users)
5952 throws SystemException {
5953 try {
5954 for (com.liferay.portal.model.User user : users) {
5955 addUser.add(pk, user.getPrimaryKey());
5956 }
5957 }
5958 catch (Exception e) {
5959 throw processException(e);
5960 }
5961 finally {
5962 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
5963 }
5964 }
5965
5966
5972 public void clearUsers(long pk) throws SystemException {
5973 try {
5974 clearUsers.clear(pk);
5975 }
5976 catch (Exception e) {
5977 throw processException(e);
5978 }
5979 finally {
5980 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
5981 }
5982 }
5983
5984
5991 public void removeUser(long pk, long userPK) throws SystemException {
5992 try {
5993 removeUser.remove(pk, userPK);
5994 }
5995 catch (Exception e) {
5996 throw processException(e);
5997 }
5998 finally {
5999 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6000 }
6001 }
6002
6003
6010 public void removeUser(long pk, com.liferay.portal.model.User user)
6011 throws SystemException {
6012 try {
6013 removeUser.remove(pk, user.getPrimaryKey());
6014 }
6015 catch (Exception e) {
6016 throw processException(e);
6017 }
6018 finally {
6019 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6020 }
6021 }
6022
6023
6030 public void removeUsers(long pk, long[] userPKs) throws SystemException {
6031 try {
6032 for (long userPK : userPKs) {
6033 removeUser.remove(pk, userPK);
6034 }
6035 }
6036 catch (Exception e) {
6037 throw processException(e);
6038 }
6039 finally {
6040 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6041 }
6042 }
6043
6044
6051 public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
6052 throws SystemException {
6053 try {
6054 for (com.liferay.portal.model.User user : users) {
6055 removeUser.remove(pk, user.getPrimaryKey());
6056 }
6057 }
6058 catch (Exception e) {
6059 throw processException(e);
6060 }
6061 finally {
6062 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6063 }
6064 }
6065
6066
6073 public void setUsers(long pk, long[] userPKs) throws SystemException {
6074 try {
6075 Set<Long> userPKSet = SetUtil.fromArray(userPKs);
6076
6077 List<com.liferay.portal.model.User> users = getUsers(pk);
6078
6079 for (com.liferay.portal.model.User user : users) {
6080 if (!userPKSet.remove(user.getPrimaryKey())) {
6081 removeUser.remove(pk, user.getPrimaryKey());
6082 }
6083 }
6084
6085 for (Long userPK : userPKSet) {
6086 addUser.add(pk, userPK);
6087 }
6088 }
6089 catch (Exception e) {
6090 throw processException(e);
6091 }
6092 finally {
6093 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6094 }
6095 }
6096
6097
6104 public void setUsers(long pk, List<com.liferay.portal.model.User> users)
6105 throws SystemException {
6106 try {
6107 long[] userPKs = new long[users.size()];
6108
6109 for (int i = 0; i < users.size(); i++) {
6110 com.liferay.portal.model.User user = users.get(i);
6111
6112 userPKs[i] = user.getPrimaryKey();
6113 }
6114
6115 setUsers(pk, userPKs);
6116 }
6117 catch (Exception e) {
6118 throw processException(e);
6119 }
6120 finally {
6121 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6122 }
6123 }
6124
6125
6128 public void afterPropertiesSet() {
6129 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
6130 com.liferay.portal.util.PropsUtil.get(
6131 "value.object.listener.com.liferay.portal.model.Role")));
6132
6133 if (listenerClassNames.length > 0) {
6134 try {
6135 List<ModelListener<Role>> listenersList = new ArrayList<ModelListener<Role>>();
6136
6137 for (String listenerClassName : listenerClassNames) {
6138 listenersList.add((ModelListener<Role>)InstanceFactory.newInstance(
6139 listenerClassName));
6140 }
6141
6142 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
6143 }
6144 catch (Exception e) {
6145 _log.error(e);
6146 }
6147 }
6148
6149 containsGroup = new ContainsGroup();
6150
6151 addGroup = new AddGroup();
6152 clearGroups = new ClearGroups();
6153 removeGroup = new RemoveGroup();
6154
6155 containsPermission = new ContainsPermission();
6156
6157 addPermission = new AddPermission();
6158 clearPermissions = new ClearPermissions();
6159 removePermission = new RemovePermission();
6160
6161 containsUser = new ContainsUser();
6162
6163 addUser = new AddUser();
6164 clearUsers = new ClearUsers();
6165 removeUser = new RemoveUser();
6166 }
6167
6168 public void destroy() {
6169 EntityCacheUtil.removeCache(RoleImpl.class.getName());
6170 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
6171 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6172 }
6173
6174 @BeanReference(type = AccountPersistence.class)
6175 protected AccountPersistence accountPersistence;
6176 @BeanReference(type = AddressPersistence.class)
6177 protected AddressPersistence addressPersistence;
6178 @BeanReference(type = BrowserTrackerPersistence.class)
6179 protected BrowserTrackerPersistence browserTrackerPersistence;
6180 @BeanReference(type = ClassNamePersistence.class)
6181 protected ClassNamePersistence classNamePersistence;
6182 @BeanReference(type = ClusterGroupPersistence.class)
6183 protected ClusterGroupPersistence clusterGroupPersistence;
6184 @BeanReference(type = CompanyPersistence.class)
6185 protected CompanyPersistence companyPersistence;
6186 @BeanReference(type = ContactPersistence.class)
6187 protected ContactPersistence contactPersistence;
6188 @BeanReference(type = CountryPersistence.class)
6189 protected CountryPersistence countryPersistence;
6190 @BeanReference(type = EmailAddressPersistence.class)
6191 protected EmailAddressPersistence emailAddressPersistence;
6192 @BeanReference(type = GroupPersistence.class)
6193 protected GroupPersistence groupPersistence;
6194 @BeanReference(type = ImagePersistence.class)
6195 protected ImagePersistence imagePersistence;
6196 @BeanReference(type = LayoutPersistence.class)
6197 protected LayoutPersistence layoutPersistence;
6198 @BeanReference(type = LayoutBranchPersistence.class)
6199 protected LayoutBranchPersistence layoutBranchPersistence;
6200 @BeanReference(type = LayoutPrototypePersistence.class)
6201 protected LayoutPrototypePersistence layoutPrototypePersistence;
6202 @BeanReference(type = LayoutRevisionPersistence.class)
6203 protected LayoutRevisionPersistence layoutRevisionPersistence;
6204 @BeanReference(type = LayoutSetPersistence.class)
6205 protected LayoutSetPersistence layoutSetPersistence;
6206 @BeanReference(type = LayoutSetBranchPersistence.class)
6207 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
6208 @BeanReference(type = LayoutSetPrototypePersistence.class)
6209 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
6210 @BeanReference(type = ListTypePersistence.class)
6211 protected ListTypePersistence listTypePersistence;
6212 @BeanReference(type = LockPersistence.class)
6213 protected LockPersistence lockPersistence;
6214 @BeanReference(type = MembershipRequestPersistence.class)
6215 protected MembershipRequestPersistence membershipRequestPersistence;
6216 @BeanReference(type = OrganizationPersistence.class)
6217 protected OrganizationPersistence organizationPersistence;
6218 @BeanReference(type = OrgGroupPermissionPersistence.class)
6219 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
6220 @BeanReference(type = OrgGroupRolePersistence.class)
6221 protected OrgGroupRolePersistence orgGroupRolePersistence;
6222 @BeanReference(type = OrgLaborPersistence.class)
6223 protected OrgLaborPersistence orgLaborPersistence;
6224 @BeanReference(type = PasswordPolicyPersistence.class)
6225 protected PasswordPolicyPersistence passwordPolicyPersistence;
6226 @BeanReference(type = PasswordPolicyRelPersistence.class)
6227 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
6228 @BeanReference(type = PasswordTrackerPersistence.class)
6229 protected PasswordTrackerPersistence passwordTrackerPersistence;
6230 @BeanReference(type = PermissionPersistence.class)
6231 protected PermissionPersistence permissionPersistence;
6232 @BeanReference(type = PhonePersistence.class)
6233 protected PhonePersistence phonePersistence;
6234 @BeanReference(type = PluginSettingPersistence.class)
6235 protected PluginSettingPersistence pluginSettingPersistence;
6236 @BeanReference(type = PortalPreferencesPersistence.class)
6237 protected PortalPreferencesPersistence portalPreferencesPersistence;
6238 @BeanReference(type = PortletPersistence.class)
6239 protected PortletPersistence portletPersistence;
6240 @BeanReference(type = PortletItemPersistence.class)
6241 protected PortletItemPersistence portletItemPersistence;
6242 @BeanReference(type = PortletPreferencesPersistence.class)
6243 protected PortletPreferencesPersistence portletPreferencesPersistence;
6244 @BeanReference(type = RegionPersistence.class)
6245 protected RegionPersistence regionPersistence;
6246 @BeanReference(type = ReleasePersistence.class)
6247 protected ReleasePersistence releasePersistence;
6248 @BeanReference(type = RepositoryPersistence.class)
6249 protected RepositoryPersistence repositoryPersistence;
6250 @BeanReference(type = RepositoryEntryPersistence.class)
6251 protected RepositoryEntryPersistence repositoryEntryPersistence;
6252 @BeanReference(type = ResourcePersistence.class)
6253 protected ResourcePersistence resourcePersistence;
6254 @BeanReference(type = ResourceActionPersistence.class)
6255 protected ResourceActionPersistence resourceActionPersistence;
6256 @BeanReference(type = ResourceBlockPersistence.class)
6257 protected ResourceBlockPersistence resourceBlockPersistence;
6258 @BeanReference(type = ResourceBlockPermissionPersistence.class)
6259 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
6260 @BeanReference(type = ResourceCodePersistence.class)
6261 protected ResourceCodePersistence resourceCodePersistence;
6262 @BeanReference(type = ResourcePermissionPersistence.class)
6263 protected ResourcePermissionPersistence resourcePermissionPersistence;
6264 @BeanReference(type = ResourceTypePermissionPersistence.class)
6265 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
6266 @BeanReference(type = RolePersistence.class)
6267 protected RolePersistence rolePersistence;
6268 @BeanReference(type = ServiceComponentPersistence.class)
6269 protected ServiceComponentPersistence serviceComponentPersistence;
6270 @BeanReference(type = ShardPersistence.class)
6271 protected ShardPersistence shardPersistence;
6272 @BeanReference(type = SubscriptionPersistence.class)
6273 protected SubscriptionPersistence subscriptionPersistence;
6274 @BeanReference(type = TeamPersistence.class)
6275 protected TeamPersistence teamPersistence;
6276 @BeanReference(type = TicketPersistence.class)
6277 protected TicketPersistence ticketPersistence;
6278 @BeanReference(type = UserPersistence.class)
6279 protected UserPersistence userPersistence;
6280 @BeanReference(type = UserGroupPersistence.class)
6281 protected UserGroupPersistence userGroupPersistence;
6282 @BeanReference(type = UserGroupGroupRolePersistence.class)
6283 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
6284 @BeanReference(type = UserGroupRolePersistence.class)
6285 protected UserGroupRolePersistence userGroupRolePersistence;
6286 @BeanReference(type = UserIdMapperPersistence.class)
6287 protected UserIdMapperPersistence userIdMapperPersistence;
6288 @BeanReference(type = UserNotificationEventPersistence.class)
6289 protected UserNotificationEventPersistence userNotificationEventPersistence;
6290 @BeanReference(type = UserTrackerPersistence.class)
6291 protected UserTrackerPersistence userTrackerPersistence;
6292 @BeanReference(type = UserTrackerPathPersistence.class)
6293 protected UserTrackerPathPersistence userTrackerPathPersistence;
6294 @BeanReference(type = VirtualHostPersistence.class)
6295 protected VirtualHostPersistence virtualHostPersistence;
6296 @BeanReference(type = WebDAVPropsPersistence.class)
6297 protected WebDAVPropsPersistence webDAVPropsPersistence;
6298 @BeanReference(type = WebsitePersistence.class)
6299 protected WebsitePersistence websitePersistence;
6300 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
6301 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
6302 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
6303 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
6304 protected ContainsGroup containsGroup;
6305 protected AddGroup addGroup;
6306 protected ClearGroups clearGroups;
6307 protected RemoveGroup removeGroup;
6308 protected ContainsPermission containsPermission;
6309 protected AddPermission addPermission;
6310 protected ClearPermissions clearPermissions;
6311 protected RemovePermission removePermission;
6312 protected ContainsUser containsUser;
6313 protected AddUser addUser;
6314 protected ClearUsers clearUsers;
6315 protected RemoveUser removeUser;
6316
6317 protected class ContainsGroup {
6318 protected ContainsGroup() {
6319 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6320 _SQL_CONTAINSGROUP,
6321 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6322 RowMapper.COUNT);
6323 }
6324
6325 protected boolean contains(long roleId, long groupId) {
6326 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6327 new Long(roleId), new Long(groupId)
6328 });
6329
6330 if (results.size() > 0) {
6331 Integer count = results.get(0);
6332
6333 if (count.intValue() > 0) {
6334 return true;
6335 }
6336 }
6337
6338 return false;
6339 }
6340
6341 private MappingSqlQuery<Integer> _mappingSqlQuery;
6342 }
6343
6344 protected class AddGroup {
6345 protected AddGroup() {
6346 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6347 "INSERT INTO Groups_Roles (roleId, groupId) VALUES (?, ?)",
6348 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6349 }
6350
6351 protected void add(long roleId, long groupId) throws SystemException {
6352 if (!containsGroup.contains(roleId, groupId)) {
6353 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
6354
6355 for (ModelListener<Role> listener : listeners) {
6356 listener.onBeforeAddAssociation(roleId,
6357 com.liferay.portal.model.Group.class.getName(), groupId);
6358 }
6359
6360 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
6361 listener.onBeforeAddAssociation(groupId,
6362 Role.class.getName(), roleId);
6363 }
6364
6365 _sqlUpdate.update(new Object[] {
6366 new Long(roleId), new Long(groupId)
6367 });
6368
6369 for (ModelListener<Role> listener : listeners) {
6370 listener.onAfterAddAssociation(roleId,
6371 com.liferay.portal.model.Group.class.getName(), groupId);
6372 }
6373
6374 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
6375 listener.onAfterAddAssociation(groupId,
6376 Role.class.getName(), roleId);
6377 }
6378 }
6379 }
6380
6381 private SqlUpdate _sqlUpdate;
6382 }
6383
6384 protected class ClearGroups {
6385 protected ClearGroups() {
6386 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6387 "DELETE FROM Groups_Roles WHERE roleId = ?",
6388 new int[] { java.sql.Types.BIGINT });
6389 }
6390
6391 protected void clear(long roleId) throws SystemException {
6392 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
6393
6394 List<com.liferay.portal.model.Group> groups = null;
6395
6396 if ((listeners.length > 0) || (groupListeners.length > 0)) {
6397 groups = getGroups(roleId);
6398
6399 for (com.liferay.portal.model.Group group : groups) {
6400 for (ModelListener<Role> listener : listeners) {
6401 listener.onBeforeRemoveAssociation(roleId,
6402 com.liferay.portal.model.Group.class.getName(),
6403 group.getPrimaryKey());
6404 }
6405
6406 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
6407 listener.onBeforeRemoveAssociation(group.getPrimaryKey(),
6408 Role.class.getName(), roleId);
6409 }
6410 }
6411 }
6412
6413 _sqlUpdate.update(new Object[] { new Long(roleId) });
6414
6415 if ((listeners.length > 0) || (groupListeners.length > 0)) {
6416 for (com.liferay.portal.model.Group group : groups) {
6417 for (ModelListener<Role> listener : listeners) {
6418 listener.onAfterRemoveAssociation(roleId,
6419 com.liferay.portal.model.Group.class.getName(),
6420 group.getPrimaryKey());
6421 }
6422
6423 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
6424 listener.onAfterRemoveAssociation(group.getPrimaryKey(),
6425 Role.class.getName(), roleId);
6426 }
6427 }
6428 }
6429 }
6430
6431 private SqlUpdate _sqlUpdate;
6432 }
6433
6434 protected class RemoveGroup {
6435 protected RemoveGroup() {
6436 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6437 "DELETE FROM Groups_Roles WHERE roleId = ? AND groupId = ?",
6438 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6439 }
6440
6441 protected void remove(long roleId, long groupId)
6442 throws SystemException {
6443 if (containsGroup.contains(roleId, groupId)) {
6444 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
6445
6446 for (ModelListener<Role> listener : listeners) {
6447 listener.onBeforeRemoveAssociation(roleId,
6448 com.liferay.portal.model.Group.class.getName(), groupId);
6449 }
6450
6451 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
6452 listener.onBeforeRemoveAssociation(groupId,
6453 Role.class.getName(), roleId);
6454 }
6455
6456 _sqlUpdate.update(new Object[] {
6457 new Long(roleId), new Long(groupId)
6458 });
6459
6460 for (ModelListener<Role> listener : listeners) {
6461 listener.onAfterRemoveAssociation(roleId,
6462 com.liferay.portal.model.Group.class.getName(), groupId);
6463 }
6464
6465 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
6466 listener.onAfterRemoveAssociation(groupId,
6467 Role.class.getName(), roleId);
6468 }
6469 }
6470 }
6471
6472 private SqlUpdate _sqlUpdate;
6473 }
6474
6475 protected class ContainsPermission {
6476 protected ContainsPermission() {
6477 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6478 _SQL_CONTAINSPERMISSION,
6479 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6480 RowMapper.COUNT);
6481 }
6482
6483 protected boolean contains(long roleId, long permissionId) {
6484 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6485 new Long(roleId), new Long(permissionId)
6486 });
6487
6488 if (results.size() > 0) {
6489 Integer count = results.get(0);
6490
6491 if (count.intValue() > 0) {
6492 return true;
6493 }
6494 }
6495
6496 return false;
6497 }
6498
6499 private MappingSqlQuery<Integer> _mappingSqlQuery;
6500 }
6501
6502 protected class AddPermission {
6503 protected AddPermission() {
6504 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6505 "INSERT INTO Roles_Permissions (roleId, permissionId) VALUES (?, ?)",
6506 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6507 }
6508
6509 protected void add(long roleId, long permissionId)
6510 throws SystemException {
6511 if (!containsPermission.contains(roleId, permissionId)) {
6512 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
6513 permissionPersistence.getListeners();
6514
6515 for (ModelListener<Role> listener : listeners) {
6516 listener.onBeforeAddAssociation(roleId,
6517 com.liferay.portal.model.Permission.class.getName(),
6518 permissionId);
6519 }
6520
6521 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6522 listener.onBeforeAddAssociation(permissionId,
6523 Role.class.getName(), roleId);
6524 }
6525
6526 _sqlUpdate.update(new Object[] {
6527 new Long(roleId), new Long(permissionId)
6528 });
6529
6530 for (ModelListener<Role> listener : listeners) {
6531 listener.onAfterAddAssociation(roleId,
6532 com.liferay.portal.model.Permission.class.getName(),
6533 permissionId);
6534 }
6535
6536 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6537 listener.onAfterAddAssociation(permissionId,
6538 Role.class.getName(), roleId);
6539 }
6540 }
6541 }
6542
6543 private SqlUpdate _sqlUpdate;
6544 }
6545
6546 protected class ClearPermissions {
6547 protected ClearPermissions() {
6548 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6549 "DELETE FROM Roles_Permissions WHERE roleId = ?",
6550 new int[] { java.sql.Types.BIGINT });
6551 }
6552
6553 protected void clear(long roleId) throws SystemException {
6554 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
6555 permissionPersistence.getListeners();
6556
6557 List<com.liferay.portal.model.Permission> permissions = null;
6558
6559 if ((listeners.length > 0) || (permissionListeners.length > 0)) {
6560 permissions = getPermissions(roleId);
6561
6562 for (com.liferay.portal.model.Permission permission : permissions) {
6563 for (ModelListener<Role> listener : listeners) {
6564 listener.onBeforeRemoveAssociation(roleId,
6565 com.liferay.portal.model.Permission.class.getName(),
6566 permission.getPrimaryKey());
6567 }
6568
6569 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6570 listener.onBeforeRemoveAssociation(permission.getPrimaryKey(),
6571 Role.class.getName(), roleId);
6572 }
6573 }
6574 }
6575
6576 _sqlUpdate.update(new Object[] { new Long(roleId) });
6577
6578 if ((listeners.length > 0) || (permissionListeners.length > 0)) {
6579 for (com.liferay.portal.model.Permission permission : permissions) {
6580 for (ModelListener<Role> listener : listeners) {
6581 listener.onAfterRemoveAssociation(roleId,
6582 com.liferay.portal.model.Permission.class.getName(),
6583 permission.getPrimaryKey());
6584 }
6585
6586 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6587 listener.onAfterRemoveAssociation(permission.getPrimaryKey(),
6588 Role.class.getName(), roleId);
6589 }
6590 }
6591 }
6592 }
6593
6594 private SqlUpdate _sqlUpdate;
6595 }
6596
6597 protected class RemovePermission {
6598 protected RemovePermission() {
6599 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6600 "DELETE FROM Roles_Permissions WHERE roleId = ? AND permissionId = ?",
6601 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6602 }
6603
6604 protected void remove(long roleId, long permissionId)
6605 throws SystemException {
6606 if (containsPermission.contains(roleId, permissionId)) {
6607 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
6608 permissionPersistence.getListeners();
6609
6610 for (ModelListener<Role> listener : listeners) {
6611 listener.onBeforeRemoveAssociation(roleId,
6612 com.liferay.portal.model.Permission.class.getName(),
6613 permissionId);
6614 }
6615
6616 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6617 listener.onBeforeRemoveAssociation(permissionId,
6618 Role.class.getName(), roleId);
6619 }
6620
6621 _sqlUpdate.update(new Object[] {
6622 new Long(roleId), new Long(permissionId)
6623 });
6624
6625 for (ModelListener<Role> listener : listeners) {
6626 listener.onAfterRemoveAssociation(roleId,
6627 com.liferay.portal.model.Permission.class.getName(),
6628 permissionId);
6629 }
6630
6631 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6632 listener.onAfterRemoveAssociation(permissionId,
6633 Role.class.getName(), roleId);
6634 }
6635 }
6636 }
6637
6638 private SqlUpdate _sqlUpdate;
6639 }
6640
6641 protected class ContainsUser {
6642 protected ContainsUser() {
6643 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6644 _SQL_CONTAINSUSER,
6645 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6646 RowMapper.COUNT);
6647 }
6648
6649 protected boolean contains(long roleId, long userId) {
6650 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6651 new Long(roleId), new Long(userId)
6652 });
6653
6654 if (results.size() > 0) {
6655 Integer count = results.get(0);
6656
6657 if (count.intValue() > 0) {
6658 return true;
6659 }
6660 }
6661
6662 return false;
6663 }
6664
6665 private MappingSqlQuery<Integer> _mappingSqlQuery;
6666 }
6667
6668 protected class AddUser {
6669 protected AddUser() {
6670 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6671 "INSERT INTO Users_Roles (roleId, userId) VALUES (?, ?)",
6672 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6673 }
6674
6675 protected void add(long roleId, long userId) throws SystemException {
6676 if (!containsUser.contains(roleId, userId)) {
6677 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
6678
6679 for (ModelListener<Role> listener : listeners) {
6680 listener.onBeforeAddAssociation(roleId,
6681 com.liferay.portal.model.User.class.getName(), userId);
6682 }
6683
6684 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6685 listener.onBeforeAddAssociation(userId,
6686 Role.class.getName(), roleId);
6687 }
6688
6689 _sqlUpdate.update(new Object[] {
6690 new Long(roleId), new Long(userId)
6691 });
6692
6693 for (ModelListener<Role> listener : listeners) {
6694 listener.onAfterAddAssociation(roleId,
6695 com.liferay.portal.model.User.class.getName(), userId);
6696 }
6697
6698 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6699 listener.onAfterAddAssociation(userId,
6700 Role.class.getName(), roleId);
6701 }
6702 }
6703 }
6704
6705 private SqlUpdate _sqlUpdate;
6706 }
6707
6708 protected class ClearUsers {
6709 protected ClearUsers() {
6710 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6711 "DELETE FROM Users_Roles WHERE roleId = ?",
6712 new int[] { java.sql.Types.BIGINT });
6713 }
6714
6715 protected void clear(long roleId) throws SystemException {
6716 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
6717
6718 List<com.liferay.portal.model.User> users = null;
6719
6720 if ((listeners.length > 0) || (userListeners.length > 0)) {
6721 users = getUsers(roleId);
6722
6723 for (com.liferay.portal.model.User user : users) {
6724 for (ModelListener<Role> listener : listeners) {
6725 listener.onBeforeRemoveAssociation(roleId,
6726 com.liferay.portal.model.User.class.getName(),
6727 user.getPrimaryKey());
6728 }
6729
6730 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6731 listener.onBeforeRemoveAssociation(user.getPrimaryKey(),
6732 Role.class.getName(), roleId);
6733 }
6734 }
6735 }
6736
6737 _sqlUpdate.update(new Object[] { new Long(roleId) });
6738
6739 if ((listeners.length > 0) || (userListeners.length > 0)) {
6740 for (com.liferay.portal.model.User user : users) {
6741 for (ModelListener<Role> listener : listeners) {
6742 listener.onAfterRemoveAssociation(roleId,
6743 com.liferay.portal.model.User.class.getName(),
6744 user.getPrimaryKey());
6745 }
6746
6747 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6748 listener.onAfterRemoveAssociation(user.getPrimaryKey(),
6749 Role.class.getName(), roleId);
6750 }
6751 }
6752 }
6753 }
6754
6755 private SqlUpdate _sqlUpdate;
6756 }
6757
6758 protected class RemoveUser {
6759 protected RemoveUser() {
6760 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6761 "DELETE FROM Users_Roles WHERE roleId = ? AND userId = ?",
6762 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6763 }
6764
6765 protected void remove(long roleId, long userId)
6766 throws SystemException {
6767 if (containsUser.contains(roleId, userId)) {
6768 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
6769
6770 for (ModelListener<Role> listener : listeners) {
6771 listener.onBeforeRemoveAssociation(roleId,
6772 com.liferay.portal.model.User.class.getName(), userId);
6773 }
6774
6775 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6776 listener.onBeforeRemoveAssociation(userId,
6777 Role.class.getName(), roleId);
6778 }
6779
6780 _sqlUpdate.update(new Object[] {
6781 new Long(roleId), new Long(userId)
6782 });
6783
6784 for (ModelListener<Role> listener : listeners) {
6785 listener.onAfterRemoveAssociation(roleId,
6786 com.liferay.portal.model.User.class.getName(), userId);
6787 }
6788
6789 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6790 listener.onAfterRemoveAssociation(userId,
6791 Role.class.getName(), roleId);
6792 }
6793 }
6794 }
6795
6796 private SqlUpdate _sqlUpdate;
6797 }
6798
6799 private static final String _SQL_SELECT_ROLE = "SELECT role FROM Role role";
6800 private static final String _SQL_SELECT_ROLE_WHERE = "SELECT role FROM Role role WHERE ";
6801 private static final String _SQL_COUNT_ROLE = "SELECT COUNT(role) FROM Role role";
6802 private static final String _SQL_COUNT_ROLE_WHERE = "SELECT COUNT(role) FROM Role role WHERE ";
6803 private static final String _SQL_GETGROUPS = "SELECT {Group_.*} FROM Group_ INNER JOIN Groups_Roles ON (Groups_Roles.groupId = Group_.groupId) WHERE (Groups_Roles.roleId = ?)";
6804 private static final String _SQL_GETGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Roles WHERE roleId = ?";
6805 private static final String _SQL_CONTAINSGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Roles WHERE roleId = ? AND groupId = ?";
6806 private static final String _SQL_GETPERMISSIONS = "SELECT {Permission_.*} FROM Permission_ INNER JOIN Roles_Permissions ON (Roles_Permissions.permissionId = Permission_.permissionId) WHERE (Roles_Permissions.roleId = ?)";
6807 private static final String _SQL_GETPERMISSIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Roles_Permissions WHERE roleId = ?";
6808 private static final String _SQL_CONTAINSPERMISSION = "SELECT COUNT(*) AS COUNT_VALUE FROM Roles_Permissions WHERE roleId = ? AND permissionId = ?";
6809 private static final String _SQL_GETUSERS = "SELECT {User_.*} FROM User_ INNER JOIN Users_Roles ON (Users_Roles.userId = User_.userId) WHERE (Users_Roles.roleId = ?)";
6810 private static final String _SQL_GETUSERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Roles WHERE roleId = ?";
6811 private static final String _SQL_CONTAINSUSER = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Roles WHERE roleId = ? AND userId = ?";
6812 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "role.companyId = ?";
6813 private static final String _FINDER_COLUMN_NAME_NAME_1 = "role.name IS NULL";
6814 private static final String _FINDER_COLUMN_NAME_NAME_2 = "role.name = ?";
6815 private static final String _FINDER_COLUMN_NAME_NAME_3 = "(role.name IS NULL OR role.name = ?)";
6816 private static final String _FINDER_COLUMN_SUBTYPE_SUBTYPE_1 = "role.subtype IS NULL";
6817 private static final String _FINDER_COLUMN_SUBTYPE_SUBTYPE_2 = "role.subtype = ?";
6818 private static final String _FINDER_COLUMN_SUBTYPE_SUBTYPE_3 = "(role.subtype IS NULL OR role.subtype = ?)";
6819 private static final String _FINDER_COLUMN_C_N_COMPANYID_2 = "role.companyId = ? AND ";
6820 private static final String _FINDER_COLUMN_C_N_NAME_1 = "role.name IS NULL";
6821 private static final String _FINDER_COLUMN_C_N_NAME_2 = "lower(role.name) = lower(CAST_TEXT(?))";
6822 private static final String _FINDER_COLUMN_C_N_NAME_3 = "(role.name IS NULL OR lower(role.name) = lower(CAST_TEXT(?)))";
6823 private static final String _FINDER_COLUMN_T_S_TYPE_2 = "role.type = ? AND ";
6824 private static final String _FINDER_COLUMN_T_S_SUBTYPE_1 = "role.subtype IS NULL";
6825 private static final String _FINDER_COLUMN_T_S_SUBTYPE_2 = "role.subtype = ?";
6826 private static final String _FINDER_COLUMN_T_S_SUBTYPE_3 = "(role.subtype IS NULL OR role.subtype = ?)";
6827 private static final String _FINDER_COLUMN_C_C_C_COMPANYID_2 = "role.companyId = ? AND ";
6828 private static final String _FINDER_COLUMN_C_C_C_CLASSNAMEID_2 = "role.classNameId = ? AND ";
6829 private static final String _FINDER_COLUMN_C_C_C_CLASSPK_2 = "role.classPK = ?";
6830 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "role.roleId";
6831 private static final String _FILTER_SQL_SELECT_ROLE_WHERE = "SELECT DISTINCT {role.*} FROM Role_ role WHERE ";
6832 private static final String _FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1 =
6833 "SELECT {Role_.*} FROM (SELECT DISTINCT role.roleId FROM Role_ role WHERE ";
6834 private static final String _FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2 =
6835 ") TEMP_TABLE INNER JOIN Role_ ON TEMP_TABLE.roleId = Role_.roleId";
6836 private static final String _FILTER_SQL_COUNT_ROLE_WHERE = "SELECT COUNT(DISTINCT role.roleId) AS COUNT_VALUE FROM Role_ role WHERE ";
6837 private static final String _FILTER_ENTITY_ALIAS = "role";
6838 private static final String _FILTER_ENTITY_TABLE = "Role_";
6839 private static final String _ORDER_BY_ENTITY_ALIAS = "role.";
6840 private static final String _ORDER_BY_ENTITY_TABLE = "Role_.";
6841 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Role exists with the primary key ";
6842 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Role exists with the key {";
6843 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
6844 private static Log _log = LogFactoryUtil.getLog(RolePersistenceImpl.class);
6845 private static Role _nullRole = new RoleImpl() {
6846 @Override
6847 public Object clone() {
6848 return this;
6849 }
6850
6851 @Override
6852 public CacheModel<Role> toCacheModel() {
6853 return _nullRoleCacheModel;
6854 }
6855 };
6856
6857 private static CacheModel<Role> _nullRoleCacheModel = new CacheModel<Role>() {
6858 public Role toEntityModel() {
6859 return _nullRole;
6860 }
6861 };
6862 }