'Passing quarkus.hibernate-orm.proc.param_null_passing" - dont work : Call Stored Procedure
Thanks a lot for the opportunity..
I will try to pass 2 parameters in my Quarkus rest code, using Hibernate call stored Procedure at oracle database.
Unfortunatily when I try to call the Oracle procedure, I receive this error:
[io.qua.config] (Quarkus Main Thread) Unrecognized configuration key "quarkus.hibernate-orm.proc.param_null_passing" was provided;
at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:106)
at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:372)
at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:218)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:519)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:261)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:161)
at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:164)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:247)
at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:138)
at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler$1.run(VertxRequestHandler.java:93)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder$13.runWith(VertxCoreRecorder.java:536)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2442)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1476)
at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.IllegalArgumentException: The parameter at position [7] was null. You need to call ParameterRegistration#enablePassingNulls(true) in order to pass null parameters.```
----------------------------
>> Follow my code:
>StoredProcedureQuery query = em.createStoredProcedureQuery("{ ? = call mypackage.myprocedure(?,?,?,?,?,?,?,?,?)} ");
> query.setHint("quarkus.hibernate-orm.proc.param_null_passing", true);
> query.registerStoredProcedureParameter(1, Integer.class, ParameterMode.OUT);
> query.registerStoredProcedureParameter(2, Long.class, ParameterMode.IN);
> query.registerStoredProcedureParameter(3, String.class, ParameterMode.IN);
> query.registerStoredProcedureParameter(4, String.class, ParameterMode.IN);
> query.registerStoredProcedureParameter(5, String.class, ParameterMode.IN);
> query.registerStoredProcedureParameter(6, Long.class, ParameterMode.IN);
> query.registerStoredProcedureParameter(7, String.class, ParameterMode.IN);
> query.registerStoredProcedureParameter(8, String.class, ParameterMode.IN);
> query.registerStoredProcedureParameter(9, String.class, ParameterMode.OUT);
> query.registerStoredProcedureParameter(10, String.class, ParameterMode.OUT);
> query.setParameter(2, x);
> query.setParameter(3, xx);
> query.setParameter(4, xxxx);
> query.setParameter(5, ccccc);
> query.setParameter(6, sssss);
> query.setParameter(7, null);
> query.setParameter(8, null);
Thanks a lot for the response and help.
Solution 1:[1]
As far as I know, you cannot use quarkus.hibernate-orm.proc.param_null_passing
as a query hint.
You can set the property hibernate.proc.param_null_passing
globally for hibernate. Quarkus doesn't let you set this directly (in you application.properties
) you would have to do it with a persistence.xml
. As noted in the quarkus hibernate docs however, you cannot mix and match the two - if you already have any hibernate-orm
properties in application.properties
you'll have to move them over to persistence.xml
Something like this for example (which I've not tested)
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="MyPersistenceUnit" >
<properties>
<property name="hibernate.proc.param_null_passing" value="true" />
</properties>
</persistence-unit>
</persistence>
You can use query hints to handle this though. You must set it for each parameter, for example a query hint query.setHint("hibernate.proc.param_null_passing.7", true)
. If you are using named instead of indexed parameters, you could set swap out 7
for the name instead.
It is worth noting, that according the hibernate documentation, this is all deprecated and will be handled implicitly (since hibernate 5.3), but I've not had any luck with that actually work - I use query hints with named parameters.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Martin Cassidy |