开发者

JPQL and clausole IN, not found

开发者 https://www.devze.com 2023-04-08 03:42 出处:网络
i have the following situation: In the dao class: ... Query q = em.createNamedQuery(\"myQuery\"); q.setPa开发者_如何学运维rameter(\"attr\", \"value\");

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号