-->
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.  [ 4 posts ] 
Author Message
 Post subject: Getting auto-generated keys uses a problematic method
PostPosted: Tue May 02, 2006 8:49 am 
Newbie

Joined: Mon Jun 20, 2005 8:02 am
Posts: 4
Hibernate version: 3.1.2

Full stack trace of any exception that occurs:

java.sql.SQLException: [mercury][SQLServer JDBC Driver]Unsupported method: Connection.prepareStatement
at com.mercury.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.mercury.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.mercury.jdbc.base.BaseConnection.prepareStatement(Unknown Source)

Name and version of the database you are using: Sql Server 2000

The JDBC driver: Data Direct for Sql Server 3.5.27

When using Identity column in Sql Server, Hibernate tries to get the auto-generated keys.
There are 2 ways to do that:
1. Connection.prepareStatement (String sql, int autoGeneratedKeys) - that allows to retrieve the generated value of a single column in the table.
2. Connection.prepareStatement (String sql, int[] columnIndexes) - that allows to retrieve the generated value of multiple columns in the table.

Hibernate uses the second method, and I don't see why the first one is not enough - There's no way to create a schema via Hibernate that has multiple generated keys in a single table!!
And if it's to support some weird legacy schema - why is that the default behaviour in Hibernate? when there are some JDBC Drivers that only support the first method!!. (like Data Direct for Sql Server)

Should I place a feature request in JIRA for that??


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 03, 2006 12:03 pm 
Newbie

Joined: Mon Apr 24, 2006 2:01 pm
Posts: 13
I'm geting the same error with Weblogic Driver for INformix.


Code:

java.sql.SQLException: [BEA][Informix JDBC Driver]Unsupported method: Connection.prepareStatement
        at weblogic.jdbc.base.BaseExceptions.createException(Unknown Source)
        at weblogic.jdbc.base.BaseExceptions.getException(Unknown Source)



Getting this error with insert statements on a table with autogenerated keys

Can someone help?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 03, 2006 12:04 pm 
Newbie

Joined: Mon Apr 24, 2006 2:01 pm
Posts: 13
I'm geting the same error with Weblogic Driver for INformix.


Code:

java.sql.SQLException: [BEA][Informix JDBC Driver]Unsupported method: Connection.prepareStatement
        at weblogic.jdbc.base.BaseExceptions.createException(Unknown Source)
        at weblogic.jdbc.base.BaseExceptions.getException(Unknown Source)



Getting this error with insert statements on a table with autogenerated keys

Can someone help?


Top
 Profile  
 
 Post subject: There's a workaround
PostPosted: Sun May 07, 2006 3:19 am 
Newbie

Joined: Mon Jun 20, 2005 8:02 am
Posts: 4
you can tell hibernate to fetch the auto-generated keys in a seperate query:
set the hibernate.jdbc.use_get_generated_keys option to false in the hibernate.properties file.
This, of course, will affect performance of inserts.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.