Add a couple missing java.time types to StatementCreatorUtils
This commit adds mapping for two types from the `java.time` package, complementing the types that are already translatable to Sql types TIME, DATE and TIMESTAMP: - `OffsetTime` maps to a `TIME_WITH_TIMEZONE` - `OffsetDateTime` maps to a `TIMESTAMP_WITH_TIMEZONE` This is in accordance with the B.4 table provided in the JDBC 4.2 specification. When preparing statements, these `java.time` types use the `setObject` method. Tests covering the 5 `java.time` classes have also been added. See gh-28778 See gh-28527 Closes gh-30123
This commit is contained in:
@@ -29,6 +29,8 @@ import java.sql.Types;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.OffsetTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
@@ -104,6 +106,8 @@ public abstract class StatementCreatorUtils {
|
||||
javaTypeToSqlTypeMap.put(LocalDate.class, Types.DATE);
|
||||
javaTypeToSqlTypeMap.put(LocalTime.class, Types.TIME);
|
||||
javaTypeToSqlTypeMap.put(LocalDateTime.class, Types.TIMESTAMP);
|
||||
javaTypeToSqlTypeMap.put(OffsetDateTime.class, Types.TIMESTAMP_WITH_TIMEZONE);
|
||||
javaTypeToSqlTypeMap.put(OffsetTime.class, Types.TIME_WITH_TIMEZONE);
|
||||
javaTypeToSqlTypeMap.put(java.sql.Date.class, Types.DATE);
|
||||
javaTypeToSqlTypeMap.put(java.sql.Time.class, Types.TIME);
|
||||
javaTypeToSqlTypeMap.put(java.sql.Timestamp.class, Types.TIMESTAMP);
|
||||
|
||||
Reference in New Issue
Block a user