2014-03-03 56 views
0

這裏是我從數據庫中選擇:JPA選擇使用IN

SELECT * FROM testlogging.employees 
where 
    EMPLOYEE_NO in (
    select EMPLOYEES_EMPLOYEE_NO from testlogging.test_logging 
    where ID in (
     select TEST_LOGGING_ID from testlogging.test_logging_detail 
     where APPROVAL_LEVELS_ID = '4' 
    ) 
) 

我會怎麼做這在JPA?

SELECT e FROM Employees e ??? 

回答

0

如果你問的JPA IN語法,你這樣做:

SELECT e FROM Employees e where e.employee_no IN :employeelist 

以及屁股

query.setParameter("employeelist" , yourlist); 

,當然建立yourlist相應。如果你不需要參數化內部查詢,你可以忽略這一點,只是走直線路線。

乾杯,