@Override
 public Category get(Long id) {
   Category category = repository.findOne(id);
   if (category == null) {
     throw new EntityNotFoundException(String.format("No category with id=%d exists!", id));
   } else {
     return category;
   }
 }
 @Override
 public Category create(Category category) {
   if (category.getId() != null && repository.findOne(category.getId()) != null) {
     throw new EntityAlreadyExistsException(
         String.format("There already exists a category with id=%d!", category.getId()));
   } else if (repository.findByName(category.getName()) != null) {
     throw new EntityAlreadyExistsException(
         String.format("There already exists a category with name=%s!", category.getName()));
   } else {
     repository.save(category);
   }
   return category;
 }