Quantcast
Channel: Spring Community Forums - Data
Viewing all articles
Browse latest Browse all 297

Controlling which relationships are linked in spring-data-rest

$
0
0
The spring-data-rest documentation says:
Quote:

If two entities are related to one another through a database-defined relationship, then that relationship will appear in the JSON as a link.
Is there a way to prevent a particular relationship from appearing as a link in the JSON, perhaps by extending RepositoryRestMvcConfiguration? I'd like for certain relationship's data to be embedded in the JSON rather than linked.

For example, currently owner is a link, but I'd rather it appeared as:
Code:

"content" : [ {
    "timestamp" : 1365191855896,
    "id" : "17109",
    "name" : "Fido",
    "owner" : {
        "id" : 2,
        "name" : "John Smith"
      }
}]

Adding @RestResource(exported = false) to the OwnerRepository would result in the JSON output I'm looking for but I'd like to still be able to query Owners directly.

Viewing all articles
Browse latest Browse all 297

Trending Articles