diff --git a/pom.xml b/pom.xml index 5e8e2ab228..dc4a460652 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.data spring-data-jpa - 2.1.0.BUILD-SNAPSHOT + 2.1.0.DATAJPA-1241-SNAPSHOT Spring Data JPA Spring Data module for JPA repositories. 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 14f40c7617..afd6a31323 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 @@ -1,5 +1,5 @@ /* - * Copyright 2008-2017 the original author or authors. + * Copyright 2008-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. @@ -54,6 +54,7 @@ * @author Thomas Darimont * @author Mark Paluch * @author Christoph Strobl + * @author Jens Schauder */ public abstract class JpaQueryExecution { @@ -334,7 +335,6 @@ static class StreamExecution extends 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) @@ -354,27 +354,7 @@ protected Object doExecute(final AbstractJpaQuery query, Object[] values) { 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);