From 57fb0722154696474e3b47911a4cbd491451fda8 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sat, 28 Jan 2023 15:43:03 +0100 Subject: [PATCH] Include all Hibernate methods in SharedEntityManagerCreator's queryTerminatingMethods Prior to this commit, we included Hibernate's Query.list() method in SharedEntityManagerCreator's queryTerminatingMethods set but did not include all of Hibernate's query-terminating methods. To address this, this commit additionally includes the stream(), uniqueResult(), and uniqueResultOptional() methods from Hibernate's Query API in SharedEntityManagerCreator's query-terminating methods set. Closes gh-29886 --- .../orm/jpa/SharedEntityManagerCreator.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) 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 eb4967245b..f262ea8839 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -60,6 +60,7 @@ import org.springframework.util.ConcurrentReferenceHashMap; * @author Rod Johnson * @author Oliver Gierke * @author Mark Paluch + * @author Sam Brannen * @since 2.0 * @see jakarta.persistence.PersistenceContext * @see jakarta.persistence.PersistenceContextType#TRANSACTION @@ -81,12 +82,15 @@ public abstract class SharedEntityManagerCreator { "refresh"); private static final Set queryTerminatingMethods = Set.of( - "execute", // JPA 2.1 StoredProcedureQuery - "executeUpdate", - "getSingleResult", - "getResultStream", - "getResultList", - "list" // Hibernate Query.list() method + "execute", // jakarta.persistence.StoredProcedureQuery.execute() + "executeUpdate", // jakarta.persistence.Query.executeUpdate() + "getSingleResult", // jakarta.persistence.Query.getSingleResult() + "getResultStream", // jakarta.persistence.Query.getResultStream() + "getResultList", // jakarta.persistence.Query.getResultList() + "list", // org.hibernate.query.Query.list() + "stream", // org.hibernate.query.Query.stream() + "uniqueResult", // org.hibernate.query.Query.uniqueResult() + "uniqueResultOptional" // org.hibernate.query.Query.uniqueResultOptional() );