具有多个输出参数的 JPA 2.1 @Procedure

JPA 2.1 @Procedure with multiple out parameters

问题:具有多个输出参数的调用过程。

@Procedure(procedureName = "procedureName" , outputParameterName = "parma1", outputParameterName = "param2")
Map<String, String> methodName();

我在从服务 class 调用方法时出现以下错误。

Caused by: java.lang.IllegalArgumentException: Type cannot be null
        at org.hibernate.query.procedure.internal.ProcedureParameterImpl.setHibernateType(ProcedureParameterImpl.java:130)
        at org.hibernate.query.procedure.internal.ProcedureParameterImpl.<init>(ProcedureParameterImpl.java:88)
        at org.hibernate.procedure.internal.ProcedureCallImpl.registerParameter(ProcedureCallImpl.java:290)
        at org.hibernate.procedure.internal.ProcedureCallImpl.registerStoredProcedureParameter(ProcedureCallImpl.java:579)
        at org.hibernate.procedure.internal.ProcedureCallImpl.registerStoredProcedureParameter(ProcedureCallImpl.java:70)
        at org.springframework.data.jpa.repository.query.StoredProcedureJpaQuery.lambda$newAdhocStoredProcedureQuery(StoredProcedureJpaQuery.java:228)
        at java.base/java.util.stream.Streams$RangeIntSpliterator.forEachRemaining(Streams.java:104)
        at java.base/java.util.stream.IntPipeline$Head.forEach(IntPipeline.java:593)
        at org.springframework.data.jpa.repository.query.StoredProcedureJpaQuery.newAdhocStoredProcedureQuery(StoredProcedureJpaQuery.java:219)
        at org.springframework.data.jpa.repository.query.StoredProcedureJpaQuery.createStoredProcedure(StoredProcedureJpaQuery.java:179)
        at org.springframework.data.jpa.repository.query.StoredProcedureJpaQuery.doCreateQuery(StoredProcedureJpaQuery.java:103)
        at org.springframework.data.jpa.repository.query.StoredProcedureJpaQuery.createQuery(StoredProcedureJpaQuery.java:93)

下面给出的详细信息 link http://roufid.com/3-ways-to-call-a-stored-procedure-with-hibernate-jpa-2-1/ 对我有用。

如下所示手动注册程序。

//动态存储过程定义。

StoredProcedureQuery addBookStoredProcedure = entityManager.createStoredProcedureQuery("addBook_sp");
addBookStoredProcedure.registerStoredProcedureParameter("sum", String.class, ParameterMode.OUT); 



/// call the stored procedure and get the result
query.execute();
Double sum = (Double) addBookStoredProcedure.getOutputParameterValue("sum");