Reputation: 386
There are two entities A and B relate one to many.
I want to extract "B_2" with there parent("A_1") and children("B_1", "B_2", "B_3") of there parent. So I try my code below.
from(QB.b).join(QB.b.a, QA.a).fetch().join(QA.a.bList).fetch().where(QB.b.name.eq("B_2"));
But result B.a.bList are just proxy object. And it occur to N+1 problem. Anyone help?
Upvotes: 0
Views: 153
Reputation: 9576
For the purposes of this example, let's called the Querydsl query types for entity A a
and for entity B b
.
.from(a)
.innerJoin(b)
.on(a.a_id).eq(b.a_id)
.where(b.name.eq("B_2"))
.fetch();
Upvotes: 1