|
I am attempting to use stored procedures with the Spring Data JPA @Procedure annotation on my repository database. I'm unable to use any H2 stored procedure do to improper handling of the "out" parameters.
I have a lengthy post here: http://stackoverflow.com/questions/32319488/how-do-i-execute-an-h2-stored-procedure-with-spring-data-jpa-hibernate which I answered with:
I did some debugging and the short answer is that Hibernate JPA (at least 5.0.0 and below) does not support stored procedures for H2Dialect.
The H2Dialect inherits Dialect.getCallableStatementSupport() which returns StandardCallableStatementSupport.NO_REF_CURSOR_INSTANCE. The standard callable statement support does not properly handle the H2 "out" parameter which is a Java return value and not a statement parameter. I tried extending the H2Dialect and StandardCallableStatementSupport classes to create versions that support H2 callable statements. I then ran into issues in the org.hibernate.procedure.internal.ProcedureCallImpl#buildOutputs method. This method implements it's own statement preparation instead of using the CallableStatementSupport#registerParameters method. There doesn't appear to be a clean way to extend ProcedureCallImpl or buildOutputs. I tried a modified version of the class to see if not including the output parameter in the statement would even work. I found that though it called the procedure it then didn't know how to process the result.
|