2017-04-14 93 views
0

使用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版本中修复了吗?我查看了休眠问题,但我无法找到有关此行为的任何信息。

此致敬礼。

+0

在我看来,作为我被咬伤https://hibernate.atlassian.net/browse/HHH-5126?focusedCommentId=62841&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment- 62841 – Nemesis

回答

0

也许这是一个错误,但它不会在4.3中修复。

您需要在测试用例5.2上复制它并打开Jira问题。

+0

嗡嗡声我们通过一个名单的要求,所以我想我们尊重这方面,但也许我不明白你的答案。 – Nemesis

+0

我更新了我的回答 –

+0

我会这么做,非常感谢! – Nemesis

0

这是一个错误,它通过休眠5.2纠正。