HHH-10269 : JDBC Statement is not closed if exception appeared during query execution
(cherry picked from commit bdb458a609
)
This commit is contained in:
parent
864ba023d5
commit
c681e48bfe
|
@ -2131,6 +2131,11 @@ public abstract class Loader {
|
|||
session.getJdbcCoordinator().afterStatementExecution();
|
||||
throw sqle;
|
||||
}
|
||||
catch (HibernateException he) {
|
||||
session.getJdbcCoordinator().getResourceRegistry().release( st );
|
||||
session.getJdbcCoordinator().afterStatementExecution();
|
||||
throw he;
|
||||
}
|
||||
}
|
||||
|
||||
protected void autoDiscoverTypes(ResultSet rs) {
|
||||
|
|
|
@ -1055,4 +1055,20 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase {
|
|||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue