使用hibernate 4.3.11.final。休眠:在子选择查询中使用IN子句时出现stange错误
我们做与@Query注解的请求,我们在子选择查询前使用在条款:
select distinct doc from DocumentType doc join doc.usages u where u.institute not in :institutes and doc.id not in (select distinct doc1.id from DocumentType doc1 join doc1.usages u1 where u1.institute in :institutes)
条款首先是正确生成(包括周围加括号),但一在次选不是。
生成的SQL是:
select distinct doc from fr.itce.pen.model.customer.folder.DocumentType doc join doc.usages u where u.institute not in (:institutes_0_, :institutes_1_) and doc.id not in (select distinct doc1.id from fr.itce.pen.model.customer.folder.DocumentType doc1 join doc1.usages u1 where u1.institute in :institutes_0_, :institutes_1_)]
一个解决办法是在申报查询用括号包围的部分为:
select distinct doc from DocumentType doc join doc.usages u where u.institute not in :institutes and doc.id not in (select distinct doc1.id from DocumentType doc1 join doc1.usages u1 where u1.institute in (:institutes))
有没有更好的办法,使工作,和/或这个'bug'在最近的hibernate版本中修复了吗?我查看了休眠问题,但我无法找到有关此行为的任何信息。
此致敬礼。
在我看来,作为我被咬伤https://hibernate.atlassian.net/browse/HHH-5126?focusedCommentId=62841&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment- 62841 – Nemesis