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

One to Many not save link array [DATAREST-1310]

Open
#1,670 5 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

in: repository type: bug
Dominant language
Java
Stars
958
Forks
568
PR merge metrics
No merged PRs in 30d

Description

sante85 opened DATAREST-1310 and commented

Hello everyone, got one (hah!) little problem of my own with Spring Data Rest... I've got a List<Child> children in my Father object, with @OneToMany(mappedBy="father"). Together with the Repositories, this lead to the fact that I can PUT a http://localhost:8080/children/1 text/uri-list to http://localhost:8080/fathers/1/children - and get a 204. But nothing changes, since the collection will be set correctly (by RepositoryPropertyReferenceController.createPropertyReference), but that doesn't change the Child.father reference. So, is there a way to automatically update it when a child is added to the list in Spring Data Rest? Or is there a way to make the thing fail at least, because atm it's failing but claiming to succeed, which is imho the worst thing possible...
Of course, the basic problem is JPA based, since already there adding something to the list and then saving the father does not update the Child.father reference. But with Spring Data Rest, it looks like it works - but the result is wrong


Affects: 3.1.3 (Lovelace SR3)

Attachments:

Issue Links:

  • DATAREST-1311 One to Many put not change a collection
    ("is duplicated by")

3 votes, 1 watchers

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.