How to expose an entity via alternate keys with spring data rest
Posted
by
dan carter
on Stack Overflow
See other posts from Stack Overflow
or by dan carter
Published on 2014-08-20T22:07:56Z
Indexed on
2014/08/20
22:20 UTC
Read the original article
Hit count: 238
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.
© Stack Overflow or respective owner