cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

Hi,

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>

       

        <primary-key>

            <generator class="sequence-identity">

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

            </generator>       

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

        </primary-key>

        <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 com.sap.db.jdbc.ConnectionSapDB.prepareStatement(ConnectionSapDB.java:2113)

at com.sap.db.jdbc.trace.Connection.prepareStatement(Connection.java:375)

at org.apache.commons.dbcp.DelegatingConnection.prepareStatement(DelegatingConnection.java:418)

at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.prepareStatement(PoolingDataSource.java:385)

at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:527)

at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:131)

at org.hibernate.id.SequenceIdentityGenerator$Delegate.prepare(SequenceIdentityGenerator.java:99)

at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:54)

at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2345)

at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2852)

at org.hibernate.impl.StatelessSessionImpl.insert(StatelessSessionImpl.java:112)

at org.hibernate.impl.StatelessSessionImpl.insert(StatelessSessionImpl.java:97)

at com.signaldemand.ui.struts.module.config.CreateAction.executeImpl(CreateAction.java:157)

at com.signaldemand.ui.struts.module.config.CrudDataAction.execute(CrudDataAction.java:72)

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

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:585)

at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)

at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)

at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)

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

Thanks!

Amit

Accepted Solutions (0)

Answers (2)

Answers (2)

lbreddemann
Active Contributor
0 Kudos

Hi Amit,

as this seems to be a duplicate of would you mind closing/deleting one of the threads?

- Lars

Former Member
0 Kudos

Hi Lars,

I am sorry about the duplicate but I created it as I was unable to view the original for a day (I am not sure why).

Anyways, I guess only a moderator can delete a thread.

Since you have answered in the other thread, let's keep that alive and close this one.

@All, you may follow the discussion at http://scn.sap.com/thread/3340106

Thanks!

Amit

Former Member
0 Kudos

I hit the same issue with Amit, is there any solution for this issue?

Thanks,

Jack