Using:
org.hibernate.dialect.Oracle10gDialect
In essence, when I try to execute a Stored Procedure, I'm faced with this error:
operation not allowed: Ordinal binding and Named binding cannot be combined!
The full stack trace is as follows:
2016-08-31 13:35:37.906+0200 | APP | WARN | MvcAsync1 | o.h.e.j.s.SqlExceptionHelper | SQL Error: 17090, SQLState: 99999
2016-08-31 13:35:37.907+0200 | APP | ERROR | MvcAsync1 | o.h.e.j.s.SqlExceptionHelper | operation not allowed: Ordinal binding and Named binding cannot be combined!
2016-08-31 13:35:37.909+0200 | APP | ERROR | http-nio-8081-exec-3 | o.a.c.c.C.[.[.[.[dispatcherServlet] | Servlet.service() for servlet dispatcherServlet threw exception
java.sql.SQLException: operation not allowed: Ordinal binding and Named binding cannot be combined!
at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:5626)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1385)
at org.hibernate.result.internal.OutputsImpl.<init>(OutputsImpl.java:52)
at org.hibernate.procedure.internal.ProcedureOutputsImpl.<init>(ProcedureOutputsImpl.java:32)
at org.hibernate.procedure.internal.ProcedureCallImpl.buildOutputs(ProcedureCallImpl.java:411)
at org.hibernate.procedure.internal.ProcedureCallImpl.getOutputs(ProcedureCallImpl.java:363)
at org.hibernate.jpa.internal.StoredProcedureQueryImpl.outputs(StoredProcedureQueryImpl.java:234)
at org.hibernate.jpa.internal.StoredProcedureQueryImpl.execute(StoredProcedureQueryImpl.java:217)
at com.mycomp.services.DocumenServiceImpl.addNewDoc(DocumentServiceImpl.java:88)
at com.mycomp.backend.rest.CreateController.lambda$0(CreateController.java:39)
at org.springframework.web.context.request.async.WebAsyncManager$4.run(WebAsyncManager.java:316)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.lang.Thread.run(Thread.java:745)
The calling code is as follows:
StoredProcedureQuery sp = em.createStoredProcedureQuery("mySp")
.registerStoredProcedureParameter("param1", Integer.class, ParameterMode.IN)
.registerStoredProcedureParameter("outParam", Integer.class, ParameterMode.OUT)
.setParameter("param1", request.getTransactiontypeId());
sp.execute();
Turning on SQL debug output, it reveals the generated sql call as
{call mySp(?,?)}
.
That seems...dodgy (as it contains no hint of the specified names), but I understand it might just be hibernate doing internal translations?
IF I change the stored proc setup to use positional parameters instead, things actually work, but I would really prefer to used named parameters.
Stored proc spec:
PROCEDURE mySp (param1 IN tdocs.transactiontype_id%TYPE,
outParam OUT tdocs.doc_id%TYPE
);
This seems to be a bug in Hibernate 5.0.9. For me, switching to Hibernate 5.0.11.Final did the trick, with no other changes.
Thanks to Mihai Cicu for pointing in that direction in the comments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With