diff --git a/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryExecution.java b/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryExecution.java index 77d718244..e65cc4ea8 100644 --- a/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryExecution.java +++ b/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryExecution.java @@ -342,7 +342,6 @@ public abstract class JpaQueryExecution { private static final String NO_SURROUNDING_TRANSACTION = "You're trying to execute a streaming query method without a surrounding transaction that keeps the connection open so that the Stream can actually be consumed. Make sure the code consuming the stream uses @Transactional or any other way of declaring a (read-only) transaction."; private static Method streamMethod = ReflectionUtils.findMethod(Query.class, "getResultStream"); - private static boolean dynamicCheck = streamMethod == null; /* * (non-Javadoc) @@ -362,27 +361,7 @@ public abstract class JpaQueryExecution { return ReflectionUtils.invokeMethod(streamMethod, jpaQuery); } - if (dynamicCheck) { - - Method method = ReflectionUtils.findMethod(jpaQuery.getClass(), "getResultStream"); - - // Implementation available but on JPA 2.1 - if (method != null) { - - // Cache for subsequent reuse to prevent repeated reflection lookups - streamMethod = method; - - return ReflectionUtils.invokeMethod(method, jpaQuery); - - } else { - - // Not available on implementation, skip further lookups - dynamicCheck = false; - } - } - // Fall back to legacy stream execution - PersistenceProvider persistenceProvider = PersistenceProvider.fromEntityManager(query.getEntityManager()); CloseableIterator iter = persistenceProvider.executeQueryWithResultStream(jpaQuery);