如何使用JPA子查询参数

问题描述:

我正在尝试编写此查询。但是这个查询在获取结果时给我一个错误。请让我知道查询有什么问题。如何使用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

添加您的错误代码还有 –

你已经错过了在查询的串联空间

null and" + "e.EMP_NO

应该是这样的:

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

+1

谢谢秒。我了解,参数不能在子查询中传递。没有看到查询语法。再次感谢 –