File tree Expand file tree Collapse file tree 7 files changed +84
-5
lines changed
main/java/org/springframework/data/jdbc/core
test/java/org/springframework/data/jdbc/core/dialect
main/java/org/springframework/data/r2dbc
test/java/org/springframework/data/r2dbc Expand file tree Collapse file tree 7 files changed +84
-5
lines changed Original file line number Diff line number Diff line change 2929import org .springframework .data .convert .ConverterBuilder ;
3030import org .springframework .data .convert .CustomConversions ;
3131import org .springframework .data .jdbc .core .mapping .JdbcSimpleTypes ;
32+ import org .springframework .data .mapping .model .SimpleTypeHolder ;
3233import org .springframework .data .relational .core .dialect .Dialect ;
3334import org .springframework .lang .Contract ;
3435import org .springframework .util .Assert ;
@@ -177,9 +178,8 @@ static JdbcConverterConfigurer from(Dialect dialect) {
177178 converters .addAll (dialect .getConverters ());
178179 converters .addAll (JdbcCustomConversions .storeConverters ());
179180
180- StoreConversions storeConversions = StoreConversions .of (JdbcSimpleTypes .HOLDER , converters );
181-
182- return new JdbcConverterConfigurer (storeConversions );
181+ SimpleTypeHolder simpleTypeHolder = new SimpleTypeHolder (dialect .simpleTypes (), JdbcSimpleTypes .HOLDER );
182+ return new JdbcConverterConfigurer (StoreConversions .of (simpleTypeHolder , converters ));
183183 }
184184
185185 /**
Original file line number Diff line number Diff line change 2222import java .util .ArrayList ;
2323import java .util .Collection ;
2424import java .util .List ;
25+ import java .util .Set ;
2526
2627import org .springframework .core .convert .converter .Converter ;
2728import org .springframework .data .convert .ReadingConverter ;
3334 * @author Jens Schauder
3435 * @author Christoph Strobl
3536 * @author Mikhail Polivakha
37+ * @author Mark Paluch
3638 * @since 2.3
3739 */
3840public class JdbcSqlServerDialect extends SqlServerDialect implements JdbcDialect {
3941
4042 public static final JdbcSqlServerDialect INSTANCE = new JdbcSqlServerDialect ();
4143
44+ private static final Set <Class <?>> SIMPLE_TYPES = Set .of (DateTimeOffset .class );
45+
46+ @ Override
47+ public Set <Class <?>> simpleTypes () {
48+ return SIMPLE_TYPES ;
49+ }
50+
4251 @ Override
4352 public Collection <Object > getConverters () {
4453
Original file line number Diff line number Diff line change 1717
1818import static org .assertj .core .api .Assertions .*;
1919
20+ import microsoft .sql .DateTimeOffset ;
21+
2022import java .time .Instant ;
2123import java .util .List ;
2224
2830 * Tests for {@link JdbcSqlServerDialect}
2931 *
3032 * @author Mikhail Polivakha
33+ * @author Mark Paluch
3134 */
3235class JdbcSqlServerDialectTest {
3336
@@ -36,7 +39,16 @@ void testCustomConversions() {
3639
3740 JdbcCustomConversions conversions = JdbcCustomConversions .of (JdbcSqlServerDialect .INSTANCE , List .of ());
3841
39- assertThat (conversions .hasCustomReadTarget (microsoft . sql . DateTimeOffset .class , Instant .class ))
42+ assertThat (conversions .hasCustomReadTarget (DateTimeOffset .class , Instant .class ))
4043 .isTrue ();
4144 }
45+
46+ @ Test // GH-2147
47+ void shouldReportSimpleTypes () {
48+
49+ JdbcCustomConversions conversions = JdbcCustomConversions .of (JdbcSqlServerDialect .INSTANCE , List .of ());
50+
51+ assertThat (conversions .isSimpleType (DateTimeOffset .class )).isTrue ();
52+ assertThat (conversions .getSimpleTypeHolder ().isSimpleType (DateTimeOffset .class )).isTrue ();
53+ }
4254}
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2018-2025 the original author or authors.
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * https://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
116package org .springframework .data .r2dbc .convert ;
217
318import java .util .ArrayList ;
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ default SimpleTypeHolder getSimpleTypeHolder() {
4949 Set <Class <?>> simpleTypes = new HashSet <>(getSimpleTypes ());
5050 simpleTypes .addAll (R2dbcSimpleTypeHolder .R2DBC_SIMPLE_TYPES );
5151
52- return new SimpleTypeHolder (simpleTypes , true );
52+ return new SimpleTypeHolder (simpleTypes , R2dbcSimpleTypeHolder . HOLDER );
5353 }
5454
5555 /**
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2025 the original author or authors.
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * https://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+ package org .springframework .data .r2dbc .convert ;
17+
18+ import static org .assertj .core .api .Assertions .*;
19+
20+ import io .r2dbc .spi .Blob ;
21+
22+ import org .junit .jupiter .api .Test ;
23+
24+ import org .springframework .data .r2dbc .dialect .H2Dialect ;
25+
26+ /**
27+ * Unit tests for {@link R2dbcCustomConversions}.
28+ *
29+ * @author Mark Paluch
30+ */
31+ class R2dbcCustomConversionsUnitTests {
32+
33+ @ Test // GH-2147
34+ void shouldReportR2dbcSimpleTypes () {
35+
36+ R2dbcCustomConversions conversions = R2dbcCustomConversions .of (H2Dialect .INSTANCE );
37+
38+ assertThat (conversions .isSimpleType (Blob .class )).isTrue ();
39+ }
40+ }
Original file line number Diff line number Diff line change 1818import static org .assertj .core .api .Assertions .*;
1919import static org .assertj .core .api .SoftAssertions .*;
2020
21+ import io .r2dbc .postgresql .codec .Box ;
22+
2123import java .util .List ;
2224
2325import org .junit .jupiter .api .Test ;
@@ -55,6 +57,7 @@ void shouldConsiderSimpleTypes() {
5557 it .assertThat (holder .isSimpleType (String .class )).isTrue ();
5658 it .assertThat (holder .isSimpleType (int .class )).isTrue ();
5759 it .assertThat (holder .isSimpleType (Integer .class )).isTrue ();
60+ it .assertThat (holder .isSimpleType (Box .class )).isTrue ();
5861 });
5962 }
6063
You can’t perform that action at this time.
0 commit comments