[JIRA] (HHH-15542) Cannot invoke "org.hibernate.query.BindableType.getBindableJavaType()" because "parameterType" is null
by Tomas Kraus (JIRA)
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=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100207- sha1:4756b15 )
2 years, 3 months
[JIRA] (HHH-15541) Loom (virtual threads) support
by Jonathan Halliday (JIRA)
Jonathan Halliday ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=632d62d... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiOWFkMTE4OTc3... ) / Improvement ( https://hibernate.atlassian.net/browse/HHH-15541?atlOrigin=eyJpIjoiOWFkMT... ) HHH-15541 ( https://hibernate.atlassian.net/browse/HHH-15541?atlOrigin=eyJpIjoiOWFkMT... ) Loom (virtual threads) support ( https://hibernate.atlassian.net/browse/HHH-15541?atlOrigin=eyJpIjoiOWFkMT... )
Issue Type: Improvement Assignee: Unassigned Created: 23/Sep/2022 01:15 AM Priority: Major Reporter: Jonathan Halliday ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=632d62d... )
The JDK 19 release brings a preview of Project Loom ( https://openjdk.org/jeps/425 ) , virtual threads for Java. As virtual threads are just Threads, Hibernate already runs on Loom without any changes. However, to utilize Loom with best efficiency, code must deal with some limitations. To avoid virtual threads pinning ( https://openjdk.org/jeps/425#Pinning ) to carrier threads, critical sections in which the CPU may be yielded e.g. when doing I/O, should be guarded with j.u.c.locks rather than object monitors i.e. ‘synchronized’ keyword.
By using a modified version of JUnit (sorry, it’s not public at this time) to run the test suite on Loom threads with {{-Djdk.tracePinnedThreads=full }}enabled, some instances of this undesirable pinning behaviour are revealed in the ORM. Fortunately these occur mainly in startup/shutdown code that is off the critical path. Nevertheless, it may be desirable to make Hibernate more Loom-friendly by refactoring to use ReentrantLock instead.
The count of pinning occurrences in the test suite is dominated by the three cases below. Note that whilst test coverage is good, the short-lived nature of test environments and the default configuration used skews the data somewhat compared to production use.
https://github.com/hibernate/hibernate-orm/blob/main/hibernate-core/src/m... ( https://github.com/hibernate/hibernate-orm/blob/main/hibernate-core/src/m... ) methods getService (though there is an unsynchronized fast path), stopService and destroy.
https://github.com/hibernate/hibernate-orm/blob/main/hibernate-core/src/m... ( https://github.com/hibernate/hibernate-orm/blob/main/hibernate-core/src/m... ) methods initiateService, configureService and destroy.
https://github.com/hibernate/hibernate-orm/blob/main/hibernate-core/src/m... ( https://github.com/hibernate/hibernate-orm/blob/main/hibernate-core/src/m... ) method generate.
The choice of JDBC driver and other components such as the logging library and connection pool are also factors in performance of Hibernate on Loom threads. Broadly speaking, the mariadb driver is well behaved, whilst the mysql and pgsql drivers have some issues. YMMV and testing in your own environment is recommended.
( https://hibernate.atlassian.net/browse/HHH-15541#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-15541#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=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100207- sha1:4756b15 )
2 years, 3 months