spring-projects / spring-projects/spring-data-rest

OneToMany Relation with direct links [DATAREST-682]

Open
#1,055 3 comments 1 reaction 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

in: repository type: enhancement
Dominant language
Java
Stars
958
Forks
568
PR merge metrics
No merged PRs in 30d

Description

Thomas Letsch opened DATAREST-682 and commented

Normally SDR creates a separate URI for a one-to-many relation. This is quite right, when the relation itself provides useful additional properties.
But this comes at a cost:
To query a list of resources with related resources, you have to do additional n queries to get the related resources as well. Now if you like to use some kind of caching for the many side of the relation, this is not possible.
Of course you can work with projections. The downside of this is that you have to use different entities in list and detail queries. Which makes things like e.g. inline editing quite hard.

The corresponding class is IMHO the LinkCollectingAssociationHandler, which is manually instanciated inside the PersistentEntityJackson2Module. Making a adjustment quite hard.
Also it differs from POST / PUT where you put the URI to the other resource directly into the links section.

It would be a great improvement to have a possibility to switch between having the relationship link pointing to its own URI or pointing to a root resource URI.
Whats your opinion?

Here some links I discovered:
http://stackoverflow.com/questions/15886897/how-do-i-avoid-n1-queries-with-spring-data-rest
http://stackoverflow.com/questions/24570279/canonical-links-with-spring-hateoas
http://stackoverflow.com/questions/25143193/hateoas-restfull-entity-relation-broken

Thanks,
Thomas


Affects: 2.4 GA (Gosling)

Reference URL: http://stackoverflow.com/questions/15886897/how-do-i-avoid-n1-queries-with-spring-data-rest

1 votes, 3 watchers

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.