JPQL and clausole IN, not found
i have the following situation:
In the dao class:
...
Query q = em.createNamedQuery("myQuery");
q.setPa开发者_如何学运维rameter("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?
In this case, if mm.id_est is a String when you set parameter don't use
" 'value' "
but use
" value "
...this was my problem. Fortunately, thanks to this post I realized that in my code I had written as I wrote here on StackOverflow
精彩评论