19
19
import io .r2dbc .spi .RowMetadata ;
20
20
21
21
import java .util .ArrayList ;
22
+ import java .util .Collection ;
22
23
import java .util .Collections ;
23
24
import java .util .List ;
24
25
import java .util .function .BiFunction ;
25
26
import java .util .function .Function ;
26
27
28
+ import org .springframework .core .annotation .AnnotatedElementUtils ;
27
29
import org .springframework .dao .InvalidDataAccessResourceUsageException ;
28
30
import org .springframework .data .convert .CustomConversions .StoreConversions ;
29
31
import org .springframework .data .mapping .context .MappingContext ;
37
39
import org .springframework .data .r2dbc .mapping .OutboundRow ;
38
40
import org .springframework .data .r2dbc .mapping .SettableValue ;
39
41
import org .springframework .data .r2dbc .query .UpdateMapper ;
42
+ import org .springframework .data .relational .core .mapping .NamingStrategy ;
40
43
import org .springframework .data .relational .core .mapping .RelationalMappingContext ;
41
44
import org .springframework .data .relational .core .mapping .RelationalPersistentEntity ;
42
45
import org .springframework .data .relational .core .mapping .RelationalPersistentProperty ;
46
+ import org .springframework .data .relational .core .mapping .Table ;
43
47
import org .springframework .data .relational .core .sql .Select ;
44
48
import org .springframework .data .relational .core .sql .render .NamingStrategies ;
45
49
import org .springframework .data .relational .core .sql .render .RenderContext ;
48
52
import org .springframework .lang .Nullable ;
49
53
import org .springframework .util .Assert ;
50
54
import org .springframework .util .ClassUtils ;
55
+ import org .springframework .util .StringUtils ;
51
56
52
57
/**
53
58
* Default {@link ReactiveDataAccessStrategy} implementation.
@@ -63,21 +68,35 @@ public class DefaultReactiveDataAccessStrategy implements ReactiveDataAccessStra
63
68
private final StatementMapper statementMapper ;
64
69
65
70
/**
66
- * Creates a new {@link DefaultReactiveDataAccessStrategy} given {@link Dialect}.
71
+ * Creates a new {@link DefaultReactiveDataAccessStrategy} given {@link Dialect} and optional
72
+ * {@link org.springframework.core.convert.converter.Converter}s.
67
73
*
68
74
* @param dialect the {@link Dialect} to use.
69
75
*/
70
76
public DefaultReactiveDataAccessStrategy (Dialect dialect ) {
71
- this (dialect , createConverter ( dialect ));
77
+ this (dialect , Collections . emptyList ( ));
72
78
}
73
79
74
- private static R2dbcConverter createConverter (Dialect dialect ) {
80
+ /**
81
+ * Creates a new {@link DefaultReactiveDataAccessStrategy} given {@link Dialect} and optional
82
+ * {@link org.springframework.core.convert.converter.Converter}s.
83
+ *
84
+ * @param dialect the {@link Dialect} to use.
85
+ * @param converters custom converters to register, must not be {@literal null}.
86
+ * @see R2dbcCustomConversions
87
+ * @see org.springframework.core.convert.converter.Converter
88
+ */
89
+ public DefaultReactiveDataAccessStrategy (Dialect dialect , Collection <?> converters ) {
90
+ this (dialect , createConverter (dialect , converters ));
91
+ }
92
+
93
+ private static R2dbcConverter createConverter (Dialect dialect , Collection <?> converters ) {
75
94
76
95
Assert .notNull (dialect , "Dialect must not be null" );
96
+ Assert .notNull (converters , "Converters must not be null" );
77
97
78
98
R2dbcCustomConversions customConversions = new R2dbcCustomConversions (
79
- StoreConversions .of (dialect .getSimpleTypeHolder (), R2dbcCustomConversions .STORE_CONVERTERS ),
80
- Collections .emptyList ());
99
+ StoreConversions .of (dialect .getSimpleTypeHolder (), R2dbcCustomConversions .STORE_CONVERTERS ), converters );
81
100
82
101
RelationalMappingContext context = new RelationalMappingContext ();
83
102
context .setSimpleTypeHolder (customConversions .getSimpleTypeHolder ());
0 commit comments