【问题标题】:JPA Hibernate could not extract ResultSetJPA Hibernate 无法提取 ResultSet
【发布时间】:2015-05-27 04:37:07
【问题描述】:

当我运行这个查询时:

String queryF = "SELECT c FROM CatRoles c WHERE c.rol IN :roles OR :roles IS NULL)";
    Query q = entityManager.createQuery(queryF);
    List<String> lstRoles = Arrays.asList("EMPLEADO","ADMINISTRADOR");
    q.setParameter("roles", lstRoles);
    List<CatRoles> actual = q.getResultList();

抛出以下错误:

原因:org.hibernate.exception.DataException:无法提取 ResultSet 在 org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:135) [hibernate-core-4.2.14.SP1-redhat-1.jar:4.2.14.SP1-redhat-1]

但是当我在 Oracle SQL developer 中运行查询时运行良好,查询的目标是,当我发送角色列表时,只部署那些希望在部署完整目录时发送 null 的角色。

【问题讨论】:

    标签: hibernate jpa


    【解决方案1】:

    我认为您希望查询是:

    ... OR c.rol is NULL
    

    而不是

    ... or :roles is NULL
    

    【讨论】:

      猜你喜欢
      • 2014-07-20
      • 1970-01-01
      • 2016-05-06
      • 2016-02-17
      • 2021-08-01
      • 2017-11-22
      • 2021-07-17
      • 2015-08-03
      相关资源
      最近更新 更多