HHH-1312 : Unclosed ResultSet when using Identity

git-svn-id: https://svn.jboss.org/repos/hibernate/core/branches/Branch_3_2@14098 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Gail Badner 2007-10-18 06:17:56 +00:00
parent 45e29dd47c
commit 0b38fa21ce
1 changed files with 13 additions and 4 deletions

View File

@ -71,10 +71,19 @@ public class IdentityGenerator extends AbstractPostInsertGenerator {
public Serializable executeAndExtract(PreparedStatement insert) throws SQLException {
insert.executeUpdate();
return IdentifierGeneratorFactory.getGeneratedIdentity(
GetGeneratedKeysHelper.getGeneratedKey( insert ),
persister.getIdentifierType()
);
ResultSet rs = null;
try {
rs = GetGeneratedKeysHelper.getGeneratedKey( insert );
return IdentifierGeneratorFactory.getGeneratedIdentity(
rs,
persister.getIdentifierType()
);
}
finally {
if ( rs != null ) {
rs.close();
}
}
}
}