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 cacheUniqueFindersCache(Role role) {
287 if (role.isNew()) {
288 Object[] args = new Object[] {
289 Long.valueOf(role.getCompanyId()),
290
291 role.getName()
292 };
293
294 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, args,
295 Long.valueOf(1));
296 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N, args, role);
297
298 args = new Object[] {
299 Long.valueOf(role.getCompanyId()),
300 Long.valueOf(role.getClassNameId()),
301 Long.valueOf(role.getClassPK())
302 };
303
304 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C, args,
305 Long.valueOf(1));
306 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C, args, role);
307 }
308 else {
309 RoleModelImpl roleModelImpl = (RoleModelImpl)role;
310
311 if ((roleModelImpl.getColumnBitmask() &
312 FINDER_PATH_FETCH_BY_C_N.getColumnBitmask()) != 0) {
313 Object[] args = new Object[] {
314 Long.valueOf(role.getCompanyId()),
315
316 role.getName()
317 };
318
319 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, args,
320 Long.valueOf(1));
321 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N, args, role);
322 }
323
324 if ((roleModelImpl.getColumnBitmask() &
325 FINDER_PATH_FETCH_BY_C_C_C.getColumnBitmask()) != 0) {
326 Object[] args = new Object[] {
327 Long.valueOf(role.getCompanyId()),
328 Long.valueOf(role.getClassNameId()),
329 Long.valueOf(role.getClassPK())
330 };
331
332 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C, args,
333 Long.valueOf(1));
334 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C, args, role);
335 }
336 }
337 }
338
339 protected void clearUniqueFindersCache(Role role) {
340 RoleModelImpl roleModelImpl = (RoleModelImpl)role;
341
342 Object[] args = new Object[] {
343 Long.valueOf(role.getCompanyId()),
344
345 role.getName()
346 };
347
348 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_N, args);
349 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N, args);
350
351 if ((roleModelImpl.getColumnBitmask() &
352 FINDER_PATH_FETCH_BY_C_N.getColumnBitmask()) != 0) {
353 args = new Object[] {
354 Long.valueOf(roleModelImpl.getOriginalCompanyId()),
355
356 roleModelImpl.getOriginalName()
357 };
358
359 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_N, args);
360 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N, args);
361 }
362
363 args = new Object[] {
364 Long.valueOf(role.getCompanyId()),
365 Long.valueOf(role.getClassNameId()),
366 Long.valueOf(role.getClassPK())
367 };
368
369 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
370 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C, args);
371
372 if ((roleModelImpl.getColumnBitmask() &
373 FINDER_PATH_FETCH_BY_C_C_C.getColumnBitmask()) != 0) {
374 args = new Object[] {
375 Long.valueOf(roleModelImpl.getOriginalCompanyId()),
376 Long.valueOf(roleModelImpl.getOriginalClassNameId()),
377 Long.valueOf(roleModelImpl.getOriginalClassPK())
378 };
379
380 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
381 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C, args);
382 }
383 }
384
385
391 public Role create(long roleId) {
392 Role role = new RoleImpl();
393
394 role.setNew(true);
395 role.setPrimaryKey(roleId);
396
397 return role;
398 }
399
400
408 public Role remove(long roleId) throws NoSuchRoleException, SystemException {
409 return remove(Long.valueOf(roleId));
410 }
411
412
420 @Override
421 public Role remove(Serializable primaryKey)
422 throws NoSuchRoleException, SystemException {
423 Session session = null;
424
425 try {
426 session = openSession();
427
428 Role role = (Role)session.get(RoleImpl.class, primaryKey);
429
430 if (role == null) {
431 if (_log.isWarnEnabled()) {
432 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
433 }
434
435 throw new NoSuchRoleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
436 primaryKey);
437 }
438
439 return remove(role);
440 }
441 catch (NoSuchRoleException nsee) {
442 throw nsee;
443 }
444 catch (Exception e) {
445 throw processException(e);
446 }
447 finally {
448 closeSession(session);
449 }
450 }
451
452 @Override
453 protected Role removeImpl(Role role) throws SystemException {
454 role = toUnwrappedModel(role);
455
456 try {
457 clearGroups.clear(role.getPrimaryKey());
458 }
459 catch (Exception e) {
460 throw processException(e);
461 }
462 finally {
463 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
464 }
465
466 try {
467 clearPermissions.clear(role.getPrimaryKey());
468 }
469 catch (Exception e) {
470 throw processException(e);
471 }
472 finally {
473 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
474 }
475
476 try {
477 clearUsers.clear(role.getPrimaryKey());
478 }
479 catch (Exception e) {
480 throw processException(e);
481 }
482 finally {
483 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
484 }
485
486 Session session = null;
487
488 try {
489 session = openSession();
490
491 BatchSessionUtil.delete(session, role);
492 }
493 catch (Exception e) {
494 throw processException(e);
495 }
496 finally {
497 closeSession(session);
498 }
499
500 clearCache(role);
501
502 return role;
503 }
504
505 @Override
506 public Role updateImpl(com.liferay.portal.model.Role role, boolean merge)
507 throws SystemException {
508 role = toUnwrappedModel(role);
509
510 boolean isNew = role.isNew();
511
512 RoleModelImpl roleModelImpl = (RoleModelImpl)role;
513
514 Session session = null;
515
516 try {
517 session = openSession();
518
519 BatchSessionUtil.update(session, role, merge);
520
521 role.setNew(false);
522 }
523 catch (Exception e) {
524 throw processException(e);
525 }
526 finally {
527 closeSession(session);
528 }
529
530 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
531
532 if (isNew || !RoleModelImpl.COLUMN_BITMASK_ENABLED) {
533 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
534 }
535
536 else {
537 if ((roleModelImpl.getColumnBitmask() &
538 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
539 Object[] args = new Object[] {
540 Long.valueOf(roleModelImpl.getOriginalCompanyId())
541 };
542
543 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
544 args);
545 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
546 args);
547
548 args = new Object[] { Long.valueOf(roleModelImpl.getCompanyId()) };
549
550 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
551 args);
552 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
553 args);
554 }
555
556 if ((roleModelImpl.getColumnBitmask() &
557 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NAME.getColumnBitmask()) != 0) {
558 Object[] args = new Object[] { roleModelImpl.getOriginalName() };
559
560 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_NAME, args);
561 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NAME,
562 args);
563
564 args = new Object[] { roleModelImpl.getName() };
565
566 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_NAME, args);
567 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NAME,
568 args);
569 }
570
571 if ((roleModelImpl.getColumnBitmask() &
572 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SUBTYPE.getColumnBitmask()) != 0) {
573 Object[] args = new Object[] { roleModelImpl.getOriginalSubtype() };
574
575 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SUBTYPE, args);
576 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SUBTYPE,
577 args);
578
579 args = new Object[] { roleModelImpl.getSubtype() };
580
581 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SUBTYPE, args);
582 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SUBTYPE,
583 args);
584 }
585
586 if ((roleModelImpl.getColumnBitmask() &
587 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S.getColumnBitmask()) != 0) {
588 Object[] args = new Object[] {
589 Integer.valueOf(roleModelImpl.getOriginalType()),
590
591 roleModelImpl.getOriginalSubtype()
592 };
593
594 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_S, args);
595 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S,
596 args);
597
598 args = new Object[] {
599 Integer.valueOf(roleModelImpl.getType()),
600
601 roleModelImpl.getSubtype()
602 };
603
604 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_S, args);
605 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S,
606 args);
607 }
608 }
609
610 EntityCacheUtil.putResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
611 RoleImpl.class, role.getPrimaryKey(), role);
612
613 clearUniqueFindersCache(role);
614 cacheUniqueFindersCache(role);
615
616 return role;
617 }
618
619 protected Role toUnwrappedModel(Role role) {
620 if (role instanceof RoleImpl) {
621 return role;
622 }
623
624 RoleImpl roleImpl = new RoleImpl();
625
626 roleImpl.setNew(role.isNew());
627 roleImpl.setPrimaryKey(role.getPrimaryKey());
628
629 roleImpl.setRoleId(role.getRoleId());
630 roleImpl.setCompanyId(role.getCompanyId());
631 roleImpl.setClassNameId(role.getClassNameId());
632 roleImpl.setClassPK(role.getClassPK());
633 roleImpl.setName(role.getName());
634 roleImpl.setTitle(role.getTitle());
635 roleImpl.setDescription(role.getDescription());
636 roleImpl.setType(role.getType());
637 roleImpl.setSubtype(role.getSubtype());
638
639 return roleImpl;
640 }
641
642
650 @Override
651 public Role findByPrimaryKey(Serializable primaryKey)
652 throws NoSuchModelException, SystemException {
653 return findByPrimaryKey(((Long)primaryKey).longValue());
654 }
655
656
664 public Role findByPrimaryKey(long roleId)
665 throws NoSuchRoleException, SystemException {
666 Role role = fetchByPrimaryKey(roleId);
667
668 if (role == null) {
669 if (_log.isWarnEnabled()) {
670 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + roleId);
671 }
672
673 throw new NoSuchRoleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
674 roleId);
675 }
676
677 return role;
678 }
679
680
687 @Override
688 public Role fetchByPrimaryKey(Serializable primaryKey)
689 throws SystemException {
690 return fetchByPrimaryKey(((Long)primaryKey).longValue());
691 }
692
693
700 public Role fetchByPrimaryKey(long roleId) throws SystemException {
701 Role role = (Role)EntityCacheUtil.getResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
702 RoleImpl.class, roleId);
703
704 if (role == _nullRole) {
705 return null;
706 }
707
708 if (role == null) {
709 Session session = null;
710
711 boolean hasException = false;
712
713 try {
714 session = openSession();
715
716 role = (Role)session.get(RoleImpl.class, Long.valueOf(roleId));
717 }
718 catch (Exception e) {
719 hasException = true;
720
721 throw processException(e);
722 }
723 finally {
724 if (role != null) {
725 cacheResult(role);
726 }
727 else if (!hasException) {
728 EntityCacheUtil.putResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
729 RoleImpl.class, roleId, _nullRole);
730 }
731
732 closeSession(session);
733 }
734 }
735
736 return role;
737 }
738
739
746 public List<Role> findByCompanyId(long companyId) throws SystemException {
747 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
748 null);
749 }
750
751
764 public List<Role> findByCompanyId(long companyId, int start, int end)
765 throws SystemException {
766 return findByCompanyId(companyId, start, end, null);
767 }
768
769
783 public List<Role> findByCompanyId(long companyId, int start, int end,
784 OrderByComparator orderByComparator) throws SystemException {
785 FinderPath finderPath = null;
786 Object[] finderArgs = null;
787
788 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
789 (orderByComparator == null)) {
790 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
791 finderArgs = new Object[] { companyId };
792 }
793 else {
794 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
795 finderArgs = new Object[] { companyId, start, end, orderByComparator };
796 }
797
798 List<Role> list = (List<Role>)FinderCacheUtil.getResult(finderPath,
799 finderArgs, this);
800
801 if ((list != null) && !list.isEmpty()) {
802 for (Role role : list) {
803 if ((companyId != role.getCompanyId())) {
804 list = null;
805
806 break;
807 }
808 }
809 }
810
811 if (list == null) {
812 StringBundler query = null;
813
814 if (orderByComparator != null) {
815 query = new StringBundler(3 +
816 (orderByComparator.getOrderByFields().length * 3));
817 }
818 else {
819 query = new StringBundler(3);
820 }
821
822 query.append(_SQL_SELECT_ROLE_WHERE);
823
824 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
825
826 if (orderByComparator != null) {
827 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
828 orderByComparator);
829 }
830
831 else {
832 query.append(RoleModelImpl.ORDER_BY_JPQL);
833 }
834
835 String sql = query.toString();
836
837 Session session = null;
838
839 try {
840 session = openSession();
841
842 Query q = session.createQuery(sql);
843
844 QueryPos qPos = QueryPos.getInstance(q);
845
846 qPos.add(companyId);
847
848 list = (List<Role>)QueryUtil.list(q, getDialect(), start, end);
849 }
850 catch (Exception e) {
851 throw processException(e);
852 }
853 finally {
854 if (list == null) {
855 FinderCacheUtil.removeResult(finderPath, finderArgs);
856 }
857 else {
858 cacheResult(list);
859
860 FinderCacheUtil.putResult(finderPath, finderArgs, list);
861 }
862
863 closeSession(session);
864 }
865 }
866
867 return list;
868 }
869
870
879 public Role findByCompanyId_First(long companyId,
880 OrderByComparator orderByComparator)
881 throws NoSuchRoleException, SystemException {
882 Role role = fetchByCompanyId_First(companyId, orderByComparator);
883
884 if (role != null) {
885 return role;
886 }
887
888 StringBundler msg = new StringBundler(4);
889
890 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
891
892 msg.append("companyId=");
893 msg.append(companyId);
894
895 msg.append(StringPool.CLOSE_CURLY_BRACE);
896
897 throw new NoSuchRoleException(msg.toString());
898 }
899
900
908 public Role fetchByCompanyId_First(long companyId,
909 OrderByComparator orderByComparator) throws SystemException {
910 List<Role> list = findByCompanyId(companyId, 0, 1, orderByComparator);
911
912 if (!list.isEmpty()) {
913 return list.get(0);
914 }
915
916 return null;
917 }
918
919
928 public Role findByCompanyId_Last(long companyId,
929 OrderByComparator orderByComparator)
930 throws NoSuchRoleException, SystemException {
931 Role role = fetchByCompanyId_Last(companyId, orderByComparator);
932
933 if (role != null) {
934 return role;
935 }
936
937 StringBundler msg = new StringBundler(4);
938
939 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
940
941 msg.append("companyId=");
942 msg.append(companyId);
943
944 msg.append(StringPool.CLOSE_CURLY_BRACE);
945
946 throw new NoSuchRoleException(msg.toString());
947 }
948
949
957 public Role fetchByCompanyId_Last(long companyId,
958 OrderByComparator orderByComparator) throws SystemException {
959 int count = countByCompanyId(companyId);
960
961 List<Role> list = findByCompanyId(companyId, count - 1, count,
962 orderByComparator);
963
964 if (!list.isEmpty()) {
965 return list.get(0);
966 }
967
968 return null;
969 }
970
971
981 public Role[] findByCompanyId_PrevAndNext(long roleId, long companyId,
982 OrderByComparator orderByComparator)
983 throws NoSuchRoleException, SystemException {
984 Role role = findByPrimaryKey(roleId);
985
986 Session session = null;
987
988 try {
989 session = openSession();
990
991 Role[] array = new RoleImpl[3];
992
993 array[0] = getByCompanyId_PrevAndNext(session, role, companyId,
994 orderByComparator, true);
995
996 array[1] = role;
997
998 array[2] = getByCompanyId_PrevAndNext(session, role, companyId,
999 orderByComparator, false);
1000
1001 return array;
1002 }
1003 catch (Exception e) {
1004 throw processException(e);
1005 }
1006 finally {
1007 closeSession(session);
1008 }
1009 }
1010
1011 protected Role getByCompanyId_PrevAndNext(Session session, Role role,
1012 long companyId, OrderByComparator orderByComparator, boolean previous) {
1013 StringBundler query = null;
1014
1015 if (orderByComparator != null) {
1016 query = new StringBundler(6 +
1017 (orderByComparator.getOrderByFields().length * 6));
1018 }
1019 else {
1020 query = new StringBundler(3);
1021 }
1022
1023 query.append(_SQL_SELECT_ROLE_WHERE);
1024
1025 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1026
1027 if (orderByComparator != null) {
1028 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1029
1030 if (orderByConditionFields.length > 0) {
1031 query.append(WHERE_AND);
1032 }
1033
1034 for (int i = 0; i < orderByConditionFields.length; i++) {
1035 query.append(_ORDER_BY_ENTITY_ALIAS);
1036 query.append(orderByConditionFields[i]);
1037
1038 if ((i + 1) < orderByConditionFields.length) {
1039 if (orderByComparator.isAscending() ^ previous) {
1040 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1041 }
1042 else {
1043 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1044 }
1045 }
1046 else {
1047 if (orderByComparator.isAscending() ^ previous) {
1048 query.append(WHERE_GREATER_THAN);
1049 }
1050 else {
1051 query.append(WHERE_LESSER_THAN);
1052 }
1053 }
1054 }
1055
1056 query.append(ORDER_BY_CLAUSE);
1057
1058 String[] orderByFields = orderByComparator.getOrderByFields();
1059
1060 for (int i = 0; i < orderByFields.length; i++) {
1061 query.append(_ORDER_BY_ENTITY_ALIAS);
1062 query.append(orderByFields[i]);
1063
1064 if ((i + 1) < orderByFields.length) {
1065 if (orderByComparator.isAscending() ^ previous) {
1066 query.append(ORDER_BY_ASC_HAS_NEXT);
1067 }
1068 else {
1069 query.append(ORDER_BY_DESC_HAS_NEXT);
1070 }
1071 }
1072 else {
1073 if (orderByComparator.isAscending() ^ previous) {
1074 query.append(ORDER_BY_ASC);
1075 }
1076 else {
1077 query.append(ORDER_BY_DESC);
1078 }
1079 }
1080 }
1081 }
1082
1083 else {
1084 query.append(RoleModelImpl.ORDER_BY_JPQL);
1085 }
1086
1087 String sql = query.toString();
1088
1089 Query q = session.createQuery(sql);
1090
1091 q.setFirstResult(0);
1092 q.setMaxResults(2);
1093
1094 QueryPos qPos = QueryPos.getInstance(q);
1095
1096 qPos.add(companyId);
1097
1098 if (orderByComparator != null) {
1099 Object[] values = orderByComparator.getOrderByConditionValues(role);
1100
1101 for (Object value : values) {
1102 qPos.add(value);
1103 }
1104 }
1105
1106 List<Role> list = q.list();
1107
1108 if (list.size() == 2) {
1109 return list.get(1);
1110 }
1111 else {
1112 return null;
1113 }
1114 }
1115
1116
1123 public List<Role> filterFindByCompanyId(long companyId)
1124 throws SystemException {
1125 return filterFindByCompanyId(companyId, QueryUtil.ALL_POS,
1126 QueryUtil.ALL_POS, null);
1127 }
1128
1129
1142 public List<Role> filterFindByCompanyId(long companyId, int start, int end)
1143 throws SystemException {
1144 return filterFindByCompanyId(companyId, start, end, null);
1145 }
1146
1147
1161 public List<Role> filterFindByCompanyId(long companyId, int start, int end,
1162 OrderByComparator orderByComparator) throws SystemException {
1163 if (!InlineSQLHelperUtil.isEnabled()) {
1164 return findByCompanyId(companyId, start, end, orderByComparator);
1165 }
1166
1167 StringBundler query = null;
1168
1169 if (orderByComparator != null) {
1170 query = new StringBundler(3 +
1171 (orderByComparator.getOrderByFields().length * 3));
1172 }
1173 else {
1174 query = new StringBundler(3);
1175 }
1176
1177 if (getDB().isSupportsInlineDistinct()) {
1178 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
1179 }
1180 else {
1181 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
1182 }
1183
1184 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1185
1186 if (!getDB().isSupportsInlineDistinct()) {
1187 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
1188 }
1189
1190 if (orderByComparator != null) {
1191 if (getDB().isSupportsInlineDistinct()) {
1192 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1193 orderByComparator);
1194 }
1195 else {
1196 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1197 orderByComparator);
1198 }
1199 }
1200
1201 else {
1202 if (getDB().isSupportsInlineDistinct()) {
1203 query.append(RoleModelImpl.ORDER_BY_JPQL);
1204 }
1205 else {
1206 query.append(RoleModelImpl.ORDER_BY_SQL);
1207 }
1208 }
1209
1210 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1211 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1212
1213 Session session = null;
1214
1215 try {
1216 session = openSession();
1217
1218 SQLQuery q = session.createSQLQuery(sql);
1219
1220 if (getDB().isSupportsInlineDistinct()) {
1221 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
1222 }
1223 else {
1224 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
1225 }
1226
1227 QueryPos qPos = QueryPos.getInstance(q);
1228
1229 qPos.add(companyId);
1230
1231 return (List<Role>)QueryUtil.list(q, getDialect(), start, end);
1232 }
1233 catch (Exception e) {
1234 throw processException(e);
1235 }
1236 finally {
1237 closeSession(session);
1238 }
1239 }
1240
1241
1251 public Role[] filterFindByCompanyId_PrevAndNext(long roleId,
1252 long companyId, OrderByComparator orderByComparator)
1253 throws NoSuchRoleException, SystemException {
1254 if (!InlineSQLHelperUtil.isEnabled()) {
1255 return findByCompanyId_PrevAndNext(roleId, companyId,
1256 orderByComparator);
1257 }
1258
1259 Role role = findByPrimaryKey(roleId);
1260
1261 Session session = null;
1262
1263 try {
1264 session = openSession();
1265
1266 Role[] array = new RoleImpl[3];
1267
1268 array[0] = filterGetByCompanyId_PrevAndNext(session, role,
1269 companyId, orderByComparator, true);
1270
1271 array[1] = role;
1272
1273 array[2] = filterGetByCompanyId_PrevAndNext(session, role,
1274 companyId, orderByComparator, false);
1275
1276 return array;
1277 }
1278 catch (Exception e) {
1279 throw processException(e);
1280 }
1281 finally {
1282 closeSession(session);
1283 }
1284 }
1285
1286 protected Role filterGetByCompanyId_PrevAndNext(Session session, Role role,
1287 long companyId, OrderByComparator orderByComparator, boolean previous) {
1288 StringBundler query = null;
1289
1290 if (orderByComparator != null) {
1291 query = new StringBundler(6 +
1292 (orderByComparator.getOrderByFields().length * 6));
1293 }
1294 else {
1295 query = new StringBundler(3);
1296 }
1297
1298 if (getDB().isSupportsInlineDistinct()) {
1299 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
1300 }
1301 else {
1302 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
1303 }
1304
1305 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1306
1307 if (!getDB().isSupportsInlineDistinct()) {
1308 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
1309 }
1310
1311 if (orderByComparator != null) {
1312 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1313
1314 if (orderByConditionFields.length > 0) {
1315 query.append(WHERE_AND);
1316 }
1317
1318 for (int i = 0; i < orderByConditionFields.length; i++) {
1319 if (getDB().isSupportsInlineDistinct()) {
1320 query.append(_ORDER_BY_ENTITY_ALIAS);
1321 }
1322 else {
1323 query.append(_ORDER_BY_ENTITY_TABLE);
1324 }
1325
1326 query.append(orderByConditionFields[i]);
1327
1328 if ((i + 1) < orderByConditionFields.length) {
1329 if (orderByComparator.isAscending() ^ previous) {
1330 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1331 }
1332 else {
1333 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1334 }
1335 }
1336 else {
1337 if (orderByComparator.isAscending() ^ previous) {
1338 query.append(WHERE_GREATER_THAN);
1339 }
1340 else {
1341 query.append(WHERE_LESSER_THAN);
1342 }
1343 }
1344 }
1345
1346 query.append(ORDER_BY_CLAUSE);
1347
1348 String[] orderByFields = orderByComparator.getOrderByFields();
1349
1350 for (int i = 0; i < orderByFields.length; i++) {
1351 if (getDB().isSupportsInlineDistinct()) {
1352 query.append(_ORDER_BY_ENTITY_ALIAS);
1353 }
1354 else {
1355 query.append(_ORDER_BY_ENTITY_TABLE);
1356 }
1357
1358 query.append(orderByFields[i]);
1359
1360 if ((i + 1) < orderByFields.length) {
1361 if (orderByComparator.isAscending() ^ previous) {
1362 query.append(ORDER_BY_ASC_HAS_NEXT);
1363 }
1364 else {
1365 query.append(ORDER_BY_DESC_HAS_NEXT);
1366 }
1367 }
1368 else {
1369 if (orderByComparator.isAscending() ^ previous) {
1370 query.append(ORDER_BY_ASC);
1371 }
1372 else {
1373 query.append(ORDER_BY_DESC);
1374 }
1375 }
1376 }
1377 }
1378
1379 else {
1380 if (getDB().isSupportsInlineDistinct()) {
1381 query.append(RoleModelImpl.ORDER_BY_JPQL);
1382 }
1383 else {
1384 query.append(RoleModelImpl.ORDER_BY_SQL);
1385 }
1386 }
1387
1388 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1389 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1390
1391 SQLQuery q = session.createSQLQuery(sql);
1392
1393 q.setFirstResult(0);
1394 q.setMaxResults(2);
1395
1396 if (getDB().isSupportsInlineDistinct()) {
1397 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
1398 }
1399 else {
1400 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
1401 }
1402
1403 QueryPos qPos = QueryPos.getInstance(q);
1404
1405 qPos.add(companyId);
1406
1407 if (orderByComparator != null) {
1408 Object[] values = orderByComparator.getOrderByConditionValues(role);
1409
1410 for (Object value : values) {
1411 qPos.add(value);
1412 }
1413 }
1414
1415 List<Role> list = q.list();
1416
1417 if (list.size() == 2) {
1418 return list.get(1);
1419 }
1420 else {
1421 return null;
1422 }
1423 }
1424
1425
1432 public List<Role> findByName(String name) throws SystemException {
1433 return findByName(name, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1434 }
1435
1436
1449 public List<Role> findByName(String name, int start, int end)
1450 throws SystemException {
1451 return findByName(name, start, end, null);
1452 }
1453
1454
1468 public List<Role> findByName(String name, int start, int end,
1469 OrderByComparator orderByComparator) throws SystemException {
1470 FinderPath finderPath = null;
1471 Object[] finderArgs = null;
1472
1473 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1474 (orderByComparator == null)) {
1475 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NAME;
1476 finderArgs = new Object[] { name };
1477 }
1478 else {
1479 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_NAME;
1480 finderArgs = new Object[] { name, start, end, orderByComparator };
1481 }
1482
1483 List<Role> list = (List<Role>)FinderCacheUtil.getResult(finderPath,
1484 finderArgs, this);
1485
1486 if ((list != null) && !list.isEmpty()) {
1487 for (Role role : list) {
1488 if (!Validator.equals(name, role.getName())) {
1489 list = null;
1490
1491 break;
1492 }
1493 }
1494 }
1495
1496 if (list == null) {
1497 StringBundler query = null;
1498
1499 if (orderByComparator != null) {
1500 query = new StringBundler(3 +
1501 (orderByComparator.getOrderByFields().length * 3));
1502 }
1503 else {
1504 query = new StringBundler(3);
1505 }
1506
1507 query.append(_SQL_SELECT_ROLE_WHERE);
1508
1509 if (name == null) {
1510 query.append(_FINDER_COLUMN_NAME_NAME_1);
1511 }
1512 else {
1513 if (name.equals(StringPool.BLANK)) {
1514 query.append(_FINDER_COLUMN_NAME_NAME_3);
1515 }
1516 else {
1517 query.append(_FINDER_COLUMN_NAME_NAME_2);
1518 }
1519 }
1520
1521 if (orderByComparator != null) {
1522 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1523 orderByComparator);
1524 }
1525
1526 else {
1527 query.append(RoleModelImpl.ORDER_BY_JPQL);
1528 }
1529
1530 String sql = query.toString();
1531
1532 Session session = null;
1533
1534 try {
1535 session = openSession();
1536
1537 Query q = session.createQuery(sql);
1538
1539 QueryPos qPos = QueryPos.getInstance(q);
1540
1541 if (name != null) {
1542 qPos.add(name);
1543 }
1544
1545 list = (List<Role>)QueryUtil.list(q, getDialect(), start, end);
1546 }
1547 catch (Exception e) {
1548 throw processException(e);
1549 }
1550 finally {
1551 if (list == null) {
1552 FinderCacheUtil.removeResult(finderPath, finderArgs);
1553 }
1554 else {
1555 cacheResult(list);
1556
1557 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1558 }
1559
1560 closeSession(session);
1561 }
1562 }
1563
1564 return list;
1565 }
1566
1567
1576 public Role findByName_First(String name,
1577 OrderByComparator orderByComparator)
1578 throws NoSuchRoleException, SystemException {
1579 Role role = fetchByName_First(name, orderByComparator);
1580
1581 if (role != null) {
1582 return role;
1583 }
1584
1585 StringBundler msg = new StringBundler(4);
1586
1587 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1588
1589 msg.append("name=");
1590 msg.append(name);
1591
1592 msg.append(StringPool.CLOSE_CURLY_BRACE);
1593
1594 throw new NoSuchRoleException(msg.toString());
1595 }
1596
1597
1605 public Role fetchByName_First(String name,
1606 OrderByComparator orderByComparator) throws SystemException {
1607 List<Role> list = findByName(name, 0, 1, orderByComparator);
1608
1609 if (!list.isEmpty()) {
1610 return list.get(0);
1611 }
1612
1613 return null;
1614 }
1615
1616
1625 public Role findByName_Last(String name, OrderByComparator orderByComparator)
1626 throws NoSuchRoleException, SystemException {
1627 Role role = fetchByName_Last(name, orderByComparator);
1628
1629 if (role != null) {
1630 return role;
1631 }
1632
1633 StringBundler msg = new StringBundler(4);
1634
1635 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1636
1637 msg.append("name=");
1638 msg.append(name);
1639
1640 msg.append(StringPool.CLOSE_CURLY_BRACE);
1641
1642 throw new NoSuchRoleException(msg.toString());
1643 }
1644
1645
1653 public Role fetchByName_Last(String name,
1654 OrderByComparator orderByComparator) throws SystemException {
1655 int count = countByName(name);
1656
1657 List<Role> list = findByName(name, count - 1, count, orderByComparator);
1658
1659 if (!list.isEmpty()) {
1660 return list.get(0);
1661 }
1662
1663 return null;
1664 }
1665
1666
1676 public Role[] findByName_PrevAndNext(long roleId, String name,
1677 OrderByComparator orderByComparator)
1678 throws NoSuchRoleException, SystemException {
1679 Role role = findByPrimaryKey(roleId);
1680
1681 Session session = null;
1682
1683 try {
1684 session = openSession();
1685
1686 Role[] array = new RoleImpl[3];
1687
1688 array[0] = getByName_PrevAndNext(session, role, name,
1689 orderByComparator, true);
1690
1691 array[1] = role;
1692
1693 array[2] = getByName_PrevAndNext(session, role, name,
1694 orderByComparator, false);
1695
1696 return array;
1697 }
1698 catch (Exception e) {
1699 throw processException(e);
1700 }
1701 finally {
1702 closeSession(session);
1703 }
1704 }
1705
1706 protected Role getByName_PrevAndNext(Session session, Role role,
1707 String name, OrderByComparator orderByComparator, boolean previous) {
1708 StringBundler query = null;
1709
1710 if (orderByComparator != null) {
1711 query = new StringBundler(6 +
1712 (orderByComparator.getOrderByFields().length * 6));
1713 }
1714 else {
1715 query = new StringBundler(3);
1716 }
1717
1718 query.append(_SQL_SELECT_ROLE_WHERE);
1719
1720 if (name == null) {
1721 query.append(_FINDER_COLUMN_NAME_NAME_1);
1722 }
1723 else {
1724 if (name.equals(StringPool.BLANK)) {
1725 query.append(_FINDER_COLUMN_NAME_NAME_3);
1726 }
1727 else {
1728 query.append(_FINDER_COLUMN_NAME_NAME_2);
1729 }
1730 }
1731
1732 if (orderByComparator != null) {
1733 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1734
1735 if (orderByConditionFields.length > 0) {
1736 query.append(WHERE_AND);
1737 }
1738
1739 for (int i = 0; i < orderByConditionFields.length; i++) {
1740 query.append(_ORDER_BY_ENTITY_ALIAS);
1741 query.append(orderByConditionFields[i]);
1742
1743 if ((i + 1) < orderByConditionFields.length) {
1744 if (orderByComparator.isAscending() ^ previous) {
1745 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1746 }
1747 else {
1748 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1749 }
1750 }
1751 else {
1752 if (orderByComparator.isAscending() ^ previous) {
1753 query.append(WHERE_GREATER_THAN);
1754 }
1755 else {
1756 query.append(WHERE_LESSER_THAN);
1757 }
1758 }
1759 }
1760
1761 query.append(ORDER_BY_CLAUSE);
1762
1763 String[] orderByFields = orderByComparator.getOrderByFields();
1764
1765 for (int i = 0; i < orderByFields.length; i++) {
1766 query.append(_ORDER_BY_ENTITY_ALIAS);
1767 query.append(orderByFields[i]);
1768
1769 if ((i + 1) < orderByFields.length) {
1770 if (orderByComparator.isAscending() ^ previous) {
1771 query.append(ORDER_BY_ASC_HAS_NEXT);
1772 }
1773 else {
1774 query.append(ORDER_BY_DESC_HAS_NEXT);
1775 }
1776 }
1777 else {
1778 if (orderByComparator.isAscending() ^ previous) {
1779 query.append(ORDER_BY_ASC);
1780 }
1781 else {
1782 query.append(ORDER_BY_DESC);
1783 }
1784 }
1785 }
1786 }
1787
1788 else {
1789 query.append(RoleModelImpl.ORDER_BY_JPQL);
1790 }
1791
1792 String sql = query.toString();
1793
1794 Query q = session.createQuery(sql);
1795
1796 q.setFirstResult(0);
1797 q.setMaxResults(2);
1798
1799 QueryPos qPos = QueryPos.getInstance(q);
1800
1801 if (name != null) {
1802 qPos.add(name);
1803 }
1804
1805 if (orderByComparator != null) {
1806 Object[] values = orderByComparator.getOrderByConditionValues(role);
1807
1808 for (Object value : values) {
1809 qPos.add(value);
1810 }
1811 }
1812
1813 List<Role> list = q.list();
1814
1815 if (list.size() == 2) {
1816 return list.get(1);
1817 }
1818 else {
1819 return null;
1820 }
1821 }
1822
1823
1830 public List<Role> filterFindByName(String name) throws SystemException {
1831 return filterFindByName(name, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1832 }
1833
1834
1847 public List<Role> filterFindByName(String name, int start, int end)
1848 throws SystemException {
1849 return filterFindByName(name, start, end, null);
1850 }
1851
1852
1866 public List<Role> filterFindByName(String name, int start, int end,
1867 OrderByComparator orderByComparator) throws SystemException {
1868 if (!InlineSQLHelperUtil.isEnabled()) {
1869 return findByName(name, start, end, orderByComparator);
1870 }
1871
1872 StringBundler query = null;
1873
1874 if (orderByComparator != null) {
1875 query = new StringBundler(3 +
1876 (orderByComparator.getOrderByFields().length * 3));
1877 }
1878 else {
1879 query = new StringBundler(3);
1880 }
1881
1882 if (getDB().isSupportsInlineDistinct()) {
1883 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
1884 }
1885 else {
1886 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
1887 }
1888
1889 if (name == null) {
1890 query.append(_FINDER_COLUMN_NAME_NAME_1);
1891 }
1892 else {
1893 if (name.equals(StringPool.BLANK)) {
1894 query.append(_FINDER_COLUMN_NAME_NAME_3);
1895 }
1896 else {
1897 query.append(_FINDER_COLUMN_NAME_NAME_2);
1898 }
1899 }
1900
1901 if (!getDB().isSupportsInlineDistinct()) {
1902 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
1903 }
1904
1905 if (orderByComparator != null) {
1906 if (getDB().isSupportsInlineDistinct()) {
1907 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1908 orderByComparator);
1909 }
1910 else {
1911 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1912 orderByComparator);
1913 }
1914 }
1915
1916 else {
1917 if (getDB().isSupportsInlineDistinct()) {
1918 query.append(RoleModelImpl.ORDER_BY_JPQL);
1919 }
1920 else {
1921 query.append(RoleModelImpl.ORDER_BY_SQL);
1922 }
1923 }
1924
1925 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1926 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1927
1928 Session session = null;
1929
1930 try {
1931 session = openSession();
1932
1933 SQLQuery q = session.createSQLQuery(sql);
1934
1935 if (getDB().isSupportsInlineDistinct()) {
1936 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
1937 }
1938 else {
1939 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
1940 }
1941
1942 QueryPos qPos = QueryPos.getInstance(q);
1943
1944 if (name != null) {
1945 qPos.add(name);
1946 }
1947
1948 return (List<Role>)QueryUtil.list(q, getDialect(), start, end);
1949 }
1950 catch (Exception e) {
1951 throw processException(e);
1952 }
1953 finally {
1954 closeSession(session);
1955 }
1956 }
1957
1958
1968 public Role[] filterFindByName_PrevAndNext(long roleId, String name,
1969 OrderByComparator orderByComparator)
1970 throws NoSuchRoleException, SystemException {
1971 if (!InlineSQLHelperUtil.isEnabled()) {
1972 return findByName_PrevAndNext(roleId, name, orderByComparator);
1973 }
1974
1975 Role role = findByPrimaryKey(roleId);
1976
1977 Session session = null;
1978
1979 try {
1980 session = openSession();
1981
1982 Role[] array = new RoleImpl[3];
1983
1984 array[0] = filterGetByName_PrevAndNext(session, role, name,
1985 orderByComparator, true);
1986
1987 array[1] = role;
1988
1989 array[2] = filterGetByName_PrevAndNext(session, role, name,
1990 orderByComparator, false);
1991
1992 return array;
1993 }
1994 catch (Exception e) {
1995 throw processException(e);
1996 }
1997 finally {
1998 closeSession(session);
1999 }
2000 }
2001
2002 protected Role filterGetByName_PrevAndNext(Session session, Role role,
2003 String name, OrderByComparator orderByComparator, boolean previous) {
2004 StringBundler query = null;
2005
2006 if (orderByComparator != null) {
2007 query = new StringBundler(6 +
2008 (orderByComparator.getOrderByFields().length * 6));
2009 }
2010 else {
2011 query = new StringBundler(3);
2012 }
2013
2014 if (getDB().isSupportsInlineDistinct()) {
2015 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
2016 }
2017 else {
2018 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
2019 }
2020
2021 if (name == null) {
2022 query.append(_FINDER_COLUMN_NAME_NAME_1);
2023 }
2024 else {
2025 if (name.equals(StringPool.BLANK)) {
2026 query.append(_FINDER_COLUMN_NAME_NAME_3);
2027 }
2028 else {
2029 query.append(_FINDER_COLUMN_NAME_NAME_2);
2030 }
2031 }
2032
2033 if (!getDB().isSupportsInlineDistinct()) {
2034 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
2035 }
2036
2037 if (orderByComparator != null) {
2038 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2039
2040 if (orderByConditionFields.length > 0) {
2041 query.append(WHERE_AND);
2042 }
2043
2044 for (int i = 0; i < orderByConditionFields.length; i++) {
2045 if (getDB().isSupportsInlineDistinct()) {
2046 query.append(_ORDER_BY_ENTITY_ALIAS);
2047 }
2048 else {
2049 query.append(_ORDER_BY_ENTITY_TABLE);
2050 }
2051
2052 query.append(orderByConditionFields[i]);
2053
2054 if ((i + 1) < orderByConditionFields.length) {
2055 if (orderByComparator.isAscending() ^ previous) {
2056 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2057 }
2058 else {
2059 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2060 }
2061 }
2062 else {
2063 if (orderByComparator.isAscending() ^ previous) {
2064 query.append(WHERE_GREATER_THAN);
2065 }
2066 else {
2067 query.append(WHERE_LESSER_THAN);
2068 }
2069 }
2070 }
2071
2072 query.append(ORDER_BY_CLAUSE);
2073
2074 String[] orderByFields = orderByComparator.getOrderByFields();
2075
2076 for (int i = 0; i < orderByFields.length; i++) {
2077 if (getDB().isSupportsInlineDistinct()) {
2078 query.append(_ORDER_BY_ENTITY_ALIAS);
2079 }
2080 else {
2081 query.append(_ORDER_BY_ENTITY_TABLE);
2082 }
2083
2084 query.append(orderByFields[i]);
2085
2086 if ((i + 1) < orderByFields.length) {
2087 if (orderByComparator.isAscending() ^ previous) {
2088 query.append(ORDER_BY_ASC_HAS_NEXT);
2089 }
2090 else {
2091 query.append(ORDER_BY_DESC_HAS_NEXT);
2092 }
2093 }
2094 else {
2095 if (orderByComparator.isAscending() ^ previous) {
2096 query.append(ORDER_BY_ASC);
2097 }
2098 else {
2099 query.append(ORDER_BY_DESC);
2100 }
2101 }
2102 }
2103 }
2104
2105 else {
2106 if (getDB().isSupportsInlineDistinct()) {
2107 query.append(RoleModelImpl.ORDER_BY_JPQL);
2108 }
2109 else {
2110 query.append(RoleModelImpl.ORDER_BY_SQL);
2111 }
2112 }
2113
2114 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2115 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2116
2117 SQLQuery q = session.createSQLQuery(sql);
2118
2119 q.setFirstResult(0);
2120 q.setMaxResults(2);
2121
2122 if (getDB().isSupportsInlineDistinct()) {
2123 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
2124 }
2125 else {
2126 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
2127 }
2128
2129 QueryPos qPos = QueryPos.getInstance(q);
2130
2131 if (name != null) {
2132 qPos.add(name);
2133 }
2134
2135 if (orderByComparator != null) {
2136 Object[] values = orderByComparator.getOrderByConditionValues(role);
2137
2138 for (Object value : values) {
2139 qPos.add(value);
2140 }
2141 }
2142
2143 List<Role> list = q.list();
2144
2145 if (list.size() == 2) {
2146 return list.get(1);
2147 }
2148 else {
2149 return null;
2150 }
2151 }
2152
2153
2160 public List<Role> findBySubtype(String subtype) throws SystemException {
2161 return findBySubtype(subtype, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2162 }
2163
2164
2177 public List<Role> findBySubtype(String subtype, int start, int end)
2178 throws SystemException {
2179 return findBySubtype(subtype, start, end, null);
2180 }
2181
2182
2196 public List<Role> findBySubtype(String subtype, int start, int end,
2197 OrderByComparator orderByComparator) throws SystemException {
2198 FinderPath finderPath = null;
2199 Object[] finderArgs = null;
2200
2201 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2202 (orderByComparator == null)) {
2203 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SUBTYPE;
2204 finderArgs = new Object[] { subtype };
2205 }
2206 else {
2207 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SUBTYPE;
2208 finderArgs = new Object[] { subtype, start, end, orderByComparator };
2209 }
2210
2211 List<Role> list = (List<Role>)FinderCacheUtil.getResult(finderPath,
2212 finderArgs, this);
2213
2214 if ((list != null) && !list.isEmpty()) {
2215 for (Role role : list) {
2216 if (!Validator.equals(subtype, role.getSubtype())) {
2217 list = null;
2218
2219 break;
2220 }
2221 }
2222 }
2223
2224 if (list == null) {
2225 StringBundler query = null;
2226
2227 if (orderByComparator != null) {
2228 query = new StringBundler(3 +
2229 (orderByComparator.getOrderByFields().length * 3));
2230 }
2231 else {
2232 query = new StringBundler(3);
2233 }
2234
2235 query.append(_SQL_SELECT_ROLE_WHERE);
2236
2237 if (subtype == null) {
2238 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
2239 }
2240 else {
2241 if (subtype.equals(StringPool.BLANK)) {
2242 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
2243 }
2244 else {
2245 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
2246 }
2247 }
2248
2249 if (orderByComparator != null) {
2250 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2251 orderByComparator);
2252 }
2253
2254 else {
2255 query.append(RoleModelImpl.ORDER_BY_JPQL);
2256 }
2257
2258 String sql = query.toString();
2259
2260 Session session = null;
2261
2262 try {
2263 session = openSession();
2264
2265 Query q = session.createQuery(sql);
2266
2267 QueryPos qPos = QueryPos.getInstance(q);
2268
2269 if (subtype != null) {
2270 qPos.add(subtype);
2271 }
2272
2273 list = (List<Role>)QueryUtil.list(q, getDialect(), start, end);
2274 }
2275 catch (Exception e) {
2276 throw processException(e);
2277 }
2278 finally {
2279 if (list == null) {
2280 FinderCacheUtil.removeResult(finderPath, finderArgs);
2281 }
2282 else {
2283 cacheResult(list);
2284
2285 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2286 }
2287
2288 closeSession(session);
2289 }
2290 }
2291
2292 return list;
2293 }
2294
2295
2304 public Role findBySubtype_First(String subtype,
2305 OrderByComparator orderByComparator)
2306 throws NoSuchRoleException, SystemException {
2307 Role role = fetchBySubtype_First(subtype, orderByComparator);
2308
2309 if (role != null) {
2310 return role;
2311 }
2312
2313 StringBundler msg = new StringBundler(4);
2314
2315 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2316
2317 msg.append("subtype=");
2318 msg.append(subtype);
2319
2320 msg.append(StringPool.CLOSE_CURLY_BRACE);
2321
2322 throw new NoSuchRoleException(msg.toString());
2323 }
2324
2325
2333 public Role fetchBySubtype_First(String subtype,
2334 OrderByComparator orderByComparator) throws SystemException {
2335 List<Role> list = findBySubtype(subtype, 0, 1, orderByComparator);
2336
2337 if (!list.isEmpty()) {
2338 return list.get(0);
2339 }
2340
2341 return null;
2342 }
2343
2344
2353 public Role findBySubtype_Last(String subtype,
2354 OrderByComparator orderByComparator)
2355 throws NoSuchRoleException, SystemException {
2356 Role role = fetchBySubtype_Last(subtype, orderByComparator);
2357
2358 if (role != null) {
2359 return role;
2360 }
2361
2362 StringBundler msg = new StringBundler(4);
2363
2364 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2365
2366 msg.append("subtype=");
2367 msg.append(subtype);
2368
2369 msg.append(StringPool.CLOSE_CURLY_BRACE);
2370
2371 throw new NoSuchRoleException(msg.toString());
2372 }
2373
2374
2382 public Role fetchBySubtype_Last(String subtype,
2383 OrderByComparator orderByComparator) throws SystemException {
2384 int count = countBySubtype(subtype);
2385
2386 List<Role> list = findBySubtype(subtype, count - 1, count,
2387 orderByComparator);
2388
2389 if (!list.isEmpty()) {
2390 return list.get(0);
2391 }
2392
2393 return null;
2394 }
2395
2396
2406 public Role[] findBySubtype_PrevAndNext(long roleId, String subtype,
2407 OrderByComparator orderByComparator)
2408 throws NoSuchRoleException, SystemException {
2409 Role role = findByPrimaryKey(roleId);
2410
2411 Session session = null;
2412
2413 try {
2414 session = openSession();
2415
2416 Role[] array = new RoleImpl[3];
2417
2418 array[0] = getBySubtype_PrevAndNext(session, role, subtype,
2419 orderByComparator, true);
2420
2421 array[1] = role;
2422
2423 array[2] = getBySubtype_PrevAndNext(session, role, subtype,
2424 orderByComparator, false);
2425
2426 return array;
2427 }
2428 catch (Exception e) {
2429 throw processException(e);
2430 }
2431 finally {
2432 closeSession(session);
2433 }
2434 }
2435
2436 protected Role getBySubtype_PrevAndNext(Session session, Role role,
2437 String subtype, OrderByComparator orderByComparator, boolean previous) {
2438 StringBundler query = null;
2439
2440 if (orderByComparator != null) {
2441 query = new StringBundler(6 +
2442 (orderByComparator.getOrderByFields().length * 6));
2443 }
2444 else {
2445 query = new StringBundler(3);
2446 }
2447
2448 query.append(_SQL_SELECT_ROLE_WHERE);
2449
2450 if (subtype == null) {
2451 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
2452 }
2453 else {
2454 if (subtype.equals(StringPool.BLANK)) {
2455 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
2456 }
2457 else {
2458 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
2459 }
2460 }
2461
2462 if (orderByComparator != null) {
2463 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2464
2465 if (orderByConditionFields.length > 0) {
2466 query.append(WHERE_AND);
2467 }
2468
2469 for (int i = 0; i < orderByConditionFields.length; i++) {
2470 query.append(_ORDER_BY_ENTITY_ALIAS);
2471 query.append(orderByConditionFields[i]);
2472
2473 if ((i + 1) < orderByConditionFields.length) {
2474 if (orderByComparator.isAscending() ^ previous) {
2475 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2476 }
2477 else {
2478 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2479 }
2480 }
2481 else {
2482 if (orderByComparator.isAscending() ^ previous) {
2483 query.append(WHERE_GREATER_THAN);
2484 }
2485 else {
2486 query.append(WHERE_LESSER_THAN);
2487 }
2488 }
2489 }
2490
2491 query.append(ORDER_BY_CLAUSE);
2492
2493 String[] orderByFields = orderByComparator.getOrderByFields();
2494
2495 for (int i = 0; i < orderByFields.length; i++) {
2496 query.append(_ORDER_BY_ENTITY_ALIAS);
2497 query.append(orderByFields[i]);
2498
2499 if ((i + 1) < orderByFields.length) {
2500 if (orderByComparator.isAscending() ^ previous) {
2501 query.append(ORDER_BY_ASC_HAS_NEXT);
2502 }
2503 else {
2504 query.append(ORDER_BY_DESC_HAS_NEXT);
2505 }
2506 }
2507 else {
2508 if (orderByComparator.isAscending() ^ previous) {
2509 query.append(ORDER_BY_ASC);
2510 }
2511 else {
2512 query.append(ORDER_BY_DESC);
2513 }
2514 }
2515 }
2516 }
2517
2518 else {
2519 query.append(RoleModelImpl.ORDER_BY_JPQL);
2520 }
2521
2522 String sql = query.toString();
2523
2524 Query q = session.createQuery(sql);
2525
2526 q.setFirstResult(0);
2527 q.setMaxResults(2);
2528
2529 QueryPos qPos = QueryPos.getInstance(q);
2530
2531 if (subtype != null) {
2532 qPos.add(subtype);
2533 }
2534
2535 if (orderByComparator != null) {
2536 Object[] values = orderByComparator.getOrderByConditionValues(role);
2537
2538 for (Object value : values) {
2539 qPos.add(value);
2540 }
2541 }
2542
2543 List<Role> list = q.list();
2544
2545 if (list.size() == 2) {
2546 return list.get(1);
2547 }
2548 else {
2549 return null;
2550 }
2551 }
2552
2553
2560 public List<Role> filterFindBySubtype(String subtype)
2561 throws SystemException {
2562 return filterFindBySubtype(subtype, QueryUtil.ALL_POS,
2563 QueryUtil.ALL_POS, null);
2564 }
2565
2566
2579 public List<Role> filterFindBySubtype(String subtype, int start, int end)
2580 throws SystemException {
2581 return filterFindBySubtype(subtype, start, end, null);
2582 }
2583
2584
2598 public List<Role> filterFindBySubtype(String subtype, int start, int end,
2599 OrderByComparator orderByComparator) throws SystemException {
2600 if (!InlineSQLHelperUtil.isEnabled()) {
2601 return findBySubtype(subtype, start, end, orderByComparator);
2602 }
2603
2604 StringBundler query = null;
2605
2606 if (orderByComparator != null) {
2607 query = new StringBundler(3 +
2608 (orderByComparator.getOrderByFields().length * 3));
2609 }
2610 else {
2611 query = new StringBundler(3);
2612 }
2613
2614 if (getDB().isSupportsInlineDistinct()) {
2615 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
2616 }
2617 else {
2618 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
2619 }
2620
2621 if (subtype == null) {
2622 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
2623 }
2624 else {
2625 if (subtype.equals(StringPool.BLANK)) {
2626 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
2627 }
2628 else {
2629 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
2630 }
2631 }
2632
2633 if (!getDB().isSupportsInlineDistinct()) {
2634 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
2635 }
2636
2637 if (orderByComparator != null) {
2638 if (getDB().isSupportsInlineDistinct()) {
2639 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2640 orderByComparator);
2641 }
2642 else {
2643 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2644 orderByComparator);
2645 }
2646 }
2647
2648 else {
2649 if (getDB().isSupportsInlineDistinct()) {
2650 query.append(RoleModelImpl.ORDER_BY_JPQL);
2651 }
2652 else {
2653 query.append(RoleModelImpl.ORDER_BY_SQL);
2654 }
2655 }
2656
2657 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2658 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2659
2660 Session session = null;
2661
2662 try {
2663 session = openSession();
2664
2665 SQLQuery q = session.createSQLQuery(sql);
2666
2667 if (getDB().isSupportsInlineDistinct()) {
2668 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
2669 }
2670 else {
2671 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
2672 }
2673
2674 QueryPos qPos = QueryPos.getInstance(q);
2675
2676 if (subtype != null) {
2677 qPos.add(subtype);
2678 }
2679
2680 return (List<Role>)QueryUtil.list(q, getDialect(), start, end);
2681 }
2682 catch (Exception e) {
2683 throw processException(e);
2684 }
2685 finally {
2686 closeSession(session);
2687 }
2688 }
2689
2690
2700 public Role[] filterFindBySubtype_PrevAndNext(long roleId, String subtype,
2701 OrderByComparator orderByComparator)
2702 throws NoSuchRoleException, SystemException {
2703 if (!InlineSQLHelperUtil.isEnabled()) {
2704 return findBySubtype_PrevAndNext(roleId, subtype, orderByComparator);
2705 }
2706
2707 Role role = findByPrimaryKey(roleId);
2708
2709 Session session = null;
2710
2711 try {
2712 session = openSession();
2713
2714 Role[] array = new RoleImpl[3];
2715
2716 array[0] = filterGetBySubtype_PrevAndNext(session, role, subtype,
2717 orderByComparator, true);
2718
2719 array[1] = role;
2720
2721 array[2] = filterGetBySubtype_PrevAndNext(session, role, subtype,
2722 orderByComparator, false);
2723
2724 return array;
2725 }
2726 catch (Exception e) {
2727 throw processException(e);
2728 }
2729 finally {
2730 closeSession(session);
2731 }
2732 }
2733
2734 protected Role filterGetBySubtype_PrevAndNext(Session session, Role role,
2735 String subtype, OrderByComparator orderByComparator, boolean previous) {
2736 StringBundler query = null;
2737
2738 if (orderByComparator != null) {
2739 query = new StringBundler(6 +
2740 (orderByComparator.getOrderByFields().length * 6));
2741 }
2742 else {
2743 query = new StringBundler(3);
2744 }
2745
2746 if (getDB().isSupportsInlineDistinct()) {
2747 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
2748 }
2749 else {
2750 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
2751 }
2752
2753 if (subtype == null) {
2754 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
2755 }
2756 else {
2757 if (subtype.equals(StringPool.BLANK)) {
2758 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
2759 }
2760 else {
2761 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
2762 }
2763 }
2764
2765 if (!getDB().isSupportsInlineDistinct()) {
2766 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
2767 }
2768
2769 if (orderByComparator != null) {
2770 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2771
2772 if (orderByConditionFields.length > 0) {
2773 query.append(WHERE_AND);
2774 }
2775
2776 for (int i = 0; i < orderByConditionFields.length; i++) {
2777 if (getDB().isSupportsInlineDistinct()) {
2778 query.append(_ORDER_BY_ENTITY_ALIAS);
2779 }
2780 else {
2781 query.append(_ORDER_BY_ENTITY_TABLE);
2782 }
2783
2784 query.append(orderByConditionFields[i]);
2785
2786 if ((i + 1) < orderByConditionFields.length) {
2787 if (orderByComparator.isAscending() ^ previous) {
2788 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2789 }
2790 else {
2791 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2792 }
2793 }
2794 else {
2795 if (orderByComparator.isAscending() ^ previous) {
2796 query.append(WHERE_GREATER_THAN);
2797 }
2798 else {
2799 query.append(WHERE_LESSER_THAN);
2800 }
2801 }
2802 }
2803
2804 query.append(ORDER_BY_CLAUSE);
2805
2806 String[] orderByFields = orderByComparator.getOrderByFields();
2807
2808 for (int i = 0; i < orderByFields.length; i++) {
2809 if (getDB().isSupportsInlineDistinct()) {
2810 query.append(_ORDER_BY_ENTITY_ALIAS);
2811 }
2812 else {
2813 query.append(_ORDER_BY_ENTITY_TABLE);
2814 }
2815
2816 query.append(orderByFields[i]);
2817
2818 if ((i + 1) < orderByFields.length) {
2819 if (orderByComparator.isAscending() ^ previous) {
2820 query.append(ORDER_BY_ASC_HAS_NEXT);
2821 }
2822 else {
2823 query.append(ORDER_BY_DESC_HAS_NEXT);
2824 }
2825 }
2826 else {
2827 if (orderByComparator.isAscending() ^ previous) {
2828 query.append(ORDER_BY_ASC);
2829 }
2830 else {
2831 query.append(ORDER_BY_DESC);
2832 }
2833 }
2834 }
2835 }
2836
2837 else {
2838 if (getDB().isSupportsInlineDistinct()) {
2839 query.append(RoleModelImpl.ORDER_BY_JPQL);
2840 }
2841 else {
2842 query.append(RoleModelImpl.ORDER_BY_SQL);
2843 }
2844 }
2845
2846 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2847 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2848
2849 SQLQuery q = session.createSQLQuery(sql);
2850
2851 q.setFirstResult(0);
2852 q.setMaxResults(2);
2853
2854 if (getDB().isSupportsInlineDistinct()) {
2855 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
2856 }
2857 else {
2858 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
2859 }
2860
2861 QueryPos qPos = QueryPos.getInstance(q);
2862
2863 if (subtype != null) {
2864 qPos.add(subtype);
2865 }
2866
2867 if (orderByComparator != null) {
2868 Object[] values = orderByComparator.getOrderByConditionValues(role);
2869
2870 for (Object value : values) {
2871 qPos.add(value);
2872 }
2873 }
2874
2875 List<Role> list = q.list();
2876
2877 if (list.size() == 2) {
2878 return list.get(1);
2879 }
2880 else {
2881 return null;
2882 }
2883 }
2884
2885
2894 public Role findByC_N(long companyId, String name)
2895 throws NoSuchRoleException, SystemException {
2896 Role role = fetchByC_N(companyId, name);
2897
2898 if (role == null) {
2899 StringBundler msg = new StringBundler(6);
2900
2901 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2902
2903 msg.append("companyId=");
2904 msg.append(companyId);
2905
2906 msg.append(", name=");
2907 msg.append(name);
2908
2909 msg.append(StringPool.CLOSE_CURLY_BRACE);
2910
2911 if (_log.isWarnEnabled()) {
2912 _log.warn(msg.toString());
2913 }
2914
2915 throw new NoSuchRoleException(msg.toString());
2916 }
2917
2918 return role;
2919 }
2920
2921
2929 public Role fetchByC_N(long companyId, String name)
2930 throws SystemException {
2931 return fetchByC_N(companyId, name, true);
2932 }
2933
2934
2943 public Role fetchByC_N(long companyId, String name,
2944 boolean retrieveFromCache) throws SystemException {
2945 Object[] finderArgs = new Object[] { companyId, name };
2946
2947 Object result = null;
2948
2949 if (retrieveFromCache) {
2950 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_N,
2951 finderArgs, this);
2952 }
2953
2954 if (result instanceof Role) {
2955 Role role = (Role)result;
2956
2957 if ((companyId != role.getCompanyId()) ||
2958 !Validator.equals(name, role.getName())) {
2959 result = null;
2960 }
2961 }
2962
2963 if (result == null) {
2964 StringBundler query = new StringBundler(4);
2965
2966 query.append(_SQL_SELECT_ROLE_WHERE);
2967
2968 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
2969
2970 if (name == null) {
2971 query.append(_FINDER_COLUMN_C_N_NAME_1);
2972 }
2973 else {
2974 if (name.equals(StringPool.BLANK)) {
2975 query.append(_FINDER_COLUMN_C_N_NAME_3);
2976 }
2977 else {
2978 query.append(_FINDER_COLUMN_C_N_NAME_2);
2979 }
2980 }
2981
2982 query.append(RoleModelImpl.ORDER_BY_JPQL);
2983
2984 String sql = query.toString();
2985
2986 Session session = null;
2987
2988 try {
2989 session = openSession();
2990
2991 Query q = session.createQuery(sql);
2992
2993 QueryPos qPos = QueryPos.getInstance(q);
2994
2995 qPos.add(companyId);
2996
2997 if (name != null) {
2998 qPos.add(name);
2999 }
3000
3001 List<Role> list = q.list();
3002
3003 result = list;
3004
3005 Role role = null;
3006
3007 if (list.isEmpty()) {
3008 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
3009 finderArgs, list);
3010 }
3011 else {
3012 role = list.get(0);
3013
3014 cacheResult(role);
3015
3016 if ((role.getCompanyId() != companyId) ||
3017 (role.getName() == null) ||
3018 !role.getName().equals(name)) {
3019 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
3020 finderArgs, role);
3021 }
3022 }
3023
3024 return role;
3025 }
3026 catch (Exception e) {
3027 throw processException(e);
3028 }
3029 finally {
3030 if (result == null) {
3031 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
3032 finderArgs);
3033 }
3034
3035 closeSession(session);
3036 }
3037 }
3038 else {
3039 if (result instanceof List<?>) {
3040 return null;
3041 }
3042 else {
3043 return (Role)result;
3044 }
3045 }
3046 }
3047
3048
3056 public List<Role> findByT_S(int type, String subtype)
3057 throws SystemException {
3058 return findByT_S(type, subtype, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3059 null);
3060 }
3061
3062
3076 public List<Role> findByT_S(int type, String subtype, int start, int end)
3077 throws SystemException {
3078 return findByT_S(type, subtype, start, end, null);
3079 }
3080
3081
3096 public List<Role> findByT_S(int type, String subtype, int start, int end,
3097 OrderByComparator orderByComparator) throws SystemException {
3098 FinderPath finderPath = null;
3099 Object[] finderArgs = null;
3100
3101 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3102 (orderByComparator == null)) {
3103 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S;
3104 finderArgs = new Object[] { type, subtype };
3105 }
3106 else {
3107 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_T_S;
3108 finderArgs = new Object[] {
3109 type, subtype,
3110
3111 start, end, orderByComparator
3112 };
3113 }
3114
3115 List<Role> list = (List<Role>)FinderCacheUtil.getResult(finderPath,
3116 finderArgs, this);
3117
3118 if ((list != null) && !list.isEmpty()) {
3119 for (Role role : list) {
3120 if ((type != role.getType()) ||
3121 !Validator.equals(subtype, role.getSubtype())) {
3122 list = null;
3123
3124 break;
3125 }
3126 }
3127 }
3128
3129 if (list == null) {
3130 StringBundler query = null;
3131
3132 if (orderByComparator != null) {
3133 query = new StringBundler(4 +
3134 (orderByComparator.getOrderByFields().length * 3));
3135 }
3136 else {
3137 query = new StringBundler(4);
3138 }
3139
3140 query.append(_SQL_SELECT_ROLE_WHERE);
3141
3142 query.append(_FINDER_COLUMN_T_S_TYPE_2);
3143
3144 if (subtype == null) {
3145 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
3146 }
3147 else {
3148 if (subtype.equals(StringPool.BLANK)) {
3149 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
3150 }
3151 else {
3152 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
3153 }
3154 }
3155
3156 if (orderByComparator != null) {
3157 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3158 orderByComparator);
3159 }
3160
3161 else {
3162 query.append(RoleModelImpl.ORDER_BY_JPQL);
3163 }
3164
3165 String sql = query.toString();
3166
3167 Session session = null;
3168
3169 try {
3170 session = openSession();
3171
3172 Query q = session.createQuery(sql);
3173
3174 QueryPos qPos = QueryPos.getInstance(q);
3175
3176 qPos.add(type);
3177
3178 if (subtype != null) {
3179 qPos.add(subtype);
3180 }
3181
3182 list = (List<Role>)QueryUtil.list(q, getDialect(), start, end);
3183 }
3184 catch (Exception e) {
3185 throw processException(e);
3186 }
3187 finally {
3188 if (list == null) {
3189 FinderCacheUtil.removeResult(finderPath, finderArgs);
3190 }
3191 else {
3192 cacheResult(list);
3193
3194 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3195 }
3196
3197 closeSession(session);
3198 }
3199 }
3200
3201 return list;
3202 }
3203
3204
3214 public Role findByT_S_First(int type, String subtype,
3215 OrderByComparator orderByComparator)
3216 throws NoSuchRoleException, SystemException {
3217 Role role = fetchByT_S_First(type, subtype, orderByComparator);
3218
3219 if (role != null) {
3220 return role;
3221 }
3222
3223 StringBundler msg = new StringBundler(6);
3224
3225 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3226
3227 msg.append("type=");
3228 msg.append(type);
3229
3230 msg.append(", subtype=");
3231 msg.append(subtype);
3232
3233 msg.append(StringPool.CLOSE_CURLY_BRACE);
3234
3235 throw new NoSuchRoleException(msg.toString());
3236 }
3237
3238
3247 public Role fetchByT_S_First(int type, String subtype,
3248 OrderByComparator orderByComparator) throws SystemException {
3249 List<Role> list = findByT_S(type, subtype, 0, 1, orderByComparator);
3250
3251 if (!list.isEmpty()) {
3252 return list.get(0);
3253 }
3254
3255 return null;
3256 }
3257
3258
3268 public Role findByT_S_Last(int type, String subtype,
3269 OrderByComparator orderByComparator)
3270 throws NoSuchRoleException, SystemException {
3271 Role role = fetchByT_S_Last(type, subtype, orderByComparator);
3272
3273 if (role != null) {
3274 return role;
3275 }
3276
3277 StringBundler msg = new StringBundler(6);
3278
3279 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3280
3281 msg.append("type=");
3282 msg.append(type);
3283
3284 msg.append(", subtype=");
3285 msg.append(subtype);
3286
3287 msg.append(StringPool.CLOSE_CURLY_BRACE);
3288
3289 throw new NoSuchRoleException(msg.toString());
3290 }
3291
3292
3301 public Role fetchByT_S_Last(int type, String subtype,
3302 OrderByComparator orderByComparator) throws SystemException {
3303 int count = countByT_S(type, subtype);
3304
3305 List<Role> list = findByT_S(type, subtype, count - 1, count,
3306 orderByComparator);
3307
3308 if (!list.isEmpty()) {
3309 return list.get(0);
3310 }
3311
3312 return null;
3313 }
3314
3315
3326 public Role[] findByT_S_PrevAndNext(long roleId, int type, String subtype,
3327 OrderByComparator orderByComparator)
3328 throws NoSuchRoleException, SystemException {
3329 Role role = findByPrimaryKey(roleId);
3330
3331 Session session = null;
3332
3333 try {
3334 session = openSession();
3335
3336 Role[] array = new RoleImpl[3];
3337
3338 array[0] = getByT_S_PrevAndNext(session, role, type, subtype,
3339 orderByComparator, true);
3340
3341 array[1] = role;
3342
3343 array[2] = getByT_S_PrevAndNext(session, role, type, subtype,
3344 orderByComparator, false);
3345
3346 return array;
3347 }
3348 catch (Exception e) {
3349 throw processException(e);
3350 }
3351 finally {
3352 closeSession(session);
3353 }
3354 }
3355
3356 protected Role getByT_S_PrevAndNext(Session session, Role role, int type,
3357 String subtype, OrderByComparator orderByComparator, boolean previous) {
3358 StringBundler query = null;
3359
3360 if (orderByComparator != null) {
3361 query = new StringBundler(6 +
3362 (orderByComparator.getOrderByFields().length * 6));
3363 }
3364 else {
3365 query = new StringBundler(3);
3366 }
3367
3368 query.append(_SQL_SELECT_ROLE_WHERE);
3369
3370 query.append(_FINDER_COLUMN_T_S_TYPE_2);
3371
3372 if (subtype == null) {
3373 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
3374 }
3375 else {
3376 if (subtype.equals(StringPool.BLANK)) {
3377 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
3378 }
3379 else {
3380 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
3381 }
3382 }
3383
3384 if (orderByComparator != null) {
3385 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3386
3387 if (orderByConditionFields.length > 0) {
3388 query.append(WHERE_AND);
3389 }
3390
3391 for (int i = 0; i < orderByConditionFields.length; i++) {
3392 query.append(_ORDER_BY_ENTITY_ALIAS);
3393 query.append(orderByConditionFields[i]);
3394
3395 if ((i + 1) < orderByConditionFields.length) {
3396 if (orderByComparator.isAscending() ^ previous) {
3397 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3398 }
3399 else {
3400 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3401 }
3402 }
3403 else {
3404 if (orderByComparator.isAscending() ^ previous) {
3405 query.append(WHERE_GREATER_THAN);
3406 }
3407 else {
3408 query.append(WHERE_LESSER_THAN);
3409 }
3410 }
3411 }
3412
3413 query.append(ORDER_BY_CLAUSE);
3414
3415 String[] orderByFields = orderByComparator.getOrderByFields();
3416
3417 for (int i = 0; i < orderByFields.length; i++) {
3418 query.append(_ORDER_BY_ENTITY_ALIAS);
3419 query.append(orderByFields[i]);
3420
3421 if ((i + 1) < orderByFields.length) {
3422 if (orderByComparator.isAscending() ^ previous) {
3423 query.append(ORDER_BY_ASC_HAS_NEXT);
3424 }
3425 else {
3426 query.append(ORDER_BY_DESC_HAS_NEXT);
3427 }
3428 }
3429 else {
3430 if (orderByComparator.isAscending() ^ previous) {
3431 query.append(ORDER_BY_ASC);
3432 }
3433 else {
3434 query.append(ORDER_BY_DESC);
3435 }
3436 }
3437 }
3438 }
3439
3440 else {
3441 query.append(RoleModelImpl.ORDER_BY_JPQL);
3442 }
3443
3444 String sql = query.toString();
3445
3446 Query q = session.createQuery(sql);
3447
3448 q.setFirstResult(0);
3449 q.setMaxResults(2);
3450
3451 QueryPos qPos = QueryPos.getInstance(q);
3452
3453 qPos.add(type);
3454
3455 if (subtype != null) {
3456 qPos.add(subtype);
3457 }
3458
3459 if (orderByComparator != null) {
3460 Object[] values = orderByComparator.getOrderByConditionValues(role);
3461
3462 for (Object value : values) {
3463 qPos.add(value);
3464 }
3465 }
3466
3467 List<Role> list = q.list();
3468
3469 if (list.size() == 2) {
3470 return list.get(1);
3471 }
3472 else {
3473 return null;
3474 }
3475 }
3476
3477
3485 public List<Role> filterFindByT_S(int type, String subtype)
3486 throws SystemException {
3487 return filterFindByT_S(type, subtype, QueryUtil.ALL_POS,
3488 QueryUtil.ALL_POS, null);
3489 }
3490
3491
3505 public List<Role> filterFindByT_S(int type, String subtype, int start,
3506 int end) throws SystemException {
3507 return filterFindByT_S(type, subtype, start, end, null);
3508 }
3509
3510
3525 public List<Role> filterFindByT_S(int type, String subtype, int start,
3526 int end, OrderByComparator orderByComparator) throws SystemException {
3527 if (!InlineSQLHelperUtil.isEnabled()) {
3528 return findByT_S(type, subtype, start, end, orderByComparator);
3529 }
3530
3531 StringBundler query = null;
3532
3533 if (orderByComparator != null) {
3534 query = new StringBundler(4 +
3535 (orderByComparator.getOrderByFields().length * 3));
3536 }
3537 else {
3538 query = new StringBundler(4);
3539 }
3540
3541 if (getDB().isSupportsInlineDistinct()) {
3542 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
3543 }
3544 else {
3545 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
3546 }
3547
3548 query.append(_FINDER_COLUMN_T_S_TYPE_2);
3549
3550 if (subtype == null) {
3551 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
3552 }
3553 else {
3554 if (subtype.equals(StringPool.BLANK)) {
3555 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
3556 }
3557 else {
3558 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
3559 }
3560 }
3561
3562 if (!getDB().isSupportsInlineDistinct()) {
3563 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
3564 }
3565
3566 if (orderByComparator != null) {
3567 if (getDB().isSupportsInlineDistinct()) {
3568 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3569 orderByComparator);
3570 }
3571 else {
3572 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3573 orderByComparator);
3574 }
3575 }
3576
3577 else {
3578 if (getDB().isSupportsInlineDistinct()) {
3579 query.append(RoleModelImpl.ORDER_BY_JPQL);
3580 }
3581 else {
3582 query.append(RoleModelImpl.ORDER_BY_SQL);
3583 }
3584 }
3585
3586 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3587 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3588
3589 Session session = null;
3590
3591 try {
3592 session = openSession();
3593
3594 SQLQuery q = session.createSQLQuery(sql);
3595
3596 if (getDB().isSupportsInlineDistinct()) {
3597 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
3598 }
3599 else {
3600 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
3601 }
3602
3603 QueryPos qPos = QueryPos.getInstance(q);
3604
3605 qPos.add(type);
3606
3607 if (subtype != null) {
3608 qPos.add(subtype);
3609 }
3610
3611 return (List<Role>)QueryUtil.list(q, getDialect(), start, end);
3612 }
3613 catch (Exception e) {
3614 throw processException(e);
3615 }
3616 finally {
3617 closeSession(session);
3618 }
3619 }
3620
3621
3632 public Role[] filterFindByT_S_PrevAndNext(long roleId, int type,
3633 String subtype, OrderByComparator orderByComparator)
3634 throws NoSuchRoleException, SystemException {
3635 if (!InlineSQLHelperUtil.isEnabled()) {
3636 return findByT_S_PrevAndNext(roleId, type, subtype,
3637 orderByComparator);
3638 }
3639
3640 Role role = findByPrimaryKey(roleId);
3641
3642 Session session = null;
3643
3644 try {
3645 session = openSession();
3646
3647 Role[] array = new RoleImpl[3];
3648
3649 array[0] = filterGetByT_S_PrevAndNext(session, role, type, subtype,
3650 orderByComparator, true);
3651
3652 array[1] = role;
3653
3654 array[2] = filterGetByT_S_PrevAndNext(session, role, type, subtype,
3655 orderByComparator, false);
3656
3657 return array;
3658 }
3659 catch (Exception e) {
3660 throw processException(e);
3661 }
3662 finally {
3663 closeSession(session);
3664 }
3665 }
3666
3667 protected Role filterGetByT_S_PrevAndNext(Session session, Role role,
3668 int type, String subtype, OrderByComparator orderByComparator,
3669 boolean previous) {
3670 StringBundler query = null;
3671
3672 if (orderByComparator != null) {
3673 query = new StringBundler(6 +
3674 (orderByComparator.getOrderByFields().length * 6));
3675 }
3676 else {
3677 query = new StringBundler(3);
3678 }
3679
3680 if (getDB().isSupportsInlineDistinct()) {
3681 query.append(_FILTER_SQL_SELECT_ROLE_WHERE);
3682 }
3683 else {
3684 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1);
3685 }
3686
3687 query.append(_FINDER_COLUMN_T_S_TYPE_2);
3688
3689 if (subtype == null) {
3690 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
3691 }
3692 else {
3693 if (subtype.equals(StringPool.BLANK)) {
3694 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
3695 }
3696 else {
3697 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
3698 }
3699 }
3700
3701 if (!getDB().isSupportsInlineDistinct()) {
3702 query.append(_FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2);
3703 }
3704
3705 if (orderByComparator != null) {
3706 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3707
3708 if (orderByConditionFields.length > 0) {
3709 query.append(WHERE_AND);
3710 }
3711
3712 for (int i = 0; i < orderByConditionFields.length; i++) {
3713 if (getDB().isSupportsInlineDistinct()) {
3714 query.append(_ORDER_BY_ENTITY_ALIAS);
3715 }
3716 else {
3717 query.append(_ORDER_BY_ENTITY_TABLE);
3718 }
3719
3720 query.append(orderByConditionFields[i]);
3721
3722 if ((i + 1) < orderByConditionFields.length) {
3723 if (orderByComparator.isAscending() ^ previous) {
3724 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3725 }
3726 else {
3727 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3728 }
3729 }
3730 else {
3731 if (orderByComparator.isAscending() ^ previous) {
3732 query.append(WHERE_GREATER_THAN);
3733 }
3734 else {
3735 query.append(WHERE_LESSER_THAN);
3736 }
3737 }
3738 }
3739
3740 query.append(ORDER_BY_CLAUSE);
3741
3742 String[] orderByFields = orderByComparator.getOrderByFields();
3743
3744 for (int i = 0; i < orderByFields.length; i++) {
3745 if (getDB().isSupportsInlineDistinct()) {
3746 query.append(_ORDER_BY_ENTITY_ALIAS);
3747 }
3748 else {
3749 query.append(_ORDER_BY_ENTITY_TABLE);
3750 }
3751
3752 query.append(orderByFields[i]);
3753
3754 if ((i + 1) < orderByFields.length) {
3755 if (orderByComparator.isAscending() ^ previous) {
3756 query.append(ORDER_BY_ASC_HAS_NEXT);
3757 }
3758 else {
3759 query.append(ORDER_BY_DESC_HAS_NEXT);
3760 }
3761 }
3762 else {
3763 if (orderByComparator.isAscending() ^ previous) {
3764 query.append(ORDER_BY_ASC);
3765 }
3766 else {
3767 query.append(ORDER_BY_DESC);
3768 }
3769 }
3770 }
3771 }
3772
3773 else {
3774 if (getDB().isSupportsInlineDistinct()) {
3775 query.append(RoleModelImpl.ORDER_BY_JPQL);
3776 }
3777 else {
3778 query.append(RoleModelImpl.ORDER_BY_SQL);
3779 }
3780 }
3781
3782 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3783 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3784
3785 SQLQuery q = session.createSQLQuery(sql);
3786
3787 q.setFirstResult(0);
3788 q.setMaxResults(2);
3789
3790 if (getDB().isSupportsInlineDistinct()) {
3791 q.addEntity(_FILTER_ENTITY_ALIAS, RoleImpl.class);
3792 }
3793 else {
3794 q.addEntity(_FILTER_ENTITY_TABLE, RoleImpl.class);
3795 }
3796
3797 QueryPos qPos = QueryPos.getInstance(q);
3798
3799 qPos.add(type);
3800
3801 if (subtype != null) {
3802 qPos.add(subtype);
3803 }
3804
3805 if (orderByComparator != null) {
3806 Object[] values = orderByComparator.getOrderByConditionValues(role);
3807
3808 for (Object value : values) {
3809 qPos.add(value);
3810 }
3811 }
3812
3813 List<Role> list = q.list();
3814
3815 if (list.size() == 2) {
3816 return list.get(1);
3817 }
3818 else {
3819 return null;
3820 }
3821 }
3822
3823
3833 public Role findByC_C_C(long companyId, long classNameId, long classPK)
3834 throws NoSuchRoleException, SystemException {
3835 Role role = fetchByC_C_C(companyId, classNameId, classPK);
3836
3837 if (role == null) {
3838 StringBundler msg = new StringBundler(8);
3839
3840 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3841
3842 msg.append("companyId=");
3843 msg.append(companyId);
3844
3845 msg.append(", classNameId=");
3846 msg.append(classNameId);
3847
3848 msg.append(", classPK=");
3849 msg.append(classPK);
3850
3851 msg.append(StringPool.CLOSE_CURLY_BRACE);
3852
3853 if (_log.isWarnEnabled()) {
3854 _log.warn(msg.toString());
3855 }
3856
3857 throw new NoSuchRoleException(msg.toString());
3858 }
3859
3860 return role;
3861 }
3862
3863
3872 public Role fetchByC_C_C(long companyId, long classNameId, long classPK)
3873 throws SystemException {
3874 return fetchByC_C_C(companyId, classNameId, classPK, true);
3875 }
3876
3877
3887 public Role fetchByC_C_C(long companyId, long classNameId, long classPK,
3888 boolean retrieveFromCache) throws SystemException {
3889 Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
3890
3891 Object result = null;
3892
3893 if (retrieveFromCache) {
3894 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C_C,
3895 finderArgs, this);
3896 }
3897
3898 if (result instanceof Role) {
3899 Role role = (Role)result;
3900
3901 if ((companyId != role.getCompanyId()) ||
3902 (classNameId != role.getClassNameId()) ||
3903 (classPK != role.getClassPK())) {
3904 result = null;
3905 }
3906 }
3907
3908 if (result == null) {
3909 StringBundler query = new StringBundler(5);
3910
3911 query.append(_SQL_SELECT_ROLE_WHERE);
3912
3913 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
3914
3915 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
3916
3917 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
3918
3919 query.append(RoleModelImpl.ORDER_BY_JPQL);
3920
3921 String sql = query.toString();
3922
3923 Session session = null;
3924
3925 try {
3926 session = openSession();
3927
3928 Query q = session.createQuery(sql);
3929
3930 QueryPos qPos = QueryPos.getInstance(q);
3931
3932 qPos.add(companyId);
3933
3934 qPos.add(classNameId);
3935
3936 qPos.add(classPK);
3937
3938 List<Role> list = q.list();
3939
3940 result = list;
3941
3942 Role role = null;
3943
3944 if (list.isEmpty()) {
3945 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
3946 finderArgs, list);
3947 }
3948 else {
3949 role = list.get(0);
3950
3951 cacheResult(role);
3952
3953 if ((role.getCompanyId() != companyId) ||
3954 (role.getClassNameId() != classNameId) ||
3955 (role.getClassPK() != classPK)) {
3956 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
3957 finderArgs, role);
3958 }
3959 }
3960
3961 return role;
3962 }
3963 catch (Exception e) {
3964 throw processException(e);
3965 }
3966 finally {
3967 if (result == null) {
3968 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C,
3969 finderArgs);
3970 }
3971
3972 closeSession(session);
3973 }
3974 }
3975 else {
3976 if (result instanceof List<?>) {
3977 return null;
3978 }
3979 else {
3980 return (Role)result;
3981 }
3982 }
3983 }
3984
3985
3991 public List<Role> findAll() throws SystemException {
3992 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3993 }
3994
3995
4007 public List<Role> findAll(int start, int end) throws SystemException {
4008 return findAll(start, end, null);
4009 }
4010
4011
4024 public List<Role> findAll(int start, int end,
4025 OrderByComparator orderByComparator) throws SystemException {
4026 FinderPath finderPath = null;
4027 Object[] finderArgs = new Object[] { start, end, orderByComparator };
4028
4029 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4030 (orderByComparator == null)) {
4031 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
4032 finderArgs = FINDER_ARGS_EMPTY;
4033 }
4034 else {
4035 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
4036 finderArgs = new Object[] { start, end, orderByComparator };
4037 }
4038
4039 List<Role> list = (List<Role>)FinderCacheUtil.getResult(finderPath,
4040 finderArgs, this);
4041
4042 if (list == null) {
4043 StringBundler query = null;
4044 String sql = null;
4045
4046 if (orderByComparator != null) {
4047 query = new StringBundler(2 +
4048 (orderByComparator.getOrderByFields().length * 3));
4049
4050 query.append(_SQL_SELECT_ROLE);
4051
4052 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4053 orderByComparator);
4054
4055 sql = query.toString();
4056 }
4057 else {
4058 sql = _SQL_SELECT_ROLE.concat(RoleModelImpl.ORDER_BY_JPQL);
4059 }
4060
4061 Session session = null;
4062
4063 try {
4064 session = openSession();
4065
4066 Query q = session.createQuery(sql);
4067
4068 if (orderByComparator == null) {
4069 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
4070 end, false);
4071
4072 Collections.sort(list);
4073 }
4074 else {
4075 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
4076 end);
4077 }
4078 }
4079 catch (Exception e) {
4080 throw processException(e);
4081 }
4082 finally {
4083 if (list == null) {
4084 FinderCacheUtil.removeResult(finderPath, finderArgs);
4085 }
4086 else {
4087 cacheResult(list);
4088
4089 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4090 }
4091
4092 closeSession(session);
4093 }
4094 }
4095
4096 return list;
4097 }
4098
4099
4105 public void removeByCompanyId(long companyId) throws SystemException {
4106 for (Role role : findByCompanyId(companyId)) {
4107 remove(role);
4108 }
4109 }
4110
4111
4117 public void removeByName(String name) throws SystemException {
4118 for (Role role : findByName(name)) {
4119 remove(role);
4120 }
4121 }
4122
4123
4129 public void removeBySubtype(String subtype) throws SystemException {
4130 for (Role role : findBySubtype(subtype)) {
4131 remove(role);
4132 }
4133 }
4134
4135
4143 public Role removeByC_N(long companyId, String name)
4144 throws NoSuchRoleException, SystemException {
4145 Role role = findByC_N(companyId, name);
4146
4147 return remove(role);
4148 }
4149
4150
4157 public void removeByT_S(int type, String subtype) throws SystemException {
4158 for (Role role : findByT_S(type, subtype)) {
4159 remove(role);
4160 }
4161 }
4162
4163
4172 public Role removeByC_C_C(long companyId, long classNameId, long classPK)
4173 throws NoSuchRoleException, SystemException {
4174 Role role = findByC_C_C(companyId, classNameId, classPK);
4175
4176 return remove(role);
4177 }
4178
4179
4184 public void removeAll() throws SystemException {
4185 for (Role role : findAll()) {
4186 remove(role);
4187 }
4188 }
4189
4190
4197 public int countByCompanyId(long companyId) throws SystemException {
4198 Object[] finderArgs = new Object[] { companyId };
4199
4200 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
4201 finderArgs, this);
4202
4203 if (count == null) {
4204 StringBundler query = new StringBundler(2);
4205
4206 query.append(_SQL_COUNT_ROLE_WHERE);
4207
4208 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
4209
4210 String sql = query.toString();
4211
4212 Session session = null;
4213
4214 try {
4215 session = openSession();
4216
4217 Query q = session.createQuery(sql);
4218
4219 QueryPos qPos = QueryPos.getInstance(q);
4220
4221 qPos.add(companyId);
4222
4223 count = (Long)q.uniqueResult();
4224 }
4225 catch (Exception e) {
4226 throw processException(e);
4227 }
4228 finally {
4229 if (count == null) {
4230 count = Long.valueOf(0);
4231 }
4232
4233 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
4234 finderArgs, count);
4235
4236 closeSession(session);
4237 }
4238 }
4239
4240 return count.intValue();
4241 }
4242
4243
4250 public int filterCountByCompanyId(long companyId) throws SystemException {
4251 if (!InlineSQLHelperUtil.isEnabled()) {
4252 return countByCompanyId(companyId);
4253 }
4254
4255 StringBundler query = new StringBundler(2);
4256
4257 query.append(_FILTER_SQL_COUNT_ROLE_WHERE);
4258
4259 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
4260
4261 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4262 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4263
4264 Session session = null;
4265
4266 try {
4267 session = openSession();
4268
4269 SQLQuery q = session.createSQLQuery(sql);
4270
4271 q.addScalar(COUNT_COLUMN_NAME,
4272 com.liferay.portal.kernel.dao.orm.Type.LONG);
4273
4274 QueryPos qPos = QueryPos.getInstance(q);
4275
4276 qPos.add(companyId);
4277
4278 Long count = (Long)q.uniqueResult();
4279
4280 return count.intValue();
4281 }
4282 catch (Exception e) {
4283 throw processException(e);
4284 }
4285 finally {
4286 closeSession(session);
4287 }
4288 }
4289
4290
4297 public int countByName(String name) throws SystemException {
4298 Object[] finderArgs = new Object[] { name };
4299
4300 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_NAME,
4301 finderArgs, this);
4302
4303 if (count == null) {
4304 StringBundler query = new StringBundler(2);
4305
4306 query.append(_SQL_COUNT_ROLE_WHERE);
4307
4308 if (name == null) {
4309 query.append(_FINDER_COLUMN_NAME_NAME_1);
4310 }
4311 else {
4312 if (name.equals(StringPool.BLANK)) {
4313 query.append(_FINDER_COLUMN_NAME_NAME_3);
4314 }
4315 else {
4316 query.append(_FINDER_COLUMN_NAME_NAME_2);
4317 }
4318 }
4319
4320 String sql = query.toString();
4321
4322 Session session = null;
4323
4324 try {
4325 session = openSession();
4326
4327 Query q = session.createQuery(sql);
4328
4329 QueryPos qPos = QueryPos.getInstance(q);
4330
4331 if (name != null) {
4332 qPos.add(name);
4333 }
4334
4335 count = (Long)q.uniqueResult();
4336 }
4337 catch (Exception e) {
4338 throw processException(e);
4339 }
4340 finally {
4341 if (count == null) {
4342 count = Long.valueOf(0);
4343 }
4344
4345 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_NAME,
4346 finderArgs, count);
4347
4348 closeSession(session);
4349 }
4350 }
4351
4352 return count.intValue();
4353 }
4354
4355
4362 public int filterCountByName(String name) throws SystemException {
4363 if (!InlineSQLHelperUtil.isEnabled()) {
4364 return countByName(name);
4365 }
4366
4367 StringBundler query = new StringBundler(2);
4368
4369 query.append(_FILTER_SQL_COUNT_ROLE_WHERE);
4370
4371 if (name == null) {
4372 query.append(_FINDER_COLUMN_NAME_NAME_1);
4373 }
4374 else {
4375 if (name.equals(StringPool.BLANK)) {
4376 query.append(_FINDER_COLUMN_NAME_NAME_3);
4377 }
4378 else {
4379 query.append(_FINDER_COLUMN_NAME_NAME_2);
4380 }
4381 }
4382
4383 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4384 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4385
4386 Session session = null;
4387
4388 try {
4389 session = openSession();
4390
4391 SQLQuery q = session.createSQLQuery(sql);
4392
4393 q.addScalar(COUNT_COLUMN_NAME,
4394 com.liferay.portal.kernel.dao.orm.Type.LONG);
4395
4396 QueryPos qPos = QueryPos.getInstance(q);
4397
4398 if (name != null) {
4399 qPos.add(name);
4400 }
4401
4402 Long count = (Long)q.uniqueResult();
4403
4404 return count.intValue();
4405 }
4406 catch (Exception e) {
4407 throw processException(e);
4408 }
4409 finally {
4410 closeSession(session);
4411 }
4412 }
4413
4414
4421 public int countBySubtype(String subtype) throws SystemException {
4422 Object[] finderArgs = new Object[] { subtype };
4423
4424 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SUBTYPE,
4425 finderArgs, this);
4426
4427 if (count == null) {
4428 StringBundler query = new StringBundler(2);
4429
4430 query.append(_SQL_COUNT_ROLE_WHERE);
4431
4432 if (subtype == null) {
4433 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
4434 }
4435 else {
4436 if (subtype.equals(StringPool.BLANK)) {
4437 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
4438 }
4439 else {
4440 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
4441 }
4442 }
4443
4444 String sql = query.toString();
4445
4446 Session session = null;
4447
4448 try {
4449 session = openSession();
4450
4451 Query q = session.createQuery(sql);
4452
4453 QueryPos qPos = QueryPos.getInstance(q);
4454
4455 if (subtype != null) {
4456 qPos.add(subtype);
4457 }
4458
4459 count = (Long)q.uniqueResult();
4460 }
4461 catch (Exception e) {
4462 throw processException(e);
4463 }
4464 finally {
4465 if (count == null) {
4466 count = Long.valueOf(0);
4467 }
4468
4469 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SUBTYPE,
4470 finderArgs, count);
4471
4472 closeSession(session);
4473 }
4474 }
4475
4476 return count.intValue();
4477 }
4478
4479
4486 public int filterCountBySubtype(String subtype) throws SystemException {
4487 if (!InlineSQLHelperUtil.isEnabled()) {
4488 return countBySubtype(subtype);
4489 }
4490
4491 StringBundler query = new StringBundler(2);
4492
4493 query.append(_FILTER_SQL_COUNT_ROLE_WHERE);
4494
4495 if (subtype == null) {
4496 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
4497 }
4498 else {
4499 if (subtype.equals(StringPool.BLANK)) {
4500 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
4501 }
4502 else {
4503 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
4504 }
4505 }
4506
4507 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4508 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4509
4510 Session session = null;
4511
4512 try {
4513 session = openSession();
4514
4515 SQLQuery q = session.createSQLQuery(sql);
4516
4517 q.addScalar(COUNT_COLUMN_NAME,
4518 com.liferay.portal.kernel.dao.orm.Type.LONG);
4519
4520 QueryPos qPos = QueryPos.getInstance(q);
4521
4522 if (subtype != null) {
4523 qPos.add(subtype);
4524 }
4525
4526 Long count = (Long)q.uniqueResult();
4527
4528 return count.intValue();
4529 }
4530 catch (Exception e) {
4531 throw processException(e);
4532 }
4533 finally {
4534 closeSession(session);
4535 }
4536 }
4537
4538
4546 public int countByC_N(long companyId, String name)
4547 throws SystemException {
4548 Object[] finderArgs = new Object[] { companyId, name };
4549
4550 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_N,
4551 finderArgs, this);
4552
4553 if (count == null) {
4554 StringBundler query = new StringBundler(3);
4555
4556 query.append(_SQL_COUNT_ROLE_WHERE);
4557
4558 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
4559
4560 if (name == null) {
4561 query.append(_FINDER_COLUMN_C_N_NAME_1);
4562 }
4563 else {
4564 if (name.equals(StringPool.BLANK)) {
4565 query.append(_FINDER_COLUMN_C_N_NAME_3);
4566 }
4567 else {
4568 query.append(_FINDER_COLUMN_C_N_NAME_2);
4569 }
4570 }
4571
4572 String sql = query.toString();
4573
4574 Session session = null;
4575
4576 try {
4577 session = openSession();
4578
4579 Query q = session.createQuery(sql);
4580
4581 QueryPos qPos = QueryPos.getInstance(q);
4582
4583 qPos.add(companyId);
4584
4585 if (name != null) {
4586 qPos.add(name);
4587 }
4588
4589 count = (Long)q.uniqueResult();
4590 }
4591 catch (Exception e) {
4592 throw processException(e);
4593 }
4594 finally {
4595 if (count == null) {
4596 count = Long.valueOf(0);
4597 }
4598
4599 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, finderArgs,
4600 count);
4601
4602 closeSession(session);
4603 }
4604 }
4605
4606 return count.intValue();
4607 }
4608
4609
4617 public int countByT_S(int type, String subtype) throws SystemException {
4618 Object[] finderArgs = new Object[] { type, subtype };
4619
4620 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_T_S,
4621 finderArgs, this);
4622
4623 if (count == null) {
4624 StringBundler query = new StringBundler(3);
4625
4626 query.append(_SQL_COUNT_ROLE_WHERE);
4627
4628 query.append(_FINDER_COLUMN_T_S_TYPE_2);
4629
4630 if (subtype == null) {
4631 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
4632 }
4633 else {
4634 if (subtype.equals(StringPool.BLANK)) {
4635 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
4636 }
4637 else {
4638 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
4639 }
4640 }
4641
4642 String sql = query.toString();
4643
4644 Session session = null;
4645
4646 try {
4647 session = openSession();
4648
4649 Query q = session.createQuery(sql);
4650
4651 QueryPos qPos = QueryPos.getInstance(q);
4652
4653 qPos.add(type);
4654
4655 if (subtype != null) {
4656 qPos.add(subtype);
4657 }
4658
4659 count = (Long)q.uniqueResult();
4660 }
4661 catch (Exception e) {
4662 throw processException(e);
4663 }
4664 finally {
4665 if (count == null) {
4666 count = Long.valueOf(0);
4667 }
4668
4669 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_S, finderArgs,
4670 count);
4671
4672 closeSession(session);
4673 }
4674 }
4675
4676 return count.intValue();
4677 }
4678
4679
4687 public int filterCountByT_S(int type, String subtype)
4688 throws SystemException {
4689 if (!InlineSQLHelperUtil.isEnabled()) {
4690 return countByT_S(type, subtype);
4691 }
4692
4693 StringBundler query = new StringBundler(3);
4694
4695 query.append(_FILTER_SQL_COUNT_ROLE_WHERE);
4696
4697 query.append(_FINDER_COLUMN_T_S_TYPE_2);
4698
4699 if (subtype == null) {
4700 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
4701 }
4702 else {
4703 if (subtype.equals(StringPool.BLANK)) {
4704 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
4705 }
4706 else {
4707 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
4708 }
4709 }
4710
4711 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4712 Role.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4713
4714 Session session = null;
4715
4716 try {
4717 session = openSession();
4718
4719 SQLQuery q = session.createSQLQuery(sql);
4720
4721 q.addScalar(COUNT_COLUMN_NAME,
4722 com.liferay.portal.kernel.dao.orm.Type.LONG);
4723
4724 QueryPos qPos = QueryPos.getInstance(q);
4725
4726 qPos.add(type);
4727
4728 if (subtype != null) {
4729 qPos.add(subtype);
4730 }
4731
4732 Long count = (Long)q.uniqueResult();
4733
4734 return count.intValue();
4735 }
4736 catch (Exception e) {
4737 throw processException(e);
4738 }
4739 finally {
4740 closeSession(session);
4741 }
4742 }
4743
4744
4753 public int countByC_C_C(long companyId, long classNameId, long classPK)
4754 throws SystemException {
4755 Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
4756
4757 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_C,
4758 finderArgs, this);
4759
4760 if (count == null) {
4761 StringBundler query = new StringBundler(4);
4762
4763 query.append(_SQL_COUNT_ROLE_WHERE);
4764
4765 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
4766
4767 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
4768
4769 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
4770
4771 String sql = query.toString();
4772
4773 Session session = null;
4774
4775 try {
4776 session = openSession();
4777
4778 Query q = session.createQuery(sql);
4779
4780 QueryPos qPos = QueryPos.getInstance(q);
4781
4782 qPos.add(companyId);
4783
4784 qPos.add(classNameId);
4785
4786 qPos.add(classPK);
4787
4788 count = (Long)q.uniqueResult();
4789 }
4790 catch (Exception e) {
4791 throw processException(e);
4792 }
4793 finally {
4794 if (count == null) {
4795 count = Long.valueOf(0);
4796 }
4797
4798 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C,
4799 finderArgs, count);
4800
4801 closeSession(session);
4802 }
4803 }
4804
4805 return count.intValue();
4806 }
4807
4808
4814 public int countAll() throws SystemException {
4815 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4816 FINDER_ARGS_EMPTY, this);
4817
4818 if (count == null) {
4819 Session session = null;
4820
4821 try {
4822 session = openSession();
4823
4824 Query q = session.createQuery(_SQL_COUNT_ROLE);
4825
4826 count = (Long)q.uniqueResult();
4827 }
4828 catch (Exception e) {
4829 throw processException(e);
4830 }
4831 finally {
4832 if (count == null) {
4833 count = Long.valueOf(0);
4834 }
4835
4836 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
4837 FINDER_ARGS_EMPTY, count);
4838
4839 closeSession(session);
4840 }
4841 }
4842
4843 return count.intValue();
4844 }
4845
4846
4853 public List<com.liferay.portal.model.Group> getGroups(long pk)
4854 throws SystemException {
4855 return getGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
4856 }
4857
4858
4871 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
4872 int end) throws SystemException {
4873 return getGroups(pk, start, end, null);
4874 }
4875
4876 public static final FinderPath FINDER_PATH_GET_GROUPS = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
4877 RoleModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES,
4878 com.liferay.portal.model.impl.GroupImpl.class,
4879 RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "getGroups",
4880 new String[] {
4881 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
4882 "com.liferay.portal.kernel.util.OrderByComparator"
4883 });
4884
4885 static {
4886 FINDER_PATH_GET_GROUPS.setCacheKeyGeneratorCacheName(null);
4887 }
4888
4889
4903 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
4904 int end, OrderByComparator orderByComparator) throws SystemException {
4905 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
4906
4907 List<com.liferay.portal.model.Group> list = (List<com.liferay.portal.model.Group>)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS,
4908 finderArgs, this);
4909
4910 if (list == null) {
4911 Session session = null;
4912
4913 try {
4914 session = openSession();
4915
4916 String sql = null;
4917
4918 if (orderByComparator != null) {
4919 sql = _SQL_GETGROUPS.concat(ORDER_BY_CLAUSE)
4920 .concat(orderByComparator.getOrderBy());
4921 }
4922 else {
4923 sql = _SQL_GETGROUPS.concat(com.liferay.portal.model.impl.GroupModelImpl.ORDER_BY_SQL);
4924 }
4925
4926 SQLQuery q = session.createSQLQuery(sql);
4927
4928 q.addEntity("Group_",
4929 com.liferay.portal.model.impl.GroupImpl.class);
4930
4931 QueryPos qPos = QueryPos.getInstance(q);
4932
4933 qPos.add(pk);
4934
4935 list = (List<com.liferay.portal.model.Group>)QueryUtil.list(q,
4936 getDialect(), start, end);
4937 }
4938 catch (Exception e) {
4939 throw processException(e);
4940 }
4941 finally {
4942 if (list == null) {
4943 FinderCacheUtil.removeResult(FINDER_PATH_GET_GROUPS,
4944 finderArgs);
4945 }
4946 else {
4947 groupPersistence.cacheResult(list);
4948
4949 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS,
4950 finderArgs, list);
4951 }
4952
4953 closeSession(session);
4954 }
4955 }
4956
4957 return list;
4958 }
4959
4960 public static final FinderPath FINDER_PATH_GET_GROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
4961 RoleModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES, Long.class,
4962 RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "getGroupsSize",
4963 new String[] { Long.class.getName() });
4964
4965 static {
4966 FINDER_PATH_GET_GROUPS_SIZE.setCacheKeyGeneratorCacheName(null);
4967 }
4968
4969
4976 public int getGroupsSize(long pk) throws SystemException {
4977 Object[] finderArgs = new Object[] { pk };
4978
4979 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS_SIZE,
4980 finderArgs, this);
4981
4982 if (count == null) {
4983 Session session = null;
4984
4985 try {
4986 session = openSession();
4987
4988 SQLQuery q = session.createSQLQuery(_SQL_GETGROUPSSIZE);
4989
4990 q.addScalar(COUNT_COLUMN_NAME,
4991 com.liferay.portal.kernel.dao.orm.Type.LONG);
4992
4993 QueryPos qPos = QueryPos.getInstance(q);
4994
4995 qPos.add(pk);
4996
4997 count = (Long)q.uniqueResult();
4998 }
4999 catch (Exception e) {
5000 throw processException(e);
5001 }
5002 finally {
5003 if (count == null) {
5004 count = Long.valueOf(0);
5005 }
5006
5007 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS_SIZE,
5008 finderArgs, count);
5009
5010 closeSession(session);
5011 }
5012 }
5013
5014 return count.intValue();
5015 }
5016
5017 public static final FinderPath FINDER_PATH_CONTAINS_GROUP = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
5018 RoleModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES, Boolean.class,
5019 RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "containsGroup",
5020 new String[] { Long.class.getName(), Long.class.getName() });
5021
5022
5030 public boolean containsGroup(long pk, long groupPK)
5031 throws SystemException {
5032 Object[] finderArgs = new Object[] { pk, groupPK };
5033
5034 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_GROUP,
5035 finderArgs, this);
5036
5037 if (value == null) {
5038 try {
5039 value = Boolean.valueOf(containsGroup.contains(pk, groupPK));
5040 }
5041 catch (Exception e) {
5042 throw processException(e);
5043 }
5044 finally {
5045 if (value == null) {
5046 value = Boolean.FALSE;
5047 }
5048
5049 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_GROUP,
5050 finderArgs, value);
5051 }
5052 }
5053
5054 return value.booleanValue();
5055 }
5056
5057
5064 public boolean containsGroups(long pk) throws SystemException {
5065 if (getGroupsSize(pk) > 0) {
5066 return true;
5067 }
5068 else {
5069 return false;
5070 }
5071 }
5072
5073
5080 public void addGroup(long pk, long groupPK) throws SystemException {
5081 try {
5082 addGroup.add(pk, groupPK);
5083 }
5084 catch (Exception e) {
5085 throw processException(e);
5086 }
5087 finally {
5088 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5089 }
5090 }
5091
5092
5099 public void addGroup(long pk, com.liferay.portal.model.Group group)
5100 throws SystemException {
5101 try {
5102 addGroup.add(pk, group.getPrimaryKey());
5103 }
5104 catch (Exception e) {
5105 throw processException(e);
5106 }
5107 finally {
5108 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5109 }
5110 }
5111
5112
5119 public void addGroups(long pk, long[] groupPKs) throws SystemException {
5120 try {
5121 for (long groupPK : groupPKs) {
5122 addGroup.add(pk, groupPK);
5123 }
5124 }
5125 catch (Exception e) {
5126 throw processException(e);
5127 }
5128 finally {
5129 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5130 }
5131 }
5132
5133
5140 public void addGroups(long pk, List<com.liferay.portal.model.Group> groups)
5141 throws SystemException {
5142 try {
5143 for (com.liferay.portal.model.Group group : groups) {
5144 addGroup.add(pk, group.getPrimaryKey());
5145 }
5146 }
5147 catch (Exception e) {
5148 throw processException(e);
5149 }
5150 finally {
5151 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5152 }
5153 }
5154
5155
5161 public void clearGroups(long pk) throws SystemException {
5162 try {
5163 clearGroups.clear(pk);
5164 }
5165 catch (Exception e) {
5166 throw processException(e);
5167 }
5168 finally {
5169 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5170 }
5171 }
5172
5173
5180 public void removeGroup(long pk, long groupPK) throws SystemException {
5181 try {
5182 removeGroup.remove(pk, groupPK);
5183 }
5184 catch (Exception e) {
5185 throw processException(e);
5186 }
5187 finally {
5188 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5189 }
5190 }
5191
5192
5199 public void removeGroup(long pk, com.liferay.portal.model.Group group)
5200 throws SystemException {
5201 try {
5202 removeGroup.remove(pk, group.getPrimaryKey());
5203 }
5204 catch (Exception e) {
5205 throw processException(e);
5206 }
5207 finally {
5208 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5209 }
5210 }
5211
5212
5219 public void removeGroups(long pk, long[] groupPKs)
5220 throws SystemException {
5221 try {
5222 for (long groupPK : groupPKs) {
5223 removeGroup.remove(pk, groupPK);
5224 }
5225 }
5226 catch (Exception e) {
5227 throw processException(e);
5228 }
5229 finally {
5230 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5231 }
5232 }
5233
5234
5241 public void removeGroups(long pk,
5242 List<com.liferay.portal.model.Group> groups) throws SystemException {
5243 try {
5244 for (com.liferay.portal.model.Group group : groups) {
5245 removeGroup.remove(pk, group.getPrimaryKey());
5246 }
5247 }
5248 catch (Exception e) {
5249 throw processException(e);
5250 }
5251 finally {
5252 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5253 }
5254 }
5255
5256
5263 public void setGroups(long pk, long[] groupPKs) throws SystemException {
5264 try {
5265 Set<Long> groupPKSet = SetUtil.fromArray(groupPKs);
5266
5267 List<com.liferay.portal.model.Group> groups = getGroups(pk);
5268
5269 for (com.liferay.portal.model.Group group : groups) {
5270 if (!groupPKSet.remove(group.getPrimaryKey())) {
5271 removeGroup.remove(pk, group.getPrimaryKey());
5272 }
5273 }
5274
5275 for (Long groupPK : groupPKSet) {
5276 addGroup.add(pk, groupPK);
5277 }
5278 }
5279 catch (Exception e) {
5280 throw processException(e);
5281 }
5282 finally {
5283 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5284 }
5285 }
5286
5287
5294 public void setGroups(long pk, List<com.liferay.portal.model.Group> groups)
5295 throws SystemException {
5296 try {
5297 long[] groupPKs = new long[groups.size()];
5298
5299 for (int i = 0; i < groups.size(); i++) {
5300 com.liferay.portal.model.Group group = groups.get(i);
5301
5302 groupPKs[i] = group.getPrimaryKey();
5303 }
5304
5305 setGroups(pk, groupPKs);
5306 }
5307 catch (Exception e) {
5308 throw processException(e);
5309 }
5310 finally {
5311 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
5312 }
5313 }
5314
5315
5322 public List<com.liferay.portal.model.Permission> getPermissions(long pk)
5323 throws SystemException {
5324 return getPermissions(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
5325 }
5326
5327
5340 public List<com.liferay.portal.model.Permission> getPermissions(long pk,
5341 int start, int end) throws SystemException {
5342 return getPermissions(pk, start, end, null);
5343 }
5344
5345 public static final FinderPath FINDER_PATH_GET_PERMISSIONS = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
5346 RoleModelImpl.FINDER_CACHE_ENABLED_ROLES_PERMISSIONS,
5347 com.liferay.portal.model.impl.PermissionImpl.class,
5348 RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME,
5349 "getPermissions",
5350 new String[] {
5351 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
5352 "com.liferay.portal.kernel.util.OrderByComparator"
5353 });
5354
5355 static {
5356 FINDER_PATH_GET_PERMISSIONS.setCacheKeyGeneratorCacheName(null);
5357 }
5358
5359
5373 public List<com.liferay.portal.model.Permission> getPermissions(long pk,
5374 int start, int end, OrderByComparator orderByComparator)
5375 throws SystemException {
5376 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
5377
5378 List<com.liferay.portal.model.Permission> list = (List<com.liferay.portal.model.Permission>)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS,
5379 finderArgs, this);
5380
5381 if (list == null) {
5382 Session session = null;
5383
5384 try {
5385 session = openSession();
5386
5387 String sql = null;
5388
5389 if (orderByComparator != null) {
5390 sql = _SQL_GETPERMISSIONS.concat(ORDER_BY_CLAUSE)
5391 .concat(orderByComparator.getOrderBy());
5392 }
5393 else {
5394 sql = _SQL_GETPERMISSIONS;
5395 }
5396
5397 SQLQuery q = session.createSQLQuery(sql);
5398
5399 q.addEntity("Permission_",
5400 com.liferay.portal.model.impl.PermissionImpl.class);
5401
5402 QueryPos qPos = QueryPos.getInstance(q);
5403
5404 qPos.add(pk);
5405
5406 list = (List<com.liferay.portal.model.Permission>)QueryUtil.list(q,
5407 getDialect(), start, end);
5408 }
5409 catch (Exception e) {
5410 throw processException(e);
5411 }
5412 finally {
5413 if (list == null) {
5414 FinderCacheUtil.removeResult(FINDER_PATH_GET_PERMISSIONS,
5415 finderArgs);
5416 }
5417 else {
5418 permissionPersistence.cacheResult(list);
5419
5420 FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS,
5421 finderArgs, list);
5422 }
5423
5424 closeSession(session);
5425 }
5426 }
5427
5428 return list;
5429 }
5430
5431 public static final FinderPath FINDER_PATH_GET_PERMISSIONS_SIZE = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
5432 RoleModelImpl.FINDER_CACHE_ENABLED_ROLES_PERMISSIONS, Long.class,
5433 RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME,
5434 "getPermissionsSize", new String[] { Long.class.getName() });
5435
5436 static {
5437 FINDER_PATH_GET_PERMISSIONS_SIZE.setCacheKeyGeneratorCacheName(null);
5438 }
5439
5440
5447 public int getPermissionsSize(long pk) throws SystemException {
5448 Object[] finderArgs = new Object[] { pk };
5449
5450 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
5451 finderArgs, this);
5452
5453 if (count == null) {
5454 Session session = null;
5455
5456 try {
5457 session = openSession();
5458
5459 SQLQuery q = session.createSQLQuery(_SQL_GETPERMISSIONSSIZE);
5460
5461 q.addScalar(COUNT_COLUMN_NAME,
5462 com.liferay.portal.kernel.dao.orm.Type.LONG);
5463
5464 QueryPos qPos = QueryPos.getInstance(q);
5465
5466 qPos.add(pk);
5467
5468 count = (Long)q.uniqueResult();
5469 }
5470 catch (Exception e) {
5471 throw processException(e);
5472 }
5473 finally {
5474 if (count == null) {
5475 count = Long.valueOf(0);
5476 }
5477
5478 FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
5479 finderArgs, count);
5480
5481 closeSession(session);
5482 }
5483 }
5484
5485 return count.intValue();
5486 }
5487
5488 public static final FinderPath FINDER_PATH_CONTAINS_PERMISSION = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
5489 RoleModelImpl.FINDER_CACHE_ENABLED_ROLES_PERMISSIONS,
5490 Boolean.class, RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME,
5491 "containsPermission",
5492 new String[] { Long.class.getName(), Long.class.getName() });
5493
5494
5502 public boolean containsPermission(long pk, long permissionPK)
5503 throws SystemException {
5504 Object[] finderArgs = new Object[] { pk, permissionPK };
5505
5506 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_PERMISSION,
5507 finderArgs, this);
5508
5509 if (value == null) {
5510 try {
5511 value = Boolean.valueOf(containsPermission.contains(pk,
5512 permissionPK));
5513 }
5514 catch (Exception e) {
5515 throw processException(e);
5516 }
5517 finally {
5518 if (value == null) {
5519 value = Boolean.FALSE;
5520 }
5521
5522 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_PERMISSION,
5523 finderArgs, value);
5524 }
5525 }
5526
5527 return value.booleanValue();
5528 }
5529
5530
5537 public boolean containsPermissions(long pk) throws SystemException {
5538 if (getPermissionsSize(pk) > 0) {
5539 return true;
5540 }
5541 else {
5542 return false;
5543 }
5544 }
5545
5546
5553 public void addPermission(long pk, long permissionPK)
5554 throws SystemException {
5555 try {
5556 addPermission.add(pk, permissionPK);
5557 }
5558 catch (Exception e) {
5559 throw processException(e);
5560 }
5561 finally {
5562 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5563 }
5564 }
5565
5566
5573 public void addPermission(long pk,
5574 com.liferay.portal.model.Permission permission)
5575 throws SystemException {
5576 try {
5577 addPermission.add(pk, permission.getPrimaryKey());
5578 }
5579 catch (Exception e) {
5580 throw processException(e);
5581 }
5582 finally {
5583 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5584 }
5585 }
5586
5587
5594 public void addPermissions(long pk, long[] permissionPKs)
5595 throws SystemException {
5596 try {
5597 for (long permissionPK : permissionPKs) {
5598 addPermission.add(pk, permissionPK);
5599 }
5600 }
5601 catch (Exception e) {
5602 throw processException(e);
5603 }
5604 finally {
5605 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5606 }
5607 }
5608
5609
5616 public void addPermissions(long pk,
5617 List<com.liferay.portal.model.Permission> permissions)
5618 throws SystemException {
5619 try {
5620 for (com.liferay.portal.model.Permission permission : permissions) {
5621 addPermission.add(pk, permission.getPrimaryKey());
5622 }
5623 }
5624 catch (Exception e) {
5625 throw processException(e);
5626 }
5627 finally {
5628 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5629 }
5630 }
5631
5632
5638 public void clearPermissions(long pk) throws SystemException {
5639 try {
5640 clearPermissions.clear(pk);
5641 }
5642 catch (Exception e) {
5643 throw processException(e);
5644 }
5645 finally {
5646 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5647 }
5648 }
5649
5650
5657 public void removePermission(long pk, long permissionPK)
5658 throws SystemException {
5659 try {
5660 removePermission.remove(pk, permissionPK);
5661 }
5662 catch (Exception e) {
5663 throw processException(e);
5664 }
5665 finally {
5666 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5667 }
5668 }
5669
5670
5677 public void removePermission(long pk,
5678 com.liferay.portal.model.Permission permission)
5679 throws SystemException {
5680 try {
5681 removePermission.remove(pk, permission.getPrimaryKey());
5682 }
5683 catch (Exception e) {
5684 throw processException(e);
5685 }
5686 finally {
5687 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5688 }
5689 }
5690
5691
5698 public void removePermissions(long pk, long[] permissionPKs)
5699 throws SystemException {
5700 try {
5701 for (long permissionPK : permissionPKs) {
5702 removePermission.remove(pk, permissionPK);
5703 }
5704 }
5705 catch (Exception e) {
5706 throw processException(e);
5707 }
5708 finally {
5709 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5710 }
5711 }
5712
5713
5720 public void removePermissions(long pk,
5721 List<com.liferay.portal.model.Permission> permissions)
5722 throws SystemException {
5723 try {
5724 for (com.liferay.portal.model.Permission permission : permissions) {
5725 removePermission.remove(pk, permission.getPrimaryKey());
5726 }
5727 }
5728 catch (Exception e) {
5729 throw processException(e);
5730 }
5731 finally {
5732 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5733 }
5734 }
5735
5736
5743 public void setPermissions(long pk, long[] permissionPKs)
5744 throws SystemException {
5745 try {
5746 Set<Long> permissionPKSet = SetUtil.fromArray(permissionPKs);
5747
5748 List<com.liferay.portal.model.Permission> permissions = getPermissions(pk);
5749
5750 for (com.liferay.portal.model.Permission permission : permissions) {
5751 if (!permissionPKSet.remove(permission.getPrimaryKey())) {
5752 removePermission.remove(pk, permission.getPrimaryKey());
5753 }
5754 }
5755
5756 for (Long permissionPK : permissionPKSet) {
5757 addPermission.add(pk, permissionPK);
5758 }
5759 }
5760 catch (Exception e) {
5761 throw processException(e);
5762 }
5763 finally {
5764 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5765 }
5766 }
5767
5768
5775 public void setPermissions(long pk,
5776 List<com.liferay.portal.model.Permission> permissions)
5777 throws SystemException {
5778 try {
5779 long[] permissionPKs = new long[permissions.size()];
5780
5781 for (int i = 0; i < permissions.size(); i++) {
5782 com.liferay.portal.model.Permission permission = permissions.get(i);
5783
5784 permissionPKs[i] = permission.getPrimaryKey();
5785 }
5786
5787 setPermissions(pk, permissionPKs);
5788 }
5789 catch (Exception e) {
5790 throw processException(e);
5791 }
5792 finally {
5793 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
5794 }
5795 }
5796
5797
5804 public List<com.liferay.portal.model.User> getUsers(long pk)
5805 throws SystemException {
5806 return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
5807 }
5808
5809
5822 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
5823 int end) throws SystemException {
5824 return getUsers(pk, start, end, null);
5825 }
5826
5827 public static final FinderPath FINDER_PATH_GET_USERS = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
5828 RoleModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES,
5829 com.liferay.portal.model.impl.UserImpl.class,
5830 RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "getUsers",
5831 new String[] {
5832 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
5833 "com.liferay.portal.kernel.util.OrderByComparator"
5834 });
5835
5836 static {
5837 FINDER_PATH_GET_USERS.setCacheKeyGeneratorCacheName(null);
5838 }
5839
5840
5854 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
5855 int end, OrderByComparator orderByComparator) throws SystemException {
5856 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
5857
5858 List<com.liferay.portal.model.User> list = (List<com.liferay.portal.model.User>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS,
5859 finderArgs, this);
5860
5861 if (list == null) {
5862 Session session = null;
5863
5864 try {
5865 session = openSession();
5866
5867 String sql = null;
5868
5869 if (orderByComparator != null) {
5870 sql = _SQL_GETUSERS.concat(ORDER_BY_CLAUSE)
5871 .concat(orderByComparator.getOrderBy());
5872 }
5873 else {
5874 sql = _SQL_GETUSERS;
5875 }
5876
5877 SQLQuery q = session.createSQLQuery(sql);
5878
5879 q.addEntity("User_",
5880 com.liferay.portal.model.impl.UserImpl.class);
5881
5882 QueryPos qPos = QueryPos.getInstance(q);
5883
5884 qPos.add(pk);
5885
5886 list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
5887 getDialect(), start, end);
5888 }
5889 catch (Exception e) {
5890 throw processException(e);
5891 }
5892 finally {
5893 if (list == null) {
5894 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERS,
5895 finderArgs);
5896 }
5897 else {
5898 userPersistence.cacheResult(list);
5899
5900 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS,
5901 finderArgs, list);
5902 }
5903
5904 closeSession(session);
5905 }
5906 }
5907
5908 return list;
5909 }
5910
5911 public static final FinderPath FINDER_PATH_GET_USERS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
5912 RoleModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES, Long.class,
5913 RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "getUsersSize",
5914 new String[] { Long.class.getName() });
5915
5916 static {
5917 FINDER_PATH_GET_USERS_SIZE.setCacheKeyGeneratorCacheName(null);
5918 }
5919
5920
5927 public int getUsersSize(long pk) throws SystemException {
5928 Object[] finderArgs = new Object[] { pk };
5929
5930 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS_SIZE,
5931 finderArgs, this);
5932
5933 if (count == null) {
5934 Session session = null;
5935
5936 try {
5937 session = openSession();
5938
5939 SQLQuery q = session.createSQLQuery(_SQL_GETUSERSSIZE);
5940
5941 q.addScalar(COUNT_COLUMN_NAME,
5942 com.liferay.portal.kernel.dao.orm.Type.LONG);
5943
5944 QueryPos qPos = QueryPos.getInstance(q);
5945
5946 qPos.add(pk);
5947
5948 count = (Long)q.uniqueResult();
5949 }
5950 catch (Exception e) {
5951 throw processException(e);
5952 }
5953 finally {
5954 if (count == null) {
5955 count = Long.valueOf(0);
5956 }
5957
5958 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS_SIZE,
5959 finderArgs, count);
5960
5961 closeSession(session);
5962 }
5963 }
5964
5965 return count.intValue();
5966 }
5967
5968 public static final FinderPath FINDER_PATH_CONTAINS_USER = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
5969 RoleModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES, Boolean.class,
5970 RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "containsUser",
5971 new String[] { Long.class.getName(), Long.class.getName() });
5972
5973
5981 public boolean containsUser(long pk, long userPK) throws SystemException {
5982 Object[] finderArgs = new Object[] { pk, userPK };
5983
5984 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USER,
5985 finderArgs, this);
5986
5987 if (value == null) {
5988 try {
5989 value = Boolean.valueOf(containsUser.contains(pk, userPK));
5990 }
5991 catch (Exception e) {
5992 throw processException(e);
5993 }
5994 finally {
5995 if (value == null) {
5996 value = Boolean.FALSE;
5997 }
5998
5999 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USER,
6000 finderArgs, value);
6001 }
6002 }
6003
6004 return value.booleanValue();
6005 }
6006
6007
6014 public boolean containsUsers(long pk) throws SystemException {
6015 if (getUsersSize(pk) > 0) {
6016 return true;
6017 }
6018 else {
6019 return false;
6020 }
6021 }
6022
6023
6030 public void addUser(long pk, long userPK) throws SystemException {
6031 try {
6032 addUser.add(pk, userPK);
6033 }
6034 catch (Exception e) {
6035 throw processException(e);
6036 }
6037 finally {
6038 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6039 }
6040 }
6041
6042
6049 public void addUser(long pk, com.liferay.portal.model.User user)
6050 throws SystemException {
6051 try {
6052 addUser.add(pk, user.getPrimaryKey());
6053 }
6054 catch (Exception e) {
6055 throw processException(e);
6056 }
6057 finally {
6058 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6059 }
6060 }
6061
6062
6069 public void addUsers(long pk, long[] userPKs) throws SystemException {
6070 try {
6071 for (long userPK : userPKs) {
6072 addUser.add(pk, userPK);
6073 }
6074 }
6075 catch (Exception e) {
6076 throw processException(e);
6077 }
6078 finally {
6079 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6080 }
6081 }
6082
6083
6090 public void addUsers(long pk, List<com.liferay.portal.model.User> users)
6091 throws SystemException {
6092 try {
6093 for (com.liferay.portal.model.User user : users) {
6094 addUser.add(pk, user.getPrimaryKey());
6095 }
6096 }
6097 catch (Exception e) {
6098 throw processException(e);
6099 }
6100 finally {
6101 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6102 }
6103 }
6104
6105
6111 public void clearUsers(long pk) throws SystemException {
6112 try {
6113 clearUsers.clear(pk);
6114 }
6115 catch (Exception e) {
6116 throw processException(e);
6117 }
6118 finally {
6119 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6120 }
6121 }
6122
6123
6130 public void removeUser(long pk, long userPK) throws SystemException {
6131 try {
6132 removeUser.remove(pk, userPK);
6133 }
6134 catch (Exception e) {
6135 throw processException(e);
6136 }
6137 finally {
6138 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6139 }
6140 }
6141
6142
6149 public void removeUser(long pk, com.liferay.portal.model.User user)
6150 throws SystemException {
6151 try {
6152 removeUser.remove(pk, user.getPrimaryKey());
6153 }
6154 catch (Exception e) {
6155 throw processException(e);
6156 }
6157 finally {
6158 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6159 }
6160 }
6161
6162
6169 public void removeUsers(long pk, long[] userPKs) throws SystemException {
6170 try {
6171 for (long userPK : userPKs) {
6172 removeUser.remove(pk, userPK);
6173 }
6174 }
6175 catch (Exception e) {
6176 throw processException(e);
6177 }
6178 finally {
6179 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6180 }
6181 }
6182
6183
6190 public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
6191 throws SystemException {
6192 try {
6193 for (com.liferay.portal.model.User user : users) {
6194 removeUser.remove(pk, user.getPrimaryKey());
6195 }
6196 }
6197 catch (Exception e) {
6198 throw processException(e);
6199 }
6200 finally {
6201 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6202 }
6203 }
6204
6205
6212 public void setUsers(long pk, long[] userPKs) throws SystemException {
6213 try {
6214 Set<Long> userPKSet = SetUtil.fromArray(userPKs);
6215
6216 List<com.liferay.portal.model.User> users = getUsers(pk);
6217
6218 for (com.liferay.portal.model.User user : users) {
6219 if (!userPKSet.remove(user.getPrimaryKey())) {
6220 removeUser.remove(pk, user.getPrimaryKey());
6221 }
6222 }
6223
6224 for (Long userPK : userPKSet) {
6225 addUser.add(pk, userPK);
6226 }
6227 }
6228 catch (Exception e) {
6229 throw processException(e);
6230 }
6231 finally {
6232 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6233 }
6234 }
6235
6236
6243 public void setUsers(long pk, List<com.liferay.portal.model.User> users)
6244 throws SystemException {
6245 try {
6246 long[] userPKs = new long[users.size()];
6247
6248 for (int i = 0; i < users.size(); i++) {
6249 com.liferay.portal.model.User user = users.get(i);
6250
6251 userPKs[i] = user.getPrimaryKey();
6252 }
6253
6254 setUsers(pk, userPKs);
6255 }
6256 catch (Exception e) {
6257 throw processException(e);
6258 }
6259 finally {
6260 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6261 }
6262 }
6263
6264
6267 public void afterPropertiesSet() {
6268 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
6269 com.liferay.portal.util.PropsUtil.get(
6270 "value.object.listener.com.liferay.portal.model.Role")));
6271
6272 if (listenerClassNames.length > 0) {
6273 try {
6274 List<ModelListener<Role>> listenersList = new ArrayList<ModelListener<Role>>();
6275
6276 for (String listenerClassName : listenerClassNames) {
6277 Class<?> clazz = getClass();
6278
6279 listenersList.add((ModelListener<Role>)InstanceFactory.newInstance(
6280 clazz.getClassLoader(), listenerClassName));
6281 }
6282
6283 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
6284 }
6285 catch (Exception e) {
6286 _log.error(e);
6287 }
6288 }
6289
6290 containsGroup = new ContainsGroup();
6291
6292 addGroup = new AddGroup();
6293 clearGroups = new ClearGroups();
6294 removeGroup = new RemoveGroup();
6295
6296 containsPermission = new ContainsPermission();
6297
6298 addPermission = new AddPermission();
6299 clearPermissions = new ClearPermissions();
6300 removePermission = new RemovePermission();
6301
6302 containsUser = new ContainsUser();
6303
6304 addUser = new AddUser();
6305 clearUsers = new ClearUsers();
6306 removeUser = new RemoveUser();
6307 }
6308
6309 public void destroy() {
6310 EntityCacheUtil.removeCache(RoleImpl.class.getName());
6311 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
6312 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6313 }
6314
6315 @BeanReference(type = AccountPersistence.class)
6316 protected AccountPersistence accountPersistence;
6317 @BeanReference(type = AddressPersistence.class)
6318 protected AddressPersistence addressPersistence;
6319 @BeanReference(type = BrowserTrackerPersistence.class)
6320 protected BrowserTrackerPersistence browserTrackerPersistence;
6321 @BeanReference(type = ClassNamePersistence.class)
6322 protected ClassNamePersistence classNamePersistence;
6323 @BeanReference(type = ClusterGroupPersistence.class)
6324 protected ClusterGroupPersistence clusterGroupPersistence;
6325 @BeanReference(type = CompanyPersistence.class)
6326 protected CompanyPersistence companyPersistence;
6327 @BeanReference(type = ContactPersistence.class)
6328 protected ContactPersistence contactPersistence;
6329 @BeanReference(type = CountryPersistence.class)
6330 protected CountryPersistence countryPersistence;
6331 @BeanReference(type = EmailAddressPersistence.class)
6332 protected EmailAddressPersistence emailAddressPersistence;
6333 @BeanReference(type = GroupPersistence.class)
6334 protected GroupPersistence groupPersistence;
6335 @BeanReference(type = ImagePersistence.class)
6336 protected ImagePersistence imagePersistence;
6337 @BeanReference(type = LayoutPersistence.class)
6338 protected LayoutPersistence layoutPersistence;
6339 @BeanReference(type = LayoutBranchPersistence.class)
6340 protected LayoutBranchPersistence layoutBranchPersistence;
6341 @BeanReference(type = LayoutPrototypePersistence.class)
6342 protected LayoutPrototypePersistence layoutPrototypePersistence;
6343 @BeanReference(type = LayoutRevisionPersistence.class)
6344 protected LayoutRevisionPersistence layoutRevisionPersistence;
6345 @BeanReference(type = LayoutSetPersistence.class)
6346 protected LayoutSetPersistence layoutSetPersistence;
6347 @BeanReference(type = LayoutSetBranchPersistence.class)
6348 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
6349 @BeanReference(type = LayoutSetPrototypePersistence.class)
6350 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
6351 @BeanReference(type = ListTypePersistence.class)
6352 protected ListTypePersistence listTypePersistence;
6353 @BeanReference(type = LockPersistence.class)
6354 protected LockPersistence lockPersistence;
6355 @BeanReference(type = MembershipRequestPersistence.class)
6356 protected MembershipRequestPersistence membershipRequestPersistence;
6357 @BeanReference(type = OrganizationPersistence.class)
6358 protected OrganizationPersistence organizationPersistence;
6359 @BeanReference(type = OrgGroupPermissionPersistence.class)
6360 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
6361 @BeanReference(type = OrgGroupRolePersistence.class)
6362 protected OrgGroupRolePersistence orgGroupRolePersistence;
6363 @BeanReference(type = OrgLaborPersistence.class)
6364 protected OrgLaborPersistence orgLaborPersistence;
6365 @BeanReference(type = PasswordPolicyPersistence.class)
6366 protected PasswordPolicyPersistence passwordPolicyPersistence;
6367 @BeanReference(type = PasswordPolicyRelPersistence.class)
6368 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
6369 @BeanReference(type = PasswordTrackerPersistence.class)
6370 protected PasswordTrackerPersistence passwordTrackerPersistence;
6371 @BeanReference(type = PermissionPersistence.class)
6372 protected PermissionPersistence permissionPersistence;
6373 @BeanReference(type = PhonePersistence.class)
6374 protected PhonePersistence phonePersistence;
6375 @BeanReference(type = PluginSettingPersistence.class)
6376 protected PluginSettingPersistence pluginSettingPersistence;
6377 @BeanReference(type = PortalPreferencesPersistence.class)
6378 protected PortalPreferencesPersistence portalPreferencesPersistence;
6379 @BeanReference(type = PortletPersistence.class)
6380 protected PortletPersistence portletPersistence;
6381 @BeanReference(type = PortletItemPersistence.class)
6382 protected PortletItemPersistence portletItemPersistence;
6383 @BeanReference(type = PortletPreferencesPersistence.class)
6384 protected PortletPreferencesPersistence portletPreferencesPersistence;
6385 @BeanReference(type = RegionPersistence.class)
6386 protected RegionPersistence regionPersistence;
6387 @BeanReference(type = ReleasePersistence.class)
6388 protected ReleasePersistence releasePersistence;
6389 @BeanReference(type = RepositoryPersistence.class)
6390 protected RepositoryPersistence repositoryPersistence;
6391 @BeanReference(type = RepositoryEntryPersistence.class)
6392 protected RepositoryEntryPersistence repositoryEntryPersistence;
6393 @BeanReference(type = ResourcePersistence.class)
6394 protected ResourcePersistence resourcePersistence;
6395 @BeanReference(type = ResourceActionPersistence.class)
6396 protected ResourceActionPersistence resourceActionPersistence;
6397 @BeanReference(type = ResourceBlockPersistence.class)
6398 protected ResourceBlockPersistence resourceBlockPersistence;
6399 @BeanReference(type = ResourceBlockPermissionPersistence.class)
6400 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
6401 @BeanReference(type = ResourceCodePersistence.class)
6402 protected ResourceCodePersistence resourceCodePersistence;
6403 @BeanReference(type = ResourcePermissionPersistence.class)
6404 protected ResourcePermissionPersistence resourcePermissionPersistence;
6405 @BeanReference(type = ResourceTypePermissionPersistence.class)
6406 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
6407 @BeanReference(type = RolePersistence.class)
6408 protected RolePersistence rolePersistence;
6409 @BeanReference(type = ServiceComponentPersistence.class)
6410 protected ServiceComponentPersistence serviceComponentPersistence;
6411 @BeanReference(type = ShardPersistence.class)
6412 protected ShardPersistence shardPersistence;
6413 @BeanReference(type = SubscriptionPersistence.class)
6414 protected SubscriptionPersistence subscriptionPersistence;
6415 @BeanReference(type = TeamPersistence.class)
6416 protected TeamPersistence teamPersistence;
6417 @BeanReference(type = TicketPersistence.class)
6418 protected TicketPersistence ticketPersistence;
6419 @BeanReference(type = UserPersistence.class)
6420 protected UserPersistence userPersistence;
6421 @BeanReference(type = UserGroupPersistence.class)
6422 protected UserGroupPersistence userGroupPersistence;
6423 @BeanReference(type = UserGroupGroupRolePersistence.class)
6424 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
6425 @BeanReference(type = UserGroupRolePersistence.class)
6426 protected UserGroupRolePersistence userGroupRolePersistence;
6427 @BeanReference(type = UserIdMapperPersistence.class)
6428 protected UserIdMapperPersistence userIdMapperPersistence;
6429 @BeanReference(type = UserNotificationEventPersistence.class)
6430 protected UserNotificationEventPersistence userNotificationEventPersistence;
6431 @BeanReference(type = UserTrackerPersistence.class)
6432 protected UserTrackerPersistence userTrackerPersistence;
6433 @BeanReference(type = UserTrackerPathPersistence.class)
6434 protected UserTrackerPathPersistence userTrackerPathPersistence;
6435 @BeanReference(type = VirtualHostPersistence.class)
6436 protected VirtualHostPersistence virtualHostPersistence;
6437 @BeanReference(type = WebDAVPropsPersistence.class)
6438 protected WebDAVPropsPersistence webDAVPropsPersistence;
6439 @BeanReference(type = WebsitePersistence.class)
6440 protected WebsitePersistence websitePersistence;
6441 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
6442 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
6443 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
6444 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
6445 protected ContainsGroup containsGroup;
6446 protected AddGroup addGroup;
6447 protected ClearGroups clearGroups;
6448 protected RemoveGroup removeGroup;
6449 protected ContainsPermission containsPermission;
6450 protected AddPermission addPermission;
6451 protected ClearPermissions clearPermissions;
6452 protected RemovePermission removePermission;
6453 protected ContainsUser containsUser;
6454 protected AddUser addUser;
6455 protected ClearUsers clearUsers;
6456 protected RemoveUser removeUser;
6457
6458 protected class ContainsGroup {
6459 protected ContainsGroup() {
6460 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6461 _SQL_CONTAINSGROUP,
6462 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6463 RowMapper.COUNT);
6464 }
6465
6466 protected boolean contains(long roleId, long groupId) {
6467 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6468 new Long(roleId), new Long(groupId)
6469 });
6470
6471 if (results.size() > 0) {
6472 Integer count = results.get(0);
6473
6474 if (count.intValue() > 0) {
6475 return true;
6476 }
6477 }
6478
6479 return false;
6480 }
6481
6482 private MappingSqlQuery<Integer> _mappingSqlQuery;
6483 }
6484
6485 protected class AddGroup {
6486 protected AddGroup() {
6487 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6488 "INSERT INTO Groups_Roles (roleId, groupId) VALUES (?, ?)",
6489 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6490 }
6491
6492 protected void add(long roleId, long groupId) throws SystemException {
6493 if (!containsGroup.contains(roleId, groupId)) {
6494 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
6495
6496 for (ModelListener<Role> listener : listeners) {
6497 listener.onBeforeAddAssociation(roleId,
6498 com.liferay.portal.model.Group.class.getName(), groupId);
6499 }
6500
6501 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
6502 listener.onBeforeAddAssociation(groupId,
6503 Role.class.getName(), roleId);
6504 }
6505
6506 _sqlUpdate.update(new Object[] {
6507 new Long(roleId), new Long(groupId)
6508 });
6509
6510 for (ModelListener<Role> listener : listeners) {
6511 listener.onAfterAddAssociation(roleId,
6512 com.liferay.portal.model.Group.class.getName(), groupId);
6513 }
6514
6515 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
6516 listener.onAfterAddAssociation(groupId,
6517 Role.class.getName(), roleId);
6518 }
6519 }
6520 }
6521
6522 private SqlUpdate _sqlUpdate;
6523 }
6524
6525 protected class ClearGroups {
6526 protected ClearGroups() {
6527 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6528 "DELETE FROM Groups_Roles WHERE roleId = ?",
6529 new int[] { java.sql.Types.BIGINT });
6530 }
6531
6532 protected void clear(long roleId) throws SystemException {
6533 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
6534
6535 List<com.liferay.portal.model.Group> groups = null;
6536
6537 if ((listeners.length > 0) || (groupListeners.length > 0)) {
6538 groups = getGroups(roleId);
6539
6540 for (com.liferay.portal.model.Group group : groups) {
6541 for (ModelListener<Role> listener : listeners) {
6542 listener.onBeforeRemoveAssociation(roleId,
6543 com.liferay.portal.model.Group.class.getName(),
6544 group.getPrimaryKey());
6545 }
6546
6547 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
6548 listener.onBeforeRemoveAssociation(group.getPrimaryKey(),
6549 Role.class.getName(), roleId);
6550 }
6551 }
6552 }
6553
6554 _sqlUpdate.update(new Object[] { new Long(roleId) });
6555
6556 if ((listeners.length > 0) || (groupListeners.length > 0)) {
6557 for (com.liferay.portal.model.Group group : groups) {
6558 for (ModelListener<Role> listener : listeners) {
6559 listener.onAfterRemoveAssociation(roleId,
6560 com.liferay.portal.model.Group.class.getName(),
6561 group.getPrimaryKey());
6562 }
6563
6564 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
6565 listener.onAfterRemoveAssociation(group.getPrimaryKey(),
6566 Role.class.getName(), roleId);
6567 }
6568 }
6569 }
6570 }
6571
6572 private SqlUpdate _sqlUpdate;
6573 }
6574
6575 protected class RemoveGroup {
6576 protected RemoveGroup() {
6577 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6578 "DELETE FROM Groups_Roles WHERE roleId = ? AND groupId = ?",
6579 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6580 }
6581
6582 protected void remove(long roleId, long groupId)
6583 throws SystemException {
6584 if (containsGroup.contains(roleId, groupId)) {
6585 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
6586
6587 for (ModelListener<Role> listener : listeners) {
6588 listener.onBeforeRemoveAssociation(roleId,
6589 com.liferay.portal.model.Group.class.getName(), groupId);
6590 }
6591
6592 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
6593 listener.onBeforeRemoveAssociation(groupId,
6594 Role.class.getName(), roleId);
6595 }
6596
6597 _sqlUpdate.update(new Object[] {
6598 new Long(roleId), new Long(groupId)
6599 });
6600
6601 for (ModelListener<Role> listener : listeners) {
6602 listener.onAfterRemoveAssociation(roleId,
6603 com.liferay.portal.model.Group.class.getName(), groupId);
6604 }
6605
6606 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
6607 listener.onAfterRemoveAssociation(groupId,
6608 Role.class.getName(), roleId);
6609 }
6610 }
6611 }
6612
6613 private SqlUpdate _sqlUpdate;
6614 }
6615
6616 protected class ContainsPermission {
6617 protected ContainsPermission() {
6618 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6619 _SQL_CONTAINSPERMISSION,
6620 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6621 RowMapper.COUNT);
6622 }
6623
6624 protected boolean contains(long roleId, long permissionId) {
6625 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6626 new Long(roleId), new Long(permissionId)
6627 });
6628
6629 if (results.size() > 0) {
6630 Integer count = results.get(0);
6631
6632 if (count.intValue() > 0) {
6633 return true;
6634 }
6635 }
6636
6637 return false;
6638 }
6639
6640 private MappingSqlQuery<Integer> _mappingSqlQuery;
6641 }
6642
6643 protected class AddPermission {
6644 protected AddPermission() {
6645 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6646 "INSERT INTO Roles_Permissions (roleId, permissionId) VALUES (?, ?)",
6647 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6648 }
6649
6650 protected void add(long roleId, long permissionId)
6651 throws SystemException {
6652 if (!containsPermission.contains(roleId, permissionId)) {
6653 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
6654 permissionPersistence.getListeners();
6655
6656 for (ModelListener<Role> listener : listeners) {
6657 listener.onBeforeAddAssociation(roleId,
6658 com.liferay.portal.model.Permission.class.getName(),
6659 permissionId);
6660 }
6661
6662 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6663 listener.onBeforeAddAssociation(permissionId,
6664 Role.class.getName(), roleId);
6665 }
6666
6667 _sqlUpdate.update(new Object[] {
6668 new Long(roleId), new Long(permissionId)
6669 });
6670
6671 for (ModelListener<Role> listener : listeners) {
6672 listener.onAfterAddAssociation(roleId,
6673 com.liferay.portal.model.Permission.class.getName(),
6674 permissionId);
6675 }
6676
6677 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6678 listener.onAfterAddAssociation(permissionId,
6679 Role.class.getName(), roleId);
6680 }
6681 }
6682 }
6683
6684 private SqlUpdate _sqlUpdate;
6685 }
6686
6687 protected class ClearPermissions {
6688 protected ClearPermissions() {
6689 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6690 "DELETE FROM Roles_Permissions WHERE roleId = ?",
6691 new int[] { java.sql.Types.BIGINT });
6692 }
6693
6694 protected void clear(long roleId) throws SystemException {
6695 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
6696 permissionPersistence.getListeners();
6697
6698 List<com.liferay.portal.model.Permission> permissions = null;
6699
6700 if ((listeners.length > 0) || (permissionListeners.length > 0)) {
6701 permissions = getPermissions(roleId);
6702
6703 for (com.liferay.portal.model.Permission permission : permissions) {
6704 for (ModelListener<Role> listener : listeners) {
6705 listener.onBeforeRemoveAssociation(roleId,
6706 com.liferay.portal.model.Permission.class.getName(),
6707 permission.getPrimaryKey());
6708 }
6709
6710 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6711 listener.onBeforeRemoveAssociation(permission.getPrimaryKey(),
6712 Role.class.getName(), roleId);
6713 }
6714 }
6715 }
6716
6717 _sqlUpdate.update(new Object[] { new Long(roleId) });
6718
6719 if ((listeners.length > 0) || (permissionListeners.length > 0)) {
6720 for (com.liferay.portal.model.Permission permission : permissions) {
6721 for (ModelListener<Role> listener : listeners) {
6722 listener.onAfterRemoveAssociation(roleId,
6723 com.liferay.portal.model.Permission.class.getName(),
6724 permission.getPrimaryKey());
6725 }
6726
6727 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6728 listener.onAfterRemoveAssociation(permission.getPrimaryKey(),
6729 Role.class.getName(), roleId);
6730 }
6731 }
6732 }
6733 }
6734
6735 private SqlUpdate _sqlUpdate;
6736 }
6737
6738 protected class RemovePermission {
6739 protected RemovePermission() {
6740 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6741 "DELETE FROM Roles_Permissions WHERE roleId = ? AND permissionId = ?",
6742 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6743 }
6744
6745 protected void remove(long roleId, long permissionId)
6746 throws SystemException {
6747 if (containsPermission.contains(roleId, permissionId)) {
6748 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
6749 permissionPersistence.getListeners();
6750
6751 for (ModelListener<Role> listener : listeners) {
6752 listener.onBeforeRemoveAssociation(roleId,
6753 com.liferay.portal.model.Permission.class.getName(),
6754 permissionId);
6755 }
6756
6757 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6758 listener.onBeforeRemoveAssociation(permissionId,
6759 Role.class.getName(), roleId);
6760 }
6761
6762 _sqlUpdate.update(new Object[] {
6763 new Long(roleId), new Long(permissionId)
6764 });
6765
6766 for (ModelListener<Role> listener : listeners) {
6767 listener.onAfterRemoveAssociation(roleId,
6768 com.liferay.portal.model.Permission.class.getName(),
6769 permissionId);
6770 }
6771
6772 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6773 listener.onAfterRemoveAssociation(permissionId,
6774 Role.class.getName(), roleId);
6775 }
6776 }
6777 }
6778
6779 private SqlUpdate _sqlUpdate;
6780 }
6781
6782 protected class ContainsUser {
6783 protected ContainsUser() {
6784 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6785 _SQL_CONTAINSUSER,
6786 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6787 RowMapper.COUNT);
6788 }
6789
6790 protected boolean contains(long roleId, long userId) {
6791 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6792 new Long(roleId), new Long(userId)
6793 });
6794
6795 if (results.size() > 0) {
6796 Integer count = results.get(0);
6797
6798 if (count.intValue() > 0) {
6799 return true;
6800 }
6801 }
6802
6803 return false;
6804 }
6805
6806 private MappingSqlQuery<Integer> _mappingSqlQuery;
6807 }
6808
6809 protected class AddUser {
6810 protected AddUser() {
6811 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6812 "INSERT INTO Users_Roles (roleId, userId) VALUES (?, ?)",
6813 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6814 }
6815
6816 protected void add(long roleId, long userId) throws SystemException {
6817 if (!containsUser.contains(roleId, userId)) {
6818 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
6819
6820 for (ModelListener<Role> listener : listeners) {
6821 listener.onBeforeAddAssociation(roleId,
6822 com.liferay.portal.model.User.class.getName(), userId);
6823 }
6824
6825 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6826 listener.onBeforeAddAssociation(userId,
6827 Role.class.getName(), roleId);
6828 }
6829
6830 _sqlUpdate.update(new Object[] {
6831 new Long(roleId), new Long(userId)
6832 });
6833
6834 for (ModelListener<Role> listener : listeners) {
6835 listener.onAfterAddAssociation(roleId,
6836 com.liferay.portal.model.User.class.getName(), userId);
6837 }
6838
6839 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6840 listener.onAfterAddAssociation(userId,
6841 Role.class.getName(), roleId);
6842 }
6843 }
6844 }
6845
6846 private SqlUpdate _sqlUpdate;
6847 }
6848
6849 protected class ClearUsers {
6850 protected ClearUsers() {
6851 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6852 "DELETE FROM Users_Roles WHERE roleId = ?",
6853 new int[] { java.sql.Types.BIGINT });
6854 }
6855
6856 protected void clear(long roleId) throws SystemException {
6857 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
6858
6859 List<com.liferay.portal.model.User> users = null;
6860
6861 if ((listeners.length > 0) || (userListeners.length > 0)) {
6862 users = getUsers(roleId);
6863
6864 for (com.liferay.portal.model.User user : users) {
6865 for (ModelListener<Role> listener : listeners) {
6866 listener.onBeforeRemoveAssociation(roleId,
6867 com.liferay.portal.model.User.class.getName(),
6868 user.getPrimaryKey());
6869 }
6870
6871 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6872 listener.onBeforeRemoveAssociation(user.getPrimaryKey(),
6873 Role.class.getName(), roleId);
6874 }
6875 }
6876 }
6877
6878 _sqlUpdate.update(new Object[] { new Long(roleId) });
6879
6880 if ((listeners.length > 0) || (userListeners.length > 0)) {
6881 for (com.liferay.portal.model.User user : users) {
6882 for (ModelListener<Role> listener : listeners) {
6883 listener.onAfterRemoveAssociation(roleId,
6884 com.liferay.portal.model.User.class.getName(),
6885 user.getPrimaryKey());
6886 }
6887
6888 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6889 listener.onAfterRemoveAssociation(user.getPrimaryKey(),
6890 Role.class.getName(), roleId);
6891 }
6892 }
6893 }
6894 }
6895
6896 private SqlUpdate _sqlUpdate;
6897 }
6898
6899 protected class RemoveUser {
6900 protected RemoveUser() {
6901 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6902 "DELETE FROM Users_Roles WHERE roleId = ? AND userId = ?",
6903 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6904 }
6905
6906 protected void remove(long roleId, long userId)
6907 throws SystemException {
6908 if (containsUser.contains(roleId, userId)) {
6909 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
6910
6911 for (ModelListener<Role> listener : listeners) {
6912 listener.onBeforeRemoveAssociation(roleId,
6913 com.liferay.portal.model.User.class.getName(), userId);
6914 }
6915
6916 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6917 listener.onBeforeRemoveAssociation(userId,
6918 Role.class.getName(), roleId);
6919 }
6920
6921 _sqlUpdate.update(new Object[] {
6922 new Long(roleId), new Long(userId)
6923 });
6924
6925 for (ModelListener<Role> listener : listeners) {
6926 listener.onAfterRemoveAssociation(roleId,
6927 com.liferay.portal.model.User.class.getName(), userId);
6928 }
6929
6930 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6931 listener.onAfterRemoveAssociation(userId,
6932 Role.class.getName(), roleId);
6933 }
6934 }
6935 }
6936
6937 private SqlUpdate _sqlUpdate;
6938 }
6939
6940 private static final String _SQL_SELECT_ROLE = "SELECT role FROM Role role";
6941 private static final String _SQL_SELECT_ROLE_WHERE = "SELECT role FROM Role role WHERE ";
6942 private static final String _SQL_COUNT_ROLE = "SELECT COUNT(role) FROM Role role";
6943 private static final String _SQL_COUNT_ROLE_WHERE = "SELECT COUNT(role) FROM Role role WHERE ";
6944 private static final String _SQL_GETGROUPS = "SELECT {Group_.*} FROM Group_ INNER JOIN Groups_Roles ON (Groups_Roles.groupId = Group_.groupId) WHERE (Groups_Roles.roleId = ?)";
6945 private static final String _SQL_GETGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Roles WHERE roleId = ?";
6946 private static final String _SQL_CONTAINSGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Roles WHERE roleId = ? AND groupId = ?";
6947 private static final String _SQL_GETPERMISSIONS = "SELECT {Permission_.*} FROM Permission_ INNER JOIN Roles_Permissions ON (Roles_Permissions.permissionId = Permission_.permissionId) WHERE (Roles_Permissions.roleId = ?)";
6948 private static final String _SQL_GETPERMISSIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Roles_Permissions WHERE roleId = ?";
6949 private static final String _SQL_CONTAINSPERMISSION = "SELECT COUNT(*) AS COUNT_VALUE FROM Roles_Permissions WHERE roleId = ? AND permissionId = ?";
6950 private static final String _SQL_GETUSERS = "SELECT {User_.*} FROM User_ INNER JOIN Users_Roles ON (Users_Roles.userId = User_.userId) WHERE (Users_Roles.roleId = ?)";
6951 private static final String _SQL_GETUSERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Roles WHERE roleId = ?";
6952 private static final String _SQL_CONTAINSUSER = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Roles WHERE roleId = ? AND userId = ?";
6953 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "role.companyId = ?";
6954 private static final String _FINDER_COLUMN_NAME_NAME_1 = "role.name IS NULL";
6955 private static final String _FINDER_COLUMN_NAME_NAME_2 = "role.name = ?";
6956 private static final String _FINDER_COLUMN_NAME_NAME_3 = "(role.name IS NULL OR role.name = ?)";
6957 private static final String _FINDER_COLUMN_SUBTYPE_SUBTYPE_1 = "role.subtype IS NULL";
6958 private static final String _FINDER_COLUMN_SUBTYPE_SUBTYPE_2 = "role.subtype = ?";
6959 private static final String _FINDER_COLUMN_SUBTYPE_SUBTYPE_3 = "(role.subtype IS NULL OR role.subtype = ?)";
6960 private static final String _FINDER_COLUMN_C_N_COMPANYID_2 = "role.companyId = ? AND ";
6961 private static final String _FINDER_COLUMN_C_N_NAME_1 = "role.name IS NULL";
6962 private static final String _FINDER_COLUMN_C_N_NAME_2 = "lower(role.name) = lower(CAST_TEXT(?))";
6963 private static final String _FINDER_COLUMN_C_N_NAME_3 = "(role.name IS NULL OR lower(role.name) = lower(CAST_TEXT(?)))";
6964 private static final String _FINDER_COLUMN_T_S_TYPE_2 = "role.type = ? AND ";
6965 private static final String _FINDER_COLUMN_T_S_SUBTYPE_1 = "role.subtype IS NULL";
6966 private static final String _FINDER_COLUMN_T_S_SUBTYPE_2 = "role.subtype = ?";
6967 private static final String _FINDER_COLUMN_T_S_SUBTYPE_3 = "(role.subtype IS NULL OR role.subtype = ?)";
6968 private static final String _FINDER_COLUMN_C_C_C_COMPANYID_2 = "role.companyId = ? AND ";
6969 private static final String _FINDER_COLUMN_C_C_C_CLASSNAMEID_2 = "role.classNameId = ? AND ";
6970 private static final String _FINDER_COLUMN_C_C_C_CLASSPK_2 = "role.classPK = ?";
6971 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "role.roleId";
6972 private static final String _FILTER_SQL_SELECT_ROLE_WHERE = "SELECT DISTINCT {role.*} FROM Role_ role WHERE ";
6973 private static final String _FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_1 =
6974 "SELECT {Role_.*} FROM (SELECT DISTINCT role.roleId FROM Role_ role WHERE ";
6975 private static final String _FILTER_SQL_SELECT_ROLE_NO_INLINE_DISTINCT_WHERE_2 =
6976 ") TEMP_TABLE INNER JOIN Role_ ON TEMP_TABLE.roleId = Role_.roleId";
6977 private static final String _FILTER_SQL_COUNT_ROLE_WHERE = "SELECT COUNT(DISTINCT role.roleId) AS COUNT_VALUE FROM Role_ role WHERE ";
6978 private static final String _FILTER_ENTITY_ALIAS = "role";
6979 private static final String _FILTER_ENTITY_TABLE = "Role_";
6980 private static final String _ORDER_BY_ENTITY_ALIAS = "role.";
6981 private static final String _ORDER_BY_ENTITY_TABLE = "Role_.";
6982 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Role exists with the primary key ";
6983 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Role exists with the key {";
6984 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
6985 private static Log _log = LogFactoryUtil.getLog(RolePersistenceImpl.class);
6986 private static Role _nullRole = new RoleImpl() {
6987 @Override
6988 public Object clone() {
6989 return this;
6990 }
6991
6992 @Override
6993 public CacheModel<Role> toCacheModel() {
6994 return _nullRoleCacheModel;
6995 }
6996 };
6997
6998 private static CacheModel<Role> _nullRoleCacheModel = new CacheModel<Role>() {
6999 public Role toEntityModel() {
7000 return _nullRole;
7001 }
7002 };
7003 }