Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when updating a @OneToMany collection resource with a nested @ManyToOne/@OneToOne resource - PUT/PATCH #2459

Open
essl-noratt opened this issue Jan 27, 2025 · 0 comments
Assignees
Labels
status: waiting-for-triage An issue we've not yet triaged

Comments

@essl-noratt
Copy link

Spring Boot version: 3.3.2

After upgrading to Spring Boot 3, we have noticed an issue when trying to update a collection resource via the PUT and PATCH endpoints provided by Spring Data REST on a @RepositoryRestResource. When trying to update a @OneToMany collection element that has a nested @ManyToOne/@OneToOne resource, the nested resource is not being persisted correctly back to the database.

  • Adding new elements to the @OneToMany collection works fine with POST, PUT and PATCH. Nested resources are mapped correctly.
  • Updating the nested resource of an existing element in the @OneToMany collection does not update the nested resource.
  • Removing an element from the @OneToMany resource where the element isn't the last in the collection, causes all the elements after to shift up an index (which is correct) but doesn't accordingly carry their nested resource up with them, resulting in all the elements after the one being removed to have the wrong nested resources.

Please have a look at this example project which shows the setup that we have, along with a test class that will help demonstrate the issue.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

3 participants