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
449 else {
450 if ((roleModelImpl.getColumnBitmask() &
451 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
452 Object[] args = new Object[] {
453 Long.valueOf(roleModelImpl.getOriginalCompanyId())
454 };
455
456 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
457 args);
458 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
459 args);
460
461 args = new Object[] { Long.valueOf(roleModelImpl.getCompanyId()) };
462
463 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
464 args);
465 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
466 args);
467 }
468
469 if ((roleModelImpl.getColumnBitmask() &
470 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NAME.getColumnBitmask()) != 0) {
471 Object[] args = new Object[] { roleModelImpl.getOriginalName() };
472
473 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_NAME, args);
474 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NAME,
475 args);
476
477 args = new Object[] { roleModelImpl.getName() };
478
479 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_NAME, args);
480 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NAME,
481 args);
482 }
483
484 if ((roleModelImpl.getColumnBitmask() &
485 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SUBTYPE.getColumnBitmask()) != 0) {
486 Object[] args = new Object[] { roleModelImpl.getOriginalSubtype() };
487
488 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SUBTYPE, args);
489 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SUBTYPE,
490 args);
491
492 args = new Object[] { roleModelImpl.getSubtype() };
493
494 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SUBTYPE, args);
495 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SUBTYPE,
496 args);
497 }
498
499 if ((roleModelImpl.getColumnBitmask() &
500 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S.getColumnBitmask()) != 0) {
501 Object[] args = new Object[] {
502 Integer.valueOf(roleModelImpl.getOriginalType()),
503
504 roleModelImpl.getOriginalSubtype()
505 };
506
507 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_S, args);
508 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S,
509 args);
510
511 args = new Object[] {
512 Integer.valueOf(roleModelImpl.getType()),
513
514 roleModelImpl.getSubtype()
515 };
516
517 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_S, args);
518 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S,
519 args);
520 }
521 }
522
523 EntityCacheUtil.putResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
524 RoleImpl.class, role.getPrimaryKey(), role);
525
526 if (isNew) {
527 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
528 new Object[] { Long.valueOf(role.getCompanyId()), role.getName() },
529 role);
530
531 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
532 new Object[] {
533 Long.valueOf(role.getCompanyId()),
534 Long.valueOf(role.getClassNameId()),
535 Long.valueOf(role.getClassPK())
536 }, role);
537 }
538 else {
539 if ((roleModelImpl.getColumnBitmask() &
540 FINDER_PATH_FETCH_BY_C_N.getColumnBitmask()) != 0) {
541 Object[] args = new Object[] {
542 Long.valueOf(roleModelImpl.getOriginalCompanyId()),
543
544 roleModelImpl.getOriginalName()
545 };
546
547 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_N, args);
548
549 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N, args);
550
551 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
552 new Object[] {
553 Long.valueOf(role.getCompanyId()),
554
555 role.getName()
556 }, role);
557 }
558
559 if ((roleModelImpl.getColumnBitmask() &
560 FINDER_PATH_FETCH_BY_C_C_C.getColumnBitmask()) != 0) {
561 Object[] args = new Object[] {
562 Long.valueOf(roleModelImpl.getOriginalCompanyId()),
563 Long.valueOf(roleModelImpl.getOriginalClassNameId()),
564 Long.valueOf(roleModelImpl.getOriginalClassPK())
565 };
566
567 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
568
569 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C, args);
570
571 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
572 new Object[] {
573 Long.valueOf(role.getCompanyId()),
574 Long.valueOf(role.getClassNameId()),
575 Long.valueOf(role.getClassPK())
576 }, role);
577 }
578 }
579
580 return role;
581 }
582
583 protected Role toUnwrappedModel(Role role) {
584 if (role instanceof RoleImpl) {
585 return role;
586 }
587
588 RoleImpl roleImpl = new RoleImpl();
589
590 roleImpl.setNew(role.isNew());
591 roleImpl.setPrimaryKey(role.getPrimaryKey());
592
593 roleImpl.setRoleId(role.getRoleId());
594 roleImpl.setCompanyId(role.getCompanyId());
595 roleImpl.setClassNameId(role.getClassNameId());
596 roleImpl.setClassPK(role.getClassPK());
597 roleImpl.setName(role.getName());
598 roleImpl.setTitle(role.getTitle());
599 roleImpl.setDescription(role.getDescription());
600 roleImpl.setType(role.getType());
601 roleImpl.setSubtype(role.getSubtype());
602
603 return roleImpl;
604 }
605
606
614 @Override
615 public Role findByPrimaryKey(Serializable primaryKey)
616 throws NoSuchModelException, SystemException {
617 return findByPrimaryKey(((Long)primaryKey).longValue());
618 }
619
620
628 public Role findByPrimaryKey(long roleId)
629 throws NoSuchRoleException, SystemException {
630 Role role = fetchByPrimaryKey(roleId);
631
632 if (role == null) {
633 if (_log.isWarnEnabled()) {
634 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + roleId);
635 }
636
637 throw new NoSuchRoleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
638 roleId);
639 }
640
641 return role;
642 }
643
644
651 @Override
652 public Role fetchByPrimaryKey(Serializable primaryKey)
653 throws SystemException {
654 return fetchByPrimaryKey(((Long)primaryKey).longValue());
655 }
656
657
664 public Role fetchByPrimaryKey(long roleId) throws SystemException {
665 Role role = (Role)EntityCacheUtil.getResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
666 RoleImpl.class, roleId);
667
668 if (role == _nullRole) {
669 return null;
670 }
671
672 if (role == null) {
673 Session session = null;
674
675 boolean hasException = false;
676
677 try {
678 session = openSession();
679
680 role = (Role)session.get(RoleImpl.class, Long.valueOf(roleId));
681 }
682 catch (Exception e) {
683 hasException = true;
684
685 throw processException(e);
686 }
687 finally {
688 if (role != null) {
689 cacheResult(role);
690 }
691 else if (!hasException) {
692 EntityCacheUtil.putResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
693 RoleImpl.class, roleId, _nullRole);
694 }
695
696 closeSession(session);
697 }
698 }
699
700 return role;
701 }
702
703
710 public List<Role> findByCompanyId(long companyId) throws SystemException {
711 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
712 null);
713 }
714
715
728 public List<Role> findByCompanyId(long companyId, int start, int end)
729 throws SystemException {
730 return findByCompanyId(companyId, start, end, null);
731 }
732
733
747 public List<Role> findByCompanyId(long companyId, int start, int end,
748 OrderByComparator orderByComparator) throws SystemException {
749 FinderPath finderPath = null;
750 Object[] finderArgs = null;
751
752 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
753 (orderByComparator == null)) {
754 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
755 finderArgs = new Object[] { companyId };
756 }
757 else {
758 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
759 finderArgs = new Object[] { companyId, start, end, orderByComparator };
760 }
761
762 List<Role> list = (List<Role>)FinderCacheUtil.getResult(finderPath,
763 finderArgs, this);
764
765 if ((list != null) && !list.isEmpty()) {
766 for (Role role : list) {
767 if ((companyId != role.getCompanyId())) {
768 list = null;
769
770 break;
771 }
772 }
773 }
774
775 if (list == null) {
776 StringBundler query = null;
777
778 if (orderByComparator != null) {
779 query = new StringBundler(3 +
780 (orderByComparator.getOrderByFields().length * 3));
781 }
782 else {
783 query = new StringBundler(3);
784 }
785
786 query.append(_SQL_SELECT_ROLE_WHERE);
787
788 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
789
790 if (orderByComparator != null) {
791 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
792 orderByComparator);
793 }
794
795 else {
796 query.append(RoleModelImpl.ORDER_BY_JPQL);
797 }
798
799 String sql = query.toString();
800
801 Session session = null;
802
803 try {
804 session = openSession();
805
806 Query q = session.createQuery(sql);
807
808 QueryPos qPos = QueryPos.getInstance(q);
809
810 qPos.add(companyId);
811
812 list = (List<Role>)QueryUtil.list(q, getDialect(), start, end);
813 }
814 catch (Exception e) {
815 throw processException(e);
816 }
817 finally {
818 if (list == null) {
819 FinderCacheUtil.removeResult(finderPath, finderArgs);
820 }
821 else {
822 cacheResult(list);
823
824 FinderCacheUtil.putResult(finderPath, finderArgs, list);
825 }
826
827 closeSession(session);
828 }
829 }
830
831 return list;
832 }
833
834
843 public Role findByCompanyId_First(long companyId,
844 OrderByComparator orderByComparator)
845 throws NoSuchRoleException, SystemException {
846 Role role = fetchByCompanyId_First(companyId, orderByComparator);
847
848 if (role != null) {
849 return role;
850 }
851
852 StringBundler msg = new StringBundler(4);
853
854 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
855
856 msg.append("companyId=");
857 msg.append(companyId);
858
859 msg.append(StringPool.CLOSE_CURLY_BRACE);
860
861 throw new NoSuchRoleException(msg.toString());
862 }
863
864
872 public Role fetchByCompanyId_First(long companyId,
873 OrderByComparator orderByComparator) throws SystemException {
874 List<Role> list = findByCompanyId(companyId, 0, 1, orderByComparator);
875
876 if (!list.isEmpty()) {
877 return list.get(0);
878 }
879
880 return null;
881 }
882
883
892 public Role findByCompanyId_Last(long companyId,
893 OrderByComparator orderByComparator)
894 throws NoSuchRoleException, SystemException {
895 Role role = fetchByCompanyId_Last(companyId, orderByComparator);
896
897 if (role != null) {
898 return role;
899 }
900
901 StringBundler msg = new StringBundler(4);
902
903 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
904
905 msg.append("companyId=");
906 msg.append(companyId);
907
908 msg.append(StringPool.CLOSE_CURLY_BRACE);
909
910 throw new NoSuchRoleException(msg.toString());
911 }
912
913
921 public Role fetchByCompanyId_Last(long companyId,
922 OrderByComparator orderByComparator) throws SystemException {
923 int count = countByCompanyId(companyId);
924
925 List<Role> list = findByCompanyId(companyId, count - 1, count,
926 orderByComparator);
927
928 if (!list.isEmpty()) {
929 return list.get(0);
930 }
931
932 return null;
933 }
934
935
945 public Role[] findByCompanyId_PrevAndNext(long roleId, long companyId,
946 OrderByComparator orderByComparator)
947 throws NoSuchRoleException, SystemException {
948 Role role = findByPrimaryKey(roleId);
949
950 Session session = null;
951
952 try {
953 session = openSession();
954
955 Role[] array = new RoleImpl[3];
956
957 array[0] = getByCompanyId_PrevAndNext(session, role, companyId,
958 orderByComparator, true);
959
960 array[1] = role;
961
962 array[2] = getByCompanyId_PrevAndNext(session, role, companyId,
963 orderByComparator, false);
964
965 return array;
966 }
967 catch (Exception e) {
968 throw processException(e);
969 }
970 finally {
971 closeSession(session);
972 }
973 }
974
975 protected Role getByCompanyId_PrevAndNext(Session session, Role role,
976 long companyId, OrderByComparator orderByComparator, boolean previous) {
977 StringBundler query = null;
978
979 if (orderByComparator != null) {
980 query = new StringBundler(6 +
981 (orderByComparator.getOrderByFields().length * 6));
982 }
983 else {
984 query = new StringBundler(3);
985 }
986
987 query.append(_SQL_SELECT_ROLE_WHERE);
988
989 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
990
991 if (orderByComparator != null) {
992 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
993
994 if (orderByConditionFields.length > 0) {
995 query.append(WHERE_AND);
996 }
997
998 for (int i = 0; i < orderByConditionFields.length; i++) {
999 query.append(_ORDER_BY_ENTITY_ALIAS);
1000 query.append(orderByConditionFields[i]);
1001
1002 if ((i + 1) < orderByConditionFields.length) {
1003 if (orderByComparator.isAscending() ^ previous) {
1004 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1005 }
1006 else {
1007 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1008 }
1009 }
1010 else {
1011 if (orderByComparator.isAscending() ^ previous) {
1012 query.append(WHERE_GREATER_THAN);
1013 }
1014 else {
1015 query.append(WHERE_LESSER_THAN);
1016 }
1017 }
1018 }
1019
1020 query.append(ORDER_BY_CLAUSE);
1021
1022 String[] orderByFields = orderByComparator.getOrderByFields();
1023
1024 for (int i = 0; i < orderByFields.length; i++) {
1025 query.append(_ORDER_BY_ENTITY_ALIAS);
1026 query.append(orderByFields[i]);
1027
1028 if ((i + 1) < orderByFields.length) {
1029 if (orderByComparator.isAscending() ^ previous) {
1030 query.append(ORDER_BY_ASC_HAS_NEXT);
1031 }
1032 else {
1033 query.append(ORDER_BY_DESC_HAS_NEXT);
1034 }
1035 }
1036 else {
1037 if (orderByComparator.isAscending() ^ previous) {
1038 query.append(ORDER_BY_ASC);
1039 }
1040 else {
1041 query.append(ORDER_BY_DESC);
1042 }
1043 }
1044 }
1045 }
1046
1047 else {
1048 query.append(RoleModelImpl.ORDER_BY_JPQL);
1049 }
1050
1051 String sql = query.toString();
1052
1053 Query q = session.createQuery(sql);
1054
1055 q.setFirstResult(0);
1056 q.setMaxResults(2);
1057
1058 QueryPos qPos = QueryPos.getInstance(q);
1059
1060 qPos.add(companyId);
1061
1062 if (orderByComparator != null) {
1063 Object[] values = orderByComparator.getOrderByConditionValues(role);
1064
1065 for (Object value : values) {
1066 qPos.add(value);
1067 }
1068 }
1069
1070 List<Role> list = q.list();
1071
1072 if (list.size() == 2) {
1073 return list.get(1);
1074 }
1075 else {
1076 return null;
1077 }
1078 }
1079
1080
1087 public List<Role> filterFindByCompanyId(long companyId)
1088 throws SystemException {
1089 return filterFindByCompanyId(companyId, QueryUtil.ALL_POS,
1090 QueryUtil.ALL_POS, null);
1091 }
1092
1093
1106 public List<Role> filterFindByCompanyId(long companyId, int start, int end)
1107 throws SystemException {
1108 return filterFindByCompanyId(companyId, start, end, null);
1109 }
1110
1111
1125 public List<Role> filterFindByCompanyId(long companyId, int start, int end,
1126 OrderByComparator orderByComparator) throws SystemException {
1127 if (!InlineSQLHelperUtil.isEnabled()) {
1128 return findByCompanyId(companyId, start, end, orderByComparator);
1129 }
1130
1131 StringBundler query = null;
1132
1133 if (orderByComparator != null) {
1134 query = new StringBundler(3 +
1135 (orderByComparator.getOrderByFields().length * 3));
1136 }
1137 else {
1138 query = new StringBundler(3);
1139 }
1140
1141 if (getDB().isSupportsInlineDistinct()) {
1142 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
1143 }
1144 else {
1145 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
1146 }
1147
1148 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1149
1150 if (!getDB().isSupportsInlineDistinct()) {
1151 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
1152 }
1153
1154 if (orderByComparator != null) {
1155 if (getDB().isSupportsInlineDistinct()) {
1156 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1157 orderByComparator);
1158 }
1159 else {
1160 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1161 orderByComparator);
1162 }
1163 }
1164
1165 else {
1166 if (getDB().isSupportsInlineDistinct()) {
1167 query.append(RoleModelImpl.ORDER_BY_JPQL);
1168 }
1169 else {
1170 query.append(RoleModelImpl.ORDER_BY_SQL);
1171 }
1172 }
1173
1174 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1175 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1176
1177 Session session = null;
1178
1179 try {
1180 session = openSession();
1181
1182 SQLQuery q = session.createSQLQuery(sql);
1183
1184 if (getDB().isSupportsInlineDistinct()) {
1185 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
1186 }
1187 else {
1188 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
1189 }
1190
1191 QueryPos qPos = QueryPos.getInstance(q);
1192
1193 qPos.add(companyId);
1194
1195 return (List<Role>)QueryUtil.list(q, getDialect(), start, end);
1196 }
1197 catch (Exception e) {
1198 throw processException(e);
1199 }
1200 finally {
1201 closeSession(session);
1202 }
1203 }
1204
1205
1215 public Role[] filterFindByCompanyId_PrevAndNext(long roleId,
1216 long companyId, OrderByComparator orderByComparator)
1217 throws NoSuchRoleException, SystemException {
1218 if (!InlineSQLHelperUtil.isEnabled()) {
1219 return findByCompanyId_PrevAndNext(roleId, companyId,
1220 orderByComparator);
1221 }
1222
1223 Role role = findByPrimaryKey(roleId);
1224
1225 Session session = null;
1226
1227 try {
1228 session = openSession();
1229
1230 Role[] array = new RoleImpl[3];
1231
1232 array[0] = filterGetByCompanyId_PrevAndNext(session, role,
1233 companyId, orderByComparator, true);
1234
1235 array[1] = role;
1236
1237 array[2] = filterGetByCompanyId_PrevAndNext(session, role,
1238 companyId, orderByComparator, false);
1239
1240 return array;
1241 }
1242 catch (Exception e) {
1243 throw processException(e);
1244 }
1245 finally {
1246 closeSession(session);
1247 }
1248 }
1249
1250 protected Role filterGetByCompanyId_PrevAndNext(Session session, Role role,
1251 long companyId, OrderByComparator orderByComparator, boolean previous) {
1252 StringBundler query = null;
1253
1254 if (orderByComparator != null) {
1255 query = new StringBundler(6 +
1256 (orderByComparator.getOrderByFields().length * 6));
1257 }
1258 else {
1259 query = new StringBundler(3);
1260 }
1261
1262 if (getDB().isSupportsInlineDistinct()) {
1263 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
1264 }
1265 else {
1266 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
1267 }
1268
1269 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1270
1271 if (!getDB().isSupportsInlineDistinct()) {
1272 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
1273 }
1274
1275 if (orderByComparator != null) {
1276 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1277
1278 if (orderByConditionFields.length > 0) {
1279 query.append(WHERE_AND);
1280 }
1281
1282 for (int i = 0; i < orderByConditionFields.length; i++) {
1283 if (getDB().isSupportsInlineDistinct()) {
1284 query.append(_ORDER_BY_ENTITY_ALIAS);
1285 }
1286 else {
1287 query.append(_ORDER_BY_ENTITY_TABLE);
1288 }
1289
1290 query.append(orderByConditionFields[i]);
1291
1292 if ((i + 1) < orderByConditionFields.length) {
1293 if (orderByComparator.isAscending() ^ previous) {
1294 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1295 }
1296 else {
1297 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1298 }
1299 }
1300 else {
1301 if (orderByComparator.isAscending() ^ previous) {
1302 query.append(WHERE_GREATER_THAN);
1303 }
1304 else {
1305 query.append(WHERE_LESSER_THAN);
1306 }
1307 }
1308 }
1309
1310 query.append(ORDER_BY_CLAUSE);
1311
1312 String[] orderByFields = orderByComparator.getOrderByFields();
1313
1314 for (int i = 0; i < orderByFields.length; i++) {
1315 if (getDB().isSupportsInlineDistinct()) {
1316 query.append(_ORDER_BY_ENTITY_ALIAS);
1317 }
1318 else {
1319 query.append(_ORDER_BY_ENTITY_TABLE);
1320 }
1321
1322 query.append(orderByFields[i]);
1323
1324 if ((i + 1) < orderByFields.length) {
1325 if (orderByComparator.isAscending() ^ previous) {
1326 query.append(ORDER_BY_ASC_HAS_NEXT);
1327 }
1328 else {
1329 query.append(ORDER_BY_DESC_HAS_NEXT);
1330 }
1331 }
1332 else {
1333 if (orderByComparator.isAscending() ^ previous) {
1334 query.append(ORDER_BY_ASC);
1335 }
1336 else {
1337 query.append(ORDER_BY_DESC);
1338 }
1339 }
1340 }
1341 }
1342
1343 else {
1344 if (getDB().isSupportsInlineDistinct()) {
1345 query.append(RoleModelImpl.ORDER_BY_JPQL);
1346 }
1347 else {
1348 query.append(RoleModelImpl.ORDER_BY_SQL);
1349 }
1350 }
1351
1352 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1353 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1354
1355 SQLQuery q = session.createSQLQuery(sql);
1356
1357 q.setFirstResult(0);
1358 q.setMaxResults(2);
1359
1360 if (getDB().isSupportsInlineDistinct()) {
1361 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
1362 }
1363 else {
1364 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
1365 }
1366
1367 QueryPos qPos = QueryPos.getInstance(q);
1368
1369 qPos.add(companyId);
1370
1371 if (orderByComparator != null) {
1372 Object[] values = orderByComparator.getOrderByConditionValues(role);
1373
1374 for (Object value : values) {
1375 qPos.add(value);
1376 }
1377 }
1378
1379 List<Role> list = q.list();
1380
1381 if (list.size() == 2) {
1382 return list.get(1);
1383 }
1384 else {
1385 return null;
1386 }
1387 }
1388
1389
1396 public List<Role> findByName(String name) throws SystemException {
1397 return findByName(name, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1398 }
1399
1400
1413 public List<Role> findByName(String name, int start, int end)
1414 throws SystemException {
1415 return findByName(name, start, end, null);
1416 }
1417
1418
1432 public List<Role> findByName(String name, int start, int end,
1433 OrderByComparator orderByComparator) throws SystemException {
1434 FinderPath finderPath = null;
1435 Object[] finderArgs = null;
1436
1437 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1438 (orderByComparator == null)) {
1439 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NAME;
1440 finderArgs = new Object[] { name };
1441 }
1442 else {
1443 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_NAME;
1444 finderArgs = new Object[] { name, start, end, orderByComparator };
1445 }
1446
1447 List<Role> list = (List<Role>)FinderCacheUtil.getResult(finderPath,
1448 finderArgs, this);
1449
1450 if ((list != null) && !list.isEmpty()) {
1451 for (Role role : list) {
1452 if (!Validator.equals(name, role.getName())) {
1453 list = null;
1454
1455 break;
1456 }
1457 }
1458 }
1459
1460 if (list == null) {
1461 StringBundler query = null;
1462
1463 if (orderByComparator != null) {
1464 query = new StringBundler(3 +
1465 (orderByComparator.getOrderByFields().length * 3));
1466 }
1467 else {
1468 query = new StringBundler(3);
1469 }
1470
1471 query.append(_SQL_SELECT_ROLE_WHERE);
1472
1473 if (name == null) {
1474 query.append(_FINDER_COLUMN_NAME_NAME_1);
1475 }
1476 else {
1477 if (name.equals(StringPool.BLANK)) {
1478 query.append(_FINDER_COLUMN_NAME_NAME_3);
1479 }
1480 else {
1481 query.append(_FINDER_COLUMN_NAME_NAME_2);
1482 }
1483 }
1484
1485 if (orderByComparator != null) {
1486 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1487 orderByComparator);
1488 }
1489
1490 else {
1491 query.append(RoleModelImpl.ORDER_BY_JPQL);
1492 }
1493
1494 String sql = query.toString();
1495
1496 Session session = null;
1497
1498 try {
1499 session = openSession();
1500
1501 Query q = session.createQuery(sql);
1502
1503 QueryPos qPos = QueryPos.getInstance(q);
1504
1505 if (name != null) {
1506 qPos.add(name);
1507 }
1508
1509 list = (List<Role>)QueryUtil.list(q, getDialect(), start, end);
1510 }
1511 catch (Exception e) {
1512 throw processException(e);
1513 }
1514 finally {
1515 if (list == null) {
1516 FinderCacheUtil.removeResult(finderPath, finderArgs);
1517 }
1518 else {
1519 cacheResult(list);
1520
1521 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1522 }
1523
1524 closeSession(session);
1525 }
1526 }
1527
1528 return list;
1529 }
1530
1531
1540 public Role findByName_First(String name,
1541 OrderByComparator orderByComparator)
1542 throws NoSuchRoleException, SystemException {
1543 Role role = fetchByName_First(name, orderByComparator);
1544
1545 if (role != null) {
1546 return role;
1547 }
1548
1549 StringBundler msg = new StringBundler(4);
1550
1551 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1552
1553 msg.append("name=");
1554 msg.append(name);
1555
1556 msg.append(StringPool.CLOSE_CURLY_BRACE);
1557
1558 throw new NoSuchRoleException(msg.toString());
1559 }
1560
1561
1569 public Role fetchByName_First(String name,
1570 OrderByComparator orderByComparator) throws SystemException {
1571 List<Role> list = findByName(name, 0, 1, orderByComparator);
1572
1573 if (!list.isEmpty()) {
1574 return list.get(0);
1575 }
1576
1577 return null;
1578 }
1579
1580
1589 public Role findByName_Last(String name, OrderByComparator orderByComparator)
1590 throws NoSuchRoleException, SystemException {
1591 Role role = fetchByName_Last(name, orderByComparator);
1592
1593 if (role != null) {
1594 return role;
1595 }
1596
1597 StringBundler msg = new StringBundler(4);
1598
1599 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1600
1601 msg.append("name=");
1602 msg.append(name);
1603
1604 msg.append(StringPool.CLOSE_CURLY_BRACE);
1605
1606 throw new NoSuchRoleException(msg.toString());
1607 }
1608
1609
1617 public Role fetchByName_Last(String name,
1618 OrderByComparator orderByComparator) throws SystemException {
1619 int count = countByName(name);
1620
1621 List<Role> list = findByName(name, count - 1, count, orderByComparator);
1622
1623 if (!list.isEmpty()) {
1624 return list.get(0);
1625 }
1626
1627 return null;
1628 }
1629
1630
1640 public Role[] findByName_PrevAndNext(long roleId, String name,
1641 OrderByComparator orderByComparator)
1642 throws NoSuchRoleException, SystemException {
1643 Role role = findByPrimaryKey(roleId);
1644
1645 Session session = null;
1646
1647 try {
1648 session = openSession();
1649
1650 Role[] array = new RoleImpl[3];
1651
1652 array[0] = getByName_PrevAndNext(session, role, name,
1653 orderByComparator, true);
1654
1655 array[1] = role;
1656
1657 array[2] = getByName_PrevAndNext(session, role, name,
1658 orderByComparator, false);
1659
1660 return array;
1661 }
1662 catch (Exception e) {
1663 throw processException(e);
1664 }
1665 finally {
1666 closeSession(session);
1667 }
1668 }
1669
1670 protected Role getByName_PrevAndNext(Session session, Role role,
1671 String name, OrderByComparator orderByComparator, boolean previous) {
1672 StringBundler query = null;
1673
1674 if (orderByComparator != null) {
1675 query = new StringBundler(6 +
1676 (orderByComparator.getOrderByFields().length * 6));
1677 }
1678 else {
1679 query = new StringBundler(3);
1680 }
1681
1682 query.append(_SQL_SELECT_ROLE_WHERE);
1683
1684 if (name == null) {
1685 query.append(_FINDER_COLUMN_NAME_NAME_1);
1686 }
1687 else {
1688 if (name.equals(StringPool.BLANK)) {
1689 query.append(_FINDER_COLUMN_NAME_NAME_3);
1690 }
1691 else {
1692 query.append(_FINDER_COLUMN_NAME_NAME_2);
1693 }
1694 }
1695
1696 if (orderByComparator != null) {
1697 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1698
1699 if (orderByConditionFields.length > 0) {
1700 query.append(WHERE_AND);
1701 }
1702
1703 for (int i = 0; i < orderByConditionFields.length; i++) {
1704 query.append(_ORDER_BY_ENTITY_ALIAS);
1705 query.append(orderByConditionFields[i]);
1706
1707 if ((i + 1) < orderByConditionFields.length) {
1708 if (orderByComparator.isAscending() ^ previous) {
1709 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1710 }
1711 else {
1712 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1713 }
1714 }
1715 else {
1716 if (orderByComparator.isAscending() ^ previous) {
1717 query.append(WHERE_GREATER_THAN);
1718 }
1719 else {
1720 query.append(WHERE_LESSER_THAN);
1721 }
1722 }
1723 }
1724
1725 query.append(ORDER_BY_CLAUSE);
1726
1727 String[] orderByFields = orderByComparator.getOrderByFields();
1728
1729 for (int i = 0; i < orderByFields.length; i++) {
1730 query.append(_ORDER_BY_ENTITY_ALIAS);
1731 query.append(orderByFields[i]);
1732
1733 if ((i + 1) < orderByFields.length) {
1734 if (orderByComparator.isAscending() ^ previous) {
1735 query.append(ORDER_BY_ASC_HAS_NEXT);
1736 }
1737 else {
1738 query.append(ORDER_BY_DESC_HAS_NEXT);
1739 }
1740 }
1741 else {
1742 if (orderByComparator.isAscending() ^ previous) {
1743 query.append(ORDER_BY_ASC);
1744 }
1745 else {
1746 query.append(ORDER_BY_DESC);
1747 }
1748 }
1749 }
1750 }
1751
1752 else {
1753 query.append(RoleModelImpl.ORDER_BY_JPQL);
1754 }
1755
1756 String sql = query.toString();
1757
1758 Query q = session.createQuery(sql);
1759
1760 q.setFirstResult(0);
1761 q.setMaxResults(2);
1762
1763 QueryPos qPos = QueryPos.getInstance(q);
1764
1765 if (name != null) {
1766 qPos.add(name);
1767 }
1768
1769 if (orderByComparator != null) {
1770 Object[] values = orderByComparator.getOrderByConditionValues(role);
1771
1772 for (Object value : values) {
1773 qPos.add(value);
1774 }
1775 }
1776
1777 List<Role> list = q.list();
1778
1779 if (list.size() == 2) {
1780 return list.get(1);
1781 }
1782 else {
1783 return null;
1784 }
1785 }
1786
1787
1794 public List<Role> filterFindByName(String name) throws SystemException {
1795 return filterFindByName(name, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1796 }
1797
1798
1811 public List<Role> filterFindByName(String name, int start, int end)
1812 throws SystemException {
1813 return filterFindByName(name, start, end, null);
1814 }
1815
1816
1830 public List<Role> filterFindByName(String name, int start, int end,
1831 OrderByComparator orderByComparator) throws SystemException {
1832 if (!InlineSQLHelperUtil.isEnabled()) {
1833 return findByName(name, start, end, orderByComparator);
1834 }
1835
1836 StringBundler query = null;
1837
1838 if (orderByComparator != null) {
1839 query = new StringBundler(3 +
1840 (orderByComparator.getOrderByFields().length * 3));
1841 }
1842 else {
1843 query = new StringBundler(3);
1844 }
1845
1846 if (getDB().isSupportsInlineDistinct()) {
1847 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
1848 }
1849 else {
1850 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
1851 }
1852
1853 if (name == null) {
1854 query.append(_FINDER_COLUMN_NAME_NAME_1);
1855 }
1856 else {
1857 if (name.equals(StringPool.BLANK)) {
1858 query.append(_FINDER_COLUMN_NAME_NAME_3);
1859 }
1860 else {
1861 query.append(_FINDER_COLUMN_NAME_NAME_2);
1862 }
1863 }
1864
1865 if (!getDB().isSupportsInlineDistinct()) {
1866 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
1867 }
1868
1869 if (orderByComparator != null) {
1870 if (getDB().isSupportsInlineDistinct()) {
1871 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1872 orderByComparator);
1873 }
1874 else {
1875 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1876 orderByComparator);
1877 }
1878 }
1879
1880 else {
1881 if (getDB().isSupportsInlineDistinct()) {
1882 query.append(RoleModelImpl.ORDER_BY_JPQL);
1883 }
1884 else {
1885 query.append(RoleModelImpl.ORDER_BY_SQL);
1886 }
1887 }
1888
1889 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1890 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1891
1892 Session session = null;
1893
1894 try {
1895 session = openSession();
1896
1897 SQLQuery q = session.createSQLQuery(sql);
1898
1899 if (getDB().isSupportsInlineDistinct()) {
1900 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
1901 }
1902 else {
1903 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
1904 }
1905
1906 QueryPos qPos = QueryPos.getInstance(q);
1907
1908 if (name != null) {
1909 qPos.add(name);
1910 }
1911
1912 return (List<Role>)QueryUtil.list(q, getDialect(), start, end);
1913 }
1914 catch (Exception e) {
1915 throw processException(e);
1916 }
1917 finally {
1918 closeSession(session);
1919 }
1920 }
1921
1922
1932 public Role[] filterFindByName_PrevAndNext(long roleId, String name,
1933 OrderByComparator orderByComparator)
1934 throws NoSuchRoleException, SystemException {
1935 if (!InlineSQLHelperUtil.isEnabled()) {
1936 return findByName_PrevAndNext(roleId, name, orderByComparator);
1937 }
1938
1939 Role role = findByPrimaryKey(roleId);
1940
1941 Session session = null;
1942
1943 try {
1944 session = openSession();
1945
1946 Role[] array = new RoleImpl[3];
1947
1948 array[0] = filterGetByName_PrevAndNext(session, role, name,
1949 orderByComparator, true);
1950
1951 array[1] = role;
1952
1953 array[2] = filterGetByName_PrevAndNext(session, role, name,
1954 orderByComparator, false);
1955
1956 return array;
1957 }
1958 catch (Exception e) {
1959 throw processException(e);
1960 }
1961 finally {
1962 closeSession(session);
1963 }
1964 }
1965
1966 protected Role filterGetByName_PrevAndNext(Session session, Role role,
1967 String name, OrderByComparator orderByComparator, boolean previous) {
1968 StringBundler query = null;
1969
1970 if (orderByComparator != null) {
1971 query = new StringBundler(6 +
1972 (orderByComparator.getOrderByFields().length * 6));
1973 }
1974 else {
1975 query = new StringBundler(3);
1976 }
1977
1978 if (getDB().isSupportsInlineDistinct()) {
1979 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
1980 }
1981 else {
1982 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
1983 }
1984
1985 if (name == null) {
1986 query.append(_FINDER_COLUMN_NAME_NAME_1);
1987 }
1988 else {
1989 if (name.equals(StringPool.BLANK)) {
1990 query.append(_FINDER_COLUMN_NAME_NAME_3);
1991 }
1992 else {
1993 query.append(_FINDER_COLUMN_NAME_NAME_2);
1994 }
1995 }
1996
1997 if (!getDB().isSupportsInlineDistinct()) {
1998 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
1999 }
2000
2001 if (orderByComparator != null) {
2002 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2003
2004 if (orderByConditionFields.length > 0) {
2005 query.append(WHERE_AND);
2006 }
2007
2008 for (int i = 0; i < orderByConditionFields.length; i++) {
2009 if (getDB().isSupportsInlineDistinct()) {
2010 query.append(_ORDER_BY_ENTITY_ALIAS);
2011 }
2012 else {
2013 query.append(_ORDER_BY_ENTITY_TABLE);
2014 }
2015
2016 query.append(orderByConditionFields[i]);
2017
2018 if ((i + 1) < orderByConditionFields.length) {
2019 if (orderByComparator.isAscending() ^ previous) {
2020 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2021 }
2022 else {
2023 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2024 }
2025 }
2026 else {
2027 if (orderByComparator.isAscending() ^ previous) {
2028 query.append(WHERE_GREATER_THAN);
2029 }
2030 else {
2031 query.append(WHERE_LESSER_THAN);
2032 }
2033 }
2034 }
2035
2036 query.append(ORDER_BY_CLAUSE);
2037
2038 String[] orderByFields = orderByComparator.getOrderByFields();
2039
2040 for (int i = 0; i < orderByFields.length; i++) {
2041 if (getDB().isSupportsInlineDistinct()) {
2042 query.append(_ORDER_BY_ENTITY_ALIAS);
2043 }
2044 else {
2045 query.append(_ORDER_BY_ENTITY_TABLE);
2046 }
2047
2048 query.append(orderByFields[i]);
2049
2050 if ((i + 1) < orderByFields.length) {
2051 if (orderByComparator.isAscending() ^ previous) {
2052 query.append(ORDER_BY_ASC_HAS_NEXT);
2053 }
2054 else {
2055 query.append(ORDER_BY_DESC_HAS_NEXT);
2056 }
2057 }
2058 else {
2059 if (orderByComparator.isAscending() ^ previous) {
2060 query.append(ORDER_BY_ASC);
2061 }
2062 else {
2063 query.append(ORDER_BY_DESC);
2064 }
2065 }
2066 }
2067 }
2068
2069 else {
2070 if (getDB().isSupportsInlineDistinct()) {
2071 query.append(RoleModelImpl.ORDER_BY_JPQL);
2072 }
2073 else {
2074 query.append(RoleModelImpl.ORDER_BY_SQL);
2075 }
2076 }
2077
2078 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2079 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2080
2081 SQLQuery q = session.createSQLQuery(sql);
2082
2083 q.setFirstResult(0);
2084 q.setMaxResults(2);
2085
2086 if (getDB().isSupportsInlineDistinct()) {
2087 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
2088 }
2089 else {
2090 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
2091 }
2092
2093 QueryPos qPos = QueryPos.getInstance(q);
2094
2095 if (name != null) {
2096 qPos.add(name);
2097 }
2098
2099 if (orderByComparator != null) {
2100 Object[] values = orderByComparator.getOrderByConditionValues(role);
2101
2102 for (Object value : values) {
2103 qPos.add(value);
2104 }
2105 }
2106
2107 List<Role> list = q.list();
2108
2109 if (list.size() == 2) {
2110 return list.get(1);
2111 }
2112 else {
2113 return null;
2114 }
2115 }
2116
2117
2124 public List<Role> findBySubtype(String subtype) throws SystemException {
2125 return findBySubtype(subtype, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2126 }
2127
2128
2141 public List<Role> findBySubtype(String subtype, int start, int end)
2142 throws SystemException {
2143 return findBySubtype(subtype, start, end, null);
2144 }
2145
2146
2160 public List<Role> findBySubtype(String subtype, int start, int end,
2161 OrderByComparator orderByComparator) throws SystemException {
2162 FinderPath finderPath = null;
2163 Object[] finderArgs = null;
2164
2165 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2166 (orderByComparator == null)) {
2167 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SUBTYPE;
2168 finderArgs = new Object[] { subtype };
2169 }
2170 else {
2171 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SUBTYPE;
2172 finderArgs = new Object[] { subtype, start, end, orderByComparator };
2173 }
2174
2175 List<Role> list = (List<Role>)FinderCacheUtil.getResult(finderPath,
2176 finderArgs, this);
2177
2178 if ((list != null) && !list.isEmpty()) {
2179 for (Role role : list) {
2180 if (!Validator.equals(subtype, role.getSubtype())) {
2181 list = null;
2182
2183 break;
2184 }
2185 }
2186 }
2187
2188 if (list == null) {
2189 StringBundler query = null;
2190
2191 if (orderByComparator != null) {
2192 query = new StringBundler(3 +
2193 (orderByComparator.getOrderByFields().length * 3));
2194 }
2195 else {
2196 query = new StringBundler(3);
2197 }
2198
2199 query.append(_SQL_SELECT_ROLE_WHERE);
2200
2201 if (subtype == null) {
2202 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
2203 }
2204 else {
2205 if (subtype.equals(StringPool.BLANK)) {
2206 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
2207 }
2208 else {
2209 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
2210 }
2211 }
2212
2213 if (orderByComparator != null) {
2214 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2215 orderByComparator);
2216 }
2217
2218 else {
2219 query.append(RoleModelImpl.ORDER_BY_JPQL);
2220 }
2221
2222 String sql = query.toString();
2223
2224 Session session = null;
2225
2226 try {
2227 session = openSession();
2228
2229 Query q = session.createQuery(sql);
2230
2231 QueryPos qPos = QueryPos.getInstance(q);
2232
2233 if (subtype != null) {
2234 qPos.add(subtype);
2235 }
2236
2237 list = (List<Role>)QueryUtil.list(q, getDialect(), start, end);
2238 }
2239 catch (Exception e) {
2240 throw processException(e);
2241 }
2242 finally {
2243 if (list == null) {
2244 FinderCacheUtil.removeResult(finderPath, finderArgs);
2245 }
2246 else {
2247 cacheResult(list);
2248
2249 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2250 }
2251
2252 closeSession(session);
2253 }
2254 }
2255
2256 return list;
2257 }
2258
2259
2268 public Role findBySubtype_First(String subtype,
2269 OrderByComparator orderByComparator)
2270 throws NoSuchRoleException, SystemException {
2271 Role role = fetchBySubtype_First(subtype, orderByComparator);
2272
2273 if (role != null) {
2274 return role;
2275 }
2276
2277 StringBundler msg = new StringBundler(4);
2278
2279 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2280
2281 msg.append("subtype=");
2282 msg.append(subtype);
2283
2284 msg.append(StringPool.CLOSE_CURLY_BRACE);
2285
2286 throw new NoSuchRoleException(msg.toString());
2287 }
2288
2289
2297 public Role fetchBySubtype_First(String subtype,
2298 OrderByComparator orderByComparator) throws SystemException {
2299 List<Role> list = findBySubtype(subtype, 0, 1, orderByComparator);
2300
2301 if (!list.isEmpty()) {
2302 return list.get(0);
2303 }
2304
2305 return null;
2306 }
2307
2308
2317 public Role findBySubtype_Last(String subtype,
2318 OrderByComparator orderByComparator)
2319 throws NoSuchRoleException, SystemException {
2320 Role role = fetchBySubtype_Last(subtype, orderByComparator);
2321
2322 if (role != null) {
2323 return role;
2324 }
2325
2326 StringBundler msg = new StringBundler(4);
2327
2328 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2329
2330 msg.append("subtype=");
2331 msg.append(subtype);
2332
2333 msg.append(StringPool.CLOSE_CURLY_BRACE);
2334
2335 throw new NoSuchRoleException(msg.toString());
2336 }
2337
2338
2346 public Role fetchBySubtype_Last(String subtype,
2347 OrderByComparator orderByComparator) throws SystemException {
2348 int count = countBySubtype(subtype);
2349
2350 List<Role> list = findBySubtype(subtype, count - 1, count,
2351 orderByComparator);
2352
2353 if (!list.isEmpty()) {
2354 return list.get(0);
2355 }
2356
2357 return null;
2358 }
2359
2360
2370 public Role[] findBySubtype_PrevAndNext(long roleId, String subtype,
2371 OrderByComparator orderByComparator)
2372 throws NoSuchRoleException, SystemException {
2373 Role role = findByPrimaryKey(roleId);
2374
2375 Session session = null;
2376
2377 try {
2378 session = openSession();
2379
2380 Role[] array = new RoleImpl[3];
2381
2382 array[0] = getBySubtype_PrevAndNext(session, role, subtype,
2383 orderByComparator, true);
2384
2385 array[1] = role;
2386
2387 array[2] = getBySubtype_PrevAndNext(session, role, subtype,
2388 orderByComparator, false);
2389
2390 return array;
2391 }
2392 catch (Exception e) {
2393 throw processException(e);
2394 }
2395 finally {
2396 closeSession(session);
2397 }
2398 }
2399
2400 protected Role getBySubtype_PrevAndNext(Session session, Role role,
2401 String subtype, OrderByComparator orderByComparator, boolean previous) {
2402 StringBundler query = null;
2403
2404 if (orderByComparator != null) {
2405 query = new StringBundler(6 +
2406 (orderByComparator.getOrderByFields().length * 6));
2407 }
2408 else {
2409 query = new StringBundler(3);
2410 }
2411
2412 query.append(_SQL_SELECT_ROLE_WHERE);
2413
2414 if (subtype == null) {
2415 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
2416 }
2417 else {
2418 if (subtype.equals(StringPool.BLANK)) {
2419 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
2420 }
2421 else {
2422 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
2423 }
2424 }
2425
2426 if (orderByComparator != null) {
2427 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2428
2429 if (orderByConditionFields.length > 0) {
2430 query.append(WHERE_AND);
2431 }
2432
2433 for (int i = 0; i < orderByConditionFields.length; i++) {
2434 query.append(_ORDER_BY_ENTITY_ALIAS);
2435 query.append(orderByConditionFields[i]);
2436
2437 if ((i + 1) < orderByConditionFields.length) {
2438 if (orderByComparator.isAscending() ^ previous) {
2439 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2440 }
2441 else {
2442 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2443 }
2444 }
2445 else {
2446 if (orderByComparator.isAscending() ^ previous) {
2447 query.append(WHERE_GREATER_THAN);
2448 }
2449 else {
2450 query.append(WHERE_LESSER_THAN);
2451 }
2452 }
2453 }
2454
2455 query.append(ORDER_BY_CLAUSE);
2456
2457 String[] orderByFields = orderByComparator.getOrderByFields();
2458
2459 for (int i = 0; i < orderByFields.length; i++) {
2460 query.append(_ORDER_BY_ENTITY_ALIAS);
2461 query.append(orderByFields[i]);
2462
2463 if ((i + 1) < orderByFields.length) {
2464 if (orderByComparator.isAscending() ^ previous) {
2465 query.append(ORDER_BY_ASC_HAS_NEXT);
2466 }
2467 else {
2468 query.append(ORDER_BY_DESC_HAS_NEXT);
2469 }
2470 }
2471 else {
2472 if (orderByComparator.isAscending() ^ previous) {
2473 query.append(ORDER_BY_ASC);
2474 }
2475 else {
2476 query.append(ORDER_BY_DESC);
2477 }
2478 }
2479 }
2480 }
2481
2482 else {
2483 query.append(RoleModelImpl.ORDER_BY_JPQL);
2484 }
2485
2486 String sql = query.toString();
2487
2488 Query q = session.createQuery(sql);
2489
2490 q.setFirstResult(0);
2491 q.setMaxResults(2);
2492
2493 QueryPos qPos = QueryPos.getInstance(q);
2494
2495 if (subtype != null) {
2496 qPos.add(subtype);
2497 }
2498
2499 if (orderByComparator != null) {
2500 Object[] values = orderByComparator.getOrderByConditionValues(role);
2501
2502 for (Object value : values) {
2503 qPos.add(value);
2504 }
2505 }
2506
2507 List<Role> list = q.list();
2508
2509 if (list.size() == 2) {
2510 return list.get(1);
2511 }
2512 else {
2513 return null;
2514 }
2515 }
2516
2517
2524 public List<Role> filterFindBySubtype(String subtype)
2525 throws SystemException {
2526 return filterFindBySubtype(subtype, QueryUtil.ALL_POS,
2527 QueryUtil.ALL_POS, null);
2528 }
2529
2530
2543 public List<Role> filterFindBySubtype(String subtype, int start, int end)
2544 throws SystemException {
2545 return filterFindBySubtype(subtype, start, end, null);
2546 }
2547
2548
2562 public List<Role> filterFindBySubtype(String subtype, int start, int end,
2563 OrderByComparator orderByComparator) throws SystemException {
2564 if (!InlineSQLHelperUtil.isEnabled()) {
2565 return findBySubtype(subtype, start, end, orderByComparator);
2566 }
2567
2568 StringBundler query = null;
2569
2570 if (orderByComparator != null) {
2571 query = new StringBundler(3 +
2572 (orderByComparator.getOrderByFields().length * 3));
2573 }
2574 else {
2575 query = new StringBundler(3);
2576 }
2577
2578 if (getDB().isSupportsInlineDistinct()) {
2579 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
2580 }
2581 else {
2582 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
2583 }
2584
2585 if (subtype == null) {
2586 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
2587 }
2588 else {
2589 if (subtype.equals(StringPool.BLANK)) {
2590 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
2591 }
2592 else {
2593 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
2594 }
2595 }
2596
2597 if (!getDB().isSupportsInlineDistinct()) {
2598 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
2599 }
2600
2601 if (orderByComparator != null) {
2602 if (getDB().isSupportsInlineDistinct()) {
2603 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2604 orderByComparator);
2605 }
2606 else {
2607 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2608 orderByComparator);
2609 }
2610 }
2611
2612 else {
2613 if (getDB().isSupportsInlineDistinct()) {
2614 query.append(RoleModelImpl.ORDER_BY_JPQL);
2615 }
2616 else {
2617 query.append(RoleModelImpl.ORDER_BY_SQL);
2618 }
2619 }
2620
2621 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2622 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2623
2624 Session session = null;
2625
2626 try {
2627 session = openSession();
2628
2629 SQLQuery q = session.createSQLQuery(sql);
2630
2631 if (getDB().isSupportsInlineDistinct()) {
2632 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
2633 }
2634 else {
2635 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
2636 }
2637
2638 QueryPos qPos = QueryPos.getInstance(q);
2639
2640 if (subtype != null) {
2641 qPos.add(subtype);
2642 }
2643
2644 return (List<Role>)QueryUtil.list(q, getDialect(), start, end);
2645 }
2646 catch (Exception e) {
2647 throw processException(e);
2648 }
2649 finally {
2650 closeSession(session);
2651 }
2652 }
2653
2654
2664 public Role[] filterFindBySubtype_PrevAndNext(long roleId, String subtype,
2665 OrderByComparator orderByComparator)
2666 throws NoSuchRoleException, SystemException {
2667 if (!InlineSQLHelperUtil.isEnabled()) {
2668 return findBySubtype_PrevAndNext(roleId, subtype, orderByComparator);
2669 }
2670
2671 Role role = findByPrimaryKey(roleId);
2672
2673 Session session = null;
2674
2675 try {
2676 session = openSession();
2677
2678 Role[] array = new RoleImpl[3];
2679
2680 array[0] = filterGetBySubtype_PrevAndNext(session, role, subtype,
2681 orderByComparator, true);
2682
2683 array[1] = role;
2684
2685 array[2] = filterGetBySubtype_PrevAndNext(session, role, subtype,
2686 orderByComparator, false);
2687
2688 return array;
2689 }
2690 catch (Exception e) {
2691 throw processException(e);
2692 }
2693 finally {
2694 closeSession(session);
2695 }
2696 }
2697
2698 protected Role filterGetBySubtype_PrevAndNext(Session session, Role role,
2699 String subtype, OrderByComparator orderByComparator, boolean previous) {
2700 StringBundler query = null;
2701
2702 if (orderByComparator != null) {
2703 query = new StringBundler(6 +
2704 (orderByComparator.getOrderByFields().length * 6));
2705 }
2706 else {
2707 query = new StringBundler(3);
2708 }
2709
2710 if (getDB().isSupportsInlineDistinct()) {
2711 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
2712 }
2713 else {
2714 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
2715 }
2716
2717 if (subtype == null) {
2718 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
2719 }
2720 else {
2721 if (subtype.equals(StringPool.BLANK)) {
2722 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
2723 }
2724 else {
2725 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
2726 }
2727 }
2728
2729 if (!getDB().isSupportsInlineDistinct()) {
2730 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
2731 }
2732
2733 if (orderByComparator != null) {
2734 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2735
2736 if (orderByConditionFields.length > 0) {
2737 query.append(WHERE_AND);
2738 }
2739
2740 for (int i = 0; i < orderByConditionFields.length; i++) {
2741 if (getDB().isSupportsInlineDistinct()) {
2742 query.append(_ORDER_BY_ENTITY_ALIAS);
2743 }
2744 else {
2745 query.append(_ORDER_BY_ENTITY_TABLE);
2746 }
2747
2748 query.append(orderByConditionFields[i]);
2749
2750 if ((i + 1) < orderByConditionFields.length) {
2751 if (orderByComparator.isAscending() ^ previous) {
2752 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2753 }
2754 else {
2755 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2756 }
2757 }
2758 else {
2759 if (orderByComparator.isAscending() ^ previous) {
2760 query.append(WHERE_GREATER_THAN);
2761 }
2762 else {
2763 query.append(WHERE_LESSER_THAN);
2764 }
2765 }
2766 }
2767
2768 query.append(ORDER_BY_CLAUSE);
2769
2770 String[] orderByFields = orderByComparator.getOrderByFields();
2771
2772 for (int i = 0; i < orderByFields.length; i++) {
2773 if (getDB().isSupportsInlineDistinct()) {
2774 query.append(_ORDER_BY_ENTITY_ALIAS);
2775 }
2776 else {
2777 query.append(_ORDER_BY_ENTITY_TABLE);
2778 }
2779
2780 query.append(orderByFields[i]);
2781
2782 if ((i + 1) < orderByFields.length) {
2783 if (orderByComparator.isAscending() ^ previous) {
2784 query.append(ORDER_BY_ASC_HAS_NEXT);
2785 }
2786 else {
2787 query.append(ORDER_BY_DESC_HAS_NEXT);
2788 }
2789 }
2790 else {
2791 if (orderByComparator.isAscending() ^ previous) {
2792 query.append(ORDER_BY_ASC);
2793 }
2794 else {
2795 query.append(ORDER_BY_DESC);
2796 }
2797 }
2798 }
2799 }
2800
2801 else {
2802 if (getDB().isSupportsInlineDistinct()) {
2803 query.append(RoleModelImpl.ORDER_BY_JPQL);
2804 }
2805 else {
2806 query.append(RoleModelImpl.ORDER_BY_SQL);
2807 }
2808 }
2809
2810 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2811 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2812
2813 SQLQuery q = session.createSQLQuery(sql);
2814
2815 q.setFirstResult(0);
2816 q.setMaxResults(2);
2817
2818 if (getDB().isSupportsInlineDistinct()) {
2819 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
2820 }
2821 else {
2822 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
2823 }
2824
2825 QueryPos qPos = QueryPos.getInstance(q);
2826
2827 if (subtype != null) {
2828 qPos.add(subtype);
2829 }
2830
2831 if (orderByComparator != null) {
2832 Object[] values = orderByComparator.getOrderByConditionValues(role);
2833
2834 for (Object value : values) {
2835 qPos.add(value);
2836 }
2837 }
2838
2839 List<Role> list = q.list();
2840
2841 if (list.size() == 2) {
2842 return list.get(1);
2843 }
2844 else {
2845 return null;
2846 }
2847 }
2848
2849
2858 public Role findByC_N(long companyId, String name)
2859 throws NoSuchRoleException, SystemException {
2860 Role role = fetchByC_N(companyId, name);
2861
2862 if (role == null) {
2863 StringBundler msg = new StringBundler(6);
2864
2865 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2866
2867 msg.append("companyId=");
2868 msg.append(companyId);
2869
2870 msg.append(", name=");
2871 msg.append(name);
2872
2873 msg.append(StringPool.CLOSE_CURLY_BRACE);
2874
2875 if (_log.isWarnEnabled()) {
2876 _log.warn(msg.toString());
2877 }
2878
2879 throw new NoSuchRoleException(msg.toString());
2880 }
2881
2882 return role;
2883 }
2884
2885
2893 public Role fetchByC_N(long companyId, String name)
2894 throws SystemException {
2895 return fetchByC_N(companyId, name, true);
2896 }
2897
2898
2907 public Role fetchByC_N(long companyId, String name,
2908 boolean retrieveFromCache) throws SystemException {
2909 Object[] finderArgs = new Object[] { companyId, name };
2910
2911 Object result = null;
2912
2913 if (retrieveFromCache) {
2914 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_N,
2915 finderArgs, this);
2916 }
2917
2918 if (result instanceof Role) {
2919 Role role = (Role)result;
2920
2921 if ((companyId != role.getCompanyId()) ||
2922 !Validator.equals(name, role.getName())) {
2923 result = null;
2924 }
2925 }
2926
2927 if (result == null) {
2928 StringBundler query = new StringBundler(4);
2929
2930 query.append(_SQL_SELECT_ROLE_WHERE);
2931
2932 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
2933
2934 if (name == null) {
2935 query.append(_FINDER_COLUMN_C_N_NAME_1);
2936 }
2937 else {
2938 if (name.equals(StringPool.BLANK)) {
2939 query.append(_FINDER_COLUMN_C_N_NAME_3);
2940 }
2941 else {
2942 query.append(_FINDER_COLUMN_C_N_NAME_2);
2943 }
2944 }
2945
2946 query.append(RoleModelImpl.ORDER_BY_JPQL);
2947
2948 String sql = query.toString();
2949
2950 Session session = null;
2951
2952 try {
2953 session = openSession();
2954
2955 Query q = session.createQuery(sql);
2956
2957 QueryPos qPos = QueryPos.getInstance(q);
2958
2959 qPos.add(companyId);
2960
2961 if (name != null) {
2962 qPos.add(name);
2963 }
2964
2965 List<Role> list = q.list();
2966
2967 result = list;
2968
2969 Role role = null;
2970
2971 if (list.isEmpty()) {
2972 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
2973 finderArgs, list);
2974 }
2975 else {
2976 role = list.get(0);
2977
2978 cacheResult(role);
2979
2980 if ((role.getCompanyId() != companyId) ||
2981 (role.getName() == null) ||
2982 !role.getName().equals(name)) {
2983 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
2984 finderArgs, role);
2985 }
2986 }
2987
2988 return role;
2989 }
2990 catch (Exception e) {
2991 throw processException(e);
2992 }
2993 finally {
2994 if (result == null) {
2995 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
2996 finderArgs);
2997 }
2998
2999 closeSession(session);
3000 }
3001 }
3002 else {
3003 if (result instanceof List<?>) {
3004 return null;
3005 }
3006 else {
3007 return (Role)result;
3008 }
3009 }
3010 }
3011
3012
3020 public List<Role> findByT_S(int type, String subtype)
3021 throws SystemException {
3022 return findByT_S(type, subtype, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3023 null);
3024 }
3025
3026
3040 public List<Role> findByT_S(int type, String subtype, int start, int end)
3041 throws SystemException {
3042 return findByT_S(type, subtype, start, end, null);
3043 }
3044
3045
3060 public List<Role> findByT_S(int type, String subtype, int start, int end,
3061 OrderByComparator orderByComparator) throws SystemException {
3062 FinderPath finderPath = null;
3063 Object[] finderArgs = null;
3064
3065 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3066 (orderByComparator == null)) {
3067 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S;
3068 finderArgs = new Object[] { type, subtype };
3069 }
3070 else {
3071 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_T_S;
3072 finderArgs = new Object[] {
3073 type, subtype,
3074
3075 start, end, orderByComparator
3076 };
3077 }
3078
3079 List<Role> list = (List<Role>)FinderCacheUtil.getResult(finderPath,
3080 finderArgs, this);
3081
3082 if ((list != null) && !list.isEmpty()) {
3083 for (Role role : list) {
3084 if ((type != role.getType()) ||
3085 !Validator.equals(subtype, role.getSubtype())) {
3086 list = null;
3087
3088 break;
3089 }
3090 }
3091 }
3092
3093 if (list == null) {
3094 StringBundler query = null;
3095
3096 if (orderByComparator != null) {
3097 query = new StringBundler(4 +
3098 (orderByComparator.getOrderByFields().length * 3));
3099 }
3100 else {
3101 query = new StringBundler(4);
3102 }
3103
3104 query.append(_SQL_SELECT_ROLE_WHERE);
3105
3106 query.append(_FINDER_COLUMN_T_S_TYPE_2);
3107
3108 if (subtype == null) {
3109 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
3110 }
3111 else {
3112 if (subtype.equals(StringPool.BLANK)) {
3113 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
3114 }
3115 else {
3116 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
3117 }
3118 }
3119
3120 if (orderByComparator != null) {
3121 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3122 orderByComparator);
3123 }
3124
3125 else {
3126 query.append(RoleModelImpl.ORDER_BY_JPQL);
3127 }
3128
3129 String sql = query.toString();
3130
3131 Session session = null;
3132
3133 try {
3134 session = openSession();
3135
3136 Query q = session.createQuery(sql);
3137
3138 QueryPos qPos = QueryPos.getInstance(q);
3139
3140 qPos.add(type);
3141
3142 if (subtype != null) {
3143 qPos.add(subtype);
3144 }
3145
3146 list = (List<Role>)QueryUtil.list(q, getDialect(), start, end);
3147 }
3148 catch (Exception e) {
3149 throw processException(e);
3150 }
3151 finally {
3152 if (list == null) {
3153 FinderCacheUtil.removeResult(finderPath, finderArgs);
3154 }
3155 else {
3156 cacheResult(list);
3157
3158 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3159 }
3160
3161 closeSession(session);
3162 }
3163 }
3164
3165 return list;
3166 }
3167
3168
3178 public Role findByT_S_First(int type, String subtype,
3179 OrderByComparator orderByComparator)
3180 throws NoSuchRoleException, SystemException {
3181 Role role = fetchByT_S_First(type, subtype, orderByComparator);
3182
3183 if (role != null) {
3184 return role;
3185 }
3186
3187 StringBundler msg = new StringBundler(6);
3188
3189 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3190
3191 msg.append("type=");
3192 msg.append(type);
3193
3194 msg.append(", subtype=");
3195 msg.append(subtype);
3196
3197 msg.append(StringPool.CLOSE_CURLY_BRACE);
3198
3199 throw new NoSuchRoleException(msg.toString());
3200 }
3201
3202
3211 public Role fetchByT_S_First(int type, String subtype,
3212 OrderByComparator orderByComparator) throws SystemException {
3213 List<Role> list = findByT_S(type, subtype, 0, 1, orderByComparator);
3214
3215 if (!list.isEmpty()) {
3216 return list.get(0);
3217 }
3218
3219 return null;
3220 }
3221
3222
3232 public Role findByT_S_Last(int type, String subtype,
3233 OrderByComparator orderByComparator)
3234 throws NoSuchRoleException, SystemException {
3235 Role role = fetchByT_S_Last(type, subtype, orderByComparator);
3236
3237 if (role != null) {
3238 return role;
3239 }
3240
3241 StringBundler msg = new StringBundler(6);
3242
3243 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3244
3245 msg.append("type=");
3246 msg.append(type);
3247
3248 msg.append(", subtype=");
3249 msg.append(subtype);
3250
3251 msg.append(StringPool.CLOSE_CURLY_BRACE);
3252
3253 throw new NoSuchRoleException(msg.toString());
3254 }
3255
3256
3265 public Role fetchByT_S_Last(int type, String subtype,
3266 OrderByComparator orderByComparator) throws SystemException {
3267 int count = countByT_S(type, subtype);
3268
3269 List<Role> list = findByT_S(type, subtype, count - 1, count,
3270 orderByComparator);
3271
3272 if (!list.isEmpty()) {
3273 return list.get(0);
3274 }
3275
3276 return null;
3277 }
3278
3279
3290 public Role[] findByT_S_PrevAndNext(long roleId, int type, String subtype,
3291 OrderByComparator orderByComparator)
3292 throws NoSuchRoleException, SystemException {
3293 Role role = findByPrimaryKey(roleId);
3294
3295 Session session = null;
3296
3297 try {
3298 session = openSession();
3299
3300 Role[] array = new RoleImpl[3];
3301
3302 array[0] = getByT_S_PrevAndNext(session, role, type, subtype,
3303 orderByComparator, true);
3304
3305 array[1] = role;
3306
3307 array[2] = getByT_S_PrevAndNext(session, role, type, subtype,
3308 orderByComparator, false);
3309
3310 return array;
3311 }
3312 catch (Exception e) {
3313 throw processException(e);
3314 }
3315 finally {
3316 closeSession(session);
3317 }
3318 }
3319
3320 protected Role getByT_S_PrevAndNext(Session session, Role role, int type,
3321 String subtype, OrderByComparator orderByComparator, boolean previous) {
3322 StringBundler query = null;
3323
3324 if (orderByComparator != null) {
3325 query = new StringBundler(6 +
3326 (orderByComparator.getOrderByFields().length * 6));
3327 }
3328 else {
3329 query = new StringBundler(3);
3330 }
3331
3332 query.append(_SQL_SELECT_ROLE_WHERE);
3333
3334 query.append(_FINDER_COLUMN_T_S_TYPE_2);
3335
3336 if (subtype == null) {
3337 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
3338 }
3339 else {
3340 if (subtype.equals(StringPool.BLANK)) {
3341 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
3342 }
3343 else {
3344 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
3345 }
3346 }
3347
3348 if (orderByComparator != null) {
3349 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3350
3351 if (orderByConditionFields.length > 0) {
3352 query.append(WHERE_AND);
3353 }
3354
3355 for (int i = 0; i < orderByConditionFields.length; i++) {
3356 query.append(_ORDER_BY_ENTITY_ALIAS);
3357 query.append(orderByConditionFields[i]);
3358
3359 if ((i + 1) < orderByConditionFields.length) {
3360 if (orderByComparator.isAscending() ^ previous) {
3361 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3362 }
3363 else {
3364 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3365 }
3366 }
3367 else {
3368 if (orderByComparator.isAscending() ^ previous) {
3369 query.append(WHERE_GREATER_THAN);
3370 }
3371 else {
3372 query.append(WHERE_LESSER_THAN);
3373 }
3374 }
3375 }
3376
3377 query.append(ORDER_BY_CLAUSE);
3378
3379 String[] orderByFields = orderByComparator.getOrderByFields();
3380
3381 for (int i = 0; i < orderByFields.length; i++) {
3382 query.append(_ORDER_BY_ENTITY_ALIAS);
3383 query.append(orderByFields[i]);
3384
3385 if ((i + 1) < orderByFields.length) {
3386 if (orderByComparator.isAscending() ^ previous) {
3387 query.append(ORDER_BY_ASC_HAS_NEXT);
3388 }
3389 else {
3390 query.append(ORDER_BY_DESC_HAS_NEXT);
3391 }
3392 }
3393 else {
3394 if (orderByComparator.isAscending() ^ previous) {
3395 query.append(ORDER_BY_ASC);
3396 }
3397 else {
3398 query.append(ORDER_BY_DESC);
3399 }
3400 }
3401 }
3402 }
3403
3404 else {
3405 query.append(RoleModelImpl.ORDER_BY_JPQL);
3406 }
3407
3408 String sql = query.toString();
3409
3410 Query q = session.createQuery(sql);
3411
3412 q.setFirstResult(0);
3413 q.setMaxResults(2);
3414
3415 QueryPos qPos = QueryPos.getInstance(q);
3416
3417 qPos.add(type);
3418
3419 if (subtype != null) {
3420 qPos.add(subtype);
3421 }
3422
3423 if (orderByComparator != null) {
3424 Object[] values = orderByComparator.getOrderByConditionValues(role);
3425
3426 for (Object value : values) {
3427 qPos.add(value);
3428 }
3429 }
3430
3431 List<Role> list = q.list();
3432
3433 if (list.size() == 2) {
3434 return list.get(1);
3435 }
3436 else {
3437 return null;
3438 }
3439 }
3440
3441
3449 public List<Role> filterFindByT_S(int type, String subtype)
3450 throws SystemException {
3451 return filterFindByT_S(type, subtype, QueryUtil.ALL_POS,
3452 QueryUtil.ALL_POS, null);
3453 }
3454
3455
3469 public List<Role> filterFindByT_S(int type, String subtype, int start,
3470 int end) throws SystemException {
3471 return filterFindByT_S(type, subtype, start, end, null);
3472 }
3473
3474
3489 public List<Role> filterFindByT_S(int type, String subtype, int start,
3490 int end, OrderByComparator orderByComparator) throws SystemException {
3491 if (!InlineSQLHelperUtil.isEnabled()) {
3492 return findByT_S(type, subtype, start, end, orderByComparator);
3493 }
3494
3495 StringBundler query = null;
3496
3497 if (orderByComparator != null) {
3498 query = new StringBundler(4 +
3499 (orderByComparator.getOrderByFields().length * 3));
3500 }
3501 else {
3502 query = new StringBundler(4);
3503 }
3504
3505 if (getDB().isSupportsInlineDistinct()) {
3506 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
3507 }
3508 else {
3509 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
3510 }
3511
3512 query.append(_FINDER_COLUMN_T_S_TYPE_2);
3513
3514 if (subtype == null) {
3515 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
3516 }
3517 else {
3518 if (subtype.equals(StringPool.BLANK)) {
3519 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
3520 }
3521 else {
3522 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
3523 }
3524 }
3525
3526 if (!getDB().isSupportsInlineDistinct()) {
3527 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
3528 }
3529
3530 if (orderByComparator != null) {
3531 if (getDB().isSupportsInlineDistinct()) {
3532 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3533 orderByComparator);
3534 }
3535 else {
3536 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3537 orderByComparator);
3538 }
3539 }
3540
3541 else {
3542 if (getDB().isSupportsInlineDistinct()) {
3543 query.append(RoleModelImpl.ORDER_BY_JPQL);
3544 }
3545 else {
3546 query.append(RoleModelImpl.ORDER_BY_SQL);
3547 }
3548 }
3549
3550 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3551 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3552
3553 Session session = null;
3554
3555 try {
3556 session = openSession();
3557
3558 SQLQuery q = session.createSQLQuery(sql);
3559
3560 if (getDB().isSupportsInlineDistinct()) {
3561 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
3562 }
3563 else {
3564 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
3565 }
3566
3567 QueryPos qPos = QueryPos.getInstance(q);
3568
3569 qPos.add(type);
3570
3571 if (subtype != null) {
3572 qPos.add(subtype);
3573 }
3574
3575 return (List<Role>)QueryUtil.list(q, getDialect(), start, end);
3576 }
3577 catch (Exception e) {
3578 throw processException(e);
3579 }
3580 finally {
3581 closeSession(session);
3582 }
3583 }
3584
3585
3596 public Role[] filterFindByT_S_PrevAndNext(long roleId, int type,
3597 String subtype, OrderByComparator orderByComparator)
3598 throws NoSuchRoleException, SystemException {
3599 if (!InlineSQLHelperUtil.isEnabled()) {
3600 return findByT_S_PrevAndNext(roleId, type, subtype,
3601 orderByComparator);
3602 }
3603
3604 Role role = findByPrimaryKey(roleId);
3605
3606 Session session = null;
3607
3608 try {
3609 session = openSession();
3610
3611 Role[] array = new RoleImpl[3];
3612
3613 array[0] = filterGetByT_S_PrevAndNext(session, role, type, subtype,
3614 orderByComparator, true);
3615
3616 array[1] = role;
3617
3618 array[2] = filterGetByT_S_PrevAndNext(session, role, type, subtype,
3619 orderByComparator, false);
3620
3621 return array;
3622 }
3623 catch (Exception e) {
3624 throw processException(e);
3625 }
3626 finally {
3627 closeSession(session);
3628 }
3629 }
3630
3631 protected Role filterGetByT_S_PrevAndNext(Session session, Role role,
3632 int type, String subtype, OrderByComparator orderByComparator,
3633 boolean previous) {
3634 StringBundler query = null;
3635
3636 if (orderByComparator != null) {
3637 query = new StringBundler(6 +
3638 (orderByComparator.getOrderByFields().length * 6));
3639 }
3640 else {
3641 query = new StringBundler(3);
3642 }
3643
3644 if (getDB().isSupportsInlineDistinct()) {
3645 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
3646 }
3647 else {
3648 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
3649 }
3650
3651 query.append(_FINDER_COLUMN_T_S_TYPE_2);
3652
3653 if (subtype == null) {
3654 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
3655 }
3656 else {
3657 if (subtype.equals(StringPool.BLANK)) {
3658 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
3659 }
3660 else {
3661 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
3662 }
3663 }
3664
3665 if (!getDB().isSupportsInlineDistinct()) {
3666 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
3667 }
3668
3669 if (orderByComparator != null) {
3670 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3671
3672 if (orderByConditionFields.length > 0) {
3673 query.append(WHERE_AND);
3674 }
3675
3676 for (int i = 0; i < orderByConditionFields.length; i++) {
3677 if (getDB().isSupportsInlineDistinct()) {
3678 query.append(_ORDER_BY_ENTITY_ALIAS);
3679 }
3680 else {
3681 query.append(_ORDER_BY_ENTITY_TABLE);
3682 }
3683
3684 query.append(orderByConditionFields[i]);
3685
3686 if ((i + 1) < orderByConditionFields.length) {
3687 if (orderByComparator.isAscending() ^ previous) {
3688 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3689 }
3690 else {
3691 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3692 }
3693 }
3694 else {
3695 if (orderByComparator.isAscending() ^ previous) {
3696 query.append(WHERE_GREATER_THAN);
3697 }
3698 else {
3699 query.append(WHERE_LESSER_THAN);
3700 }
3701 }
3702 }
3703
3704 query.append(ORDER_BY_CLAUSE);
3705
3706 String[] orderByFields = orderByComparator.getOrderByFields();
3707
3708 for (int i = 0; i < orderByFields.length; i++) {
3709 if (getDB().isSupportsInlineDistinct()) {
3710 query.append(_ORDER_BY_ENTITY_ALIAS);
3711 }
3712 else {
3713 query.append(_ORDER_BY_ENTITY_TABLE);
3714 }
3715
3716 query.append(orderByFields[i]);
3717
3718 if ((i + 1) < orderByFields.length) {
3719 if (orderByComparator.isAscending() ^ previous) {
3720 query.append(ORDER_BY_ASC_HAS_NEXT);
3721 }
3722 else {
3723 query.append(ORDER_BY_DESC_HAS_NEXT);
3724 }
3725 }
3726 else {
3727 if (orderByComparator.isAscending() ^ previous) {
3728 query.append(ORDER_BY_ASC);
3729 }
3730 else {
3731 query.append(ORDER_BY_DESC);
3732 }
3733 }
3734 }
3735 }
3736
3737 else {
3738 if (getDB().isSupportsInlineDistinct()) {
3739 query.append(RoleModelImpl.ORDER_BY_JPQL);
3740 }
3741 else {
3742 query.append(RoleModelImpl.ORDER_BY_SQL);
3743 }
3744 }
3745
3746 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3747 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3748
3749 SQLQuery q = session.createSQLQuery(sql);
3750
3751 q.setFirstResult(0);
3752 q.setMaxResults(2);
3753
3754 if (getDB().isSupportsInlineDistinct()) {
3755 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
3756 }
3757 else {
3758 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
3759 }
3760
3761 QueryPos qPos = QueryPos.getInstance(q);
3762
3763 qPos.add(type);
3764
3765 if (subtype != null) {
3766 qPos.add(subtype);
3767 }
3768
3769 if (orderByComparator != null) {
3770 Object[] values = orderByComparator.getOrderByConditionValues(role);
3771
3772 for (Object value : values) {
3773 qPos.add(value);
3774 }
3775 }
3776
3777 List<Role> list = q.list();
3778
3779 if (list.size() == 2) {
3780 return list.get(1);
3781 }
3782 else {
3783 return null;
3784 }
3785 }
3786
3787
3797 public Role findByC_C_C(long companyId, long classNameId, long classPK)
3798 throws NoSuchRoleException, SystemException {
3799 Role role = fetchByC_C_C(companyId, classNameId, classPK);
3800
3801 if (role == null) {
3802 StringBundler msg = new StringBundler(8);
3803
3804 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3805
3806 msg.append("companyId=");
3807 msg.append(companyId);
3808
3809 msg.append(", classNameId=");
3810 msg.append(classNameId);
3811
3812 msg.append(", classPK=");
3813 msg.append(classPK);
3814
3815 msg.append(StringPool.CLOSE_CURLY_BRACE);
3816
3817 if (_log.isWarnEnabled()) {
3818 _log.warn(msg.toString());
3819 }
3820
3821 throw new NoSuchRoleException(msg.toString());
3822 }
3823
3824 return role;
3825 }
3826
3827
3836 public Role fetchByC_C_C(long companyId, long classNameId, long classPK)
3837 throws SystemException {
3838 return fetchByC_C_C(companyId, classNameId, classPK, true);
3839 }
3840
3841
3851 public Role fetchByC_C_C(long companyId, long classNameId, long classPK,
3852 boolean retrieveFromCache) throws SystemException {
3853 Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
3854
3855 Object result = null;
3856
3857 if (retrieveFromCache) {
3858 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C_C,
3859 finderArgs, this);
3860 }
3861
3862 if (result instanceof Role) {
3863 Role role = (Role)result;
3864
3865 if ((companyId != role.getCompanyId()) ||
3866 (classNameId != role.getClassNameId()) ||
3867 (classPK != role.getClassPK())) {
3868 result = null;
3869 }
3870 }
3871
3872 if (result == null) {
3873 StringBundler query = new StringBundler(5);
3874
3875 query.append(_SQL_SELECT_ROLE_WHERE);
3876
3877 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
3878
3879 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
3880
3881 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
3882
3883 query.append(RoleModelImpl.ORDER_BY_JPQL);
3884
3885 String sql = query.toString();
3886
3887 Session session = null;
3888
3889 try {
3890 session = openSession();
3891
3892 Query q = session.createQuery(sql);
3893
3894 QueryPos qPos = QueryPos.getInstance(q);
3895
3896 qPos.add(companyId);
3897
3898 qPos.add(classNameId);
3899
3900 qPos.add(classPK);
3901
3902 List<Role> list = q.list();
3903
3904 result = list;
3905
3906 Role role = null;
3907
3908 if (list.isEmpty()) {
3909 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
3910 finderArgs, list);
3911 }
3912 else {
3913 role = list.get(0);
3914
3915 cacheResult(role);
3916
3917 if ((role.getCompanyId() != companyId) ||
3918 (role.getClassNameId() != classNameId) ||
3919 (role.getClassPK() != classPK)) {
3920 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
3921 finderArgs, role);
3922 }
3923 }
3924
3925 return role;
3926 }
3927 catch (Exception e) {
3928 throw processException(e);
3929 }
3930 finally {
3931 if (result == null) {
3932 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C,
3933 finderArgs);
3934 }
3935
3936 closeSession(session);
3937 }
3938 }
3939 else {
3940 if (result instanceof List<?>) {
3941 return null;
3942 }
3943 else {
3944 return (Role)result;
3945 }
3946 }
3947 }
3948
3949
3955 public List<Role> findAll() throws SystemException {
3956 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3957 }
3958
3959
3971 public List<Role> findAll(int start, int end) throws SystemException {
3972 return findAll(start, end, null);
3973 }
3974
3975
3988 public List<Role> findAll(int start, int end,
3989 OrderByComparator orderByComparator) throws SystemException {
3990 FinderPath finderPath = null;
3991 Object[] finderArgs = new Object[] { start, end, orderByComparator };
3992
3993 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3994 (orderByComparator == null)) {
3995 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3996 finderArgs = FINDER_ARGS_EMPTY;
3997 }
3998 else {
3999 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
4000 finderArgs = new Object[] { start, end, orderByComparator };
4001 }
4002
4003 List<Role> list = (List<Role>)FinderCacheUtil.getResult(finderPath,
4004 finderArgs, this);
4005
4006 if (list == null) {
4007 StringBundler query = null;
4008 String sql = null;
4009
4010 if (orderByComparator != null) {
4011 query = new StringBundler(2 +
4012 (orderByComparator.getOrderByFields().length * 3));
4013
4014 query.append(_SQL_SELECT_ROLE);
4015
4016 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4017 orderByComparator);
4018
4019 sql = query.toString();
4020 }
4021 else {
4022 sql = _SQL_SELECT_ROLE.concat(RoleModelImpl.ORDER_BY_JPQL);
4023 }
4024
4025 Session session = null;
4026
4027 try {
4028 session = openSession();
4029
4030 Query q = session.createQuery(sql);
4031
4032 if (orderByComparator == null) {
4033 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
4034 end, false);
4035
4036 Collections.sort(list);
4037 }
4038 else {
4039 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
4040 end);
4041 }
4042 }
4043 catch (Exception e) {
4044 throw processException(e);
4045 }
4046 finally {
4047 if (list == null) {
4048 FinderCacheUtil.removeResult(finderPath, finderArgs);
4049 }
4050 else {
4051 cacheResult(list);
4052
4053 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4054 }
4055
4056 closeSession(session);
4057 }
4058 }
4059
4060 return list;
4061 }
4062
4063
4069 public void removeByCompanyId(long companyId) throws SystemException {
4070 for (Role role : findByCompanyId(companyId)) {
4071 remove(role);
4072 }
4073 }
4074
4075
4081 public void removeByName(String name) throws SystemException {
4082 for (Role role : findByName(name)) {
4083 remove(role);
4084 }
4085 }
4086
4087
4093 public void removeBySubtype(String subtype) throws SystemException {
4094 for (Role role : findBySubtype(subtype)) {
4095 remove(role);
4096 }
4097 }
4098
4099
4107 public Role removeByC_N(long companyId, String name)
4108 throws NoSuchRoleException, SystemException {
4109 Role role = findByC_N(companyId, name);
4110
4111 return remove(role);
4112 }
4113
4114
4121 public void removeByT_S(int type, String subtype) throws SystemException {
4122 for (Role role : findByT_S(type, subtype)) {
4123 remove(role);
4124 }
4125 }
4126
4127
4136 public Role removeByC_C_C(long companyId, long classNameId, long classPK)
4137 throws NoSuchRoleException, SystemException {
4138 Role role = findByC_C_C(companyId, classNameId, classPK);
4139
4140 return remove(role);
4141 }
4142
4143
4148 public void removeAll() throws SystemException {
4149 for (Role role : findAll()) {
4150 remove(role);
4151 }
4152 }
4153
4154
4161 public int countByCompanyId(long companyId) throws SystemException {
4162 Object[] finderArgs = new Object[] { companyId };
4163
4164 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
4165 finderArgs, this);
4166
4167 if (count == null) {
4168 StringBundler query = new StringBundler(2);
4169
4170 query.append(_SQL_COUNT_ROLE_WHERE);
4171
4172 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
4173
4174 String sql = query.toString();
4175
4176 Session session = null;
4177
4178 try {
4179 session = openSession();
4180
4181 Query q = session.createQuery(sql);
4182
4183 QueryPos qPos = QueryPos.getInstance(q);
4184
4185 qPos.add(companyId);
4186
4187 count = (Long)q.uniqueResult();
4188 }
4189 catch (Exception e) {
4190 throw processException(e);
4191 }
4192 finally {
4193 if (count == null) {
4194 count = Long.valueOf(0);
4195 }
4196
4197 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
4198 finderArgs, count);
4199
4200 closeSession(session);
4201 }
4202 }
4203
4204 return count.intValue();
4205 }
4206
4207
4214 public int filterCountByCompanyId(long companyId) throws SystemException {
4215 if (!InlineSQLHelperUtil.isEnabled()) {
4216 return countByCompanyId(companyId);
4217 }
4218
4219 StringBundler query = new StringBundler(2);
4220
4221 query.append(_FILTER_SQL_COUNT_ROLE_WHERE);
4222
4223 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
4224
4225 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4226 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4227
4228 Session session = null;
4229
4230 try {
4231 session = openSession();
4232
4233 SQLQuery q = session.createSQLQuery(sql);
4234
4235 q.addScalar(COUNT_COLUMN_NAME,
4236 com.liferay.portal.kernel.dao.orm.Type.LONG);
4237
4238 QueryPos qPos = QueryPos.getInstance(q);
4239
4240 qPos.add(companyId);
4241
4242 Long count = (Long)q.uniqueResult();
4243
4244 return count.intValue();
4245 }
4246 catch (Exception e) {
4247 throw processException(e);
4248 }
4249 finally {
4250 closeSession(session);
4251 }
4252 }
4253
4254
4261 public int countByName(String name) throws SystemException {
4262 Object[] finderArgs = new Object[] { name };
4263
4264 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_NAME,
4265 finderArgs, this);
4266
4267 if (count == null) {
4268 StringBundler query = new StringBundler(2);
4269
4270 query.append(_SQL_COUNT_ROLE_WHERE);
4271
4272 if (name == null) {
4273 query.append(_FINDER_COLUMN_NAME_NAME_1);
4274 }
4275 else {
4276 if (name.equals(StringPool.BLANK)) {
4277 query.append(_FINDER_COLUMN_NAME_NAME_3);
4278 }
4279 else {
4280 query.append(_FINDER_COLUMN_NAME_NAME_2);
4281 }
4282 }
4283
4284 String sql = query.toString();
4285
4286 Session session = null;
4287
4288 try {
4289 session = openSession();
4290
4291 Query q = session.createQuery(sql);
4292
4293 QueryPos qPos = QueryPos.getInstance(q);
4294
4295 if (name != null) {
4296 qPos.add(name);
4297 }
4298
4299 count = (Long)q.uniqueResult();
4300 }
4301 catch (Exception e) {
4302 throw processException(e);
4303 }
4304 finally {
4305 if (count == null) {
4306 count = Long.valueOf(0);
4307 }
4308
4309 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_NAME,
4310 finderArgs, count);
4311
4312 closeSession(session);
4313 }
4314 }
4315
4316 return count.intValue();
4317 }
4318
4319
4326 public int filterCountByName(String name) throws SystemException {
4327 if (!InlineSQLHelperUtil.isEnabled()) {
4328 return countByName(name);
4329 }
4330
4331 StringBundler query = new StringBundler(2);
4332
4333 query.append(_FILTER_SQL_COUNT_ROLE_WHERE);
4334
4335 if (name == null) {
4336 query.append(_FINDER_COLUMN_NAME_NAME_1);
4337 }
4338 else {
4339 if (name.equals(StringPool.BLANK)) {
4340 query.append(_FINDER_COLUMN_NAME_NAME_3);
4341 }
4342 else {
4343 query.append(_FINDER_COLUMN_NAME_NAME_2);
4344 }
4345 }
4346
4347 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4348 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4349
4350 Session session = null;
4351
4352 try {
4353 session = openSession();
4354
4355 SQLQuery q = session.createSQLQuery(sql);
4356
4357 q.addScalar(COUNT_COLUMN_NAME,
4358 com.liferay.portal.kernel.dao.orm.Type.LONG);
4359
4360 QueryPos qPos = QueryPos.getInstance(q);
4361
4362 if (name != null) {
4363 qPos.add(name);
4364 }
4365
4366 Long count = (Long)q.uniqueResult();
4367
4368 return count.intValue();
4369 }
4370 catch (Exception e) {
4371 throw processException(e);
4372 }
4373 finally {
4374 closeSession(session);
4375 }
4376 }
4377
4378
4385 public int countBySubtype(String subtype) throws SystemException {
4386 Object[] finderArgs = new Object[] { subtype };
4387
4388 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SUBTYPE,
4389 finderArgs, this);
4390
4391 if (count == null) {
4392 StringBundler query = new StringBundler(2);
4393
4394 query.append(_SQL_COUNT_ROLE_WHERE);
4395
4396 if (subtype == null) {
4397 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
4398 }
4399 else {
4400 if (subtype.equals(StringPool.BLANK)) {
4401 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
4402 }
4403 else {
4404 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
4405 }
4406 }
4407
4408 String sql = query.toString();
4409
4410 Session session = null;
4411
4412 try {
4413 session = openSession();
4414
4415 Query q = session.createQuery(sql);
4416
4417 QueryPos qPos = QueryPos.getInstance(q);
4418
4419 if (subtype != null) {
4420 qPos.add(subtype);
4421 }
4422
4423 count = (Long)q.uniqueResult();
4424 }
4425 catch (Exception e) {
4426 throw processException(e);
4427 }
4428 finally {
4429 if (count == null) {
4430 count = Long.valueOf(0);
4431 }
4432
4433 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SUBTYPE,
4434 finderArgs, count);
4435
4436 closeSession(session);
4437 }
4438 }
4439
4440 return count.intValue();
4441 }
4442
4443
4450 public int filterCountBySubtype(String subtype) throws SystemException {
4451 if (!InlineSQLHelperUtil.isEnabled()) {
4452 return countBySubtype(subtype);
4453 }
4454
4455 StringBundler query = new StringBundler(2);
4456
4457 query.append(_FILTER_SQL_COUNT_ROLE_WHERE);
4458
4459 if (subtype == null) {
4460 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
4461 }
4462 else {
4463 if (subtype.equals(StringPool.BLANK)) {
4464 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
4465 }
4466 else {
4467 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
4468 }
4469 }
4470
4471 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4472 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4473
4474 Session session = null;
4475
4476 try {
4477 session = openSession();
4478
4479 SQLQuery q = session.createSQLQuery(sql);
4480
4481 q.addScalar(COUNT_COLUMN_NAME,
4482 com.liferay.portal.kernel.dao.orm.Type.LONG);
4483
4484 QueryPos qPos = QueryPos.getInstance(q);
4485
4486 if (subtype != null) {
4487 qPos.add(subtype);
4488 }
4489
4490 Long count = (Long)q.uniqueResult();
4491
4492 return count.intValue();
4493 }
4494 catch (Exception e) {
4495 throw processException(e);
4496 }
4497 finally {
4498 closeSession(session);
4499 }
4500 }
4501
4502
4510 public int countByC_N(long companyId, String name)
4511 throws SystemException {
4512 Object[] finderArgs = new Object[] { companyId, name };
4513
4514 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_N,
4515 finderArgs, this);
4516
4517 if (count == null) {
4518 StringBundler query = new StringBundler(3);
4519
4520 query.append(_SQL_COUNT_ROLE_WHERE);
4521
4522 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
4523
4524 if (name == null) {
4525 query.append(_FINDER_COLUMN_C_N_NAME_1);
4526 }
4527 else {
4528 if (name.equals(StringPool.BLANK)) {
4529 query.append(_FINDER_COLUMN_C_N_NAME_3);
4530 }
4531 else {
4532 query.append(_FINDER_COLUMN_C_N_NAME_2);
4533 }
4534 }
4535
4536 String sql = query.toString();
4537
4538 Session session = null;
4539
4540 try {
4541 session = openSession();
4542
4543 Query q = session.createQuery(sql);
4544
4545 QueryPos qPos = QueryPos.getInstance(q);
4546
4547 qPos.add(companyId);
4548
4549 if (name != null) {
4550 qPos.add(name);
4551 }
4552
4553 count = (Long)q.uniqueResult();
4554 }
4555 catch (Exception e) {
4556 throw processException(e);
4557 }
4558 finally {
4559 if (count == null) {
4560 count = Long.valueOf(0);
4561 }
4562
4563 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, finderArgs,
4564 count);
4565
4566 closeSession(session);
4567 }
4568 }
4569
4570 return count.intValue();
4571 }
4572
4573
4581 public int countByT_S(int type, String subtype) throws SystemException {
4582 Object[] finderArgs = new Object[] { type, subtype };
4583
4584 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_T_S,
4585 finderArgs, this);
4586
4587 if (count == null) {
4588 StringBundler query = new StringBundler(3);
4589
4590 query.append(_SQL_COUNT_ROLE_WHERE);
4591
4592 query.append(_FINDER_COLUMN_T_S_TYPE_2);
4593
4594 if (subtype == null) {
4595 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
4596 }
4597 else {
4598 if (subtype.equals(StringPool.BLANK)) {
4599 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
4600 }
4601 else {
4602 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
4603 }
4604 }
4605
4606 String sql = query.toString();
4607
4608 Session session = null;
4609
4610 try {
4611 session = openSession();
4612
4613 Query q = session.createQuery(sql);
4614
4615 QueryPos qPos = QueryPos.getInstance(q);
4616
4617 qPos.add(type);
4618
4619 if (subtype != null) {
4620 qPos.add(subtype);
4621 }
4622
4623 count = (Long)q.uniqueResult();
4624 }
4625 catch (Exception e) {
4626 throw processException(e);
4627 }
4628 finally {
4629 if (count == null) {
4630 count = Long.valueOf(0);
4631 }
4632
4633 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_S, finderArgs,
4634 count);
4635
4636 closeSession(session);
4637 }
4638 }
4639
4640 return count.intValue();
4641 }
4642
4643
4651 public int filterCountByT_S(int type, String subtype)
4652 throws SystemException {
4653 if (!InlineSQLHelperUtil.isEnabled()) {
4654 return countByT_S(type, subtype);
4655 }
4656
4657 StringBundler query = new StringBundler(3);
4658
4659 query.append(_FILTER_SQL_COUNT_ROLE_WHERE);
4660
4661 query.append(_FINDER_COLUMN_T_S_TYPE_2);
4662
4663 if (subtype == null) {
4664 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
4665 }
4666 else {
4667 if (subtype.equals(StringPool.BLANK)) {
4668 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
4669 }
4670 else {
4671 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
4672 }
4673 }
4674
4675 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4676 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4677
4678 Session session = null;
4679
4680 try {
4681 session = openSession();
4682
4683 SQLQuery q = session.createSQLQuery(sql);
4684
4685 q.addScalar(COUNT_COLUMN_NAME,
4686 com.liferay.portal.kernel.dao.orm.Type.LONG);
4687
4688 QueryPos qPos = QueryPos.getInstance(q);
4689
4690 qPos.add(type);
4691
4692 if (subtype != null) {
4693 qPos.add(subtype);
4694 }
4695
4696 Long count = (Long)q.uniqueResult();
4697
4698 return count.intValue();
4699 }
4700 catch (Exception e) {
4701 throw processException(e);
4702 }
4703 finally {
4704 closeSession(session);
4705 }
4706 }
4707
4708
4717 public int countByC_C_C(long companyId, long classNameId, long classPK)
4718 throws SystemException {
4719 Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
4720
4721 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_C,
4722 finderArgs, this);
4723
4724 if (count == null) {
4725 StringBundler query = new StringBundler(4);
4726
4727 query.append(_SQL_COUNT_ROLE_WHERE);
4728
4729 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
4730
4731 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
4732
4733 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
4734
4735 String sql = query.toString();
4736
4737 Session session = null;
4738
4739 try {
4740 session = openSession();
4741
4742 Query q = session.createQuery(sql);
4743
4744 QueryPos qPos = QueryPos.getInstance(q);
4745
4746 qPos.add(companyId);
4747
4748 qPos.add(classNameId);
4749
4750 qPos.add(classPK);
4751
4752 count = (Long)q.uniqueResult();
4753 }
4754 catch (Exception e) {
4755 throw processException(e);
4756 }
4757 finally {
4758 if (count == null) {
4759 count = Long.valueOf(0);
4760 }
4761
4762 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C,
4763 finderArgs, count);
4764
4765 closeSession(session);
4766 }
4767 }
4768
4769 return count.intValue();
4770 }
4771
4772
4778 public int countAll() throws SystemException {
4779 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4780 FINDER_ARGS_EMPTY, this);
4781
4782 if (count == null) {
4783 Session session = null;
4784
4785 try {
4786 session = openSession();
4787
4788 Query q = session.createQuery(_SQL_COUNT_ROLE);
4789
4790 count = (Long)q.uniqueResult();
4791 }
4792 catch (Exception e) {
4793 throw processException(e);
4794 }
4795 finally {
4796 if (count == null) {
4797 count = Long.valueOf(0);
4798 }
4799
4800 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
4801 FINDER_ARGS_EMPTY, count);
4802
4803 closeSession(session);
4804 }
4805 }
4806
4807 return count.intValue();
4808 }
4809
4810
4817 public List<com.liferay.portal.model.Group> getGroups(long pk)
4818 throws SystemException {
4819 return getGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
4820 }
4821
4822
4835 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
4836 int end) throws SystemException {
4837 return getGroups(pk, start, end, null);
4838 }
4839
4840 public static final FinderPath FINDER_PATH_GET_GROUPS = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
4841 RoleModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES,
4842 com.liferay.portal.model.impl.GroupImpl.class,
4843 RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "getGroups",
4844 new String[] {
4845 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
4846 "com.liferay.portal.kernel.util.OrderByComparator"
4847 });
4848
4849 static {
4850 FINDER_PATH_GET_GROUPS.setCacheKeyGeneratorCacheName(null);
4851 }
4852
4853
4867 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
4868 int end, OrderByComparator orderByComparator) throws SystemException {
4869 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
4870
4871 List<com.liferay.portal.model.Group> list = (List<com.liferay.portal.model.Group>)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS,
4872 finderArgs, this);
4873
4874 if (list == null) {
4875 Session session = null;
4876
4877 try {
4878 session = openSession();
4879
4880 String sql = null;
4881
4882 if (orderByComparator != null) {
4883 sql = _SQL_GETGROUPS.concat(ORDER_BY_CLAUSE)
4884 .concat(orderByComparator.getOrderBy());
4885 }
4886 else {
4887 sql = _SQL_GETGROUPS.concat(com.liferay.portal.model.impl.GroupModelImpl.ORDER_BY_SQL);
4888 }
4889
4890 SQLQuery q = session.createSQLQuery(sql);
4891
4892 q.addEntity("Group_",
4893 com.liferay.portal.model.impl.GroupImpl.class);
4894
4895 QueryPos qPos = QueryPos.getInstance(q);
4896
4897 qPos.add(pk);
4898
4899 list = (List<com.liferay.portal.model.Group>)QueryUtil.list(q,
4900 getDialect(), start, end);
4901 }
4902 catch (Exception e) {
4903 throw processException(e);
4904 }
4905 finally {
4906 if (list == null) {
4907 FinderCacheUtil.removeResult(FINDER_PATH_GET_GROUPS,
4908 finderArgs);
4909 }
4910 else {
4911 groupPersistence.cacheResult(list);
4912
4913 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS,
4914 finderArgs, list);
4915 }
4916
4917 closeSession(session);
4918 }
4919 }
4920
4921 return list;
4922 }
4923
4924 public static final FinderPath FINDER_PATH_GET_GROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
4925 RoleModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES, Long.class,
4926 RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "getGroupsSize",
4927 new String[] { Long.class.getName() });
4928
4929 static {
4930 FINDER_PATH_GET_GROUPS_SIZE.setCacheKeyGeneratorCacheName(null);
4931 }
4932
4933
4940 public int getGroupsSize(long pk) throws SystemException {
4941 Object[] finderArgs = new Object[] { pk };
4942
4943 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS_SIZE,
4944 finderArgs, this);
4945
4946 if (count == null) {
4947 Session session = null;
4948
4949 try {
4950 session = openSession();
4951
4952 SQLQuery q = session.createSQLQuery(_SQL_GETGROUPSSIZE);
4953
4954 q.addScalar(COUNT_COLUMN_NAME,
4955 com.liferay.portal.kernel.dao.orm.Type.LONG);
4956
4957 QueryPos qPos = QueryPos.getInstance(q);
4958
4959 qPos.add(pk);
4960
4961 count = (Long)q.uniqueResult();
4962 }
4963 catch (Exception e) {
4964 throw processException(e);
4965 }
4966 finally {
4967 if (count == null) {
4968 count = Long.valueOf(0);
4969 }
4970
4971 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS_SIZE,
4972 finderArgs, count);
4973
4974 closeSession(session);
4975 }
4976 }
4977
4978 return count.intValue();
4979 }
4980
4981 public static final FinderPath FINDER_PATH_CONTAINS_GROUP = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
4982 RoleModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES, Boolean.class,
4983 RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "containsGroup",
4984 new String[] { Long.class.getName(), Long.class.getName() });
4985
4986
4994 public boolean containsGroup(long pk, long groupPK)
4995 throws SystemException {
4996 Object[] finderArgs = new Object[] { pk, groupPK };
4997
4998 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_GROUP,
4999 finderArgs, this);
5000
5001 if (value == null) {
5002 try {
5003 value = Boolean.valueOf(containsGroup.contains(pk, groupPK));
5004 }
5005 catch (Exception e) {
5006 throw processException(e);
5007 }
5008 finally {
5009 if (value == null) {
5010 value = Boolean.FALSE;
5011 }
5012
5013 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_GROUP,
5014 finderArgs, value);
5015 }
5016 }
5017
5018 return value.booleanValue();
5019 }
5020
5021
5028 public boolean containsGroups(long pk) throws SystemException {
5029 if (getGroupsSize(pk) > 0) {
5030 return true;
5031 }
5032 else {
5033 return false;
5034 }
5035 }
5036
5037
5044 public void addGroup(long pk, long groupPK) throws SystemException {
5045 try {
5046 addGroup.add(pk, groupPK);
5047 }
5048 catch (Exception e) {
5049 throw processException(e);
5050 }
5051 finally {
5052 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5053 }
5054 }
5055
5056
5063 public void addGroup(long pk, com.liferay.portal.model.Group group)
5064 throws SystemException {
5065 try {
5066 addGroup.add(pk, group.getPrimaryKey());
5067 }
5068 catch (Exception e) {
5069 throw processException(e);
5070 }
5071 finally {
5072 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5073 }
5074 }
5075
5076
5083 public void addGroups(long pk, long[] groupPKs) throws SystemException {
5084 try {
5085 for (long groupPK : groupPKs) {
5086 addGroup.add(pk, groupPK);
5087 }
5088 }
5089 catch (Exception e) {
5090 throw processException(e);
5091 }
5092 finally {
5093 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5094 }
5095 }
5096
5097
5104 public void addGroups(long pk, List<com.liferay.portal.model.Group> groups)
5105 throws SystemException {
5106 try {
5107 for (com.liferay.portal.model.Group group : groups) {
5108 addGroup.add(pk, group.getPrimaryKey());
5109 }
5110 }
5111 catch (Exception e) {
5112 throw processException(e);
5113 }
5114 finally {
5115 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5116 }
5117 }
5118
5119
5125 public void clearGroups(long pk) throws SystemException {
5126 try {
5127 clearGroups.clear(pk);
5128 }
5129 catch (Exception e) {
5130 throw processException(e);
5131 }
5132 finally {
5133 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5134 }
5135 }
5136
5137
5144 public void removeGroup(long pk, long groupPK) throws SystemException {
5145 try {
5146 removeGroup.remove(pk, groupPK);
5147 }
5148 catch (Exception e) {
5149 throw processException(e);
5150 }
5151 finally {
5152 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5153 }
5154 }
5155
5156
5163 public void removeGroup(long pk, com.liferay.portal.model.Group group)
5164 throws SystemException {
5165 try {
5166 removeGroup.remove(pk, group.getPrimaryKey());
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 void removeGroups(long pk, long[] groupPKs)
5184 throws SystemException {
5185 try {
5186 for (long groupPK : groupPKs) {
5187 removeGroup.remove(pk, groupPK);
5188 }
5189 }
5190 catch (Exception e) {
5191 throw processException(e);
5192 }
5193 finally {
5194 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5195 }
5196 }
5197
5198
5205 public void removeGroups(long pk,
5206 List<com.liferay.portal.model.Group> groups) throws SystemException {
5207 try {
5208 for (com.liferay.portal.model.Group group : groups) {
5209 removeGroup.remove(pk, group.getPrimaryKey());
5210 }
5211 }
5212 catch (Exception e) {
5213 throw processException(e);
5214 }
5215 finally {
5216 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5217 }
5218 }
5219
5220
5227 public void setGroups(long pk, long[] groupPKs) throws SystemException {
5228 try {
5229 Set<Long> groupPKSet = SetUtil.fromArray(groupPKs);
5230
5231 List<com.liferay.portal.model.Group> groups = getGroups(pk);
5232
5233 for (com.liferay.portal.model.Group group : groups) {
5234 if (!groupPKSet.remove(group.getPrimaryKey())) {
5235 removeGroup.remove(pk, group.getPrimaryKey());
5236 }
5237 }
5238
5239 for (Long groupPK : groupPKSet) {
5240 addGroup.add(pk, groupPK);
5241 }
5242 }
5243 catch (Exception e) {
5244 throw processException(e);
5245 }
5246 finally {
5247 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5248 }
5249 }
5250
5251
5258 public void setGroups(long pk, List<com.liferay.portal.model.Group> groups)
5259 throws SystemException {
5260 try {
5261 long[] groupPKs = new long[groups.size()];
5262
5263 for (int i = 0; i < groups.size(); i++) {
5264 com.liferay.portal.model.Group group = groups.get(i);
5265
5266 groupPKs[i] = group.getPrimaryKey();
5267 }
5268
5269 setGroups(pk, groupPKs);
5270 }
5271 catch (Exception e) {
5272 throw processException(e);
5273 }
5274 finally {
5275 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5276 }
5277 }
5278
5279
5286 public List<com.liferay.portal.model.Permission> getPermissions(long pk)
5287 throws SystemException {
5288 return getPermissions(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
5289 }
5290
5291
5304 public List<com.liferay.portal.model.Permission> getPermissions(long pk,
5305 int start, int end) throws SystemException {
5306 return getPermissions(pk, start, end, null);
5307 }
5308
5309 public static final FinderPath FINDER_PATH_GET_PERMISSIONS = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
5310 RoleModelImpl.FINDER_CACHE_ENABLED_ROLES_PERMISSIONS,
5311 com.liferay.portal.model.impl.PermissionImpl.class,
5312 RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME,
5313 "getPermissions",
5314 new String[] {
5315 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
5316 "com.liferay.portal.kernel.util.OrderByComparator"
5317 });
5318
5319 static {
5320 FINDER_PATH_GET_PERMISSIONS.setCacheKeyGeneratorCacheName(null);
5321 }
5322
5323
5337 public List<com.liferay.portal.model.Permission> getPermissions(long pk,
5338 int start, int end, OrderByComparator orderByComparator)
5339 throws SystemException {
5340 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
5341
5342 List<com.liferay.portal.model.Permission> list = (List<com.liferay.portal.model.Permission>)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS,
5343 finderArgs, this);
5344
5345 if (list == null) {
5346 Session session = null;
5347
5348 try {
5349 session = openSession();
5350
5351 String sql = null;
5352
5353 if (orderByComparator != null) {
5354 sql = _SQL_GETPERMISSIONS.concat(ORDER_BY_CLAUSE)
5355 .concat(orderByComparator.getOrderBy());
5356 }
5357 else {
5358 sql = _SQL_GETPERMISSIONS;
5359 }
5360
5361 SQLQuery q = session.createSQLQuery(sql);
5362
5363 q.addEntity("Permission_",
5364 com.liferay.portal.model.impl.PermissionImpl.class);
5365
5366 QueryPos qPos = QueryPos.getInstance(q);
5367
5368 qPos.add(pk);
5369
5370 list = (List<com.liferay.portal.model.Permission>)QueryUtil.list(q,
5371 getDialect(), start, end);
5372 }
5373 catch (Exception e) {
5374 throw processException(e);
5375 }
5376 finally {
5377 if (list == null) {
5378 FinderCacheUtil.removeResult(FINDER_PATH_GET_PERMISSIONS,
5379 finderArgs);
5380 }
5381 else {
5382 permissionPersistence.cacheResult(list);
5383
5384 FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS,
5385 finderArgs, list);
5386 }
5387
5388 closeSession(session);
5389 }
5390 }
5391
5392 return list;
5393 }
5394
5395 public static final FinderPath FINDER_PATH_GET_PERMISSIONS_SIZE = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
5396 RoleModelImpl.FINDER_CACHE_ENABLED_ROLES_PERMISSIONS, Long.class,
5397 RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME,
5398 "getPermissionsSize", new String[] { Long.class.getName() });
5399
5400 static {
5401 FINDER_PATH_GET_PERMISSIONS_SIZE.setCacheKeyGeneratorCacheName(null);
5402 }
5403
5404
5411 public int getPermissionsSize(long pk) throws SystemException {
5412 Object[] finderArgs = new Object[] { pk };
5413
5414 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
5415 finderArgs, this);
5416
5417 if (count == null) {
5418 Session session = null;
5419
5420 try {
5421 session = openSession();
5422
5423 SQLQuery q = session.createSQLQuery(_SQL_GETPERMISSIONSSIZE);
5424
5425 q.addScalar(COUNT_COLUMN_NAME,
5426 com.liferay.portal.kernel.dao.orm.Type.LONG);
5427
5428 QueryPos qPos = QueryPos.getInstance(q);
5429
5430 qPos.add(pk);
5431
5432 count = (Long)q.uniqueResult();
5433 }
5434 catch (Exception e) {
5435 throw processException(e);
5436 }
5437 finally {
5438 if (count == null) {
5439 count = Long.valueOf(0);
5440 }
5441
5442 FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
5443 finderArgs, count);
5444
5445 closeSession(session);
5446 }
5447 }
5448
5449 return count.intValue();
5450 }
5451
5452 public static final FinderPath FINDER_PATH_CONTAINS_PERMISSION = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
5453 RoleModelImpl.FINDER_CACHE_ENABLED_ROLES_PERMISSIONS,
5454 Boolean.class, RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME,
5455 "containsPermission",
5456 new String[] { Long.class.getName(), Long.class.getName() });
5457
5458
5466 public boolean containsPermission(long pk, long permissionPK)
5467 throws SystemException {
5468 Object[] finderArgs = new Object[] { pk, permissionPK };
5469
5470 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_PERMISSION,
5471 finderArgs, this);
5472
5473 if (value == null) {
5474 try {
5475 value = Boolean.valueOf(containsPermission.contains(pk,
5476 permissionPK));
5477 }
5478 catch (Exception e) {
5479 throw processException(e);
5480 }
5481 finally {
5482 if (value == null) {
5483 value = Boolean.FALSE;
5484 }
5485
5486 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_PERMISSION,
5487 finderArgs, value);
5488 }
5489 }
5490
5491 return value.booleanValue();
5492 }
5493
5494
5501 public boolean containsPermissions(long pk) throws SystemException {
5502 if (getPermissionsSize(pk) > 0) {
5503 return true;
5504 }
5505 else {
5506 return false;
5507 }
5508 }
5509
5510
5517 public void addPermission(long pk, long permissionPK)
5518 throws SystemException {
5519 try {
5520 addPermission.add(pk, permissionPK);
5521 }
5522 catch (Exception e) {
5523 throw processException(e);
5524 }
5525 finally {
5526 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5527 }
5528 }
5529
5530
5537 public void addPermission(long pk,
5538 com.liferay.portal.model.Permission permission)
5539 throws SystemException {
5540 try {
5541 addPermission.add(pk, permission.getPrimaryKey());
5542 }
5543 catch (Exception e) {
5544 throw processException(e);
5545 }
5546 finally {
5547 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5548 }
5549 }
5550
5551
5558 public void addPermissions(long pk, long[] permissionPKs)
5559 throws SystemException {
5560 try {
5561 for (long permissionPK : permissionPKs) {
5562 addPermission.add(pk, permissionPK);
5563 }
5564 }
5565 catch (Exception e) {
5566 throw processException(e);
5567 }
5568 finally {
5569 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5570 }
5571 }
5572
5573
5580 public void addPermissions(long pk,
5581 List<com.liferay.portal.model.Permission> permissions)
5582 throws SystemException {
5583 try {
5584 for (com.liferay.portal.model.Permission permission : permissions) {
5585 addPermission.add(pk, permission.getPrimaryKey());
5586 }
5587 }
5588 catch (Exception e) {
5589 throw processException(e);
5590 }
5591 finally {
5592 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5593 }
5594 }
5595
5596
5602 public void clearPermissions(long pk) throws SystemException {
5603 try {
5604 clearPermissions.clear(pk);
5605 }
5606 catch (Exception e) {
5607 throw processException(e);
5608 }
5609 finally {
5610 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5611 }
5612 }
5613
5614
5621 public void removePermission(long pk, long permissionPK)
5622 throws SystemException {
5623 try {
5624 removePermission.remove(pk, permissionPK);
5625 }
5626 catch (Exception e) {
5627 throw processException(e);
5628 }
5629 finally {
5630 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5631 }
5632 }
5633
5634
5641 public void removePermission(long pk,
5642 com.liferay.portal.model.Permission permission)
5643 throws SystemException {
5644 try {
5645 removePermission.remove(pk, permission.getPrimaryKey());
5646 }
5647 catch (Exception e) {
5648 throw processException(e);
5649 }
5650 finally {
5651 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5652 }
5653 }
5654
5655
5662 public void removePermissions(long pk, long[] permissionPKs)
5663 throws SystemException {
5664 try {
5665 for (long permissionPK : permissionPKs) {
5666 removePermission.remove(pk, permissionPK);
5667 }
5668 }
5669 catch (Exception e) {
5670 throw processException(e);
5671 }
5672 finally {
5673 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5674 }
5675 }
5676
5677
5684 public void removePermissions(long pk,
5685 List<com.liferay.portal.model.Permission> permissions)
5686 throws SystemException {
5687 try {
5688 for (com.liferay.portal.model.Permission permission : permissions) {
5689 removePermission.remove(pk, permission.getPrimaryKey());
5690 }
5691 }
5692 catch (Exception e) {
5693 throw processException(e);
5694 }
5695 finally {
5696 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5697 }
5698 }
5699
5700
5707 public void setPermissions(long pk, long[] permissionPKs)
5708 throws SystemException {
5709 try {
5710 Set<Long> permissionPKSet = SetUtil.fromArray(permissionPKs);
5711
5712 List<com.liferay.portal.model.Permission> permissions = getPermissions(pk);
5713
5714 for (com.liferay.portal.model.Permission permission : permissions) {
5715 if (!permissionPKSet.remove(permission.getPrimaryKey())) {
5716 removePermission.remove(pk, permission.getPrimaryKey());
5717 }
5718 }
5719
5720 for (Long permissionPK : permissionPKSet) {
5721 addPermission.add(pk, permissionPK);
5722 }
5723 }
5724 catch (Exception e) {
5725 throw processException(e);
5726 }
5727 finally {
5728 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5729 }
5730 }
5731
5732
5739 public void setPermissions(long pk,
5740 List<com.liferay.portal.model.Permission> permissions)
5741 throws SystemException {
5742 try {
5743 long[] permissionPKs = new long[permissions.size()];
5744
5745 for (int i = 0; i < permissions.size(); i++) {
5746 com.liferay.portal.model.Permission permission = permissions.get(i);
5747
5748 permissionPKs[i] = permission.getPrimaryKey();
5749 }
5750
5751 setPermissions(pk, permissionPKs);
5752 }
5753 catch (Exception e) {
5754 throw processException(e);
5755 }
5756 finally {
5757 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5758 }
5759 }
5760
5761
5768 public List<com.liferay.portal.model.User> getUsers(long pk)
5769 throws SystemException {
5770 return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
5771 }
5772
5773
5786 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
5787 int end) throws SystemException {
5788 return getUsers(pk, start, end, null);
5789 }
5790
5791 public static final FinderPath FINDER_PATH_GET_USERS = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
5792 RoleModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES,
5793 com.liferay.portal.model.impl.UserImpl.class,
5794 RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "getUsers",
5795 new String[] {
5796 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
5797 "com.liferay.portal.kernel.util.OrderByComparator"
5798 });
5799
5800 static {
5801 FINDER_PATH_GET_USERS.setCacheKeyGeneratorCacheName(null);
5802 }
5803
5804
5818 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
5819 int end, OrderByComparator orderByComparator) throws SystemException {
5820 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
5821
5822 List<com.liferay.portal.model.User> list = (List<com.liferay.portal.model.User>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS,
5823 finderArgs, this);
5824
5825 if (list == null) {
5826 Session session = null;
5827
5828 try {
5829 session = openSession();
5830
5831 String sql = null;
5832
5833 if (orderByComparator != null) {
5834 sql = _SQL_GETUSERS.concat(ORDER_BY_CLAUSE)
5835 .concat(orderByComparator.getOrderBy());
5836 }
5837 else {
5838 sql = _SQL_GETUSERS;
5839 }
5840
5841 SQLQuery q = session.createSQLQuery(sql);
5842
5843 q.addEntity("User_",
5844 com.liferay.portal.model.impl.UserImpl.class);
5845
5846 QueryPos qPos = QueryPos.getInstance(q);
5847
5848 qPos.add(pk);
5849
5850 list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
5851 getDialect(), start, end);
5852 }
5853 catch (Exception e) {
5854 throw processException(e);
5855 }
5856 finally {
5857 if (list == null) {
5858 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERS,
5859 finderArgs);
5860 }
5861 else {
5862 userPersistence.cacheResult(list);
5863
5864 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS,
5865 finderArgs, list);
5866 }
5867
5868 closeSession(session);
5869 }
5870 }
5871
5872 return list;
5873 }
5874
5875 public static final FinderPath FINDER_PATH_GET_USERS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
5876 RoleModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES, Long.class,
5877 RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "getUsersSize",
5878 new String[] { Long.class.getName() });
5879
5880 static {
5881 FINDER_PATH_GET_USERS_SIZE.setCacheKeyGeneratorCacheName(null);
5882 }
5883
5884
5891 public int getUsersSize(long pk) throws SystemException {
5892 Object[] finderArgs = new Object[] { pk };
5893
5894 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS_SIZE,
5895 finderArgs, this);
5896
5897 if (count == null) {
5898 Session session = null;
5899
5900 try {
5901 session = openSession();
5902
5903 SQLQuery q = session.createSQLQuery(_SQL_GETUSERSSIZE);
5904
5905 q.addScalar(COUNT_COLUMN_NAME,
5906 com.liferay.portal.kernel.dao.orm.Type.LONG);
5907
5908 QueryPos qPos = QueryPos.getInstance(q);
5909
5910 qPos.add(pk);
5911
5912 count = (Long)q.uniqueResult();
5913 }
5914 catch (Exception e) {
5915 throw processException(e);
5916 }
5917 finally {
5918 if (count == null) {
5919 count = Long.valueOf(0);
5920 }
5921
5922 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS_SIZE,
5923 finderArgs, count);
5924
5925 closeSession(session);
5926 }
5927 }
5928
5929 return count.intValue();
5930 }
5931
5932 public static final FinderPath FINDER_PATH_CONTAINS_USER = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
5933 RoleModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES, Boolean.class,
5934 RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "containsUser",
5935 new String[] { Long.class.getName(), Long.class.getName() });
5936
5937
5945 public boolean containsUser(long pk, long userPK) throws SystemException {
5946 Object[] finderArgs = new Object[] { pk, userPK };
5947
5948 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USER,
5949 finderArgs, this);
5950
5951 if (value == null) {
5952 try {
5953 value = Boolean.valueOf(containsUser.contains(pk, userPK));
5954 }
5955 catch (Exception e) {
5956 throw processException(e);
5957 }
5958 finally {
5959 if (value == null) {
5960 value = Boolean.FALSE;
5961 }
5962
5963 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USER,
5964 finderArgs, value);
5965 }
5966 }
5967
5968 return value.booleanValue();
5969 }
5970
5971
5978 public boolean containsUsers(long pk) throws SystemException {
5979 if (getUsersSize(pk) > 0) {
5980 return true;
5981 }
5982 else {
5983 return false;
5984 }
5985 }
5986
5987
5994 public void addUser(long pk, long userPK) throws SystemException {
5995 try {
5996 addUser.add(pk, userPK);
5997 }
5998 catch (Exception e) {
5999 throw processException(e);
6000 }
6001 finally {
6002 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6003 }
6004 }
6005
6006
6013 public void addUser(long pk, com.liferay.portal.model.User user)
6014 throws SystemException {
6015 try {
6016 addUser.add(pk, user.getPrimaryKey());
6017 }
6018 catch (Exception e) {
6019 throw processException(e);
6020 }
6021 finally {
6022 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6023 }
6024 }
6025
6026
6033 public void addUsers(long pk, long[] userPKs) throws SystemException {
6034 try {
6035 for (long userPK : userPKs) {
6036 addUser.add(pk, userPK);
6037 }
6038 }
6039 catch (Exception e) {
6040 throw processException(e);
6041 }
6042 finally {
6043 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6044 }
6045 }
6046
6047
6054 public void addUsers(long pk, List<com.liferay.portal.model.User> users)
6055 throws SystemException {
6056 try {
6057 for (com.liferay.portal.model.User user : users) {
6058 addUser.add(pk, user.getPrimaryKey());
6059 }
6060 }
6061 catch (Exception e) {
6062 throw processException(e);
6063 }
6064 finally {
6065 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6066 }
6067 }
6068
6069
6075 public void clearUsers(long pk) throws SystemException {
6076 try {
6077 clearUsers.clear(pk);
6078 }
6079 catch (Exception e) {
6080 throw processException(e);
6081 }
6082 finally {
6083 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6084 }
6085 }
6086
6087
6094 public void removeUser(long pk, long userPK) throws SystemException {
6095 try {
6096 removeUser.remove(pk, userPK);
6097 }
6098 catch (Exception e) {
6099 throw processException(e);
6100 }
6101 finally {
6102 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6103 }
6104 }
6105
6106
6113 public void removeUser(long pk, com.liferay.portal.model.User user)
6114 throws SystemException {
6115 try {
6116 removeUser.remove(pk, user.getPrimaryKey());
6117 }
6118 catch (Exception e) {
6119 throw processException(e);
6120 }
6121 finally {
6122 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6123 }
6124 }
6125
6126
6133 public void removeUsers(long pk, long[] userPKs) throws SystemException {
6134 try {
6135 for (long userPK : userPKs) {
6136 removeUser.remove(pk, userPK);
6137 }
6138 }
6139 catch (Exception e) {
6140 throw processException(e);
6141 }
6142 finally {
6143 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6144 }
6145 }
6146
6147
6154 public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
6155 throws SystemException {
6156 try {
6157 for (com.liferay.portal.model.User user : users) {
6158 removeUser.remove(pk, user.getPrimaryKey());
6159 }
6160 }
6161 catch (Exception e) {
6162 throw processException(e);
6163 }
6164 finally {
6165 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6166 }
6167 }
6168
6169
6176 public void setUsers(long pk, long[] userPKs) throws SystemException {
6177 try {
6178 Set<Long> userPKSet = SetUtil.fromArray(userPKs);
6179
6180 List<com.liferay.portal.model.User> users = getUsers(pk);
6181
6182 for (com.liferay.portal.model.User user : users) {
6183 if (!userPKSet.remove(user.getPrimaryKey())) {
6184 removeUser.remove(pk, user.getPrimaryKey());
6185 }
6186 }
6187
6188 for (Long userPK : userPKSet) {
6189 addUser.add(pk, userPK);
6190 }
6191 }
6192 catch (Exception e) {
6193 throw processException(e);
6194 }
6195 finally {
6196 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6197 }
6198 }
6199
6200
6207 public void setUsers(long pk, List<com.liferay.portal.model.User> users)
6208 throws SystemException {
6209 try {
6210 long[] userPKs = new long[users.size()];
6211
6212 for (int i = 0; i < users.size(); i++) {
6213 com.liferay.portal.model.User user = users.get(i);
6214
6215 userPKs[i] = user.getPrimaryKey();
6216 }
6217
6218 setUsers(pk, userPKs);
6219 }
6220 catch (Exception e) {
6221 throw processException(e);
6222 }
6223 finally {
6224 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6225 }
6226 }
6227
6228
6231 public void afterPropertiesSet() {
6232 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
6233 com.liferay.portal.util.PropsUtil.get(
6234 "value.object.listener.com.liferay.portal.model.Role")));
6235
6236 if (listenerClassNames.length > 0) {
6237 try {
6238 List<ModelListener<Role>> listenersList = new ArrayList<ModelListener<Role>>();
6239
6240 for (String listenerClassName : listenerClassNames) {
6241 listenersList.add((ModelListener<Role>)InstanceFactory.newInstance(
6242 listenerClassName));
6243 }
6244
6245 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
6246 }
6247 catch (Exception e) {
6248 _log.error(e);
6249 }
6250 }
6251
6252 containsGroup = new ContainsGroup();
6253
6254 addGroup = new AddGroup();
6255 clearGroups = new ClearGroups();
6256 removeGroup = new RemoveGroup();
6257
6258 containsPermission = new ContainsPermission();
6259
6260 addPermission = new AddPermission();
6261 clearPermissions = new ClearPermissions();
6262 removePermission = new RemovePermission();
6263
6264 containsUser = new ContainsUser();
6265
6266 addUser = new AddUser();
6267 clearUsers = new ClearUsers();
6268 removeUser = new RemoveUser();
6269 }
6270
6271 public void destroy() {
6272 EntityCacheUtil.removeCache(RoleImpl.class.getName());
6273 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
6274 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6275 }
6276
6277 @BeanReference(type = AccountPersistence.class)
6278 protected AccountPersistence accountPersistence;
6279 @BeanReference(type = AddressPersistence.class)
6280 protected AddressPersistence addressPersistence;
6281 @BeanReference(type = BrowserTrackerPersistence.class)
6282 protected BrowserTrackerPersistence browserTrackerPersistence;
6283 @BeanReference(type = ClassNamePersistence.class)
6284 protected ClassNamePersistence classNamePersistence;
6285 @BeanReference(type = ClusterGroupPersistence.class)
6286 protected ClusterGroupPersistence clusterGroupPersistence;
6287 @BeanReference(type = CompanyPersistence.class)
6288 protected CompanyPersistence companyPersistence;
6289 @BeanReference(type = ContactPersistence.class)
6290 protected ContactPersistence contactPersistence;
6291 @BeanReference(type = CountryPersistence.class)
6292 protected CountryPersistence countryPersistence;
6293 @BeanReference(type = EmailAddressPersistence.class)
6294 protected EmailAddressPersistence emailAddressPersistence;
6295 @BeanReference(type = GroupPersistence.class)
6296 protected GroupPersistence groupPersistence;
6297 @BeanReference(type = ImagePersistence.class)
6298 protected ImagePersistence imagePersistence;
6299 @BeanReference(type = LayoutPersistence.class)
6300 protected LayoutPersistence layoutPersistence;
6301 @BeanReference(type = LayoutBranchPersistence.class)
6302 protected LayoutBranchPersistence layoutBranchPersistence;
6303 @BeanReference(type = LayoutPrototypePersistence.class)
6304 protected LayoutPrototypePersistence layoutPrototypePersistence;
6305 @BeanReference(type = LayoutRevisionPersistence.class)
6306 protected LayoutRevisionPersistence layoutRevisionPersistence;
6307 @BeanReference(type = LayoutSetPersistence.class)
6308 protected LayoutSetPersistence layoutSetPersistence;
6309 @BeanReference(type = LayoutSetBranchPersistence.class)
6310 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
6311 @BeanReference(type = LayoutSetPrototypePersistence.class)
6312 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
6313 @BeanReference(type = ListTypePersistence.class)
6314 protected ListTypePersistence listTypePersistence;
6315 @BeanReference(type = LockPersistence.class)
6316 protected LockPersistence lockPersistence;
6317 @BeanReference(type = MembershipRequestPersistence.class)
6318 protected MembershipRequestPersistence membershipRequestPersistence;
6319 @BeanReference(type = OrganizationPersistence.class)
6320 protected OrganizationPersistence organizationPersistence;
6321 @BeanReference(type = OrgGroupPermissionPersistence.class)
6322 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
6323 @BeanReference(type = OrgGroupRolePersistence.class)
6324 protected OrgGroupRolePersistence orgGroupRolePersistence;
6325 @BeanReference(type = OrgLaborPersistence.class)
6326 protected OrgLaborPersistence orgLaborPersistence;
6327 @BeanReference(type = PasswordPolicyPersistence.class)
6328 protected PasswordPolicyPersistence passwordPolicyPersistence;
6329 @BeanReference(type = PasswordPolicyRelPersistence.class)
6330 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
6331 @BeanReference(type = PasswordTrackerPersistence.class)
6332 protected PasswordTrackerPersistence passwordTrackerPersistence;
6333 @BeanReference(type = PermissionPersistence.class)
6334 protected PermissionPersistence permissionPersistence;
6335 @BeanReference(type = PhonePersistence.class)
6336 protected PhonePersistence phonePersistence;
6337 @BeanReference(type = PluginSettingPersistence.class)
6338 protected PluginSettingPersistence pluginSettingPersistence;
6339 @BeanReference(type = PortalPreferencesPersistence.class)
6340 protected PortalPreferencesPersistence portalPreferencesPersistence;
6341 @BeanReference(type = PortletPersistence.class)
6342 protected PortletPersistence portletPersistence;
6343 @BeanReference(type = PortletItemPersistence.class)
6344 protected PortletItemPersistence portletItemPersistence;
6345 @BeanReference(type = PortletPreferencesPersistence.class)
6346 protected PortletPreferencesPersistence portletPreferencesPersistence;
6347 @BeanReference(type = RegionPersistence.class)
6348 protected RegionPersistence regionPersistence;
6349 @BeanReference(type = ReleasePersistence.class)
6350 protected ReleasePersistence releasePersistence;
6351 @BeanReference(type = RepositoryPersistence.class)
6352 protected RepositoryPersistence repositoryPersistence;
6353 @BeanReference(type = RepositoryEntryPersistence.class)
6354 protected RepositoryEntryPersistence repositoryEntryPersistence;
6355 @BeanReference(type = ResourcePersistence.class)
6356 protected ResourcePersistence resourcePersistence;
6357 @BeanReference(type = ResourceActionPersistence.class)
6358 protected ResourceActionPersistence resourceActionPersistence;
6359 @BeanReference(type = ResourceBlockPersistence.class)
6360 protected ResourceBlockPersistence resourceBlockPersistence;
6361 @BeanReference(type = ResourceBlockPermissionPersistence.class)
6362 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
6363 @BeanReference(type = ResourceCodePersistence.class)
6364 protected ResourceCodePersistence resourceCodePersistence;
6365 @BeanReference(type = ResourcePermissionPersistence.class)
6366 protected ResourcePermissionPersistence resourcePermissionPersistence;
6367 @BeanReference(type = ResourceTypePermissionPersistence.class)
6368 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
6369 @BeanReference(type = RolePersistence.class)
6370 protected RolePersistence rolePersistence;
6371 @BeanReference(type = ServiceComponentPersistence.class)
6372 protected ServiceComponentPersistence serviceComponentPersistence;
6373 @BeanReference(type = ShardPersistence.class)
6374 protected ShardPersistence shardPersistence;
6375 @BeanReference(type = SubscriptionPersistence.class)
6376 protected SubscriptionPersistence subscriptionPersistence;
6377 @BeanReference(type = TeamPersistence.class)
6378 protected TeamPersistence teamPersistence;
6379 @BeanReference(type = TicketPersistence.class)
6380 protected TicketPersistence ticketPersistence;
6381 @BeanReference(type = UserPersistence.class)
6382 protected UserPersistence userPersistence;
6383 @BeanReference(type = UserGroupPersistence.class)
6384 protected UserGroupPersistence userGroupPersistence;
6385 @BeanReference(type = UserGroupGroupRolePersistence.class)
6386 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
6387 @BeanReference(type = UserGroupRolePersistence.class)
6388 protected UserGroupRolePersistence userGroupRolePersistence;
6389 @BeanReference(type = UserIdMapperPersistence.class)
6390 protected UserIdMapperPersistence userIdMapperPersistence;
6391 @BeanReference(type = UserNotificationEventPersistence.class)
6392 protected UserNotificationEventPersistence userNotificationEventPersistence;
6393 @BeanReference(type = UserTrackerPersistence.class)
6394 protected UserTrackerPersistence userTrackerPersistence;
6395 @BeanReference(type = UserTrackerPathPersistence.class)
6396 protected UserTrackerPathPersistence userTrackerPathPersistence;
6397 @BeanReference(type = VirtualHostPersistence.class)
6398 protected VirtualHostPersistence virtualHostPersistence;
6399 @BeanReference(type = WebDAVPropsPersistence.class)
6400 protected WebDAVPropsPersistence webDAVPropsPersistence;
6401 @BeanReference(type = WebsitePersistence.class)
6402 protected WebsitePersistence websitePersistence;
6403 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
6404 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
6405 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
6406 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
6407 protected ContainsGroup containsGroup;
6408 protected AddGroup addGroup;
6409 protected ClearGroups clearGroups;
6410 protected RemoveGroup removeGroup;
6411 protected ContainsPermission containsPermission;
6412 protected AddPermission addPermission;
6413 protected ClearPermissions clearPermissions;
6414 protected RemovePermission removePermission;
6415 protected ContainsUser containsUser;
6416 protected AddUser addUser;
6417 protected ClearUsers clearUsers;
6418 protected RemoveUser removeUser;
6419
6420 protected class ContainsGroup {
6421 protected ContainsGroup() {
6422 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6423 _SQL_CONTAINSGROUP,
6424 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6425 RowMapper.COUNT);
6426 }
6427
6428 protected boolean contains(long roleId, long groupId) {
6429 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6430 new Long(roleId), new Long(groupId)
6431 });
6432
6433 if (results.size() > 0) {
6434 Integer count = results.get(0);
6435
6436 if (count.intValue() > 0) {
6437 return true;
6438 }
6439 }
6440
6441 return false;
6442 }
6443
6444 private MappingSqlQuery<Integer> _mappingSqlQuery;
6445 }
6446
6447 protected class AddGroup {
6448 protected AddGroup() {
6449 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6450 "INSERT INTO Groups_Roles (roleId, groupId) VALUES (?, ?)",
6451 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6452 }
6453
6454 protected void add(long roleId, long groupId) throws SystemException {
6455 if (!containsGroup.contains(roleId, groupId)) {
6456 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
6457
6458 for (ModelListener<Role> listener : listeners) {
6459 listener.onBeforeAddAssociation(roleId,
6460 com.liferay.portal.model.Group.class.getName(), groupId);
6461 }
6462
6463 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
6464 listener.onBeforeAddAssociation(groupId,
6465 Role.class.getName(), roleId);
6466 }
6467
6468 _sqlUpdate.update(new Object[] {
6469 new Long(roleId), new Long(groupId)
6470 });
6471
6472 for (ModelListener<Role> listener : listeners) {
6473 listener.onAfterAddAssociation(roleId,
6474 com.liferay.portal.model.Group.class.getName(), groupId);
6475 }
6476
6477 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
6478 listener.onAfterAddAssociation(groupId,
6479 Role.class.getName(), roleId);
6480 }
6481 }
6482 }
6483
6484 private SqlUpdate _sqlUpdate;
6485 }
6486
6487 protected class ClearGroups {
6488 protected ClearGroups() {
6489 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6490 "DELETE FROM Groups_Roles WHERE roleId = ?",
6491 new int[] { java.sql.Types.BIGINT });
6492 }
6493
6494 protected void clear(long roleId) throws SystemException {
6495 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
6496
6497 List<com.liferay.portal.model.Group> groups = null;
6498
6499 if ((listeners.length > 0) || (groupListeners.length > 0)) {
6500 groups = getGroups(roleId);
6501
6502 for (com.liferay.portal.model.Group group : groups) {
6503 for (ModelListener<Role> listener : listeners) {
6504 listener.onBeforeRemoveAssociation(roleId,
6505 com.liferay.portal.model.Group.class.getName(),
6506 group.getPrimaryKey());
6507 }
6508
6509 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
6510 listener.onBeforeRemoveAssociation(group.getPrimaryKey(),
6511 Role.class.getName(), roleId);
6512 }
6513 }
6514 }
6515
6516 _sqlUpdate.update(new Object[] { new Long(roleId) });
6517
6518 if ((listeners.length > 0) || (groupListeners.length > 0)) {
6519 for (com.liferay.portal.model.Group group : groups) {
6520 for (ModelListener<Role> listener : listeners) {
6521 listener.onAfterRemoveAssociation(roleId,
6522 com.liferay.portal.model.Group.class.getName(),
6523 group.getPrimaryKey());
6524 }
6525
6526 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
6527 listener.onAfterRemoveAssociation(group.getPrimaryKey(),
6528 Role.class.getName(), roleId);
6529 }
6530 }
6531 }
6532 }
6533
6534 private SqlUpdate _sqlUpdate;
6535 }
6536
6537 protected class RemoveGroup {
6538 protected RemoveGroup() {
6539 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6540 "DELETE FROM Groups_Roles WHERE roleId = ? AND groupId = ?",
6541 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6542 }
6543
6544 protected void remove(long roleId, long groupId)
6545 throws SystemException {
6546 if (containsGroup.contains(roleId, groupId)) {
6547 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
6548
6549 for (ModelListener<Role> listener : listeners) {
6550 listener.onBeforeRemoveAssociation(roleId,
6551 com.liferay.portal.model.Group.class.getName(), groupId);
6552 }
6553
6554 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
6555 listener.onBeforeRemoveAssociation(groupId,
6556 Role.class.getName(), roleId);
6557 }
6558
6559 _sqlUpdate.update(new Object[] {
6560 new Long(roleId), new Long(groupId)
6561 });
6562
6563 for (ModelListener<Role> listener : listeners) {
6564 listener.onAfterRemoveAssociation(roleId,
6565 com.liferay.portal.model.Group.class.getName(), groupId);
6566 }
6567
6568 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
6569 listener.onAfterRemoveAssociation(groupId,
6570 Role.class.getName(), roleId);
6571 }
6572 }
6573 }
6574
6575 private SqlUpdate _sqlUpdate;
6576 }
6577
6578 protected class ContainsPermission {
6579 protected ContainsPermission() {
6580 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6581 _SQL_CONTAINSPERMISSION,
6582 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6583 RowMapper.COUNT);
6584 }
6585
6586 protected boolean contains(long roleId, long permissionId) {
6587 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6588 new Long(roleId), new Long(permissionId)
6589 });
6590
6591 if (results.size() > 0) {
6592 Integer count = results.get(0);
6593
6594 if (count.intValue() > 0) {
6595 return true;
6596 }
6597 }
6598
6599 return false;
6600 }
6601
6602 private MappingSqlQuery<Integer> _mappingSqlQuery;
6603 }
6604
6605 protected class AddPermission {
6606 protected AddPermission() {
6607 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6608 "INSERT INTO Roles_Permissions (roleId, permissionId) VALUES (?, ?)",
6609 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6610 }
6611
6612 protected void add(long roleId, long permissionId)
6613 throws SystemException {
6614 if (!containsPermission.contains(roleId, permissionId)) {
6615 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
6616 permissionPersistence.getListeners();
6617
6618 for (ModelListener<Role> listener : listeners) {
6619 listener.onBeforeAddAssociation(roleId,
6620 com.liferay.portal.model.Permission.class.getName(),
6621 permissionId);
6622 }
6623
6624 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6625 listener.onBeforeAddAssociation(permissionId,
6626 Role.class.getName(), roleId);
6627 }
6628
6629 _sqlUpdate.update(new Object[] {
6630 new Long(roleId), new Long(permissionId)
6631 });
6632
6633 for (ModelListener<Role> listener : listeners) {
6634 listener.onAfterAddAssociation(roleId,
6635 com.liferay.portal.model.Permission.class.getName(),
6636 permissionId);
6637 }
6638
6639 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6640 listener.onAfterAddAssociation(permissionId,
6641 Role.class.getName(), roleId);
6642 }
6643 }
6644 }
6645
6646 private SqlUpdate _sqlUpdate;
6647 }
6648
6649 protected class ClearPermissions {
6650 protected ClearPermissions() {
6651 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6652 "DELETE FROM Roles_Permissions WHERE roleId = ?",
6653 new int[] { java.sql.Types.BIGINT });
6654 }
6655
6656 protected void clear(long roleId) throws SystemException {
6657 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
6658 permissionPersistence.getListeners();
6659
6660 List<com.liferay.portal.model.Permission> permissions = null;
6661
6662 if ((listeners.length > 0) || (permissionListeners.length > 0)) {
6663 permissions = getPermissions(roleId);
6664
6665 for (com.liferay.portal.model.Permission permission : permissions) {
6666 for (ModelListener<Role> listener : listeners) {
6667 listener.onBeforeRemoveAssociation(roleId,
6668 com.liferay.portal.model.Permission.class.getName(),
6669 permission.getPrimaryKey());
6670 }
6671
6672 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6673 listener.onBeforeRemoveAssociation(permission.getPrimaryKey(),
6674 Role.class.getName(), roleId);
6675 }
6676 }
6677 }
6678
6679 _sqlUpdate.update(new Object[] { new Long(roleId) });
6680
6681 if ((listeners.length > 0) || (permissionListeners.length > 0)) {
6682 for (com.liferay.portal.model.Permission permission : permissions) {
6683 for (ModelListener<Role> listener : listeners) {
6684 listener.onAfterRemoveAssociation(roleId,
6685 com.liferay.portal.model.Permission.class.getName(),
6686 permission.getPrimaryKey());
6687 }
6688
6689 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6690 listener.onAfterRemoveAssociation(permission.getPrimaryKey(),
6691 Role.class.getName(), roleId);
6692 }
6693 }
6694 }
6695 }
6696
6697 private SqlUpdate _sqlUpdate;
6698 }
6699
6700 protected class RemovePermission {
6701 protected RemovePermission() {
6702 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6703 "DELETE FROM Roles_Permissions WHERE roleId = ? AND permissionId = ?",
6704 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6705 }
6706
6707 protected void remove(long roleId, long permissionId)
6708 throws SystemException {
6709 if (containsPermission.contains(roleId, permissionId)) {
6710 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
6711 permissionPersistence.getListeners();
6712
6713 for (ModelListener<Role> listener : listeners) {
6714 listener.onBeforeRemoveAssociation(roleId,
6715 com.liferay.portal.model.Permission.class.getName(),
6716 permissionId);
6717 }
6718
6719 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6720 listener.onBeforeRemoveAssociation(permissionId,
6721 Role.class.getName(), roleId);
6722 }
6723
6724 _sqlUpdate.update(new Object[] {
6725 new Long(roleId), new Long(permissionId)
6726 });
6727
6728 for (ModelListener<Role> listener : listeners) {
6729 listener.onAfterRemoveAssociation(roleId,
6730 com.liferay.portal.model.Permission.class.getName(),
6731 permissionId);
6732 }
6733
6734 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6735 listener.onAfterRemoveAssociation(permissionId,
6736 Role.class.getName(), roleId);
6737 }
6738 }
6739 }
6740
6741 private SqlUpdate _sqlUpdate;
6742 }
6743
6744 protected class ContainsUser {
6745 protected ContainsUser() {
6746 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6747 _SQL_CONTAINSUSER,
6748 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6749 RowMapper.COUNT);
6750 }
6751
6752 protected boolean contains(long roleId, long userId) {
6753 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6754 new Long(roleId), new Long(userId)
6755 });
6756
6757 if (results.size() > 0) {
6758 Integer count = results.get(0);
6759
6760 if (count.intValue() > 0) {
6761 return true;
6762 }
6763 }
6764
6765 return false;
6766 }
6767
6768 private MappingSqlQuery<Integer> _mappingSqlQuery;
6769 }
6770
6771 protected class AddUser {
6772 protected AddUser() {
6773 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6774 "INSERT INTO Users_Roles (roleId, userId) VALUES (?, ?)",
6775 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6776 }
6777
6778 protected void add(long roleId, long userId) throws SystemException {
6779 if (!containsUser.contains(roleId, userId)) {
6780 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
6781
6782 for (ModelListener<Role> listener : listeners) {
6783 listener.onBeforeAddAssociation(roleId,
6784 com.liferay.portal.model.User.class.getName(), userId);
6785 }
6786
6787 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6788 listener.onBeforeAddAssociation(userId,
6789 Role.class.getName(), roleId);
6790 }
6791
6792 _sqlUpdate.update(new Object[] {
6793 new Long(roleId), new Long(userId)
6794 });
6795
6796 for (ModelListener<Role> listener : listeners) {
6797 listener.onAfterAddAssociation(roleId,
6798 com.liferay.portal.model.User.class.getName(), userId);
6799 }
6800
6801 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6802 listener.onAfterAddAssociation(userId,
6803 Role.class.getName(), roleId);
6804 }
6805 }
6806 }
6807
6808 private SqlUpdate _sqlUpdate;
6809 }
6810
6811 protected class ClearUsers {
6812 protected ClearUsers() {
6813 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6814 "DELETE FROM Users_Roles WHERE roleId = ?",
6815 new int[] { java.sql.Types.BIGINT });
6816 }
6817
6818 protected void clear(long roleId) throws SystemException {
6819 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
6820
6821 List<com.liferay.portal.model.User> users = null;
6822
6823 if ((listeners.length > 0) || (userListeners.length > 0)) {
6824 users = getUsers(roleId);
6825
6826 for (com.liferay.portal.model.User user : users) {
6827 for (ModelListener<Role> listener : listeners) {
6828 listener.onBeforeRemoveAssociation(roleId,
6829 com.liferay.portal.model.User.class.getName(),
6830 user.getPrimaryKey());
6831 }
6832
6833 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6834 listener.onBeforeRemoveAssociation(user.getPrimaryKey(),
6835 Role.class.getName(), roleId);
6836 }
6837 }
6838 }
6839
6840 _sqlUpdate.update(new Object[] { new Long(roleId) });
6841
6842 if ((listeners.length > 0) || (userListeners.length > 0)) {
6843 for (com.liferay.portal.model.User user : users) {
6844 for (ModelListener<Role> listener : listeners) {
6845 listener.onAfterRemoveAssociation(roleId,
6846 com.liferay.portal.model.User.class.getName(),
6847 user.getPrimaryKey());
6848 }
6849
6850 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6851 listener.onAfterRemoveAssociation(user.getPrimaryKey(),
6852 Role.class.getName(), roleId);
6853 }
6854 }
6855 }
6856 }
6857
6858 private SqlUpdate _sqlUpdate;
6859 }
6860
6861 protected class RemoveUser {
6862 protected RemoveUser() {
6863 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6864 "DELETE FROM Users_Roles WHERE roleId = ? AND userId = ?",
6865 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6866 }
6867
6868 protected void remove(long roleId, long userId)
6869 throws SystemException {
6870 if (containsUser.contains(roleId, userId)) {
6871 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
6872
6873 for (ModelListener<Role> listener : listeners) {
6874 listener.onBeforeRemoveAssociation(roleId,
6875 com.liferay.portal.model.User.class.getName(), userId);
6876 }
6877
6878 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6879 listener.onBeforeRemoveAssociation(userId,
6880 Role.class.getName(), roleId);
6881 }
6882
6883 _sqlUpdate.update(new Object[] {
6884 new Long(roleId), new Long(userId)
6885 });
6886
6887 for (ModelListener<Role> listener : listeners) {
6888 listener.onAfterRemoveAssociation(roleId,
6889 com.liferay.portal.model.User.class.getName(), userId);
6890 }
6891
6892 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6893 listener.onAfterRemoveAssociation(userId,
6894 Role.class.getName(), roleId);
6895 }
6896 }
6897 }
6898
6899 private SqlUpdate _sqlUpdate;
6900 }
6901
6902 private static final String _SQL_SELECT_ROLE = "SELECT role FROM Role role";
6903 private static final String _SQL_SELECT_ROLE_WHERE = "SELECT role FROM Role role WHERE ";
6904 private static final String _SQL_COUNT_ROLE = "SELECT COUNT(role) FROM Role role";
6905 private static final String _SQL_COUNT_ROLE_WHERE = "SELECT COUNT(role) FROM Role role WHERE ";
6906 private static final String _SQL_GETGROUPS = "SELECT {Group_.*} FROM Group_ INNER JOIN Groups_Roles ON (Groups_Roles.groupId = Group_.groupId) WHERE (Groups_Roles.roleId = ?)";
6907 private static final String _SQL_GETGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Roles WHERE roleId = ?";
6908 private static final String _SQL_CONTAINSGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Roles WHERE roleId = ? AND groupId = ?";
6909 private static final String _SQL_GETPERMISSIONS = "SELECT {Permission_.*} FROM Permission_ INNER JOIN Roles_Permissions ON (Roles_Permissions.permissionId = Permission_.permissionId) WHERE (Roles_Permissions.roleId = ?)";
6910 private static final String _SQL_GETPERMISSIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Roles_Permissions WHERE roleId = ?";
6911 private static final String _SQL_CONTAINSPERMISSION = "SELECT COUNT(*) AS COUNT_VALUE FROM Roles_Permissions WHERE roleId = ? AND permissionId = ?";
6912 private static final String _SQL_GETUSERS = "SELECT {User_.*} FROM User_ INNER JOIN Users_Roles ON (Users_Roles.userId = User_.userId) WHERE (Users_Roles.roleId = ?)";
6913 private static final String _SQL_GETUSERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Roles WHERE roleId = ?";
6914 private static final String _SQL_CONTAINSUSER = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Roles WHERE roleId = ? AND userId = ?";
6915 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "role.companyId = ?";
6916 private static final String _FINDER_COLUMN_NAME_NAME_1 = "role.name IS NULL";
6917 private static final String _FINDER_COLUMN_NAME_NAME_2 = "role.name = ?";
6918 private static final String _FINDER_COLUMN_NAME_NAME_3 = "(role.name IS NULL OR role.name = ?)";
6919 private static final String _FINDER_COLUMN_SUBTYPE_SUBTYPE_1 = "role.subtype IS NULL";
6920 private static final String _FINDER_COLUMN_SUBTYPE_SUBTYPE_2 = "role.subtype = ?";
6921 private static final String _FINDER_COLUMN_SUBTYPE_SUBTYPE_3 = "(role.subtype IS NULL OR role.subtype = ?)";
6922 private static final String _FINDER_COLUMN_C_N_COMPANYID_2 = "role.companyId = ? AND ";
6923 private static final String _FINDER_COLUMN_C_N_NAME_1 = "role.name IS NULL";
6924 private static final String _FINDER_COLUMN_C_N_NAME_2 = "lower(role.name) = lower(CAST_TEXT(?))";
6925 private static final String _FINDER_COLUMN_C_N_NAME_3 = "(role.name IS NULL OR lower(role.name) = lower(CAST_TEXT(?)))";
6926 private static final String _FINDER_COLUMN_T_S_TYPE_2 = "role.type = ? AND ";
6927 private static final String _FINDER_COLUMN_T_S_SUBTYPE_1 = "role.subtype IS NULL";
6928 private static final String _FINDER_COLUMN_T_S_SUBTYPE_2 = "role.subtype = ?";
6929 private static final String _FINDER_COLUMN_T_S_SUBTYPE_3 = "(role.subtype IS NULL OR role.subtype = ?)";
6930 private static final String _FINDER_COLUMN_C_C_C_COMPANYID_2 = "role.companyId = ? AND ";
6931 private static final String _FINDER_COLUMN_C_C_C_CLASSNAMEID_2 = "role.classNameId = ? AND ";
6932 private static final String _FINDER_COLUMN_C_C_C_CLASSPK_2 = "role.classPK = ?";
6933 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "role.roleId";
6934 private static final String _FILTER_SQL_SELECT_ROLE_WHERE = "SELECT DISTINCT {role.*} FROM Role_ role WHERE ";
6935 private static final String _FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1 =
6936 "SELECT {Role_.*} FROM (SELECT DISTINCT role.roleId FROM Role_ role WHERE ";
6937 private static final String _FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2 =
6938 ") TEMP_TABLE INNER JOIN Role_ ON TEMP_TABLE.roleId = Role_.roleId";
6939 private static final String _FILTER_SQL_COUNT_ROLE_WHERE = "SELECT COUNT(DISTINCT role.roleId) AS COUNT_VALUE FROM Role_ role WHERE ";
6940 private static final String _FILTER_ENTITY_ALIAS = "role";
6941 private static final String _FILTER_ENTITY_TABLE = "Role_";
6942 private static final String _ORDER_BY_ENTITY_ALIAS = "role.";
6943 private static final String _ORDER_BY_ENTITY_TABLE = "Role_.";
6944 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Role exists with the primary key ";
6945 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Role exists with the key {";
6946 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
6947 private static Log _log = LogFactoryUtil.getLog(RolePersistenceImpl.class);
6948 private static Role _nullRole = new RoleImpl() {
6949 @Override
6950 public Object clone() {
6951 return this;
6952 }
6953
6954 @Override
6955 public CacheModel<Role> toCacheModel() {
6956 return _nullRoleCacheModel;
6957 }
6958 };
6959
6960 private static CacheModel<Role> _nullRoleCacheModel = new CacheModel<Role>() {
6961 public Role toEntityModel() {
6962 return _nullRole;
6963 }
6964 };
6965 }