You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Incorporated feedback from review. Polished documentation and Javadoc. Minor code improvements restructuring for better readability. Removed unused methods types. Some polishing for compiler warnings.
Original pull request: #106.
Spring Data R2DBC reacts to database specifics by inspecting `ConnectionFactoryMetadata` and selects the appropriate database dialect.
240
-
You can configure an own `Dialect` if the used driver is not yet known to Spring Data R2DBC.
239
+
Spring Data R2DBC reacts to database specifics by inspecting `ConnectionFactoryMetadata` exposed by the `ConnectionFactory` and selects the appropriate database dialect accordingly.
240
+
You can configure an own https://docs.spring.io/spring-data/r2dbc/docs/{version}/api/org/springframework/data/r2dbc/dialect/Dialect.html[`Dialect`] if the used driver is not yet known to Spring Data R2DBC.
The above method creates a `DatabaseClient` with default settings.
26
26
27
-
You can also use `DatabaseClient.builder()` with further options to customize the client:
27
+
You can also obtain a `Builder` instance via `DatabaseClient.builder()` with further options to customize the client by calling the following methods:
28
28
29
-
* `exceptionTranslator`: Supply a specific `R2dbcExceptionTranslator` to customize how R2DBC exceptions are translated into Spring's portable Data Access Exception hierarchy. See "`<<r2dbc.exception>>`" for more information.
30
-
* `dataAccessStrategy`: Strategy how SQL queries are generated and how objects are mapped.
29
+
* `….exceptionTranslator(…)`: Supply a specific `R2dbcExceptionTranslator` to customize how R2DBC exceptions are translated into Spring's portable Data Access Exception hierarchy. See "`<<r2dbc.exception>>`" for more information.
30
+
* `….dataAccessStrategy(…)`: Strategy how SQL queries are generated and how objects are mapped.
31
31
32
32
Once built, a `DatabaseClient` instance is immutable. However, you can clone it and build a modified copy without affecting the original instance, as the following example shows:
33
33
@@ -50,6 +50,19 @@ When you use Spring Data R2DBC, you can create a `ConnectionFactory` using your
50
50
`ConnectionFactory` implementations can either return the same connection, different connections or provide connection pooling.
51
51
`DatabaseClient` uses `ConnectionFactory` to create and release connections per operation without affinity to a particular connection across multiple operations.
52
52
53
+
Assuming you'd be using H2 as a database, a typical programmatic setup looks something like this:
54
+
55
+
[source, java]
56
+
----
57
+
H2ConnectionConfiguration config = … <1>
58
+
ConnectionFactory factory = new H2ConnectionFactory(config); <2>
<1> Prepare the database specific configuration (host, port, credentials etc.)
63
+
<2> Create a connection factory using that configuration.
64
+
<3> Create a `DatabaseClient` to use that connection factory.
65
+
53
66
[[r2dbc.exception]]
54
67
= Exception Translation
55
68
@@ -66,7 +79,7 @@ It considers R2DBC's categorized exception hierarchy to translate these into Spr
66
79
`SqlErrorCodeR2dbcExceptionTranslator` uses specific vendor codes using Spring JDBC's `SQLErrorCodes`.
67
80
It is more precise than the SQLState implementation.
68
81
The error code translations are based on codes held in a JavaBean type class called `SQLErrorCodes`.
69
-
This class is created and populated by an `SQLErrorCodesFactory`, which (as the name suggests) is a factory for creating SQLErrorCodes based on the contents of a configuration file named `sql-error-codes.xml` from Spring's Data Access module.
82
+
Instances of this class are created and populated by an `SQLErrorCodesFactory`, which (as the name suggests) is a factory for creating SQLErrorCodes based on the contents of a configuration file named `sql-error-codes.xml` from Spring's Data Access module.
70
83
This file is populated with vendor codes and based on the `ConnectionFactoryName` taken from `ConnectionFactoryMetadata`.
71
84
The codes for the actual database you are using are used.
0 commit comments