Skip to content

Commit

Permalink
HHH-10269 : JDBC Statement is not closed if exception appeared during…
Browse files Browse the repository at this point in the history
… query execution
  • Loading branch information
gbadner committed Mar 11, 2016
1 parent 3e00630 commit bdb458a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions hibernate-core/src/main/java/org/hibernate/loader/Loader.java
Expand Up @@ -2130,6 +2130,11 @@ protected final ResultSet getResultSet(
session.getJdbcCoordinator().afterStatementExecution();
throw sqle;
}
catch (HibernateException he) {
session.getJdbcCoordinator().getResourceRegistry().release( st );
session.getJdbcCoordinator().afterStatementExecution();
throw he;
}
}

protected void autoDiscoverTypes(ResultSet rs) {
Expand Down
Expand Up @@ -1055,4 +1055,20 @@ public void testTypedScalarQueries() {

em.close();
}

@Test
@TestForIssue( jiraKey = "HHH-10269")
public void testFailingNativeQuery() {
final EntityManager entityManager = getOrCreateEntityManager();
// Tests that Oracle does not run out of cursors.
for (int i = 0; i < 1000; i++) {
try {
entityManager.createNativeQuery("Select 1 from NotExistedTable").getResultList();
fail( "expected PersistenceException" );
} catch (PersistenceException e) {
// expected
}
}

}
}

0 comments on commit bdb458a

Please sign in to comment.