From 5b387615c67fb147c2cbd87881cf4b58b042e994 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 10 Sep 2025 18:06:44 +0200 Subject: [PATCH] Clarify intended nestedTransactionAllowed default in JpaTransactionManager Closes gh-35212 --- .../hibernate5/HibernateTransactionManager.java | 4 ++-- .../orm/jpa/JpaTransactionManager.java | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTransactionManager.java b/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTransactionManager.java index f44a5c249c1..01d6518c4a5 100644 --- a/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTransactionManager.java +++ b/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTransactionManager.java @@ -88,12 +88,12 @@ import org.springframework.util.Assert; * such a scenario (see container setup). * *

This transaction manager supports nested transactions via JDBC Savepoints. - * The {@link #setNestedTransactionAllowed} "nestedTransactionAllowed"} flag defaults + * The {@link #setNestedTransactionAllowed "nestedTransactionAllowed"} flag defaults * to "false", though, as nested transactions will just apply to the JDBC Connection, * not to the Hibernate Session and its cached entity objects and related context. * You can manually set the flag to "true" if you want to use nested transactions * for JDBC access code which participates in Hibernate transactions (provided that - * your JDBC driver supports Savepoints). Note that Hibernate itself does not + * your JDBC driver supports savepoints). Note that Hibernate itself does not * support nested transactions! Hence, do not expect Hibernate access code to * semantically participate in a nested transaction. * diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java b/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java index bec3bda232f..e77520e416c 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java @@ -93,13 +93,14 @@ import org.springframework.util.CollectionUtils; * *

This transaction manager supports nested transactions via JDBC Savepoints. * The {@link #setNestedTransactionAllowed "nestedTransactionAllowed"} flag defaults - * to {@code false} though, since nested transactions will just apply to the JDBC - * Connection, not to the JPA EntityManager and its cached entity objects and related - * context. You can manually set the flag to {@code true} if you want to use nested - * transactions for JDBC access code which participates in JPA transactions (provided - * that your JDBC driver supports Savepoints). Note that JPA itself does not support - * nested transactions! Hence, do not expect JPA access code to semantically - * participate in a nested transaction. + * to "true" but should rather be "false", as nested transactions will just apply to + * the JDBC Connection, not to the JPA EntityManager and its cached entity objects + * and related context. As of Spring Framework 7.0, the default will be "false" in + * alignment with other transaction managers, requiring an explicit switch to "true" + * if you want to use nested transactions for JDBC access code which participates + * in JPA transactions (provided that your JDBC driver supports savepoints). + * Note that JPA itself does not support nested transactions! Hence, do not + * expect JPA access code to semantically participate in a nested transaction. * * @author Juergen Hoeller * @since 2.0