#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.
This commit is contained in:
Mark Paluch
2019-04-24 14:40:54 +02:00
parent f7d3124c63
commit 72ffccbfbc
10 changed files with 53 additions and 17 deletions

View File

@@ -18,7 +18,6 @@ package org.springframework.data.r2dbc;
import io.r2dbc.spi.R2dbcException;
import org.springframework.dao.InvalidDataAccessResourceUsageException;
import org.springframework.jdbc.BadSqlGrammarException;
import org.springframework.lang.Nullable;
/**

View File

@@ -57,7 +57,6 @@ import org.springframework.data.r2dbc.domain.SettableValue;
import org.springframework.data.r2dbc.function.connectionfactory.ConnectionProxy;
import org.springframework.data.r2dbc.function.convert.ColumnMapRowMapper;
import org.springframework.data.r2dbc.support.R2dbcExceptionTranslator;
import org.springframework.jdbc.core.SqlProvider;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;

View File

@@ -38,7 +38,7 @@ class DefaultFetchSpec<T> implements FetchSpec<T> {
private final Function<Connection, Mono<Integer>> updatedRowsFunction;
/* (non-Javadoc)
* @see org.springframework.data.jdbc.core.function.FetchSpec#one()
* @see org.springframework.data.r2dbc.function.FetchSpec#one()
*/
@Override
public Mono<T> one() {
@@ -60,7 +60,7 @@ class DefaultFetchSpec<T> implements FetchSpec<T> {
}
/* (non-Javadoc)
* @see org.springframework.data.jdbc.core.function.FetchSpec#first()
* @see org.springframework.data.r2dbc.function.FetchSpec#first()
*/
@Override
public Mono<T> first() {
@@ -68,7 +68,7 @@ class DefaultFetchSpec<T> implements FetchSpec<T> {
}
/* (non-Javadoc)
* @see org.springframework.data.jdbc.core.function.FetchSpec#all()
* @see org.springframework.data.r2dbc.function.FetchSpec#all()
*/
@Override
public Flux<T> all() {
@@ -76,7 +76,7 @@ class DefaultFetchSpec<T> implements FetchSpec<T> {
}
/* (non-Javadoc)
* @see org.springframework.data.jdbc.core.function.FetchSpec#rowsUpdated()
* @see org.springframework.data.r2dbc.function.FetchSpec#rowsUpdated()
*/
@Override
public Mono<Integer> rowsUpdated() {

View File

@@ -25,7 +25,6 @@ import reactor.core.publisher.Mono;
import java.util.function.BiFunction;
import java.util.function.Function;
import org.springframework.jdbc.core.SqlProvider;
/**
* Default {@link SqlResult} implementation.
@@ -110,7 +109,7 @@ class DefaultSqlResult<T> implements SqlResult<T> {
}
/* (non-Javadoc)
* @see org.springframework.data.jdbc.core.function.SqlResult#map(java.util.function.BiFunction)
* @see org.springframework.data.r2dbc.function.SqlResult#map(java.util.function.BiFunction)
*/
@Override
public <R> SqlResult<R> map(BiFunction<Row, RowMetadata, R> mappingFunction) {
@@ -118,7 +117,7 @@ class DefaultSqlResult<T> implements SqlResult<T> {
}
/* (non-Javadoc)
* @see org.springframework.data.jdbc.core.function.FetchSpec#one()
* @see org.springframework.data.r2dbc.function.FetchSpec#one()
*/
@Override
public Mono<T> one() {
@@ -126,7 +125,7 @@ class DefaultSqlResult<T> implements SqlResult<T> {
}
/* (non-Javadoc)
* @see org.springframework.data.jdbc.core.function.FetchSpec#first()
* @see org.springframework.data.r2dbc.function.FetchSpec#first()
*/
@Override
public Mono<T> first() {
@@ -134,7 +133,7 @@ class DefaultSqlResult<T> implements SqlResult<T> {
}
/* (non-Javadoc)
* @see org.springframework.data.jdbc.core.function.FetchSpec#all()
* @see org.springframework.data.r2dbc.function.FetchSpec#all()
*/
@Override
public Flux<T> all() {
@@ -142,7 +141,7 @@ class DefaultSqlResult<T> implements SqlResult<T> {
}
/* (non-Javadoc)
* @see org.springframework.data.jdbc.core.function.FetchSpec#rowsUpdated()
* @see org.springframework.data.r2dbc.function.FetchSpec#rowsUpdated()
*/
@Override
public Mono<Integer> rowsUpdated() {

View File

@@ -39,7 +39,7 @@ import org.springframework.util.Assert;
* Only intended for internal use within Spring's Data's R2DBC framework. Partially extracted from Spring's JDBC named
* parameter support.
* <p>
* This is a subset of Spring Frameworks's {@code org.springframework.jdbc.core.namedparam.NamedParameterUtils}.
* This is a subset of Spring Frameworks's {@code org.springframework.r2dbc.namedparam.NamedParameterUtils}.
*
* @author Thomas Risberg
* @author Juergen Hoeller

View File

@@ -21,7 +21,7 @@ import java.util.List;
/**
* Holds information about a parsed SQL statement.
* <p>
* This is a copy of Spring Frameworks's {@code org.springframework.jdbc.core.namedparam.ParsedSql}.
* This is a copy of Spring Frameworks's {@code org.springframework.r2dbc.namedparam.ParsedSql}.
*
* @author Thomas Risberg
* @author Juergen Hoeller

View File

@@ -0,0 +1,39 @@
/*
* Copyright 2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.r2dbc.function;
import org.springframework.lang.Nullable;
/**
* Interface to be implemented by objects that can provide SQL strings.
* <p>
* Typically implemented by objects that want to expose the SQL they use to create their statements, to allow for better
* contextual information in case of exceptions.
*
* @author Juergen Hoeller
* @author Mark Paluch
*/
public interface SqlProvider {
/**
* Return the SQL string for this object, i.e. typically the SQL used for creating statements.
*
* @return the SQL string, or {@code null}.
*/
@Nullable
String getSql();
}

View File

@@ -79,7 +79,7 @@ class R2dbcParameterAccessor extends RelationalParametersParameterAccessor {
}
/* (non-Javadoc)
* @see org.springframework.data.jdbc.repository.query.JdbcParametersParameterAccessor#getValues()
* @see org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor#getValues()
*/
@Override
public Object[] getValues() {

View File

@@ -49,7 +49,7 @@ interface R2dbcQueryExecution {
private final @NonNull Converter<Object, Object> converter;
/* (non-Javadoc)
* @see org.springframework.data.jdbc.repository.query.R2dbcQueryExecution#execute(org.springframework.data.jdbc.core.function.FetchSpec, java.lang.Class, java.lang.String)
* @see org.springframework.data.r2dbc.repository.query.R2dbcQueryExecution#execute(org.springframework.data.r2dbc.function.FetchSpec, java.lang.Class, java.lang.String)
*/
@Override
public Object execute(FetchSpec<?> query, Class<?> type, String tableName) {

View File

@@ -75,7 +75,7 @@ public class StringBasedR2dbcQuery extends AbstractR2dbcQuery {
}
/* (non-Javadoc)
* @see org.springframework.data.jdbc.repository.query.AbstractR2dbcQuery#createQuery(org.springframework.data.jdbc.repository.query.JdbcParameterAccessor)
* @see org.springframework.data.r2dbc.repository.query.AbstractR2dbcQuery#createQuery(org.springframework.data.relational.repository.query.RelationalParameterAccessor)
*/
@Override
protected BindableQuery createQuery(RelationalParameterAccessor accessor) {