I'm using Spring Data REST and Hateoas in combination with HAL browser. This works perfectly, but now I would like to make a JSON dump of a specific entity with (a set of) its associated objects. I used @Projection
but then I got stuck again.
FYI: The normal behaviour (with embedded and links etc) should remain besides the new endpoint (without embedded and links).
To further illustrate my problem/question:
class Person {
String name;
List<Company> companies;
}
class Company {
String name;
Address address;
}
class Address {
String street;
}
Now I would like to see something like this:
{
"name": "John",
"companies": [
{
"name": "Stackoverflow",
"address": {"street": "Highway blvd."}
},
{
"name": "Oracle",
"address": {"street": "Main rd."}
}
]
}
While I'm getting this:
{
"name": "John",
"_links": {
"self": {"href": "http...."},
"companies": {"href": "http ..."}
},
}
See also: http://docs.spring.io/spring-data/rest/docs/current/reference/html/#projections-excerpts
In my example I introduced two difficulties I have: Lists (companies) and multiple levels: person->company->address. Both are required to work (probably 5 levels, some of which have 'many' relations).