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 answers
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
- HTTPS configuration in Spring Boot, server returning timeout
- Multi Tenancy in Spring - Partitioned Data Approach
- How to create beans of the same class for multiple template parameters in Spring
- org.telegram.telegrambots.meta.exceptions.TelegramApiException: Bot token and username can't be empty
- Springboot: How to get an entity optional property and check null?
- How do I propagate the current SecurityContext to my @RabbitListener in Spring Boot?
- Spring's XML based bean configuration for Object Mapper's Case Insensitive property
- Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. I'm using Postgresql
- springboot class org.hibernate.mapping.Bag cannot be cast to class org.hibernate.mapping.SimpleValue
- Issue while deploying JDK 17 and Spring 6 application in Tomcat 10.1.20
- Spring JPA Data Auditing - How to design it?
- Springframework test: Async not started
- Error: Cannot invoke "jakarta.servlet.http.HttpSession.getAttribute(String)" because "session" is null
- How does spring-retry determine which methods to retry when @Retryable is placed at the class level?
- problem with edge server registration in Eureka
Related Questions in SPRING-DATA-REST
- Multi Tenancy in Spring - Partitioned Data Approach
- Update with Values in Spring JPA Native Query for Postgresql
- Spring boot with Spring data rest handle ManyToMany relation
- Configure Spring-Hateoas in a Spring-Data-Rest application for non Rest components
- Using custom media type (not HAL)
- Spring data rest - Is there a way to restrict some operations?
- How to specify "not null" to Spring Data REST / QueryDsl for a HTTP query parameter?
- Modelling entities in hibernate
- How to make Spring Data REST fail on a DB constraint error on POST?
- Why does Spring Data REST ignore cascade ops on an associated entity?
- Cannot instantiate Querydsl Predicate in Spring Data Rest
- model mapper not being able to map a nested entity to a dto
- How can I convert an Object to a JSON reperesentation using Spring Data REST outside of RestController?
- How to add api doc to generated spring jpa endpoints
- Disable profile controller in spring boot
Related Questions in SPRING-HATEOAS
- How to serialize object to application/hal+json in Spring Boot Unit test?
- Spring HATEOAS relation link encoding
- How to prevent Spring boot from calling Hateoas org.springframework.hateoas.mvc.UriComponentsContributor
- Jackson convertValue with RepresentationModel objects
- Configure Spring-Hateoas in a Spring-Data-Rest application for non Rest components
- Model name mapping with Open API Code generator
- Target url placeholders missing after upgrading from spring-hateoas 1.3.5 to 2.1.2
- hateoas links are not properly creating after spring boot 3 upgrade
- How can I populate links to paged entities in Spring Boot?
- Rename "_embedded" to "data" or anything else in spring-hateoas
- Use case of HATEOAS between Angular frontend and Spring Boot
- How do I configure Spring Data REST to return links with templated ID such as users/{id}
- Spring hateoas could not resolve entity from URI when requestbody is List<EntityModel<Data1>> - Bulk Add
- linkTo(): Not enough variable values to expand when @RequestMapping("${app-controller.path}") comes from properties
- How to implement hateoas in Quarkus
Related Questions in HYPERMEDIA
- SpringBoot Hypermedia without HATEOAS
- Why does HATEOAS not specify a schema for the request body
- HATEOS with HAL and links to embedded ressources
- How to reference a resource in a update-request of a hypermedia api?
- URL Format for a PATCH that links two objects
- Does the API Platform framework fully support HATEOAS?
- Hypertext Forms - ETag in the hypermedia control
- REST - Should an API client "advance" to the "next" resource like a browser?
- REST - Typed resources vs HYDRA classes
- How to handle nested resources with JSON HAL?
- How to access 'rel' from Links in header? Hypermedia link relations
- HAL - is it a violation to the HAL format/standard if links are in the main body?
- RESTful service response should be splited into pieces
- How to get a response in HAL-Format with Spring-Hateoas
- Hypermedia API - Is direct requests an anti pattern?
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?
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)
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.