File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
main/java/org/springframework/data/jdbc/core/convert
test/java/org/springframework/data/jdbc/core/convert Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 1818import java .sql .Timestamp ;
1919import java .time .LocalDateTime ;
2020import java .time .OffsetDateTime ;
21+ import java .time .Year ;
2122import java .time .ZonedDateTime ;
2223import java .time .temporal .Temporal ;
2324import java .util .LinkedHashMap ;
@@ -40,6 +41,7 @@ public enum JdbcColumnTypes {
4041
4142 private final ConcurrentLruCache <Class <?>, Class <?>> cache = new ConcurrentLruCache <>(64 , this ::doResolve );
4243
44+ @ Override
4345 @ SuppressWarnings ({ "unchecked" , "rawtypes" })
4446 public Class <?> resolvePrimitiveType (Class <?> type ) {
4547 return cache .get (type );
@@ -62,6 +64,7 @@ private Class<?> doResolve(Class<?> type) {
6264 javaToDbType .put (ZonedDateTime .class , String .class );
6365 javaToDbType .put (OffsetDateTime .class , OffsetDateTime .class );
6466 javaToDbType .put (LocalDateTime .class , LocalDateTime .class );
67+ javaToDbType .put (Year .class , Integer .class );
6568 javaToDbType .put (Temporal .class , Timestamp .class );
6669 }
6770
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 .jdbc .core .convert ;
17+
18+ import static org .assertj .core .api .Assertions .*;
19+
20+ import java .time .Year ;
21+
22+ import org .junit .jupiter .api .Test ;
23+
24+ /**
25+ * Unit tests for {@link JdbcColumnTypes}.
26+ *
27+ * @author Oliver Drotbohm
28+ */
29+ class JdbcColumnTypesUnitTests {
30+
31+ @ Test
32+ void usesIntegerForYear () {
33+ assertThat (JdbcColumnTypes .INSTANCE .resolvePrimitiveType (Year .class )).isEqualTo (Integer .class );
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments