139140141142143144145146147148149
final List<?> result = query.list(); if (result.size() > 0) return null; final Role role = new Role(roleName); role.setPermissions(permissions); final Serializable entityId = session.save(role); return (Role) session.get(Role.class, entityId); }
8687888990919293949596979899
final Set<String> permissionNames = new HashSet<String>(); for (final String roleName : roleNames) { final Role role = getRole(roleName); if (role != null) for (final Permission permission : role.getPermissions()) permissionNames.add(permission.getPermissionName()); } return permissionNames; }