43
43
import static org .hibernate .type .SqlTypes .NVARCHAR ;
44
44
import static org .hibernate .type .SqlTypes .REAL ;
45
45
import static org .hibernate .type .SqlTypes .SMALLINT ;
46
- import static org .hibernate .type .SqlTypes .TIME ;
47
46
import static org .hibernate .type .SqlTypes .TIMESTAMP ;
47
+ import static org .hibernate .type .SqlTypes .TIMESTAMP_UTC ;
48
48
import static org .hibernate .type .SqlTypes .TIMESTAMP_WITH_TIMEZONE ;
49
49
import static org .hibernate .type .SqlTypes .TIME_WITH_TIMEZONE ;
50
50
import static org .hibernate .type .SqlTypes .TINYINT ;
51
51
import static org .hibernate .type .SqlTypes .VARBINARY ;
52
52
import static org .hibernate .type .SqlTypes .VARCHAR ;
53
53
import org .hibernate .type .StandardBasicTypes ;
54
+ import org .hibernate .type .descriptor .sql .internal .DdlTypeImpl ;
55
+ import org .hibernate .type .descriptor .sql .spi .DdlTypeRegistry ;
54
56
import tech .ydb .hibernate .dialect .exporter .EmptyExporter ;
55
57
import tech .ydb .hibernate .dialect .exporter .YdbIndexExporter ;
56
58
import tech .ydb .hibernate .dialect .hint .IndexQueryHintHandler ;
57
59
import tech .ydb .hibernate .dialect .translator .YdbSqlAstTranslatorFactory ;
60
+ import tech .ydb .hibernate .dialect .types .InstantJavaType ;
61
+ import tech .ydb .hibernate .dialect .types .InstantJdbcType ;
62
+ import tech .ydb .hibernate .dialect .types .LocalDateJavaType ;
63
+ import tech .ydb .hibernate .dialect .types .LocalDateJdbcType ;
58
64
import tech .ydb .hibernate .dialect .types .LocalDateTimeJavaType ;
59
65
import tech .ydb .hibernate .dialect .types .LocalDateTimeJdbcType ;
66
+ import static tech .ydb .hibernate .dialect .types .LocalDateTimeJdbcType .JDBC_TYPE_DATETIME_CODE ;
60
67
61
68
/**
62
69
* @author Kirill Kurdyukov
@@ -82,9 +89,9 @@ protected String columnType(int sqlTypeCode) {
82
89
case DOUBLE -> "Double" ;
83
90
case NUMERIC , DECIMAL -> "Decimal (22,9)" ; // Fixed
84
91
case DATE -> "Date" ;
85
- case TIME -> "Datetime" ;
92
+ case JDBC_TYPE_DATETIME_CODE -> "Datetime" ;
86
93
case TIME_WITH_TIMEZONE -> "TzDateTime" ;
87
- case TIMESTAMP -> "Timestamp" ;
94
+ case TIMESTAMP , TIMESTAMP_UTC -> "Timestamp" ;
88
95
case TIMESTAMP_WITH_TIMEZONE -> "TzTimestamp" ;
89
96
case CHAR , VARCHAR , CLOB , NCHAR , NVARCHAR , NCLOB ,
90
97
LONG32VARCHAR , LONG32NVARCHAR , LONGVARCHAR , LONGNVARCHAR -> "Text" ;
@@ -100,6 +107,19 @@ public void contributeTypes(TypeContributions typeContributions, ServiceRegistry
100
107
101
108
typeContributions .contributeJavaType (LocalDateTimeJavaType .INSTANCE );
102
109
typeContributions .contributeJdbcType (LocalDateTimeJdbcType .INSTANCE );
110
+ typeContributions .contributeJavaType (LocalDateJavaType .INSTANCE );
111
+ typeContributions .contributeJdbcType (LocalDateJdbcType .INSTANCE );
112
+ typeContributions .contributeJavaType (InstantJavaType .INSTANCE );
113
+ typeContributions .contributeJdbcType (InstantJdbcType .INSTANCE );
114
+ }
115
+
116
+ @ Override
117
+ protected void registerColumnTypes (TypeContributions typeContributions , ServiceRegistry serviceRegistry ) {
118
+ super .registerColumnTypes (typeContributions , serviceRegistry );
119
+
120
+ final DdlTypeRegistry ddlTypeRegistry = typeContributions .getTypeConfiguration ().getDdlTypeRegistry ();
121
+
122
+ ddlTypeRegistry .addDescriptor (new DdlTypeImpl (JDBC_TYPE_DATETIME_CODE , "Datetime" , "Datetime" , this ));
103
123
}
104
124
105
125
@ Override
0 commit comments