Skip to content

Commit 72ffccb

Browse files
committed
#100 - Remove Spring JDBC as mandatory dependency.
We now ship our own SqlProvider variant to not require Spring JDBC as mandatory dependency. Spring JDBC can be provided optionally to use SQL-code based exception translation.
1 parent f7d3124 commit 72ffccb

10 files changed

+53
-17
lines changed

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

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import io.r2dbc.spi.R2dbcException;
1919

2020
import org.springframework.dao.InvalidDataAccessResourceUsageException;
21-
import org.springframework.jdbc.BadSqlGrammarException;
2221
import org.springframework.lang.Nullable;
2322

2423
/**

src/main/java/org/springframework/data/r2dbc/function/DefaultDatabaseClient.java

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
import org.springframework.data.r2dbc.function.connectionfactory.ConnectionProxy;
5858
import org.springframework.data.r2dbc.function.convert.ColumnMapRowMapper;
5959
import org.springframework.data.r2dbc.support.R2dbcExceptionTranslator;
60-
import org.springframework.jdbc.core.SqlProvider;
6160
import org.springframework.lang.Nullable;
6261
import org.springframework.util.Assert;
6362

src/main/java/org/springframework/data/r2dbc/function/DefaultFetchSpec.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class DefaultFetchSpec<T> implements FetchSpec<T> {
3838
private final Function<Connection, Mono<Integer>> updatedRowsFunction;
3939

4040
/* (non-Javadoc)
41-
* @see org.springframework.data.jdbc.core.function.FetchSpec#one()
41+
* @see org.springframework.data.r2dbc.function.FetchSpec#one()
4242
*/
4343
@Override
4444
public Mono<T> one() {
@@ -60,23 +60,23 @@ public Mono<T> one() {
6060
}
6161

6262
/* (non-Javadoc)
63-
* @see org.springframework.data.jdbc.core.function.FetchSpec#first()
63+
* @see org.springframework.data.r2dbc.function.FetchSpec#first()
6464
*/
6565
@Override
6666
public Mono<T> first() {
6767
return all().next();
6868
}
6969

7070
/* (non-Javadoc)
71-
* @see org.springframework.data.jdbc.core.function.FetchSpec#all()
71+
* @see org.springframework.data.r2dbc.function.FetchSpec#all()
7272
*/
7373
@Override
7474
public Flux<T> all() {
7575
return connectionAccessor.inConnectionMany(resultFunction);
7676
}
7777

7878
/* (non-Javadoc)
79-
* @see org.springframework.data.jdbc.core.function.FetchSpec#rowsUpdated()
79+
* @see org.springframework.data.r2dbc.function.FetchSpec#rowsUpdated()
8080
*/
8181
@Override
8282
public Mono<Integer> rowsUpdated() {

src/main/java/org/springframework/data/r2dbc/function/DefaultSqlResult.java

+5-6
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.util.function.BiFunction;
2626
import java.util.function.Function;
2727

28-
import org.springframework.jdbc.core.SqlProvider;
2928

3029
/**
3130
* Default {@link SqlResult} implementation.
@@ -110,39 +109,39 @@ public static <R> SqlResult<R> empty() {
110109
}
111110

112111
/* (non-Javadoc)
113-
* @see org.springframework.data.jdbc.core.function.SqlResult#map(java.util.function.BiFunction)
112+
* @see org.springframework.data.r2dbc.function.SqlResult#map(java.util.function.BiFunction)
114113
*/
115114
@Override
116115
public <R> SqlResult<R> map(BiFunction<Row, RowMetadata, R> mappingFunction) {
117116
return new DefaultSqlResult<>(connectionAccessor, sql, resultFunction, updatedRowsFunction, mappingFunction);
118117
}
119118

120119
/* (non-Javadoc)
121-
* @see org.springframework.data.jdbc.core.function.FetchSpec#one()
120+
* @see org.springframework.data.r2dbc.function.FetchSpec#one()
122121
*/
123122
@Override
124123
public Mono<T> one() {
125124
return fetchSpec.one();
126125
}
127126

128127
/* (non-Javadoc)
129-
* @see org.springframework.data.jdbc.core.function.FetchSpec#first()
128+
* @see org.springframework.data.r2dbc.function.FetchSpec#first()
130129
*/
131130
@Override
132131
public Mono<T> first() {
133132
return fetchSpec.first();
134133
}
135134

136135
/* (non-Javadoc)
137-
* @see org.springframework.data.jdbc.core.function.FetchSpec#all()
136+
* @see org.springframework.data.r2dbc.function.FetchSpec#all()
138137
*/
139138
@Override
140139
public Flux<T> all() {
141140
return fetchSpec.all();
142141
}
143142

144143
/* (non-Javadoc)
145-
* @see org.springframework.data.jdbc.core.function.FetchSpec#rowsUpdated()
144+
* @see org.springframework.data.r2dbc.function.FetchSpec#rowsUpdated()
146145
*/
147146
@Override
148147
public Mono<Integer> rowsUpdated() {

src/main/java/org/springframework/data/r2dbc/function/NamedParameterUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
* Only intended for internal use within Spring's Data's R2DBC framework. Partially extracted from Spring's JDBC named
4040
* parameter support.
4141
* <p>
42-
* This is a subset of Spring Frameworks's {@code org.springframework.jdbc.core.namedparam.NamedParameterUtils}.
42+
* This is a subset of Spring Frameworks's {@code org.springframework.r2dbc.namedparam.NamedParameterUtils}.
4343
*
4444
* @author Thomas Risberg
4545
* @author Juergen Hoeller

src/main/java/org/springframework/data/r2dbc/function/ParsedSql.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
/**
2222
* Holds information about a parsed SQL statement.
2323
* <p>
24-
* This is a copy of Spring Frameworks's {@code org.springframework.jdbc.core.namedparam.ParsedSql}.
24+
* This is a copy of Spring Frameworks's {@code org.springframework.r2dbc.namedparam.ParsedSql}.
2525
*
2626
* @author Thomas Risberg
2727
* @author Juergen Hoeller
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.data.r2dbc.function;
17+
18+
import org.springframework.lang.Nullable;
19+
20+
/**
21+
* Interface to be implemented by objects that can provide SQL strings.
22+
* <p>
23+
* Typically implemented by objects that want to expose the SQL they use to create their statements, to allow for better
24+
* contextual information in case of exceptions.
25+
*
26+
* @author Juergen Hoeller
27+
* @author Mark Paluch
28+
*/
29+
public interface SqlProvider {
30+
31+
/**
32+
* Return the SQL string for this object, i.e. typically the SQL used for creating statements.
33+
*
34+
* @return the SQL string, or {@code null}.
35+
*/
36+
@Nullable
37+
String getSql();
38+
39+
}

src/main/java/org/springframework/data/r2dbc/repository/query/R2dbcParameterAccessor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ protected <T> T getValue(int index) {
7979
}
8080

8181
/* (non-Javadoc)
82-
* @see org.springframework.data.jdbc.repository.query.JdbcParametersParameterAccessor#getValues()
82+
* @see org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor#getValues()
8383
*/
8484
@Override
8585
public Object[] getValues() {

src/main/java/org/springframework/data/r2dbc/repository/query/R2dbcQueryExecution.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ final class ResultProcessingExecution implements R2dbcQueryExecution {
4949
private final @NonNull Converter<Object, Object> converter;
5050

5151
/* (non-Javadoc)
52-
* @see org.springframework.data.jdbc.repository.query.R2dbcQueryExecution#execute(org.springframework.data.jdbc.core.function.FetchSpec, java.lang.Class, java.lang.String)
52+
* @see org.springframework.data.r2dbc.repository.query.R2dbcQueryExecution#execute(org.springframework.data.r2dbc.function.FetchSpec, java.lang.Class, java.lang.String)
5353
*/
5454
@Override
5555
public Object execute(FetchSpec<?> query, Class<?> type, String tableName) {

src/main/java/org/springframework/data/r2dbc/repository/query/StringBasedR2dbcQuery.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public StringBasedR2dbcQuery(String query, R2dbcQueryMethod method, DatabaseClie
7575
}
7676

7777
/* (non-Javadoc)
78-
* @see org.springframework.data.jdbc.repository.query.AbstractR2dbcQuery#createQuery(org.springframework.data.jdbc.repository.query.JdbcParameterAccessor)
78+
* @see org.springframework.data.r2dbc.repository.query.AbstractR2dbcQuery#createQuery(org.springframework.data.relational.repository.query.RelationalParameterAccessor)
7979
*/
8080
@Override
8181
protected BindableQuery createQuery(RelationalParameterAccessor accessor) {

0 commit comments

Comments
 (0)