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

Loading…
Cancel
Save