JPA Hibernate 左连接获取生成多个查询
我有一个 jpql 查询来急切地获取多级关联,如下所示
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 (?);
这会生成多个查询,尽管我在第一个选择本身中获取了所有必需的信息。所有额外的查询都是为了查询 SingerIdentifier 表数据以获取与第一个查询不同的 IdentifierId。
非常感谢在这方面的任何帮助。
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 IdentifierIds from the first query.
Any help in this regard is highly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许是拼写错误?
Maybe a typo?