You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to eager join OneToMany mappings of three entities, e.g.:
class A {
int id;
@OneToMany
Set<B> b;
}
class B {
int id;
@OneToMany
Set<C> c;
}
class C {
int id;
}
When fetching an object of class A, the EntityGraphFactory.create method receives in the "properties" parameter a set of:
"b.c.id",
"b.id",
"id"
As it processes the "b.c.id" property, it adds a subgraph for B to the entityGraph, then adds a subgraph for C to the subgraph for B.
However, when it proceeds to the "b.id" property, it adds a new subgraph for B to the entityGraph and overrides the previous one. Instead, it should check if the entityGraph already contains a subgraph and enrich it.
I ran into this when integrating Spring Data JPA with Spring GraphQL, and noticed that a GraphQL query
{
a {
b {
c {
id
}
}
}
}
correctly generates a single SQL query with joins, but a query
{
a {
b {
id,
c {
id
}
}
}
}
does not, and instead triggers N+1 lazy loads
The text was updated successfully, but these errors were encountered:
I'm trying to eager join OneToMany mappings of three entities, e.g.:
When fetching an object of class A, the EntityGraphFactory.create method receives in the "properties" parameter a set of:
"b.c.id",
"b.id",
"id"
As it processes the "b.c.id" property, it adds a subgraph for B to the entityGraph, then adds a subgraph for C to the subgraph for B.
However, when it proceeds to the "b.id" property, it adds a new subgraph for B to the entityGraph and overrides the previous one. Instead, it should check if the entityGraph already contains a subgraph and enrich it.
I ran into this when integrating Spring Data JPA with Spring GraphQL, and noticed that a GraphQL query
correctly generates a single SQL query with joins, but a query
does not, and instead triggers N+1 lazy loads
The text was updated successfully, but these errors were encountered: