I had was to expose the primary key which is annotated with @Id in entity.the ID field is only visible on the resource path, but not on the JSON body.
How to expose the resourceId with Spring Data Rest
7.1k Views Asked by Chandra At
2
There are 2 best solutions below
0
nahueltori
On
The best solution would be not to using the IDs of your entities, and use the link references the hypermedia provides. You just need to parse your JSON accordingly to the HAL specification used by Spring Data Rest.
Related Questions in SPRING
- Redirect inside java interceptor
- Spring RestTemplate passing the type of the response
- spring-integration-dsl-groovy-http return null when i use httpGet method
- Custom Spring annotation for request parameters
- Spring - configure Jboss Intros for xml with java config?
- HTTP Status 404 - Not Found in Spring 3.2.7
- AndroidAnnotations how to use setBearerAuth
- android I/O error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found
- Show login dialog when not authenticated yet
- Spring Data Rest supporting json and xml
- @Value annotation not resolved in a class that belongs to dependency jar
- Remove nested _embedded fields while using projections
- How to send Rest GET request that contains "#" value in url parameters?
- How to inject spring bean into Validator(hibernate)
- How to keep a variable in the URL when using Spring LocaleChangeInterceptor
Related Questions in SPRING-DATA-REST
- Spring Data Rest supporting json and xml
- Remove nested _embedded fields while using projections
- Spring Cloud FeignClient decoding application/hal+json Resource<Object> return type
- Error consuming subresources link with RestTemplate
- Spring Data Rest: Return Resources of User
- how to introduce etag and version headers with spring data rest abstraction
- Build Neo4J Graph from Json in Spring
- Accept header precedence with spring-data-rest
- LocalDateTime is not converted to String but to Json object
- Spring Data Rest executes query but returns 500 internal Server Error
- is there any sparql vocab parser available for java so I can use that to read SPARQL and create JPA criteria out of it
- Spring Boot LocalDate field serialization and deserialization
- Expose all IDs when using Spring Data Rest
- Spring data Rest Partitioning Data
- Empty references and collections in Projections processing issue
Related Questions in SPRING-HATEOAS
- Spring HATEOAS + JPA links
- Spring Cloud FeignClient decoding application/hal+json Resource<Object> return type
- Error consuming subresources link with RestTemplate
- how to introduce etag and version headers with spring data rest abstraction
- Jackson vs. Spring HATEOAS vs. Polymorphism
- Use a different column as path for resource
- Spring HATEOAS. Embedded resource + ability to CRUD it?
- Spring Data REST and IdClass - not compatible?
- AngularJS - $routeProvider's resolve property results in undefined object in corresponding controller
- How to access HAL _links within _embedded resources with JavaScript / AngularJS
- Gradle Not Honoring Forced Dependency Version
- @RepositoryRestResource sub path configuration
- Customising json output in spring hateoas
- Spring Boot's TestRestTemplate with HATEOAS PagedResources
- Cross-service linking for HATEOAS micro-services
Related Questions in HYPERMEDIA
- Is it possible to do Hypermedia Driven RESTFul service in a microservices world?
- Does HATEOAS increase the number of calls to server?
- Should a RESTful API avoid requiring the client to know the resource hierarchy?
- Optionally disable HATEOAS format in Spring Data Rest
- Links (relations) to REST resources in AngularJS
- REST without hypermedia?
- RESTFul way to reference resource with unique fields
- Sails.JS and Hypermedia HATEOAS Examples?
- REST Hypermedia: Should the actions be filtered based on the user's permissions?
- Understanding the abstract jargons in REST
- Get route by name
- HATEOS with HAL and links to embedded ressources
- Hypermedia API Link Traversal & Practicality
- Implementing hypermedia-driven API with Grape (or Sinatra)
- Implementing Hypermedia using flask-restless
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
You can configure this using the
RepositoryRestConfigurerAdapteron entity level.Be aware that using this you are working against the principles of spring-data-rest - sdr promotes hypermedia to be able to use an API by navigating between resources using links - here your resources are identified and referenced by links and thus the ids are not needed anymore. Using ids on your client pushes the complexity of constructing links to resources to the client. And the client should not be bothered with this knowledge.