spring-projects / spring-projects/spring-data-rest
Incorrect link to association resource [DATAREST-558]
@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
Luan Nguyen opened DATAREST-558 and commented
The reference URL above was about the embedding resource, but the problem happening on the main, not embedding resource as well. Here is how you can reproduce:
class Person {
private String name;
@OneToMany(mappedBy="person", cascade = CascadeType.ALL)
private List<Address> addresses;
}
public class Address {
private String zip;
@ManyToOne
private Person person;
}
Define an empty repository for Person:
public interface PersonRepository extends PagingAndSortingRepository<Person, Long> { }
Do not have a repository for Address. Here is the output you get when POST-ing a Person and GET-ing it back. Please note that the _links contains a strange rel person to /persons/1/person which is incorrect.
C:\test>curl -X POST -H "Content-Type:application/json" -d '{ "name" : "Frodo" }' http://localhost:8084/persons
C:\test>curl http://localhost:8084/persons/1
{
"name" : "Frodo",
"addresses" : [ ],
"_links" : {
"self" : {
"href" : "http://localhost:8084/persons/1"
},
"person" : {
"href" : "http://localhost:8084/persons/1/person"
}
}
}
Affects: 2.2.2 (Evans SR2)
Reference URL: http://stackoverflow.com/questions/29828020/spring-data-rest-generating-link-for-embedded-collection-incorrectly
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.