2013-05-16 18 views
-1

查詢:如何在jpa中寫這個oracle查詢?

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

此查詢工作正常,並返回我的記錄,從表「easquestioninfo」當questionname等於由內部查詢返回的一個返回questionname的地方isconflict =「是」集。

+0

這個問題沒有直接關係,也不符合JSF也不PrimeFaces。 –

+0

你說得對。但是我想在xhtml頁面上使用primefaces標籤顯示這個查詢返回的數據。 – OnkarY

回答

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

+0

非常感謝James!有效 :) – OnkarY