// @CacheEvict(value="SpringSecurityCache",allEntries=true) public void deleteRelatedPrivilegeR2s(String roleId, Collection<String> r2Ids) { Role role = roleDao.findOne(roleId); Iterable<RoleR2Privilege> r2s = roleR2PrivilegeDao.findAll(r2Ids); for (RoleR2Privilege r2 : r2s) { // 确认检查传入的关联主键是否的确属于当前关联角色 if (r2.getRole().equals(role)) { roleR2PrivilegeDao.delete(r2); } } }
@Transactional(readOnly = true) public Page<RoleR2Privilege> findRelatedRoleR2PrivilegesForRole( final String roleId, final GroupPropertyFilter groupFilter, Pageable pageable) { Specification<RoleR2Privilege> specification = new Specification<RoleR2Privilege>() { @Override public Predicate toPredicate( Root<RoleR2Privilege> root, CriteriaQuery<?> query, CriteriaBuilder builder) { Predicate predicate = buildPredicatesFromFilters(groupFilter, root, query, builder); return builder.and(predicate, builder.equal(root.get("role").get("id"), roleId)); } }; return roleR2PrivilegeDao.findAll(specification, pageable); }