I'm having a problem to expose RevisionRepository
(Spring Data Envers) endpoints for my repository which extends RevisionRepository
as below :
@RepositoryRestResource(path = "disciplines", itemResourceRel = "disciplines")
public interface DisciplineRepository extends
RevisionRepository<Discipline, Integer, Integer>,
CrudRepository<Discipline, Integer>{
@RestResource(path = "findByName", rel = "findByName")
List<Discipline> findByName(String name);
}
Only findByName
method is exposed, is there any other way to expose the methods in RevisionRepository
? I've also tried to override those methods in DisciplineRepository
but it doesn't work.
Thank You...
You'll have to write a custom controller method to implement this, something like the following:
@Autowired
private DisciplineRepository disciplineRepository;
@RequestMapping(value = "/disciplines/{id}/changes", method = RequestMethod.GET)
public ResponseEntity<Resource<RevisionsObject>> getDisciplineRevisions(@PathVariable(value = "id")Discipline discipline) {
if (discipline != null) {
Revisions<Integer, Discipline> disciplineRevisions = disciplineRepository.findRevisions(discipline.getId());
return new ResponseEntity<>(new Resource<>(disciplineRevisions), HttpStatus.OK);
} else {
throw new ResourceNotFoundException();
}
}