Skip to content

Commit

Permalink
Include all Hibernate methods in SharedEntityManagerCreator's queryTe…
Browse files Browse the repository at this point in the history
…rminatingMethods

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-29888
  • Loading branch information
sbrannen committed Jan 28, 2023
1 parent 90ea39c commit 3d6d853
Showing 1 changed file with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 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.
Expand Down Expand Up @@ -62,6 +62,7 @@
* @author Rod Johnson
* @author Oliver Gierke
* @author Mark Paluch
* @author Sam Brannen
* @since 2.0
* @see javax.persistence.PersistenceContext
* @see javax.persistence.PersistenceContextType#TRANSACTION
Expand All @@ -74,9 +75,9 @@ public abstract class SharedEntityManagerCreator {

private static final Map<Class<?>, Class<?>[]> cachedQueryInterfaces = new ConcurrentReferenceHashMap<>(4);

private static final Set<String> transactionRequiringMethods = new HashSet<>(8);
private static final Set<String> transactionRequiringMethods = new HashSet<>(6);

private static final Set<String> queryTerminatingMethods = new HashSet<>(8);
private static final Set<String> queryTerminatingMethods = new HashSet<>(9);

static {
transactionRequiringMethods.add("joinTransaction");
Expand All @@ -86,12 +87,15 @@ public abstract class SharedEntityManagerCreator {
transactionRequiringMethods.add("remove");
transactionRequiringMethods.add("refresh");

queryTerminatingMethods.add("execute"); // JPA 2.1 StoredProcedureQuery
queryTerminatingMethods.add("executeUpdate");
queryTerminatingMethods.add("getSingleResult");
queryTerminatingMethods.add("getResultStream");
queryTerminatingMethods.add("getResultList");
queryTerminatingMethods.add("list"); // Hibernate Query.list() method
queryTerminatingMethods.add("execute"); // javax.persistence.StoredProcedureQuery.execute()
queryTerminatingMethods.add("executeUpdate"); // javax.persistence.Query.executeUpdate()
queryTerminatingMethods.add("getSingleResult"); // javax.persistence.Query.getSingleResult()
queryTerminatingMethods.add("getResultStream"); // javax.persistence.Query.getResultStream()
queryTerminatingMethods.add("getResultList"); // javax.persistence.Query.getResultList()
queryTerminatingMethods.add("list"); // org.hibernate.query.Query.list()
queryTerminatingMethods.add("stream"); // org.hibernate.query.Query.stream()
queryTerminatingMethods.add("uniqueResult"); // org.hibernate.query.Query.uniqueResult()
queryTerminatingMethods.add("uniqueResultOptional"); // org.hibernate.query.Query.uniqueResultOptional()
}


Expand Down

0 comments on commit 3d6d853

Please sign in to comment.