Skip to content

Commit 259bd52

Browse files
committed
Consistent javadoc references to JdbcTransactionManager
1 parent cef0462 commit 259bd52

File tree

5 files changed

+99
-98
lines changed

5 files changed

+99
-98
lines changed

spring-jdbc/src/main/java/org/springframework/jdbc/datasource/DataSourceTransactionManager.java

Lines changed: 57 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,49 +35,52 @@
3535
import org.springframework.util.Assert;
3636

3737
/**
38-
* {@link org.springframework.transaction.PlatformTransactionManager}
39-
* implementation for a single JDBC {@link javax.sql.DataSource}. This class is
40-
* capable of working in any environment with any JDBC driver, as long as the setup
41-
* uses a {@code javax.sql.DataSource} as its {@code Connection} factory mechanism.
42-
* Binds a JDBC Connection from the specified DataSource to the current thread,
43-
* potentially allowing for one thread-bound Connection per DataSource.
38+
* {@link org.springframework.transaction.PlatformTransactionManager} implementation
39+
* for a single JDBC {@link javax.sql.DataSource}. This class is capable of working
40+
* in any environment with any JDBC driver, as long as the setup uses a
41+
* {@code javax.sql.DataSource} as its {@code Connection} factory mechanism.
42+
* Binds a JDBC {@code Connection} from the specified {@code DataSource} to the
43+
* current thread, potentially allowing for one thread-bound {@code Connection}
44+
* per {@code DataSource}.
4445
*
45-
* <p><b>Note: The DataSource that this transaction manager operates on needs
46-
* to return independent Connections.</b> The Connections may come from a pool
47-
* (the typical case), but the DataSource must not return thread-scoped /
48-
* request-scoped Connections or the like. This transaction manager will
49-
* associate Connections with thread-bound transactions itself, according
50-
* to the specified propagation behavior. It assumes that a separate,
51-
* independent Connection can be obtained even during an ongoing transaction.
46+
* <p><b>Note: The {@code DataSource} that this transaction manager operates on
47+
* needs to return independent {@code Connection}s.</b> The {@code Connection}s
48+
* typically come from a connection pool but the {@code DataSource} must not return
49+
* specifically scoped or constrained {@code Connection}s. This transaction manager
50+
* will associate {@code Connection}s with thread-bound transactions, according
51+
* to the specified propagation behavior. It assumes that a separate, independent
52+
* {@code Connection} can be obtained even during an ongoing transaction.
5253
*
53-
* <p>Application code is required to retrieve the JDBC Connection via
54+
* <p>Application code is required to retrieve the JDBC {@code Connection} via
5455
* {@link DataSourceUtils#getConnection(DataSource)} instead of a standard
55-
* Java EE-style {@link DataSource#getConnection()} call. Spring classes such as
56+
* EE-style {@link DataSource#getConnection()} call. Spring classes such as
5657
* {@link org.springframework.jdbc.core.JdbcTemplate} use this strategy implicitly.
5758
* If not used in combination with this transaction manager, the
5859
* {@link DataSourceUtils} lookup strategy behaves exactly like the native
59-
* DataSource lookup; it can thus be used in a portable fashion.
60+
* {@code DataSource} lookup; it can thus be used in a portable fashion.
6061
*
6162
* <p>Alternatively, you can allow application code to work with the standard
62-
* Java EE-style lookup pattern {@link DataSource#getConnection()}, for example for
63-
* legacy code that is not aware of Spring at all. In that case, define a
64-
* {@link TransactionAwareDataSourceProxy} for your target DataSource, and pass
65-
* that proxy DataSource to your DAOs, which will automatically participate in
66-
* Spring-managed transactions when accessing it.
63+
* EE-style lookup pattern {@link DataSource#getConnection()}, for example
64+
* for legacy code that is not aware of Spring at all. In that case, define a
65+
* {@link TransactionAwareDataSourceProxy} for your target {@code DataSource},
66+
* and pass that proxy {@code DataSource} to your DAOs which will automatically
67+
* participate in Spring-managed transactions when accessing it.
6768
*
6869
* <p>Supports custom isolation levels, and timeouts which get applied as
6970
* appropriate JDBC statement timeouts. To support the latter, application code
7071
* must either use {@link org.springframework.jdbc.core.JdbcTemplate}, call
71-
* {@link DataSourceUtils#applyTransactionTimeout} for each created JDBC Statement,
72-
* or go through a {@link TransactionAwareDataSourceProxy} which will create
73-
* timeout-aware JDBC Connections and Statements automatically.
72+
* {@link DataSourceUtils#applyTransactionTimeout} for each created JDBC
73+
* {@code Statement}, or go through a {@link TransactionAwareDataSourceProxy}
74+
* which will create timeout-aware JDBC {@code Connection}s and {@code Statement}s
75+
* automatically.
7476
*
7577
* <p>Consider defining a {@link LazyConnectionDataSourceProxy} for your target
76-
* DataSource, pointing both this transaction manager and your DAOs to it.
78+
* {@code DataSource}, pointing both this transaction manager and your DAOs to it.
7779
* This will lead to optimized handling of "empty" transactions, i.e. of transactions
78-
* without any JDBC statements executed. A LazyConnectionDataSourceProxy will not fetch
79-
* an actual JDBC Connection from the target DataSource until a Statement gets executed,
80-
* lazily applying the specified transaction settings to the target Connection.
80+
* without any JDBC statements executed. A {@code LazyConnectionDataSourceProxy} will
81+
* not fetch an actual JDBC {@code Connection} from the target {@code DataSource}
82+
* until a {@code Statement} gets executed, lazily applying the specified transaction
83+
* settings to the target {@code Connection}.
8184
*
8285
* <p>This transaction manager supports nested transactions via the JDBC 3.0
8386
* {@link java.sql.Savepoint} mechanism. The
@@ -88,9 +91,9 @@
8891
* <p>This transaction manager can be used as a replacement for the
8992
* {@link org.springframework.transaction.jta.JtaTransactionManager} in the single
9093
* resource case, as it does not require a container that supports JTA, typically
91-
* in combination with a locally defined JDBC DataSource (e.g. an Apache Commons
92-
* DBCP connection pool). Switching between this local strategy and a JTA
93-
* environment is just a matter of configuration!
94+
* in combination with a locally defined JDBC {@code DataSource} (e.g. a Hikari
95+
* connection pool). Switching between this local strategy and a JTA environment
96+
* is just a matter of configuration!
9497
*
9598
* <p>As of 4.3.4, this transaction manager triggers flush callbacks on registered
9699
* transaction synchronizations (if synchronization is generally active), assuming
@@ -112,6 +115,7 @@
112115
* @see TransactionAwareDataSourceProxy
113116
* @see LazyConnectionDataSourceProxy
114117
* @see org.springframework.jdbc.core.JdbcTemplate
118+
* @see org.springframework.jdbc.support.JdbcTransactionManager
115119
*/
116120
@SuppressWarnings("serial")
117121
public class DataSourceTransactionManager extends AbstractPlatformTransactionManager
@@ -124,16 +128,16 @@ public class DataSourceTransactionManager extends AbstractPlatformTransactionMan
124128

125129

126130
/**
127-
* Create a new DataSourceTransactionManager instance.
128-
* A DataSource has to be set to be able to use it.
131+
* Create a new {@code DataSourceTransactionManager} instance.
132+
* A {@code DataSource} has to be set to be able to use it.
129133
* @see #setDataSource
130134
*/
131135
public DataSourceTransactionManager() {
132136
setNestedTransactionAllowed(true);
133137
}
134138

135139
/**
136-
* Create a new DataSourceTransactionManager instance.
140+
* Create a new {@code DataSourceTransactionManager} instance.
137141
* @param dataSource the JDBC DataSource to manage transactions for
138142
*/
139143
public DataSourceTransactionManager(DataSource dataSource) {
@@ -144,22 +148,22 @@ public DataSourceTransactionManager(DataSource dataSource) {
144148

145149

146150
/**
147-
* Set the JDBC DataSource that this instance should manage transactions for.
148-
* <p>This will typically be a locally defined DataSource, for example an
149-
* Apache Commons DBCP connection pool. Alternatively, you can also drive
150-
* transactions for a non-XA J2EE DataSource fetched from JNDI. For an XA
151-
* DataSource, use JtaTransactionManager.
152-
* <p>The DataSource specified here should be the target DataSource to manage
153-
* transactions for, not a TransactionAwareDataSourceProxy. Only data access
154-
* code may work with TransactionAwareDataSourceProxy, while the transaction
155-
* manager needs to work on the underlying target DataSource. If there's
156-
* nevertheless a TransactionAwareDataSourceProxy passed in, it will be
157-
* unwrapped to extract its target DataSource.
158-
* <p><b>The DataSource passed in here needs to return independent Connections.</b>
159-
* The Connections may come from a pool (the typical case), but the DataSource
160-
* must not return thread-scoped / request-scoped Connections or the like.
161-
* @see TransactionAwareDataSourceProxy
162-
* @see org.springframework.transaction.jta.JtaTransactionManager
151+
* Set the JDBC {@code DataSource} that this instance should manage transactions for.
152+
* <p>This will typically be a locally defined {@code DataSource}, for example a
153+
* Hikari connection pool. Alternatively, you can also manage transactions for a
154+
* non-XA {@code DataSource} fetched from JNDI. For an XA {@code DataSource},
155+
* use {@link org.springframework.transaction.jta.JtaTransactionManager} instead.
156+
* <p>The {@code DataSource} specified here should be the target {@code DataSource}
157+
* to manage transactions for, not a {@link TransactionAwareDataSourceProxy}.
158+
* Only data access code may work with {@code TransactionAwareDataSourceProxy} while
159+
* the transaction manager needs to work on the underlying target {@code DataSource}.
160+
* If there is nevertheless a {@code TransactionAwareDataSourceProxy} passed in,
161+
* it will be unwrapped to extract its target {@code DataSource}.
162+
* <p><b>The {@code DataSource} passed in here needs to return independent
163+
* {@code Connection}s.</b> The {@code Connection}s typically come from a
164+
* connection pool but the {@code DataSource} must not return specifically
165+
* scoped or constrained {@code Connection}s, just possibly lazily fetched.
166+
* @see LazyConnectionDataSourceProxy
163167
*/
164168
public void setDataSource(@Nullable DataSource dataSource) {
165169
if (dataSource instanceof TransactionAwareDataSourceProxy) {
@@ -174,15 +178,15 @@ public void setDataSource(@Nullable DataSource dataSource) {
174178
}
175179

176180
/**
177-
* Return the JDBC DataSource that this instance manages transactions for.
181+
* Return the JDBC {@code DataSource} that this instance manages transactions for.
178182
*/
179183
@Nullable
180184
public DataSource getDataSource() {
181185
return this.dataSource;
182186
}
183187

184188
/**
185-
* Obtain the DataSource for actual use.
189+
* Obtain the {@code DataSource} for actual use.
186190
* @return the DataSource (never {@code null})
187191
* @throws IllegalStateException in case of no DataSource set
188192
* @since 5.0

spring-jdbc/src/main/java/org/springframework/jdbc/datasource/DataSourceUtils.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
import org.springframework.util.Assert;
3434

3535
/**
36-
* Helper class that provides static methods for obtaining JDBC Connections from
37-
* a {@link javax.sql.DataSource}. Includes special support for Spring-managed
38-
* transactional Connections, e.g. managed by {@link DataSourceTransactionManager}
36+
* Helper class that provides static methods for obtaining JDBC {@code Connection}s
37+
* from a {@link javax.sql.DataSource}. Includes special support for Spring-managed
38+
* transactional {@code Connection}s, e.g. managed by {@link DataSourceTransactionManager}
3939
* or {@link org.springframework.transaction.jta.JtaTransactionManager}.
4040
*
4141
* <p>Used internally by Spring's {@link org.springframework.jdbc.core.JdbcTemplate},
@@ -46,7 +46,8 @@
4646
* @author Juergen Hoeller
4747
* @see #getConnection
4848
* @see #releaseConnection
49-
* @see DataSourceTransactionManager
49+
* @see org.springframework.jdbc.core.JdbcTemplate
50+
* @see org.springframework.jdbc.support.JdbcTransactionManager
5051
* @see org.springframework.transaction.jta.JtaTransactionManager
5152
* @see org.springframework.transaction.support.TransactionSynchronizationManager
5253
*/
@@ -474,7 +475,7 @@ private static class ConnectionSynchronization implements TransactionSynchroniza
474475

475476
private final DataSource dataSource;
476477

477-
private int order;
478+
private final int order;
478479

479480
private boolean holderActive = true;
480481

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -105,7 +105,7 @@
105105
* @see DataSourceUtils#getConnection
106106
* @see DataSourceUtils#releaseConnection
107107
* @see org.springframework.jdbc.core.JdbcTemplate
108-
* @see org.springframework.jdbc.datasource.DataSourceTransactionManager
108+
* @see org.springframework.jdbc.support.JdbcTransactionManager
109109
* @see org.springframework.transaction.jta.JtaTransactionManager
110110
*/
111111
@SuppressWarnings("serial")

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -109,7 +109,7 @@
109109
* @see org.springframework.jdbc.datasource.DataSourceUtils#getConnection
110110
* @see org.springframework.jdbc.datasource.DataSourceUtils#releaseConnection
111111
* @see org.springframework.jdbc.core.JdbcTemplate
112-
* @see org.springframework.jdbc.datasource.DataSourceTransactionManager
112+
* @see org.springframework.jdbc.support.JdbcTransactionManager
113113
* @see org.springframework.transaction.jta.JtaTransactionManager
114114
*/
115115
@SuppressWarnings("serial")

spring-r2dbc/src/main/java/org/springframework/r2dbc/connection/R2dbcTransactionManager.java

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -36,41 +36,36 @@
3636
import org.springframework.util.Assert;
3737

3838
/**
39-
* {@link org.springframework.transaction.ReactiveTransactionManager}
40-
* implementation for a single R2DBC {@link ConnectionFactory}. This class is
41-
* capable of working in any environment with any R2DBC driver, as long as the
42-
* setup uses a {@code ConnectionFactory} as its {@link Connection} factory
43-
* mechanism. Binds a R2DBC {@code Connection} from the specified
44-
* {@code ConnectionFactory} to the current subscriber context, potentially
45-
* allowing for one context-bound {@code Connection} per {@code ConnectionFactory}.
39+
* {@link org.springframework.transaction.ReactiveTransactionManager} implementation
40+
* for a single R2DBC {@link ConnectionFactory}. This class is capable of working
41+
* in any environment with any R2DBC driver, as long as the setup uses a
42+
* {@code ConnectionFactory} as its {@link Connection} factory mechanism.
43+
* Binds a R2DBC {@code Connection} from the specified {@code ConnectionFactory}
44+
* to the current subscriber context, potentially allowing for one context-bound
45+
* {@code Connection} per {@code ConnectionFactory}.
4646
*
47-
* <p><b>Note: The {@code ConnectionFactory} that this transaction manager
48-
* operates on needs to return independent {@code Connection}s.</b>
49-
* The {@code Connection}s may come from a pool (the typical case), but the
50-
* {@code ConnectionFactory} must not return scoped {@code Connection}s
51-
* or the like. This transaction manager will associate {@code Connection}
52-
* with context-bound transactions itself, according to the specified propagation
53-
* behavior. It assumes that a separate, independent {@code Connection} can
54-
* be obtained even during an ongoing transaction.
47+
* <p><b>Note: The {@code ConnectionFactory} that this transaction manager operates
48+
* on needs to return independent {@code Connection}s.</b> The {@code Connection}s
49+
* typically come from a connection pool but the {@code ConnectionFactory} must not
50+
* return specifically scoped or constrained {@code Connection}s. This transaction
51+
* manager will associate {@code Connection} with context-bound transactions,
52+
* according to the specified propagation behavior. It assumes that a separate,
53+
* independent {@code Connection} can be obtained even during an ongoing transaction.
5554
*
5655
* <p>Application code is required to retrieve the R2DBC Connection via
5756
* {@link ConnectionFactoryUtils#getConnection(ConnectionFactory)}
5857
* instead of a standard R2DBC-style {@link ConnectionFactory#create()} call.
5958
* Spring classes such as {@code DatabaseClient} use this strategy implicitly.
6059
* If not used in combination with this transaction manager, the
61-
* {@link ConnectionFactoryUtils} lookup strategy behaves exactly like the
62-
* native {@code ConnectionFactory} lookup; it can thus be used in a portable fashion.
60+
* {@link ConnectionFactoryUtils} lookup strategy behaves exactly like the native
61+
* {@code ConnectionFactory} lookup; it can thus be used in a portable fashion.
6362
*
64-
* <p>Alternatively, you can allow application code to work with the standard
65-
* R2DBC lookup pattern {@link ConnectionFactory#create()}, for example for code
66-
* that is not aware of Spring at all. In that case, define a
67-
* {@link TransactionAwareConnectionFactoryProxy} for your target {@code ConnectionFactory},
68-
* and pass that proxy {@code ConnectionFactory} to your DAOs, which will automatically
69-
* participate in Spring-managed transactions when accessing it.
70-
*
71-
* <p>This transaction manager triggers flush callbacks on registered transaction
72-
* synchronizations (if synchronization is generally active), assuming resources
73-
* operating on the underlying R2DBC {@code Connection}.
63+
* <p>Alternatively, you can allow application code to work with the lookup pattern
64+
* {@link ConnectionFactory#create()}, for example for code not aware of Spring.
65+
* In that case, define a {@link TransactionAwareConnectionFactoryProxy} for your
66+
* target {@code ConnectionFactory}, and pass that proxy {@code ConnectionFactory}
67+
* to your DAOs which will automatically participate in Spring-managed transactions
68+
* when accessing it.
7469
*
7570
* @author Mark Paluch
7671
* @since 5.3
@@ -89,7 +84,7 @@ public class R2dbcTransactionManager extends AbstractReactiveTransactionManager
8984

9085
/**
9186
* Create a new {@code R2dbcTransactionManager} instance.
92-
* A ConnectionFactory has to be set to be able to use it.
87+
* A {@code ConnectionFactory} has to be set to be able to use it.
9388
* @see #setConnectionFactory
9489
*/
9590
public R2dbcTransactionManager() {}
@@ -106,12 +101,13 @@ public R2dbcTransactionManager(ConnectionFactory connectionFactory) {
106101

107102

108103
/**
109-
* Set the R2DBC {@link ConnectionFactory} that this instance should manage transactions for.
110-
* <p>This will typically be a locally defined {@code ConnectionFactory}, for example a connection pool.
111-
* <p><b>The {@code ConnectionFactory} passed in here needs to return independent {@link Connection}s.</b>
112-
* The {@code Connection}s may come from a pool (the typical case), but the {@code ConnectionFactory}
113-
* must not return scoped {@code Connection}s or the like.
114-
* @see TransactionAwareConnectionFactoryProxy
104+
* Set the R2DBC {@link ConnectionFactory} that this instance should manage transactions
105+
* for. This will typically be a locally defined {@code ConnectionFactory}, for example
106+
* an R2DBC connection pool.
107+
* <p><b>The {@code ConnectionFactory} passed in here needs to return independent
108+
* {@link Connection}s.</b> The {@code Connection}s typically come from a connection
109+
* pool but the {@code ConnectionFactory} must not return specifically scoped or
110+
* constrained {@code Connection}s.
115111
*/
116112
public void setConnectionFactory(@Nullable ConnectionFactory connectionFactory) {
117113
this.connectionFactory = connectionFactory;
@@ -142,8 +138,8 @@ protected ConnectionFactory obtainConnectionFactory() {
142138
* transactional connection: "SET TRANSACTION READ ONLY" as understood by Oracle,
143139
* MySQL and Postgres.
144140
* <p>The exact treatment, including any SQL statement executed on the connection,
145-
* can be customized through {@link #prepareTransactionalConnection(Connection, TransactionDefinition)}.
146-
* @see #prepareTransactionalConnection(Connection, TransactionDefinition)
141+
* can be customized through {@link #prepareTransactionalConnection}.
142+
* @see #prepareTransactionalConnection
147143
*/
148144
public void setEnforceReadOnly(boolean enforceReadOnly) {
149145
this.enforceReadOnly = enforceReadOnly;

0 commit comments

Comments
 (0)