Skip to content

Commit 59804ab

Browse files
committed
Align JpaTransactionManager default for nestedTransactionAllowed flag
Closes gh-35457
1 parent dd60fdd commit 59804ab

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@
9393
*
9494
* <p>This transaction manager supports nested transactions via JDBC Savepoints.
9595
* The {@link #setNestedTransactionAllowed "nestedTransactionAllowed"} flag defaults
96-
* to {@code false} though, since nested transactions will just apply to the JDBC
97-
* Connection, not to the JPA EntityManager and its cached entity objects and related
98-
* context. You can manually set the flag to {@code true} if you want to use nested
99-
* transactions for JDBC access code which participates in JPA transactions (provided
100-
* that your JDBC driver supports Savepoints). <i>Note that JPA itself does not support
96+
* to "false", though, as nested transactions will just apply to the JDBC Connection,
97+
* not to the JPA EntityManager and its cached entity objects and related context.
98+
* You can manually set the flag to "true" if you want to use nested transactions
99+
* for JDBC access code which participates in JPA transactions (provided that your
100+
* JDBC driver supports savepoints). <i>Note that JPA itself does not support
101101
* nested transactions! Hence, do not expect JPA access code to semantically
102102
* participate in a nested transaction.</i>
103103
*
@@ -136,15 +136,13 @@ public class JpaTransactionManager extends AbstractPlatformTransactionManager
136136
* @see #setEntityManagerFactory
137137
*/
138138
public JpaTransactionManager() {
139-
setNestedTransactionAllowed(true);
140139
}
141140

142141
/**
143142
* Create a new JpaTransactionManager instance.
144143
* @param emf the EntityManagerFactory to manage transactions for
145144
*/
146145
public JpaTransactionManager(EntityManagerFactory emf) {
147-
this();
148146
this.entityManagerFactory = emf;
149147
afterPropertiesSet();
150148
}

spring-orm/src/main/java/org/springframework/orm/jpa/hibernate/HibernateTransactionManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@
8888
* such a scenario (see container setup).
8989
*
9090
* <p>This transaction manager supports nested transactions via JDBC Savepoints.
91-
* The {@link #setNestedTransactionAllowed} "nestedTransactionAllowed"} flag defaults
91+
* The {@link #setNestedTransactionAllowed "nestedTransactionAllowed"} flag defaults
9292
* to "false", though, as nested transactions will just apply to the JDBC Connection,
9393
* not to the Hibernate Session and its cached entity objects and related context.
9494
* You can manually set the flag to "true" if you want to use nested transactions
9595
* for JDBC access code which participates in Hibernate transactions (provided that
96-
* your JDBC driver supports Savepoints). <i>Note that Hibernate itself does not
96+
* your JDBC driver supports savepoints). <i>Note that Hibernate itself does not
9797
* support nested transactions! Hence, do not expect Hibernate access code to
9898
* semantically participate in a nested transaction.</i>
9999
*

0 commit comments

Comments
 (0)