image:https://spring.io/badges/spring-data-r2dbc/snapshot.svg["Spring Data R2DBC", link="https://spring.io/projects/spring-data-r2dbc#learn"]
image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-r2dbc%2Fmaster&subject=master["Spring Data R2DBC", link="https://jenkins.spring.io/view/SpringData/job/spring-data-r2dbc/"]
= Spring Data R2DBC
The primary goal of the https://projects.spring.io/spring-data[Spring Data] project is to make it easier to build Spring-powered applications that use data access technologies. *Spring Data R2DBC* offers the popular Repository abstraction based on https://r2dbc.io[R2DBC].
R2DBC is the abbreviation for https://github.com/r2dbc/[Reactive Relational Database Connectivity], an incubator to integrate relational databases using a reactive driver.
The state of R2DBC is incubating to evaluate how an reactive integration could look like. To get started, you need a R2DBC driver first.
== This is NOT an ORM
Spring Data R2DBC does not try to be an ORM.
Instead it is more of a construction kit for your personal reactive relational data access component that you can define the way you like or need it.
== Maven Coordinates
[source,xml]
----
org.springframework.data
spring-data-r2dbc
1.0.0.BUILD-SNAPSHOT
----
== DatabaseClient
All functionality is encapsulated in `DatabaseClient` which is the entry point for applications that wish to integrate with relational databases using reactive drivers:
[source,java]
----
PostgresqlConnectionFactory connectionFactory = new PostgresqlConnectionFactory(PostgresqlConnectionConfiguration.builder()
.host(…)
.database(…)
.username(…)
.password(…).build());
DatabaseClient databaseClient = DatabaseClient.create(connectionFactory);
----
The client API provides covers the following features:
* Execution of generic SQL and consumption of update count/row results.
* Generic `SELECT` with paging and ordering.
* `SELECT` of mapped objects with paging and ordering.
* Generic `INSERT` with parameter binding.
* `INSERT` of mapped objects.
* Parameter binding using the native syntax.
* Result consumption: Update count, unmapped (`Map`), mapped to entities, extraction function.
* Reactive repositories using `@Query` annotated methods.
* Transaction Management.
=== Examples executing generic SQL statements
[source,java]
----
Mono count = databaseClient.execute()
.sql("INSERT INTO legoset (id, name, manual) VALUES($1, $2, $3)")
.bind("$1", 42055)
.bind("$2", "Description")
.bindNull("$3", Integer.class)
.fetch()
.rowsUpdated();
Flux