Skip to content

Commit eea838c

Browse files
committed
Deprecate R2dbcCustomConversions constructor taking Collection of converters.
Creating R2dbcCustomConversions without a dialect or StoreConversions can easily lead to misconfiguration that isn't immediately obvious because of missing store simple types. We now deprecated the constructor and have added guidance on how to properly create R2dbcCustomConversions that is associated with a dialect. Closes #628
1 parent f6fee72 commit eea838c

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

Diff for: src/main/java/org/springframework/data/r2dbc/convert/MappingR2dbcConverter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public class MappingR2dbcConverter extends BasicRelationalConverter implements R
7070
*/
7171
public MappingR2dbcConverter(
7272
MappingContext<? extends RelationalPersistentEntity<?>, ? extends RelationalPersistentProperty> context) {
73-
super(context, new R2dbcCustomConversions(Collections.emptyList()));
73+
super(context, new R2dbcCustomConversions(CustomConversions.StoreConversions.NONE, Collections.emptyList()));
7474
}
7575

7676
/**

Diff for: src/main/java/org/springframework/data/r2dbc/convert/R2dbcCustomConversions.java

+4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ public class R2dbcCustomConversions extends CustomConversions {
4141
* Create a new {@link R2dbcCustomConversions} instance registering the given converters.
4242
*
4343
* @param converters must not be {@literal null}.
44+
* @deprecated since 1.3, use {@link #of(R2dbcDialect, Object...)} or
45+
* {@link #R2dbcCustomConversions(StoreConversions, Collection)} directly to consider dialect-native
46+
* simple types. Use {@link CustomConversions.StoreConversions#NONE} to omit store-specific converters.
4447
*/
48+
@Deprecated
4549
public R2dbcCustomConversions(Collection<?> converters) {
4650
super(new R2dbcCustomConversionsConfiguration(STORE_CONVERSIONS, appendOverrides(converters)));
4751
}

Diff for: src/test/java/org/springframework/data/r2dbc/convert/MappingR2dbcConverterUnitTests.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.springframework.dao.InvalidDataAccessApiUsageException;
4242
import org.springframework.data.annotation.Id;
4343
import org.springframework.data.annotation.Transient;
44+
import org.springframework.data.convert.CustomConversions;
4445
import org.springframework.data.convert.ReadingConverter;
4546
import org.springframework.data.convert.WritingConverter;
4647
import org.springframework.data.r2dbc.mapping.OutboundRow;
@@ -62,7 +63,7 @@ public class MappingR2dbcConverterUnitTests {
6263
@BeforeEach
6364
void before() {
6465

65-
R2dbcCustomConversions conversions = new R2dbcCustomConversions(
66+
R2dbcCustomConversions conversions = new R2dbcCustomConversions(CustomConversions.StoreConversions.NONE,
6667
Arrays.asList(StringToMapConverter.INSTANCE, MapToStringConverter.INSTANCE,
6768
CustomConversionPersonToOutboundRowConverter.INSTANCE, RowToCustomConversionPerson.INSTANCE));
6869

Diff for: src/test/java/org/springframework/data/r2dbc/mapping/R2dbcMappingContextUnitTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class R2dbcMappingContextUnitTests {
4545
@Test
4646
public void shouldCreateMetadataForConvertedTypes() {
4747

48-
R2dbcCustomConversions conversions = new R2dbcCustomConversions(
48+
R2dbcCustomConversions conversions = new R2dbcCustomConversions(CustomConversions.StoreConversions.NONE,
4949
Arrays.asList(ConvertedEntityToRow.INSTANCE, RowToConvertedEntity.INSTANCE));
5050
R2dbcMappingContext context = new R2dbcMappingContext();
5151
context.setSimpleTypeHolder(conversions.getSimpleTypeHolder());

0 commit comments

Comments
 (0)