From 0b38fa21cef9dbbb67e67042c4945788b821873e Mon Sep 17 00:00:00 2001 From: Gail Badner Date: Thu, 18 Oct 2007 06:17:56 +0000 Subject: [PATCH] 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 --- src/org/hibernate/id/IdentityGenerator.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/org/hibernate/id/IdentityGenerator.java b/src/org/hibernate/id/IdentityGenerator.java index fd9fda2054..0c9a825ce6 100644 --- a/src/org/hibernate/id/IdentityGenerator.java +++ b/src/org/hibernate/id/IdentityGenerator.java @@ -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(); + } + } } }