HikariCP as Hibernate's ConnectionProvider

595 views
Skip to first unread message

Luca Burgazzoli

unread,
Jan 6, 2014, 10:03:27 AM1/6/14
to hika...@googlegroups.com
Hi,

I have an issue to make it working properly as Hibernate throws the following exception for a simple query:

java.lang.UnsupportedOperationException: org.hibernate.dialect.HSQLDialect does not support resultsets via stored procedures
at org.hibernate.dialect.Dialect.getResultSet(Dialect.java:1627)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:100)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:74)
at org.hibernate.loader.Loader.getResultSet(Loader.java:2065)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1862)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1838)
at org.hibernate.loader.Loader.doQuery(Loader.java:909)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:354)
at org.hibernate.loader.Loader.doList(Loader.java:2551)
at org.hibernate.loader.Loader.doList(Loader.java:2537)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2367)
at org.hibernate.loader.Loader.list(Loader.java:2362)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:496)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:387)
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:229)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1260)
at org.hibernate.internal.QueryImpl.list(QueryImpl.java:103)
at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:573)
at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:449)
at com.github.lburgazzoli.sandbox.jpa.hibernate.HibernateJpaMain.list(HibernateJpaMain.java:63)
at com.github.lburgazzoli.sandbox.jpa.hibernate.HibernateJpaMain.main(HibernateJpaMain.java:101)

I do not know if it is because of HicariCP behaviour or ah Hibernate issue, is there any obvious error in my project?
You can test it with: 

cd lb-sandbox-java
./gradlew hibernateJpaMain

Thx,
Luca

Brett Wooldridge

unread,
Jan 6, 2014, 7:43:34 PM1/6/14
to hika...@googlegroups.com
I did notice that in HibernateJpaMain:111 you set Hibernate to auto-commit = false, but HikariCP itself is going to default to auto-commit = true, but that is not the cause of this issue.  Anyway, I don't know if Hibernate will set the auto-commit state appropriately internally or not, but you might want to explicitly configure HikariCP with matching auto-commit.

Regarding the issue above, it appears that you are running Hibernate 4.3.0.Beta5 correct?  I'm not sure what is up, but it appears that 4.3 is a pretty dramatic change from 4.2.  The error is originating from line 1627 here:


That line always throws, so one would expect that individual dialects would need to override that method.  However looking at the HSQLDialect, we see that it does not in fact override that method:


...thus the exception is thrown.

I would recommend trying Hibernate 4.2.6.Final instead, or if 4.3.0.Beta5 is essential, reporting the issue to the Hibernate project (you might want to do that anyway).

-Brett

Luca Burgazzoli

unread,
Jan 7, 2014, 5:18:31 AM1/7/14
to hika...@googlegroups.com
Hi Brett,
thanks for the answer.

I'm using Hibernate 4.3.0.Final but the problem occurs even if I switch to 4.2.7.Final.
Then I've tested with C3P0ConnectionProvider and a custom HSQLConnectionProvider and the issue does not appears.

It looks like the problem comes from HikariCP, I'll try to understand a little bit more.

Brett Wooldridge

unread,
Jan 7, 2014, 5:31:39 AM1/7/14
to hika...@googlegroups.com
Ok, I'll clone your sandbox and take a look.  I'll post what I find in a few hours...

Brett Wooldridge

unread,
Jan 7, 2014, 9:16:08 AM1/7/14
to hika...@googlegroups.com
Luca,

I found the issue.  HikariCP's Javassist generated proxies around PreparedStatement is actually injecting the CallableStatement interface.  In normal interaction with the proxy this never causes an issue, because the returned proxy is cast as PreparedStatement therefore callers have no way to invoke the [nonexistent] CallableStatement methods.  However, Hibernate in its ResultSetReturnImpl class is performing instanceof checks on objects it holds as Statements, it is therefore thinking that the HikariCP PreparedStatement proxy is actually a CallableStatement and taking a different branch in the code.

A new release, HikariCP-1.2.3 has been pushed to the central repository.  It may take several hours to appear.

Brett

Reply all
Reply to author
Forward
0 new messages