我正在使用 JPA 2.1 中的一项名为 Entity Graphs 的新功能与 QueryDSL .它工作得很好。但是当我使用 subgraph , JPA 生成无效的 SQL。这是我的示例:
@NamedEntityGraph(
name="defaultGet",
attributeNodes = {
@NamedAttributeNode("client"),
@NamedAttributeNode(value = "tests", subgraph = "testsSG")
},
subgraphs ={
@NamedSubgraph(
name="testsSG",
attributeNodes = {
@NamedAttributeNode("template")
}
)
}
)
这里是生成的SQL:
select
...correct stuff....
from
iq_applicant applicant0_
left outer join
iq_test tests1_
on applicant0_.id=tests1_.applicant
left outer join
iq_template template2_
on tests1_.template=template2_.id cross
join
//WTF?? empty lane??
left outer join
iq_client client3_
on applicant0_.client=client3_.id
那条空荡荡的车道在那里做什么?这是错误吗?
最佳答案
我想这是 Hibernate 的问题。有几个问题: https://hibernate.atlassian.net/browse/HHH-9175 https://hibernate.atlassian.net/browse/HHH-9392
关于java - JPA 2.1 实体图的子图生成空连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21780017/