Skip to content

Commit 9c1ca3b

Browse files
committed
#368 - Deprecate API provided by Spring R2DBC.
This commit deprecates API that has been moved to Spring R2DBC.
1 parent 2cb8de6 commit 9c1ca3b

File tree

99 files changed

+487
-793
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+487
-793
lines changed

pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@
109109
<version>${springdata.relational}</version>
110110
</dependency>
111111

112+
<dependency>
113+
<groupId>org.springframework</groupId>
114+
<artifactId>spring-r2dbc</artifactId>
115+
</dependency>
116+
112117
<dependency>
113118
<groupId>org.springframework</groupId>
114119
<artifactId>spring-tx</artifactId>

src/main/asciidoc/index.adoc

+1
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@ include::reference/kotlin.adoc[leveloffset=+1]
4848
:numbered!:
4949
include::{spring-data-commons-docs}/repository-query-keywords-reference.adoc[leveloffset=+1]
5050
include::{spring-data-commons-docs}/repository-query-return-types-reference.adoc[leveloffset=+1]
51+
include::reference/r2dbc-upgrading.adoc[leveloffset=+1]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
[appendix]
2+
= Migration Guide
3+
4+
The following sections explain how to migrate to a newer version of Spring Data R2DBC.
5+
6+
[[upgrading.1.1-1.2]]
7+
== Upgrading from 1.1.x to 1.2.x
8+
9+
Spring Data R2DBC was developed with the intent to evaluate how well R2DBC can integrate with Spring applications.
10+
One of the main aspects was to move core support into Spring Framework once R2DBC support has proven useful.
11+
Spring Framework 5.3 ships with a new module: Spring R2DBC.
12+
13+
`spring-r2dbc` ships core R2DBC functionality (a slim variant of `DatabaseClient`, Transaction Manager, Connection Factory initialization, Exception translation) that was initially provided by Spring Data R2DBC. The 1.2.0 release aligns with what's provided in Spring R2DBC by making several changes outlined in the following sections.
14+
15+
[[upgrading.1.1-1.2.deprecation]]
16+
=== Deprecations
17+
18+
* Deprecation of `o.s.d.r2dbc.core.DatabaseClient` and its support classes `ConnectionAccessor`, `FetchSpec`, `SqlProvider` and a few more.
19+
Named parameter support classes such as `NamedParameterExpander` are encapsulated by Spring R2DBC's `DatabaseClient` implementation hence we're not providing replacements as this was internal API in the first place.
20+
Use `o.s.r2dbc.core.DatabaseClient` and their Spring R2DBC replacements available from `org.springframework.r2dbc.core`.
21+
Entity-based methods (`select`/`insert`/`update`/`delete`) methods are available through `R2dbcEntityTemplate` which was introduced with version 1.1.
22+
* Deprecation of `o.s.d.r2dbc.connectionfactory`, `o.s.d.r2dbc.connectionfactory.init`, and `o.s.d.r2dbc.connectionfactory.lookup` packages.
23+
Use Spring R2DBC's variant which you can find at `o.s.r2dbc.connection`.
24+
* Deprecation of `o.s.d.r2dbc.convert.ColumnMapRowMapper`.
25+
Use `o.s.r2dbc.core.ColumnMapRowMapper` instead.
26+
* Deprecation of binding support classes `o.s.d.r2dbc.dialect.Bindings`, `BindMarker`, `BindMarkers`, `BindMarkersFactory` and related types.
27+
Use replacements from `org.springframework.r2dbc.core.binding`.
28+
* Deprecation of `BadSqlGrammarException`, `UncategorizedR2dbcException` and exception translation at `o.s.d.r2dbc.support`.
29+
Spring R2DBC provides a slim exception translation variant without an SPI for now available through `o.s.r2dbc.connection.ConnectionFactoryUtils#convertR2dbcException`.
30+
31+
[[upgrading.1.1-1.2.replacements]]
32+
=== Usage of replacements provided by Spring R2DBC
33+
34+
To ease migration, several deprecated types are now subtypes of their replacements provided by Spring R2DBC. Spring Data R2DBC has changes several methods or introduced new methods accepting Spring R2DBC types.
35+
Specifically the following classes are affected:
36+
37+
* `R2dbcEntityTemplate`
38+
* `R2dbcDialect`
39+
* Types in `org.springframework.data.r2dbc.query`
40+
41+
We recommend that you review your imports if you work with these types directly.
42+
43+
[[upgrading.1.1-1.2.dependencies]]
44+
=== Dependency Changes
45+
46+
To make use of Spring R2DBC, make sure to include the following dependency:
47+
48+
* `org.springframework:spring-r2dbc`

src/main/java/org/springframework/data/r2dbc/BadSqlGrammarException.java

+5-10
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
import io.r2dbc.spi.R2dbcException;
1919

20-
import org.springframework.dao.InvalidDataAccessResourceUsageException;
21-
2220
/**
2321
* Exception thrown when SQL specified is invalid. Such exceptions always have a {@link io.r2dbc.spi.R2dbcException}
2422
* root cause.
@@ -28,13 +26,13 @@
2826
* without affecting code using this class.
2927
*
3028
* @author Mark Paluch
29+
* @deprecated since 1.2, use directly Spring R2DBC's {@link org.springframework.r2dbc.BadSqlGrammarException} instead.
3130
*/
32-
public class BadSqlGrammarException extends InvalidDataAccessResourceUsageException {
31+
@Deprecated
32+
public class BadSqlGrammarException extends org.springframework.r2dbc.BadSqlGrammarException {
3333

3434
private static final long serialVersionUID = 3814579246913482054L;
3535

36-
private final String sql;
37-
3836
/**
3937
* Creates a new {@link BadSqlGrammarException}.
4038
*
@@ -43,10 +41,7 @@ public class BadSqlGrammarException extends InvalidDataAccessResourceUsageExcept
4341
* @param ex the root cause.
4442
*/
4543
public BadSqlGrammarException(String task, String sql, R2dbcException ex) {
46-
47-
super(task + "; bad SQL grammar [" + sql + "]", ex);
48-
49-
this.sql = sql;
44+
super(task, sql, ex);
5045
}
5146

5247
/**
@@ -60,6 +55,6 @@ public R2dbcException getR2dbcException() {
6055
* Return the SQL that caused the problem.
6156
*/
6257
public String getSql() {
63-
return this.sql;
58+
return super.getSql();
6459
}
6560
}

src/main/java/org/springframework/data/r2dbc/InvalidResultAccessException.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@
2424
* Exception thrown when a {@link io.r2dbc.spi.Result} has been accessed in an invalid fashion. Such exceptions always
2525
* have a {@link io.r2dbc.spi.R2dbcException} root cause.
2626
* <p>
27-
* This typically happens when an invalid {@link org.springframework.data.r2dbc.core.FetchSpec} column index or name
28-
* has been specified.
27+
* This typically happens when an invalid {@link org.springframework.data.r2dbc.core.FetchSpec} column index or name has
28+
* been specified.
2929
*
3030
* @author Mark Paluch
3131
* @see BadSqlGrammarException
32+
* @deprecated since 1.2, not in use anymore.
3233
*/
3334
@SuppressWarnings("serial")
35+
@Deprecated
3436
public class InvalidResultAccessException extends InvalidDataAccessResourceUsageException {
3537

3638
private final @Nullable String sql;

src/main/java/org/springframework/data/r2dbc/UncategorizedR2dbcException.java

+5-12
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,19 @@
1717

1818
import io.r2dbc.spi.R2dbcException;
1919

20-
import org.springframework.dao.UncategorizedDataAccessException;
2120
import org.springframework.lang.Nullable;
2221

2322
/**
2423
* Exception thrown when we can't classify a {@link R2dbcException} into one of our generic data access exceptions.
2524
*
2625
* @author Mark Paluch
26+
* @deprecated since 1.2, use Spring R2DBC's {@link org.springframework.r2dbc.UncategorizedR2dbcException} instead.
2727
*/
28-
public class UncategorizedR2dbcException extends UncategorizedDataAccessException {
28+
@Deprecated
29+
public class UncategorizedR2dbcException extends org.springframework.r2dbc.UncategorizedR2dbcException {
2930

3031
private static final long serialVersionUID = 361587356435210266L;
3132

32-
/**
33-
* SQL that led to the problem
34-
*/
35-
private final @Nullable String sql;
36-
3733
/**
3834
* Creates a new {@link UncategorizedR2dbcException}.
3935
*
@@ -42,10 +38,7 @@ public class UncategorizedR2dbcException extends UncategorizedDataAccessExceptio
4238
* @param ex the root cause
4339
*/
4440
public UncategorizedR2dbcException(String task, @Nullable String sql, R2dbcException ex) {
45-
46-
super(String.format("%s; uncategorized R2dbcException%s; %s", task, sql != null ? " for SQL [" + sql + "]" : "",
47-
ex.getMessage()), ex);
48-
this.sql = sql;
41+
super(task, sql, ex);
4942
}
5043

5144
/**
@@ -62,6 +55,6 @@ public R2dbcException getR2dbcException() {
6255
*/
6356
@Nullable
6457
public String getSql() {
65-
return this.sql;
58+
return super.getSql();
6659
}
6760
}

src/main/java/org/springframework/data/r2dbc/config/AbstractR2dbcConfiguration.java

+2-19
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040
import org.springframework.data.r2dbc.dialect.R2dbcDialect;
4141
import org.springframework.data.r2dbc.mapping.R2dbcMappingContext;
4242
import org.springframework.data.r2dbc.support.R2dbcExceptionSubclassTranslator;
43-
import org.springframework.data.r2dbc.support.R2dbcExceptionTranslator;
44-
import org.springframework.data.r2dbc.support.SqlStateR2dbcExceptionTranslator;
4543
import org.springframework.data.relational.core.conversion.BasicRelationalConverter;
4644
import org.springframework.data.relational.core.mapping.NamingStrategy;
4745
import org.springframework.lang.Nullable;
@@ -100,11 +98,9 @@ public R2dbcDialect getDialect(ConnectionFactory connectionFactory) {
10098
* @throws IllegalArgumentException if any of the required args is {@literal null}.
10199
*/
102100
@Bean({ "r2dbcDatabaseClient", "databaseClient" })
103-
public DatabaseClient databaseClient(ReactiveDataAccessStrategy dataAccessStrategy,
104-
R2dbcExceptionTranslator exceptionTranslator) {
101+
public DatabaseClient databaseClient(ReactiveDataAccessStrategy dataAccessStrategy) {
105102

106103
Assert.notNull(dataAccessStrategy, "DataAccessStrategy must not be null!");
107-
Assert.notNull(exceptionTranslator, "ExceptionTranslator must not be null!");
108104

109105
SpelAwareProxyProjectionFactory projectionFactory = new SpelAwareProxyProjectionFactory();
110106
if (context != null) {
@@ -115,7 +111,7 @@ public DatabaseClient databaseClient(ReactiveDataAccessStrategy dataAccessStrate
115111
return DatabaseClient.builder() //
116112
.connectionFactory(lookupConnectionFactory()) //
117113
.dataAccessStrategy(dataAccessStrategy) //
118-
.exceptionTranslator(exceptionTranslator) //
114+
.exceptionTranslator(new R2dbcExceptionSubclassTranslator()) //
119115
.projectionFactory(projectionFactory) //
120116
.build();
121117
}
@@ -200,19 +196,6 @@ protected StoreConversions getStoreConversions() {
200196
return StoreConversions.of(dialect.getSimpleTypeHolder(), converters);
201197
}
202198

203-
/**
204-
* Creates a {@link R2dbcExceptionTranslator} using the configured {@link #connectionFactory() ConnectionFactory}.
205-
*
206-
* @return must not be {@literal null}.
207-
* @see #connectionFactory()
208-
* @see R2dbcExceptionSubclassTranslator
209-
* @see SqlStateR2dbcExceptionTranslator
210-
*/
211-
@Bean
212-
public R2dbcExceptionTranslator exceptionTranslator() {
213-
return new R2dbcExceptionSubclassTranslator();
214-
}
215-
216199
ConnectionFactory lookupConnectionFactory() {
217200

218201
ApplicationContext context = this.context;

src/main/java/org/springframework/data/r2dbc/connectionfactory/ConnectionFactoryUtils.java

+2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@
3939
*
4040
* @author Mark Paluch
4141
* @author Christoph Strobl
42+
* @deprecated since 1.2 in favor of Spring R2DBC. Use {@link org.springframework.r2dbc.connection} instead.
4243
*/
44+
@Deprecated
4345
public abstract class ConnectionFactoryUtils {
4446

4547
/**

src/main/java/org/springframework/data/r2dbc/connectionfactory/ConnectionHandle.java

+2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
* @author Mark Paluch
2424
* @see SimpleConnectionHandle
2525
* @see ConnectionHolder
26+
* @deprecated since 1.2 in favor of Spring R2DBC. Use {@link org.springframework.r2dbc.connection} instead.
2627
*/
2728
@FunctionalInterface
29+
@Deprecated
2830
public interface ConnectionHandle {
2931

3032
/**

src/main/java/org/springframework/data/r2dbc/connectionfactory/ConnectionHolder.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
import org.springframework.util.Assert;
2323

2424
/**
25-
* Resource holder wrapping a R2DBC {@link Connection}. {@link R2dbcTransactionManager} binds instances of
26-
* this class to the thread, for a specific {@link ConnectionFactory}.
25+
* Resource holder wrapping a R2DBC {@link Connection}. {@link R2dbcTransactionManager} binds instances of this class to
26+
* the thread, for a specific {@link ConnectionFactory}.
2727
* <p>
2828
* Inherits rollback-only support for nested R2DBC transactions and reference count functionality from the base class.
2929
* <p>
@@ -33,7 +33,9 @@
3333
* @author Christoph Strobl
3434
* @see R2dbcTransactionManager
3535
* @see ConnectionFactoryUtils
36+
* @deprecated since 1.2 in favor of Spring R2DBC. Use {@link org.springframework.r2dbc.connection} instead.
3637
*/
38+
@Deprecated
3739
public class ConnectionHolder extends ResourceHolderSupport {
3840

3941
@Nullable private ConnectionHandle connectionHandle;

src/main/java/org/springframework/data/r2dbc/connectionfactory/ConnectionProxy.java

+2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
*
2727
* @author Mark Paluch
2828
* @author Christoph Strobl
29+
* @deprecated since 1.2 in favor of Spring R2DBC. Use R2DBC's {@link Wrapped} mechanism instead.
2930
*/
31+
@Deprecated
3032
public interface ConnectionProxy extends Connection, Wrapped<Connection> {
3133

3234
/**

src/main/java/org/springframework/data/r2dbc/connectionfactory/DelegatingConnectionFactory.java

+2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
*
3333
* @author Mark Paluch
3434
* @see #create
35+
* @deprecated since 1.2 in favor of Spring R2DBC. Use {@link org.springframework.r2dbc.connection} instead.
3536
*/
37+
@Deprecated
3638
public class DelegatingConnectionFactory implements ConnectionFactory, Wrapped<ConnectionFactory> {
3739

3840
private final ConnectionFactory targetConnectionFactory;

src/main/java/org/springframework/data/r2dbc/connectionfactory/R2dbcTransactionManager.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@
7373
* @see ConnectionFactoryUtils#releaseConnection
7474
* @see TransactionAwareConnectionFactoryProxy
7575
* @see DatabaseClient
76+
* @deprecated since 1.2 in favor of Spring R2DBC. Use {@link org.springframework.r2dbc.connection} instead.
7677
*/
78+
@Deprecated
7779
public class R2dbcTransactionManager extends AbstractReactiveTransactionManager implements InitializingBean {
7880

7981
private ConnectionFactory connectionFactory;
@@ -135,7 +137,7 @@ public ConnectionFactory getConnectionFactory() {
135137
* <p>
136138
* If no custom translator is provided, a default {@link R2dbcExceptionSubclassTranslator} is used which translates
137139
* {@link R2dbcException}'s subclasses into Springs {@link DataAccessException} hierarchy.
138-
*
140+
*
139141
* @see R2dbcExceptionSubclassTranslator
140142
* @since 1.1
141143
*/
@@ -526,7 +528,7 @@ protected IsolationLevel resolveIsolationLevel(int isolationLevel) {
526528
* <p>
527529
* The default implementation throws a {@link TransactionSystemException}. Subclasses may specifically identify
528530
* concurrency failures etc.
529-
*
531+
*
530532
* @param task the task description (commit or rollback).
531533
* @param ex the SQLException thrown from commit/rollback.
532534
* @return the translated exception to throw, either a {@link org.springframework.dao.DataAccessException} or a

src/main/java/org/springframework/data/r2dbc/connectionfactory/SimpleConnectionHandle.java

+2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
*
2525
* @author Mark Paluch
2626
* @author Christoph Strobl
27+
* @deprecated since 1.2 in favor of Spring R2DBC. Use {@link org.springframework.r2dbc.connection} instead.
2728
*/
29+
@Deprecated
2830
public class SimpleConnectionHandle implements ConnectionHandle {
2931

3032
private final Connection connection;

src/main/java/org/springframework/data/r2dbc/connectionfactory/SingleConnectionConnectionFactory.java

+2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@
5353
* @see #create()
5454
* @see io.r2dbc.spi.Connection#close()
5555
* @see ConnectionFactoryUtils#releaseConnection(io.r2dbc.spi.Connection, ConnectionFactory)
56+
* @deprecated since 1.2 in favor of Spring R2DBC. Use {@link org.springframework.r2dbc.connection} instead.
5657
*/
58+
@Deprecated
5759
public class SingleConnectionConnectionFactory extends DelegatingConnectionFactory
5860
implements SmartConnectionFactory, DisposableBean {
5961

src/main/java/org/springframework/data/r2dbc/connectionfactory/SmartConnectionFactory.java

+2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
*
2828
* @author Mark Paluch
2929
* @see ConnectionFactoryUtils#closeConnection
30+
* @deprecated since 1.2 in favor of Spring R2DBC. Use {@link org.springframework.r2dbc.connection} instead.
3031
*/
32+
@Deprecated
3133
public interface SmartConnectionFactory extends ConnectionFactory {
3234

3335
/**

src/main/java/org/springframework/data/r2dbc/connectionfactory/TransactionAwareConnectionFactoryProxy.java

+2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@
6060
* @see Connection#close
6161
* @see ConnectionFactoryUtils#doGetConnection
6262
* @see ConnectionFactoryUtils#doReleaseConnection
63+
* @deprecated since 1.2 in favor of Spring R2DBC. Use {@link org.springframework.r2dbc.connection} instead.
6364
*/
65+
@Deprecated
6466
public class TransactionAwareConnectionFactoryProxy extends DelegatingConnectionFactory {
6567

6668
/**

src/main/java/org/springframework/data/r2dbc/connectionfactory/init/CannotReadScriptException.java

+2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
* Thrown by {@link ScriptUtils} if an SQL script cannot be read.
2222
*
2323
* @author Mark Paluch
24+
* @deprecated since 1.2 in favor of Spring R2DBC. Use {@link org.springframework.r2dbc.connection.init} instead.
2425
*/
26+
@Deprecated
2527
public class CannotReadScriptException extends ScriptException {
2628

2729
private static final long serialVersionUID = 7253084944991764250L;

src/main/java/org/springframework/data/r2dbc/connectionfactory/init/CompositeDatabasePopulator.java

+2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
* executing all scripts.
3232
*
3333
* @author Mark Paluch
34+
* @deprecated since 1.2 in favor of Spring R2DBC. Use {@link org.springframework.r2dbc.connection.init} instead.
3435
*/
36+
@Deprecated
3537
public class CompositeDatabasePopulator implements DatabasePopulator {
3638

3739
private final List<DatabasePopulator> populators = new ArrayList<>(4);

src/main/java/org/springframework/data/r2dbc/connectionfactory/init/ConnectionFactoryInitializer.java

+2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
*
2929
* @author Mark Paluch
3030
* @see DatabasePopulator
31+
* @deprecated since 1.2 in favor of Spring R2DBC. Use {@link org.springframework.r2dbc.connection.init} instead.
3132
*/
33+
@Deprecated
3234
public class ConnectionFactoryInitializer implements InitializingBean, DisposableBean {
3335

3436
private @Nullable ConnectionFactory connectionFactory;

src/main/java/org/springframework/data/r2dbc/connectionfactory/init/DatabasePopulator.java

+2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@
2525
* @see ResourceDatabasePopulator
2626
* @see DatabasePopulatorUtils
2727
* @see ConnectionFactoryInitializer
28+
* @deprecated since 1.2 in favor of Spring R2DBC. Use {@link org.springframework.r2dbc.connection.init} instead.
2829
*/
2930
@FunctionalInterface
31+
@Deprecated
3032
public interface DatabasePopulator {
3133

3234
/**

0 commit comments

Comments
 (0)