spring-projects / spring-projects/spring-data-rest
Updating records with foreign key relations fails silently [DATAREST-1466]
@odrotbohm is already working on this.
Since Dec 31, 2020.
- Dominant language
- Java
- Stars
- 958
- Forks
- 568
- PR merge metrics
- No merged PRs in 30d
Description
jwenting opened DATAREST-1466 and commented
When having 2 entities Group and AllowedEmailAddress, with AllowedEmailAddress having a foreign key into Group, trying to update the foreign key to another record in Group fails without error.
For example, I create 2 records in Group, with IDs 1 and 2.
Then create a record in AllowedEmailAddress pointing to record 1 in Group.
Now through the REST interface try to update this record to point to record 2.
On retrieval of AllowedEmailAddress it still points to record 1 in table Group (and also the database is not updated).
Debugging leads to the following code path:
AllowedEmailAddress->MethodProperty->BeanDeserializer->ObjectReader->DomainObjectReader->JsonPatchHandler-> #data lost# PersistentEntityResourceHandlerMethodArgumentResolver
Demo project to reproduce this has been attached. Problem has been identified in versions of Spring Boot going back to 2.0.x, in Spring Boot 1.4.x it worked as expected.
Affects: 3.2.3 (Moore SR3)
Attachments:
- spring-data-jpa-error-demo.zip (124.85 kB)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.