Skip to content

Add support for R2DBC #25065

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ configure(allprojects) { project ->
mavenBom "com.fasterxml.jackson:jackson-bom:2.11.0"
mavenBom "io.netty:netty-bom:4.1.50.Final"
mavenBom "io.projectreactor:reactor-bom:2020.0.0-SNAPSHOT"
mavenBom "io.r2dbc:r2dbc-bom:Arabba-SR5"
mavenBom "io.rsocket:rsocket-bom:1.0.1"
mavenBom "org.eclipse.jetty:jetty-bom:9.4.29.v20200521"
mavenBom "org.jetbrains.kotlin:kotlin-bom:1.3.72"
Expand Down
1 change: 1 addition & 0 deletions integration-tests/integration-tests.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ dependencies {
testCompile(testFixtures(project(":spring-tx")))
testCompile(project(":spring-expression"))
testCompile(project(":spring-jdbc"))
testCompile(project(":spring-r2dbc"))
testCompile(project(":spring-orm"))
testCompile(project(":spring-test"))
testCompile(project(":spring-tx"))
Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ include "spring-expression"
include "spring-instrument"
include "spring-jcl"
include "spring-jdbc"
include "spring-r2dbc"
include "spring-jms"
include "spring-messaging"
include "spring-orm"
Expand Down
23 changes: 23 additions & 0 deletions spring-r2dbc/spring-r2dbc.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
description = "Spring R2DBC"

apply plugin: "kotlin"

dependencies {
compile(project(":spring-beans"))
compile(project(":spring-core"))
compile(project(":spring-tx"))
compile("io.r2dbc:r2dbc-spi")
compile("io.projectreactor:reactor-core")
compileOnly(project(":kotlin-coroutines"))
optional("org.jetbrains.kotlin:kotlin-reflect")
optional("org.jetbrains.kotlin:kotlin-stdlib")
optional("org.jetbrains.kotlinx:kotlinx-coroutines-core")
optional("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
testCompile(project(":kotlin-coroutines"))
testCompile(testFixtures(project(":spring-beans")))
testCompile(testFixtures(project(":spring-core")))
testCompile(testFixtures(project(":spring-context")))
testCompile("io.projectreactor:reactor-test")
testCompile("io.r2dbc:r2dbc-h2")
testCompile("io.r2dbc:r2dbc-spi-test:0.8.1.RELEASE")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright 2002-2020 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.r2dbc;

import io.r2dbc.spi.R2dbcException;

import org.springframework.dao.InvalidDataAccessResourceUsageException;


/**
* Exception thrown when SQL specified is invalid. Such exceptions always have a
* {@link io.r2dbc.spi.R2dbcException} root cause.
*
* <p>It would be possible to have subclasses for no such table, no such column etc.
* A custom R2dbcExceptionTranslator could create such more specific exceptions,
* without affecting code using this class.
*
* @author Mark Paluch
* @since 5.3
*/
@SuppressWarnings("serial")
public class BadSqlGrammarException extends InvalidDataAccessResourceUsageException {

private final String sql;


/**
* Constructor for BadSqlGrammarException.
* @param task name of current task
* @param sql the offending SQL statement
* @param ex the root cause
*/
public BadSqlGrammarException(String task, String sql, R2dbcException ex) {
super(task + "; bad SQL grammar [" + sql + "]", ex);
this.sql = sql;
}


/**
* Return the wrapped {@link R2dbcException}.
*/
public R2dbcException getR2dbcException() {
return (R2dbcException) getCause();
}

/**
* Return the SQL that caused the problem.
*/
public String getSql() {
return this.sql;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright 2002-2020 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.r2dbc;

import io.r2dbc.spi.R2dbcException;

import org.springframework.dao.UncategorizedDataAccessException;
import org.springframework.lang.Nullable;

/**
* Exception thrown when we can't classify a {@link R2dbcException} into
* one of our generic data access exceptions.
*
* @author Mark Paluch
* @since 5.3
*/
@SuppressWarnings("serial")
public class UncategorizedR2dbcException extends UncategorizedDataAccessException {

/** SQL that led to the problem. */
@Nullable
private final String sql;


/**
* Constructor for {@code UncategorizedSQLException}.
* @param msg the detail message
* @param sql the offending SQL statement
* @param ex the exception thrown by underlying data access API
*/
public UncategorizedR2dbcException(String msg, @Nullable String sql, R2dbcException ex) {
super(msg, ex);
this.sql = sql;
}


/**
* Return the wrapped {@link R2dbcException}.
*/
public R2dbcException getR2dbcException() {
return (R2dbcException) getCause();
}

/**
* Return the SQL that led to the problem (if known).
*/
@Nullable
public String getSql() {
return this.sql;
}

}
Loading