DongHoon  Kim
DongHoon Kim

Reputation: 386

Is that possible using queryDSL?

There are two entities A and B relate one to many.

enter image description here

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

Answers (1)

Robert Bain
Robert Bain

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

Related Questions