如何使用JPA子查询使用参数

时间:2015-09-28 11:34:08

标签: java 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 个答案:

答案 0 :(得分:1)

您在查询的串联中错过了一个空格

null and" + "e.EMP_NO

应该是这样的:

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