-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 posts ] 
Author Message
 Post subject: UnsupportedOperationException with SAP HANA and Hibernate
PostPosted: Tue Mar 28, 2017 5:24 am 
Newbie

Joined: Tue Mar 28, 2017 1:55 am
Posts: 4
I want to connect to a SAP HANA database using Hibernate.
My test database consists of only 1 column based table:

Code:
PERSON (ID, FIRSTNAME, SURNAME)


and the corresponding Hibernate object ‘Person’.


When I try to execute a simple query using

Code:
aHibernateSession.createCriteria(Person.class).list()


I get the following exception:

Code:
java.lang.UnsupportedOperationException: org.hibernate.dialect.HANAColumnStoreDialect does not support resultsets via stored procedures
   at org.hibernate.dialect.Dialect.getResultSet(Dialect.java:1524)


This exception appears using Hibernate 4.3 as well as using Hibernate 5.2, using HANAColumnStoreDialect as well as HANARowStoreDialect

When turning on the show-sql flag the only statement that is executed is

Code:
select this_.ID as ID1_0_0_, this_.FIRSTNAME as FIRSTNAME2_0_0_, this_.SURNAME as SURNAME3_0_0_ from PERSON this_


Why does Hibernate try to call a stored procedure here? Or do I miss something?


Top
 Profile  
 
 Post subject: Re: UnsupportedOperationException with SAP HANA and Hibernate
PostPosted: Tue Mar 28, 2017 5:54 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1638
Location: Romania
I'm not aware of how a Criteria query can end up calling a Stored Procedure. You should debug it and see where the call originate from.

Did you override the default SELECT, INSERT, UPDATE or DELETE statements when you mapped the entity?


Top
 Profile  
 
 Post subject: Re: UnsupportedOperationException with SAP HANA and Hibernate
PostPosted: Tue Mar 28, 2017 6:08 am 
Newbie

Joined: Tue Mar 28, 2017 1:55 am
Posts: 4
Thank you for your quick reply.

No, I didn't override anything. My test scenario is as simple as possible.

Even when I use a plain sql statment like

Code:
session.createSQLQuery("select * from PERSON").list();


I get the exception.

Here is the full stack trace:

Code:
java.lang.UnsupportedOperationException: org.hibernate.dialect.HANAColumnStoreDialect does not support resultsets via stored procedures
   at org.hibernate.dialect.Dialect.getResultSet(Dialect.java:1524)
   at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:117)
   at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:64)
   at org.hibernate.loader.Loader.getResultSet(Loader.java:2123)
   at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1911)
   at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1887)
   at org.hibernate.loader.Loader.doQuery(Loader.java:932)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349)
   at org.hibernate.loader.Loader.doList(Loader.java:2615)
   at org.hibernate.loader.Loader.doList(Loader.java:2598)
   at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2430)
   at org.hibernate.loader.Loader.list(Loader.java:2425)
   at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:335)
   at org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:2153)
   at org.hibernate.internal.AbstractSharedSessionContract.list(AbstractSharedSessionContract.java:991)
   at org.hibernate.query.internal.NativeQueryImpl.doList(NativeQueryImpl.java:147)
   at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1410)
   at ts.HanaTestHibernate5.main(HanaTestHibernate5.java:98)


Top
 Profile  
 
 Post subject: Re: UnsupportedOperationException with SAP HANA and Hibernate
PostPosted: Tue Mar 28, 2017 9:00 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1638
Location: Romania
It might be an issue with the HANA Driver.

You need to help me debug it since I don't have HANA installed locally. If you debug the

Code:
org.hibernate.engine.jdbc.internal.ResultSetReturnImpl


at line 59:

Code:
if ( isTypeOf( statement, CallableStatement.class ) ) {


Is the PreparedStatement implementing CallableStatement?

That could be the problem.


Top
 Profile  
 
 Post subject: Re: UnsupportedOperationException with SAP HANA and Hibernate
PostPosted: Tue Mar 28, 2017 9:09 am 
Newbie

Joined: Tue Mar 28, 2017 1:55 am
Posts: 4
Yes, the created statement is of class

Code:
com.sap.db.jdbc.CallableStatementSapDBFinalize
.


Top
 Profile  
 
 Post subject: Re: UnsupportedOperationException with SAP HANA and Hibernate
PostPosted: Tue Mar 28, 2017 10:13 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1638
Location: Romania
Thanks for confirming it. I created the HHH-11600 Jira issue for it.

What I need you to do is confirm if the proposed fix works. So, you need to do as follows:

1. Create a class CustomHANARowStoreDialect or CustomHANAColumnStoreDialect depending on what storage engine you need to use, and this class should either extend HANARowStoreDialect or HANAColumnStoreDialect from Hibernate.
2. Add this overriding method:

Code:
@Override
public ResultSet getResultSet(CallableStatement ps) throws SQLException {
   return ps.executeQuery();
}


3. Set the hibernate.dialect to use your CustomHANARowStoreDialect or CustomHANAColumnStoreDialect :

Code:
<property name="hibernate.dialect" value="my.package.CustomHANARowStoreDialect" />


Let me know if it works, as I could then apply the fix to Hibernate as well.


Top
 Profile  
 
 Post subject: Re: UnsupportedOperationException with SAP HANA and Hibernate
PostPosted: Wed Mar 29, 2017 1:12 am 
Newbie

Joined: Tue Mar 28, 2017 1:55 am
Posts: 4
Thank you very much.

Overriding
Code:
getResultSet
of
Code:
HANAColumnStoreDialect
worked.
Now I can retrieve the result list.


Top
 Profile  
 
 Post subject: Re: UnsupportedOperationException with SAP HANA and Hibernate
PostPosted: Wed Mar 29, 2017 2:01 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1638
Location: Romania
This is only a workaround! Thanks for testing it, and I'll fix it properly in the core as well.


Top
 Profile  
 
 Post subject: Re: UnsupportedOperationException with SAP HANA and Hibernate
PostPosted: Fri Jan 05, 2018 6:11 am 
Newbie

Joined: Fri Jan 05, 2018 6:09 am
Posts: 2
Hello,

I ran into the same problem and this work-around worked or me too. I was wondering if and when this will be fixed and what the release version/date if any is?

Any idea?

Regards,
Chetan


Top
 Profile  
 
 Post subject: Re: UnsupportedOperationException with SAP HANA and Hibernate
PostPosted: Fri Jan 05, 2018 6:58 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1638
Location: Romania
The fix is available since 5.2.11.


Top
 Profile  
 
 Post subject: Re: UnsupportedOperationException with SAP HANA and Hibernate
PostPosted: Fri Jan 05, 2018 7:59 am 
Newbie

Joined: Fri Jan 05, 2018 6:09 am
Posts: 2
Thanks for the information. Looks like i was using the version 5.0.12.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.