Skip to content

Commit 29688c9

Browse files
evgdimschauder
authored andcommitted
DATAJDBC-287 - Document registration of custom converters.
Original pull request: #106.
1 parent 4d0ada1 commit 29688c9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/main/asciidoc/jdbc.adoc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,27 @@ This also means references are 1-1 or 1-n, but not n-1 or n-m.
145145
If you have n-1 or n-m references, you are, by definition, dealing with two separate aggregates.
146146
References between those should be encoded as simple `id` values, which should map properly with Spring Data JDBC.
147147

148+
=== Custom converters
149+
Custom coverters can be registered, for types that are not supported by default, by inheriting your configuration from `JdbcConfiguration` and overwriting the method `jdbcCustomConversions()`.
150+
====
151+
[source, java]
152+
----
153+
@Configuration
154+
public class DataJdbcConfiguration extends JdbcConfiguration {
155+
@Override
156+
protected JdbcCustomConversions jdbcCustomConversions() {
157+
return new JdbcCustomConversions(Arrays.asList(new Converter<TIMESTAMPTZ, Date>() {
158+
@Override
159+
public Date convert(TIMESTAMPTZ source) {
160+
//...
161+
}
162+
}));
163+
}
164+
}
165+
----
166+
====
167+
The constructor of `JdbcCustomConversions` accepts a list of `org.springframework.core.convert.converter.Converter`.
168+
148169
[[jdbc.entity-persistence.naming-strategy]]
149170
=== `NamingStrategy`
150171

0 commit comments

Comments
 (0)