Browse Source

Clarify intended nestedTransactionAllowed default in JpaTransactionManager

Closes gh-35212
pull/35587/head
Juergen Hoeller 3 months ago
parent
commit
5b387615c6
  1. 4
      spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTransactionManager.java
  2. 15
      spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java

4
spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTransactionManager.java

@ -88,12 +88,12 @@ import org.springframework.util.Assert; @@ -88,12 +88,12 @@ import org.springframework.util.Assert;
* such a scenario (see container setup).
*
* <p>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). <i>Note that Hibernate itself does not
* your JDBC driver supports savepoints). <i>Note that Hibernate itself does not
* support nested transactions! Hence, do not expect Hibernate access code to
* semantically participate in a nested transaction.</i>
*

15
spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java

@ -93,13 +93,14 @@ import org.springframework.util.CollectionUtils; @@ -93,13 +93,14 @@ import org.springframework.util.CollectionUtils;
*
* <p>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). <i>Note that JPA itself does not support
* nested transactions! Hence, do not expect JPA access code to semantically
* participate in a nested transaction.</i>
* 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).
* <i>Note that JPA itself does not support nested transactions! Hence, do not
* expect JPA access code to semantically participate in a nested transaction.</i>
*
* @author Juergen Hoeller
* @since 2.0

Loading…
Cancel
Save