2015-09-28 95 views
1

我正在嘗試編寫此查詢。但是這個查詢在獲取結果時給我一個錯誤。請讓我知道查詢有什麼問題。如何使用JPA子查詢參數

List<String[]> returnList = new ArrayList<String[]>(); 
    String nativeQuery = "select EMP_NO, FIRST_NAME, LAST_NAME from isisdba.emplyee e where e.EMP_ACTIVE_IND='A' and e.END_DATE is null and" + 
     "e.EMP_NO in (select er.EMP_NO from isisdba.employee_role er where er.ROLE_id in (select r.ROLE_ID from isisdba.roles r where r.ROLE_NAME in (:roles)))"; 
    Query query = em.createNativeQuery(nativeQuery); 
    query.setParameter("roles" 

, roles); 

由於提前

+1

添加您的錯誤代碼還有 –

回答

1

你已經錯過了在查詢的串聯空間

null and" + "e.EMP_NO

應該是這樣的:

null and " + /* Here space is needed */ "e.EMP_NO

+1

謝謝秒。我瞭解,參數不能在子查詢中傳遞。沒有看到查詢語法。再次感謝 –