英文:
JPA 2.1 @Procedure with multiple out parameters
问题
问题:调用带有多个输出参数的存储过程。
@Procedure(procedureName = "procedureName", outputParameterName = "parma1", outputParameterName = "param2")
Map<String, String> methodName();
在从服务类调用方法时,我遇到以下错误。
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$1(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)
英文:
Issue: call procedure with multiple out parameters.
@Procedure(procedureName = "procedureName" , outputParameterName = "parma1", outputParameterName = "param2")
Map<String, String> methodName();
I am getting below error while calling method from service 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$1(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)
答案1
得分: 0
以下是翻译好的内容:
在下方网址提供的详细信息中 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);
/// 调用存储过程并获取结果
query.execute();
Double sum = (Double) addBookStoredProcedure.getOutputParameterValue("sum");
英文:
Detail given below web link http://roufid.com/3-ways-to-call-a-stored-procedure-with-hibernate-jpa-2-1/ work for me.
Register the procedure manually as given below.
// Dynamic stored procedure definition.
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");
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论