如何在jpa中编写这个oracle查询?

时间:2013-05-16 07:45:36

标签: oracle jpa

查询:

select *
from easquestionsinfo 
where questionname in(select questionname 
                      from easresponseinfo 
                      where isconflict = 'yes')

当queryname等于内部查询返回的记录时,此查询正常工作并返回表'easquestioninfo'中的记录,内部查询返回questionname的集合,其中isconflict ='yes'。

1 个答案:

答案 0 :(得分:1)

JPA支持JPQL,SQL和Criteria。

您可以使用createNativeQuery()直接执行此SQL。

对于JPQL,它取决于您的对象模型,可能类似于

Select q fom QuestionInfo q where q.name in (Select r.name from ResponseInfo q2 where r.isConflict = 'yes')

请参阅, http://en.wikibooks.org/wiki/Java_Persistence/JPQL