@Override @Transactional @PreAuthorize("hasRole('ROLE_ADMIN')") public void remove(Long id) throws IllegalArgumentException { Category category = categoryRepository.findOne(id); if (category == null) { throw new IllegalArgumentException(String.format("Category with id=%d does not exist.", id)); } /*List<Question> questions = questionRepository.findByCategory(category); for (Question question : questions) { question.setCategory(null); questionRepository.save(question); }*/ categoryRepository.delete(id); }
@Override public Category findOne(Long id) { return categoryRepository.findOne(id); }