On my Spring Data Rest project I have a Competition entity that references an GeoLocation entity:
public class Competition {
@Id
private String uname;
[...]
@NotNull
@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
private GeoLocation geoLocation;
}
public class GeoLocation {
@Id private Long id;
private Double latitude;
private Double longitude;
}
Since every Competition must have a GeoLocation defined, the Competition entity handles the creation via cascade. When creating a new Competition entity via POST, I get the following response:
{
"uname": "Some Competition",
"geoLocation": {
[content of geoLocation]
},
"_links": {
[...]
}
}
But when I call the newly created competition, the content of the GeoLocation will be wrapped in a content field.
{
"uname": "Some Competition",
"geoLocation": {
"content": {
[content of geoLocation]
}
},
"_links": {
[...]
}
}
I would expect that both requests would deliver the same response?