9494import org .hibernate .type .descriptor .jdbc .SqlTypedJdbcType ;
9595import org .hibernate .type .descriptor .jdbc .spi .JdbcTypeRegistry ;
9696import org .hibernate .type .descriptor .sql .internal .ArrayDdlTypeImpl ;
97+ import org .hibernate .type .descriptor .sql .internal .CapacityDependentDdlType ;
9798import org .hibernate .type .descriptor .sql .internal .DdlTypeImpl ;
9899import org .hibernate .type .descriptor .sql .internal .NamedNativeEnumDdlTypeImpl ;
99100import org .hibernate .type .descriptor .sql .internal .NamedNativeOrdinalEnumDdlTypeImpl ;
110111import static org .hibernate .cfg .AvailableSettings .BATCH_VERSIONED_DATA ;
111112import static org .hibernate .cfg .DialectSpecificSettings .ORACLE_EXTENDED_STRING_SIZE ;
112113import static org .hibernate .cfg .DialectSpecificSettings .ORACLE_AUTONOMOUS_DATABASE ;
114+ import static org .hibernate .cfg .DialectSpecificSettings .ORACLE_USE_BINARY_FLOATS ;
113115import static org .hibernate .dialect .OracleJdbcHelper .getArrayJdbcTypeConstructor ;
114116import static org .hibernate .dialect .OracleJdbcHelper .getNestedTableJdbcTypeConstructor ;
115117import static org .hibernate .exception .spi .TemplatedViolatedConstraintNameExtractor .extractUsingTemplate ;
@@ -204,11 +206,9 @@ protected void applyAggregateColumnCheck(StringBuilder buf, AggregateColumn aggr
204206
205207 // Is the database accessed using a database service protected by Application Continuity.
206208 protected final boolean applicationContinuity ;
207-
208209 protected final int driverMajorVersion ;
209-
210210 protected final int driverMinorVersion ;
211-
211+ private boolean useBinaryFloat ;
212212
213213 public OracleDialect () {
214214 this ( MINIMUM_VERSION );
@@ -804,11 +804,11 @@ protected String columnType(int sqlTypeCode) {
804804 return "number(19,0)" ;
805805 case REAL :
806806 // Oracle's 'real' type is actually double precision
807- return "float(24)" ;
807+ return useBinaryFloat ? "binary_float" : "float(24)" ;
808808 case DOUBLE :
809809 // Oracle's 'double precision' means float(126), and
810810 // we never need 126 bits (38 decimal digits)
811- return "float(53)" ;
811+ return useBinaryFloat ? "binary_double" : "float(53)" ;
812812
813813 case NUMERIC :
814814 case DECIMAL :
@@ -999,6 +999,9 @@ public Exporter<UserDefinedType> getUserDefinedTypeExporter() {
999999
10001000 @ Override
10011001 public void contributeTypes (TypeContributions typeContributions , ServiceRegistry serviceRegistry ) {
1002+ final ConfigurationService configurationService = serviceRegistry .requireService ( ConfigurationService .class );
1003+ useBinaryFloat = configurationService .getSetting ( ORACLE_USE_BINARY_FLOATS , StandardConverters .BOOLEAN , true );
1004+
10021005 super .contributeTypes ( typeContributions , serviceRegistry );
10031006 if ( ConfigurationHelper .getPreferredSqlTypeCodeForBoolean ( serviceRegistry , this ) == BIT ) {
10041007 typeContributions .contributeJdbcType ( OracleBooleanJdbcType .INSTANCE );
@@ -1014,10 +1017,19 @@ public void contributeTypes(TypeContributions typeContributions, ServiceRegistry
10141017
10151018 // account for Oracle's deprecated support for LONGVARBINARY
10161019 // prefer BLOB, unless the user explicitly opts out
1017- final boolean preferLong = serviceRegistry . requireService ( ConfigurationService . class )
1018- .getSetting ( PREFER_LONG_RAW , StandardConverters .BOOLEAN , false );
1020+ final boolean preferLong =
1021+ configurationService .getSetting ( PREFER_LONG_RAW , StandardConverters .BOOLEAN , false );
10191022 typeContributions .contributeJdbcType ( preferLong ? BlobJdbcType .PRIMITIVE_ARRAY_BINDING : BlobJdbcType .DEFAULT );
10201023
1024+ if ( useBinaryFloat ) {
1025+ // Override the descriptor for float to produce binary_float or binary_double based on precision
1026+ typeContributions .getTypeConfiguration ().getDdlTypeRegistry ().addDescriptor (
1027+ CapacityDependentDdlType .builder ( FLOAT , columnType ( DOUBLE ), this )
1028+ .withTypeCapacity ( getFloatPrecision (), columnType ( REAL ) )
1029+ .build ()
1030+ );
1031+ }
1032+
10211033 if ( getVersion ().isSameOrAfter ( 21 ) ) {
10221034 typeContributions .contributeJdbcType ( OracleJsonJdbcType .INSTANCE );
10231035 typeContributions .contributeJdbcTypeConstructor ( OracleJsonArrayJdbcTypeConstructor .NATIVE_INSTANCE );
0 commit comments