@Transactional(readOnly = true) public User getUserWithRoles() { User user = userRepository.findOneByLogin(SecurityUtils.getCurrentUser().getUsername()).get(); user.getRoles().size(); // eagerly load the association return user; }
@Transactional(readOnly = true) public User getUserWithRoles(Long id) { User user = userRepository.findOne(id); user.getRoles().size(); // eagerly load the association return user; }