甲骨文。参数为空时,JPA 2.1“缺少IN或OUT参数”

时间:2015-01-30 12:29:27

标签: oracle hibernate jpa

我尝试使用null参数调用oracle存储过程。并得到错误 " java.sql.sqlexception在索引中缺少in或out参数..."

命名存储过程声明

    @NamedStoredProcedureQuery(
    name = "testDeal",
    procedureName = "pkg_api.test_deal",
    parameters = {
       @StoredProcedureParameter(mode = ParameterMode.IN, name = "p_id_in", type = Integer.class),
       @StoredProcedureParameter(mode = ParameterMode.OUT, name = "p_id_out", type = Integer.class)
    }
    ),

致电

   StoredProcedureQuery query = em.createNamedStoredProcedureQuery("testDeal");
    query.setParameter("p_id_in",null);
    query.execute();

PL / SQL

  procedure test_deal(p_id_in      in  number default null,
                     p_id_out     out  number) is
  begin
    p_id_out:= coalesce(p_id_in,666);  
  end;                  

如果我用非null参数执行过程,它可以正常工作。

我用:

Ojdbc7 12.1.0.2

休眠-JPA-2.1

Spring 4.1.1

Oracle版本12.1.0.2

0 个答案:

没有答案