How to expose an entity via alternate keys with spring data rest
- by dan carter
Spring-data-rest does a great job exposing entities via their primary key for GET, PUT and DELETE etc. operations.
/myentityies/123
It also exposes search operations.
/myentities/search/byMyOtherKey?myOtherKey=123
In my case the entities have a number of alternate keys. The systems calling us, will know the objects by these IDs, rather than our internal primary key. Is it possible to expose the objects via another URL and have the GET, PUT and DELETE handled by the built-in spring-data-rest controllers?
/myentities/myotherkey/456
We'd like to avoid forcing the calling systems to have to make two requests for each update.
I've tried playing with @RestResource path value, but there doesn't seem to be a way to add additional paths.