spring-projects / spring-projects/spring-data-rest

Updating records with foreign key relations fails silently [DATAREST-1466]

Open
#1,829 0 comments 1 reaction 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

type: bug
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:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.