Announcement Announcement Module
No announcement yet.
Controlling which relationships are linked in spring-data-rest Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Controlling which relationships are linked in spring-data-rest

    The spring-data-rest documentation says:
    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:
    "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.
    Last edited by engywook; Apr 17th, 2013, 04:43 PM. Reason: Note about @RestResource(exported=false)

  • #2
    @RestResource only seems to work for the entities directly controlled by the repository. It will work for your parent object.
    Also, unfortunately the Jackson annotations @JsonIgnore is also ignored.
    There is a defect raised on it
    Please vote this to help priorities.