Query termination for JPA 2.1 StoredProcedureQuery.execute() method
Includes backported support for JPA 2.2 getResultStream() method. Issue: SPR-16826
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -65,9 +65,9 @@ public abstract class SharedEntityManagerCreator {
|
||||
|
||||
private static final Class<?>[] NO_ENTITY_MANAGER_INTERFACES = new Class<?>[0];
|
||||
|
||||
private static final Set<String> transactionRequiringMethods = new HashSet<String>(6);
|
||||
private static final Set<String> transactionRequiringMethods = new HashSet<String>(8);
|
||||
|
||||
private static final Set<String> queryTerminationMethods = new HashSet<String>(3);
|
||||
private static final Set<String> queryTerminatingMethods = new HashSet<String>(8);
|
||||
|
||||
static {
|
||||
transactionRequiringMethods.add("joinTransaction");
|
||||
@@ -77,9 +77,11 @@ public abstract class SharedEntityManagerCreator {
|
||||
transactionRequiringMethods.add("remove");
|
||||
transactionRequiringMethods.add("refresh");
|
||||
|
||||
queryTerminationMethods.add("getResultList");
|
||||
queryTerminationMethods.add("getSingleResult");
|
||||
queryTerminationMethods.add("executeUpdate");
|
||||
queryTerminatingMethods.add("execute"); // JPA 2.1 StoredProcedureQuery
|
||||
queryTerminatingMethods.add("executeUpdate");
|
||||
queryTerminatingMethods.add("getSingleResult");
|
||||
queryTerminatingMethods.add("getResultList");
|
||||
queryTerminatingMethods.add("getResultStream");
|
||||
}
|
||||
|
||||
|
||||
@@ -376,7 +378,7 @@ public abstract class SharedEntityManagerCreator {
|
||||
throw ex.getTargetException();
|
||||
}
|
||||
finally {
|
||||
if (queryTerminationMethods.contains(method.getName())) {
|
||||
if (queryTerminatingMethods.contains(method.getName())) {
|
||||
// Actual execution of the query: close the EntityManager right
|
||||
// afterwards, since that was the only reason we kept it open.
|
||||
EntityManagerFactoryUtils.closeEntityManager(this.em);
|
||||
|
||||
Reference in New Issue
Block a user