开发者

JPA Hibernate left join fetch generating mutiple queries

开发者 https://www.devze.com 2023-04-11 06:05 出处:网络
I have a jpql query to eagerly fetch multi level associations as follows select distinct s from Singer s

I have a jpql query to eagerly fetch multi level associations as follows

  select distinct s from Singer s
  left join fetch s.singerIdentifiers si  //singerIdentifiers is collection in Singer object
  left join fetch si.identifier i
  left join fetch i.identifierReportedAreas ira
  left join fetch irc.reportedArea ra
  left join fetch rc.reportingSystem rs
  where s.id in (?);

This generates multiples queries, though I am getting all the required information in the first select itself. All extra queries are for querying SingerIdentifier table data for distinct Identi开发者_运维知识库fierIds from the first query.

Any help in this regard is highly appreciated.


Maybe a typo?

  left join fetch i.identifierReportedAreas -->ira<--
  left join fetch -->irc<---.reportedArea ra
0

精彩评论

暂无评论...
验证码 换一张
取 消