JPQL 和clausole IN,未找到
我有以下情况:
在 dao 类中:
...
Query q = em.createNamedQuery("myQuery");
q.setParameter("attr", "value");
List<MyObj> listMyObj = q.getResultList();
...
在我的文件 orm.xlm 中,我定义了此查询:
<named-query name="myQuery">
<query><![CDATA[
select m from MyEntity1
where id_est in (select mm.id from MyEntity2 where mm.id_est = :attr)
]]></query>
</named-query>
一切正常,没有配置问题和/或代码,但在 sql 中执行相同查询时,此查询返回 0 个元素返回预期的项目。为什么? JPQL 中有一些我忽略的东西吗?
i have the following situation:
In the dao class:
...
Query q = em.createNamedQuery("myQuery");
q.setParameter("attr", "value");
List<MyObj> listMyObj = q.getResultList();
...
In my file orm.xlm, i defined this query:
<named-query name="myQuery">
<query><![CDATA[
select m from MyEntity1
where id_est in (select mm.id from MyEntity2 where mm.id_est = :attr)
]]></query>
</named-query>
Everything works, there are no configuration problems and / or code, but this query returns 0 elements, when execute the same query in sql returns items expected . Why? There is something i ignore in JPQL?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这种情况下,如果 mm.id_est 是一个字符串,当您设置参数时不要使用
而是使用
...这是我的问题。幸运的是,多亏了这篇文章,我意识到在我的代码中我写的就像我在 StackOverflow 上写的那样
In this case, if mm.id_est is a String when you set parameter don't use
but use
...this was my problem. Fortunately, thanks to this post I realized that in my code I had written as I wrote here on StackOverflow