Tomas Kraus (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=632dad3...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZDNlOGIwNDQw...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-15542?atlOrigin=eyJpIjoiZDNlOG...
) HHH-15542 (
https://hibernate.atlassian.net/browse/HHH-15542?atlOrigin=eyJpIjoiZDNlOG...
) Cannot invoke "org.hibernate.query.BindableType.getBindableJavaType()" because
"parameterType" is null (
https://hibernate.atlassian.net/browse/HHH-15542?atlOrigin=eyJpIjoiZDNlOG...
)
Issue Type: Bug Affects Versions: 6.0.0, 6.1.3 Assignee: Unassigned Components:
hibernate-core Created: 23/Sep/2022 06:15 AM Environment: Hibernate 6.1.3.Final, Oracle
21c, ojdbc11 21.3.0.0, Helidon 3.0.1, JDK 17, 18, 19RC Priority: Critical Reporter: Tomas
Kraus (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=632dad3...
)
query.registerStoredProcedureParameter("rec_out", ResultSet.class,
ParameterMode.REF_CURSOR);
does not work since 6.0.0.Beta2 , last working version was 6.0.0.Beta1.
Test case:
Have following stored procedure
CREATE OR REPLACE PROCEDURE GET_ADDRESS_BY_NAME (
fname_in IN PERSON.FIRST_NAME%TYPE,
lname_in IN PERSON.LAST_NAME%TYPE,
rec_out OUT SYS_REFCURSOR,
err_out OUT VARCHAR) IS
BEGIN
OPEN rec_out FOR
SELECT A.STREET, A.CITY, A.ZIP
FROM PERSON P, ADDRESS A
WHERE P.ADDRESS_ID = A.ID
AND P.FIRST_NAME = fname_in
AND P.LAST_NAME = lname_in;
EXCEPTION
WHEN OTHERS THEN
err_out := SQLCODE || ' ' || SQLERRM;
END;
/
and DB tables:
CREATE TABLE ADDRESS (
ID NUMBER NOT NULL PRIMARY KEY ,
STREET VARCHAR (64),
CITY VARCHAR (64),
ZIP VARCHAR (16)
);
CREATE TABLE PERSON (
ID NUMBER NOT NULL PRIMARY KEY ,
FIRST_NAME VARCHAR (64),
LAST_NAME VARCHAR (64),
BIRTH_DATE DATE ,
ADDRESS_ID NUMBER REFERENCES ADDRESS(ID)
);
And code to call stored procedure from hibernate:
public List<Address> listAddressesForName( String firstName, String lastName) {
StoredProcedureQuery query = em.createStoredProcedureQuery(
"GET_ADDRESS_BY_NAME" );
query.registerStoredProcedureParameter( "fname_in" , String.class,
ParameterMode.IN);
query.registerStoredProcedureParameter( "lname_in" , String.class,
ParameterMode.IN);
query.registerStoredProcedureParameter( "rec_out" , ResultSet.class,
ParameterMode.REF_CURSOR);
query.registerStoredProcedureParameter( "err_out" , String.class,
ParameterMode.OUT);
ResultSet rs = null ;
try {
query
.setParameter( "fname_in" , firstName)
.setParameter( "lname_in" , lastName);
query.execute();
rs = (ResultSet) query.getOutputParameterValue( "rec_out" );
List<Address> listAddress = new LinkedList<>();
while (rs.next()) {
Address address = new Address(
-1,
rs.getString(1),
rs.getString(2),
rs.getString(3));
listAddress.add(address);
}
return new ArrayList<>(listAddress);
} catch (SQLException e) {
e.printStackTrace();
throw new TestException( "Could not retrieve Addresses for " +
firstName + " " + lastName, e);
} finally {
if (rs != null ) {
try {
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
Call of registerStoredProcedureParameter("rec_out", ResultSet.class,
ParameterMode.REF_CURSOR); always fails with
java.util.concurrent.ExecutionException: Unhandled 'cause' of this exception
encountered.
at
io.helidon.webserver.RequestRouting$RoutedRequest.defaultHandler(RequestRouting.java:398)
at
io.helidon.webserver.RequestRouting$RoutedRequest.nextNoCheck(RequestRouting.java:379)
at
io.helidon.webserver.RequestRouting$RoutedRequest.nextNoCheck(RequestRouting.java:347)
at io.helidon.webserver.RequestRouting$RoutedResponse.send(RequestRouting.java:484)
at
com.oracle.test.service.TestService.lambda$listAddressesForName$14(TestService.java:156)
at
java.base/java.util.concurrent.CompletableFuture.uniExceptionally(CompletableFuture.java:990)
at
java.base/java.util.concurrent.CompletableFuture$UniExceptionally.tryFire(CompletableFuture.java:974)
at
java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
at
java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1773)
at
java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
at
java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
at
java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Caused by: java.lang.NullPointerException: Cannot invoke
"org.hibernate.query.BindableType.getBindableJavaType()" because
"parameterType" is null
at
org.hibernate.procedure.internal.ProcedureCallImpl.registerParameter(ProcedureCallImpl.java:521)
at
org.hibernate.procedure.internal.ProcedureCallImpl.registerStoredProcedureParameter(ProcedureCallImpl.java:407)
at
org.hibernate.procedure.internal.ProcedureCallImpl.registerStoredProcedureParameter(ProcedureCallImpl.java:103)
at com.oracle.test.dao.PersonDao.listAddressesForName(PersonDao.java:84)
at
com.oracle.test.service.TestService.lambda$listAddressesForName$12(TestService.java:146)
at
java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
... 6 more
But this code is regular use-case to call stored procedure which is returning DB CURSOR as
one of OUT parameters. It was working fine in older releases and it looks like 6.0.0.Beta2
regression.
(
https://hibernate.atlassian.net/browse/HHH-15542#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-15542#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100207- sha1:4756b15 )