Skip to Content
Former Member
Apr 05, 2013 at 11:54 PM

HANA JDBC support for prepareStatement(String sql, int autoGeneratedKeys)



Our application is connecting to a HANA database via Hibernate (we are using the SAPDBDialect).

I am able to read, update and delete records.

For create, we use a database sequence (running number) to get the id which will be used as the primary key of the new record being inserted.

<table name="TABLE1">

<meta attribute="implements">Object1</meta>


<generator class="sequence-identity">

<param name="sequence">PK_SEQ</param>


<key-column name="ID" type="java.lang.Long"/>


<column name="SEQ" type="java.lang.Short"/>

<column name="MIN_RANGE" type="java.lang.Short"/>


Above is the hibernate configuration that allows us to do this in ONE call with Oracle.

I know the call translates to the following JDBC call

prepareStatement(String sql, int autoGeneratedKeys)

With Hana, we get the following exception

java.lang.UnsupportedOperationException: Retrieving auto generated keys is not supported.



at org.apache.commons.dbcp.DelegatingConnection.prepareStatement(

at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.prepareStatement(

at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(

at org.hibernate.jdbc.AbstractBatcher.prepareStatement(



at org.hibernate.persister.entity.AbstractEntityPersister.insert(

at org.hibernate.persister.entity.AbstractEntityPersister.insert(

at org.hibernate.impl.StatelessSessionImpl.insert(

at org.hibernate.impl.StatelessSessionImpl.insert(

at com.signaldemand.ui.struts.module.config.CreateAction.executeImpl(

at com.signaldemand.ui.struts.module.config.CrudDataAction.execute(

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(

at sun.reflect.DelegatingMethodAccessorImpl.invoke(

at java.lang.reflect.Method.invoke(

at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(

at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(

at com.opensymphony.xwork2.DefaultActionInvocation.invoke(

It seems HANA JDBC driver does not support prepareStatement(String sql, int autoGeneratedKeys).

Can someone confirm? If so, is there a plan to fix this?

We don't really want to do it in 2 separate calls/steps

a) get the next number from running sequence

b) insert the record with id and other values