[英]JPQL join for eager fetch association
Say I have entity A that is the parent with @OneToMany
association to entity B. Also say I set fetch mode to eager.假设我有实体 A,它是与实体 B 具有
@OneToMany
关联的父实体。还说我将获取模式设置为渴望。 So when I use a JPQL to fetch my entities A base on some filter do I need to use join in order to get its children?因此,当我使用 JPQL 来获取我的实体基于某个过滤器时,我是否需要使用 join 来获取其子级?
You have to use join
when children are part of the query, for example:当孩子是查询的一部分时,您必须使用
join
,例如:
select p
from parent p
inner join p.children c
where c ...
but you don't have to use fetch
before join to initialize entities.但是您不必在加入之前使用
fetch
来初始化实体。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.