From b0beac4acdd85ed7c8b3543fce9f1c5bbf0360e3 Mon Sep 17 00:00:00 2001 From: Gail Badner Date: Thu, 18 Oct 2007 06:20:04 +0000 Subject: [PATCH] HHH-1312 : Unclosed ResultSet when using Identity git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@14099 1b8cb986-b30d-0410-93ca-fae66ebed9b2 --- .../org/hibernate/id/IdentityGenerator.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/hibernate/id/IdentityGenerator.java b/core/src/main/java/org/hibernate/id/IdentityGenerator.java index 37da1d7891..62be3ea96b 100644 --- a/core/src/main/java/org/hibernate/id/IdentityGenerator.java +++ b/core/src/main/java/org/hibernate/id/IdentityGenerator.java @@ -70,10 +70,19 @@ public class IdentityGenerator extends AbstractPostInsertGenerator { public Serializable executeAndExtract(PreparedStatement insert) throws SQLException { insert.executeUpdate(); - return IdentifierGeneratorFactory.getGeneratedIdentity( - insert.getGeneratedKeys(), - persister.getIdentifierType() - ); + ResultSet rs = null; + try { + rs = insert.getGeneratedKeys(); + return IdentifierGeneratorFactory.getGeneratedIdentity( + rs, + persister.getIdentifierType() + ); + } + finally { + if ( rs != null ) { + rs.close(); + } + } } }