Skip to content

Commit 370f65a

Browse files
committed
[#2738] Return the correct column data type for Oracle
The Oracle schema extractor is only partially implemented, returning data type 0 for most of the SQL column types. This causes the schema validation to fail even if the columns on the table are valid.
1 parent 2563326 commit 370f65a

File tree

1 file changed

+38
-5
lines changed

1 file changed

+38
-5
lines changed

hibernate-reactive-core/src/main/java/org/hibernate/reactive/provider/service/OracleSqlReactiveInformationExtractorImpl.java

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,45 @@ protected String getResultSetIsNullableLabel() {
185185

186186
@Override
187187
protected int dataTypeCode(String typeName) {
188-
// ORACLE only supports "float" sql type for double precision
189-
// so return code for double for both double and float column types
190-
if ( typeName.equalsIgnoreCase( "float" ) ||
191-
typeName.toLowerCase().startsWith( "double" ) ) {
188+
if ( typeName.equalsIgnoreCase( "float" )
189+
|| typeName.toLowerCase().startsWith( "double" )
190+
|| typeName.equalsIgnoreCase( "binary_double" ) ) {
192191
return Types.DOUBLE;
193192
}
194-
return super.dataTypeCode( typeName );
193+
if ( typeName.equalsIgnoreCase( "timestamp" ) ) {
194+
return Types.TIMESTAMP;
195+
}
196+
if ( typeName.equalsIgnoreCase( "timestamp with time zone" )
197+
|| typeName.equalsIgnoreCase( "timestamp with local time zone" ) ) {
198+
return Types.TIMESTAMP_WITH_TIMEZONE;
199+
}
200+
if ( typeName.equalsIgnoreCase( "clob" ) ) {
201+
return Types.CLOB;
202+
}
203+
if ( typeName.equalsIgnoreCase( "blob" ) ) {
204+
return Types.BLOB;
205+
}
206+
if ( typeName.equalsIgnoreCase( "raw" ) ) {
207+
return Types.VARBINARY;
208+
}
209+
if ( typeName.equalsIgnoreCase( "long raw" ) ) {
210+
return Types.LONGVARBINARY;
211+
}
212+
if ( typeName.equalsIgnoreCase( "ref cursor" ) ) {
213+
return Types.REF_CURSOR;
214+
}
215+
if ( typeName.equalsIgnoreCase( "number" ) ) {
216+
return Types.NUMERIC;
217+
}
218+
if ( typeName.equalsIgnoreCase( "date" ) ) {
219+
return Types.DATE;
220+
}
221+
if ( typeName.equalsIgnoreCase( "nvarchar2" ) ) {
222+
return Types.NVARCHAR;
223+
}
224+
if ( typeName.equalsIgnoreCase( "varchar2" ) ) {
225+
return Types.VARCHAR;
226+
}
227+
return 0;
195228
}
196229
}

0 commit comments

Comments
 (0)