From 6fcf3a104f05718cf34255af9fcfebd47b8358a7 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 25 May 2017 13:16:51 +0200 Subject: [PATCH] SharedEntityManagerCreator detects JPA 2.2's getResultStream method as query-terminating This commit also changes "hibval5Version" to the more general "hibvalVersion" build variable, and includes dependency updates to Caffeine 2.5.1 and JRuby 9.1.9. Issue: SPR-13482 --- build.gradle | 16 ++++++++-------- .../orm/jpa/SharedEntityManagerCreator.java | 13 +++++++------ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/build.gradle b/build.gradle index ada9ccc492c..d66922e4d47 100644 --- a/build.gradle +++ b/build.gradle @@ -40,7 +40,7 @@ configure(allprojects) { project -> ext.aspectjVersion = "1.9.0.BETA-5" ext.beanvalVersion = "1.1.0.Final" ext.cacheApiVersion = "1.0.0" - ext.caffeineVersion = "2.5.0" + ext.caffeineVersion = "2.5.1" ext.eclipselinkVersion = "2.6.4" ext.ehcacheVersion = "2.10.4" ext.ehcachejcacheVersion = "1.0.1" @@ -53,7 +53,7 @@ configure(allprojects) { project -> ext.gsonVersion = "2.8.0" ext.hamcrestVersion = "1.3" ext.hibernate5Version = "5.2.10.Final" - ext.hibval5Version = "5.4.1.Final" + ext.hibvalVersion = "5.4.1.Final" ext.hsqldbVersion = "2.4.0" ext.httpasyncVersion = "4.1.3" ext.httpclientVersion = "4.5.3" @@ -504,7 +504,7 @@ project("spring-context") { optional("javax.money:money-api:1.0.1") optional("org.eclipse.persistence:javax.persistence:${jpaVersion}") optional("javax.validation:validation-api:${beanvalVersion}") - optional("org.hibernate:hibernate-validator:${hibval5Version}") + optional("org.hibernate:hibernate-validator:${hibvalVersion}") optional("joda-time:joda-time:${jodaVersion}") optional("org.aspectj:aspectjweaver:${aspectjVersion}") optional("org.codehaus.groovy:groovy-all:${groovyVersion}") @@ -805,7 +805,7 @@ project("spring-webflux") { optional("org.jetbrains.kotlin:kotlin-stdlib-jre8:${kotlinVersion}") testCompile("io.projectreactor.addons:reactor-test") testCompile("javax.validation:validation-api:${beanvalVersion}") - testCompile("org.hibernate:hibernate-validator:${hibval5Version}") + testCompile("org.hibernate:hibernate-validator:${hibvalVersion}") testCompile("org.apache.tomcat:tomcat-util:${tomcatVersion}") testCompile("org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}") testCompile("org.eclipse.jetty:jetty-server:${jettyVersion}") @@ -821,7 +821,7 @@ project("spring-webflux") { testCompile("org.jetbrains.kotlin:kotlin-script-runtime:${kotlinVersion}") testRuntime("org.jetbrains.kotlin:kotlin-script-util:${kotlinVersion}") testRuntime("org.jetbrains.kotlin:kotlin-compiler:${kotlinVersion}") - testRuntime("org.jruby:jruby:9.1.8.0") + testRuntime("org.jruby:jruby:9.1.9.0") testRuntime("org.python:jython-standalone:2.5.3") testRuntime("org.webjars:underscorejs:1.8.3") testRuntime("org.glassfish:javax.el:3.0.1-b08") @@ -918,7 +918,7 @@ project("spring-webmvc") { exclude group: "javax.servlet", module: "javax.servlet" } testCompile("javax.validation:validation-api:${beanvalVersion}") - testCompile("org.hibernate:hibernate-validator:${hibval5Version}") + testCompile("org.hibernate:hibernate-validator:${hibvalVersion}") testCompile("org.apache.httpcomponents:httpclient:${httpclientVersion}") { exclude group: "commons-logging", module: "commons-logging" } @@ -933,7 +933,7 @@ project("spring-webmvc") { testCompile("org.jetbrains.kotlin:kotlin-script-runtime:${kotlinVersion}") testRuntime("org.jetbrains.kotlin:kotlin-script-util:${kotlinVersion}") testRuntime("org.jetbrains.kotlin:kotlin-compiler:${kotlinVersion}") - testRuntime("org.jruby:jruby:9.1.8.0") + testRuntime("org.jruby:jruby:9.1.9.0") testRuntime("org.python:jython-standalone:2.5.3") testRuntime("org.webjars:underscorejs:1.8.3") testRuntime("org.glassfish:javax.el:3.0.1-b08") @@ -1036,7 +1036,7 @@ project("spring-test") { testCompile("javax.ejb:javax.ejb-api:${ejbApiVersion}") testCompile("javax.interceptor:javax.interceptor-api:${interceptorApiVersion}") testCompile("org.hibernate:hibernate-core:${hibernate5Version}") - testCompile("org.hibernate:hibernate-validator:${hibval5Version}") + testCompile("org.hibernate:hibernate-validator:${hibvalVersion}") // Enable use of the JUnitPlatform Runner testCompile("org.junit.platform:junit-platform-runner:${junitPlatformVersion}") testCompile("com.thoughtworks.xstream:xstream:${xstreamVersion}") diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java b/spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java index fb5f21f6715..9582c8f7953 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java @@ -65,9 +65,9 @@ public abstract class SharedEntityManagerCreator { private static final Class[] NO_ENTITY_MANAGER_INTERFACES = new Class[0]; - private static final Set transactionRequiringMethods = new HashSet<>(6); + private static final Set transactionRequiringMethods = new HashSet<>(8); - private static final Set queryTerminationMethods = new HashSet<>(3); + private static final Set queryTerminatingMethods = new HashSet<>(8); static { transactionRequiringMethods.add("joinTransaction"); @@ -77,9 +77,10 @@ public abstract class SharedEntityManagerCreator { transactionRequiringMethods.add("remove"); transactionRequiringMethods.add("refresh"); - queryTerminationMethods.add("getResultList"); - queryTerminationMethods.add("getSingleResult"); - queryTerminationMethods.add("executeUpdate"); + queryTerminatingMethods.add("executeUpdate"); + queryTerminatingMethods.add("getSingleResult"); + queryTerminatingMethods.add("getResultList"); + queryTerminatingMethods.add("getResultStream"); } @@ -376,7 +377,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);