spring-projects / spring-projects/spring-data-rest
Nested entities in are not rendered correctly [DATAREST-266]
@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
Johannes Hiemer opened DATAREST-266 and commented
I have a nested Object in MongoDB which looks as follows:
@Document
public class Entity extends AbstractDocument {
private String name;
private List<SubEntity> subEntities;
This document has the SubEntity:
public class SubEntity {
private String name;
private Units units;
In this SubEntity we have the class Units, which in turn contains the problematic @DBRef annotations, which do not work.
public class Units {
@DBRef
private Unit unit;
@DBRef
private Unit divisor;
When storing a new Dataset in MongoDB, the data is saved correctly.
{
"_id" : ObjectId("5318e2db4d1a10c59b94cfaa"),
"name" : "1234",
"subEntities" : [
{
"name" : "1234"
"units" : {}
},
{
"name" : "1234"
"units" : {}
},
{
"name" : "1234"
"units" : {
"unit" : {
"$ref" : "unit",
"$id" : ObjectId("531825594d1a10c59b94cfa2")
}
}
},
Calling this dataset via SD REST, the @DBRef relation is not rendered.
{
"name": "1234",
"subEntities": [
{
"name": "1234",
"units": { }
},
{
"name": "1234",
"units": { }
},
{
"name": "1234",
"units": { }
},
Referenced from: commits https://github.com/spring-projects/spring-data-rest/commit/c7059e06a52f19a328d18bed486f7405176a1fe4
0 votes, 5 watchers
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.