spring-data-rest icon indicating copy to clipboard operation
spring-data-rest copied to clipboard

Expose ManyToOne relations from composite key in _links?

Open mwyrembl opened this issue 2 years ago • 3 comments

I have an Embeddable composite key consisting of two ManyToOne relations. Currently they are exposed as one self href item resource link. Is it possible to additionally expose each ManyToOne relation as a separate item resource link in the _links section?

mwyrembl avatar Mar 16 '23 20:03 mwyrembl

Could you include a link to a reproducer, staged on github, ideally using https://start.spring.io, H2 (or Testcontainers for PostGreSQL, etc.), that demonstrates the feature you are looking?

gregturn avatar Mar 20 '23 15:03 gregturn

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-projects-issues avatar Mar 27 '23 15:03 spring-projects-issues

@gregturn Here is the reproducer: https://github.com/mwyrembl/spring-data-rest-2240 If you start the project and request the resource: http://localhost:8080/cs/1_1 you get:

{
  "d": {},
  "_links": {
    "self": {
      "href": "http://localhost:8080/cs/1_1"
    },
    "c": {
      "href": "http://localhost:8080/cs/1_1"
    }
  }
}

my question is if it is also possible to include links to A and B from the CId class like this without adding many-to-one relations in C class directly:

{
  "d": {},
  "a": {},
  "b": {},
  "_links": {
    "self": {
      "href": "http://localhost:8080/cs/1_1"
    },
    "c": {
      "href": "http://localhost:8080/cs/1_1"
    }
  }
}

mwyrembl avatar Mar 28 '23 08:03 mwyrembl