From c50d7a59e92a3b0b68590b743f628585e6ab3ecd Mon Sep 17 00:00:00 2001 From: Jens Schauder Date: Fri, 5 Jan 2018 09:02:46 +0100 Subject: [PATCH 1/2] DATAJPA-1241 - Prepare branch --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. From b1502d3e9016d04223b71dc1ee0a35340ac71e36 Mon Sep 17 00:00:00 2001 From: Jens Schauder Date: Fri, 5 Jan 2018 09:16:27 +0100 Subject: [PATCH 2/2] DATAJPA-1241 - Removed dynamic check for getResultStream. --- .../repository/query/JpaQueryExecution.java | 24 ++----------------- 1 file changed, 2 insertions(+), 22 deletions(-) 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);