From: <leg...@at...> - 2003-11-05 03:37:14
|
The following comment has been added to this issue: Author: David Morris Created: Tue, 4 Nov 2003 9:36 PM Body: It is a bug in the driver if you did not get back all generated keys. Here is the spec: "Calling ResultSet.getMetaData on the ResultSet object returned by getGeneratedKeys will produce a ResultSetMetaData object that can be used to determine the number, type and properties of the generated keys. In some cases, such as in an insert select statement, more than one key may be returned. The ResultSet object returned by getGeneratedKeys will contain a row for each key that a statement generated. If no keys are generated, an empty result set will be returned. The concurrency of the ResultSet object returned by getGeneratedKeys must be CONCUR_READ_ONLY. The type of the ResultSet object must be either TYPE_FORWARD_ONLY or TYPE_SCROLL_INSENSITIVE." You should have received all keys generated with metadata describing the keys. I can see a problem with the spec because the metadata returned from a result set can't cover the results of more than one SQL statement and the specification says "the ResultSet object" infering that there is only one result set therefore one type. That probably doesn't help much. As a workaround, can you add your records in a pre-insert key? it shouldn't be too bad except that you may need to delete a constraint (that could be moved to your trigger). --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-380 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-380 Summary: Use ResultSet.getGeneratedKeys() when supported by JDBC driver Type: Improvement Status: Assigned Priority: Minor Project: Hibernate2 Components: core Versions: 2.1 Assignee: Gavin King Reporter: David Morris Created: Sat, 4 Oct 2003 1:02 AM Updated: Tue, 4 Nov 2003 12:06 AM Environment: JDBC 3.0 Drivers with 1.4 JDKs. MySql and DB2 both have JDBC drivers that support get generated keys. Description: Retrieve ResultSet of natively generated keys after inserting records into databases that provide this support. Performance is genrally better with this technique. The code change should be backward compatable with 1.3 JREs and older JDBC drivers. --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |