44 */
55package org .hibernate .dialect ;
66
7- import java .sql .CallableStatement ;
8- import java .sql .DatabaseMetaData ;
9- import java .sql .ResultSet ;
10- import java .sql .SQLException ;
11- import java .sql .Types ;
12- import java .time .temporal .ChronoField ;
13- import java .time .temporal .TemporalAccessor ;
14- import java .util .TimeZone ;
15- import java .util .regex .Matcher ;
16- import java .util .regex .Pattern ;
17-
7+ import jakarta .persistence .GenerationType ;
8+ import jakarta .persistence .TemporalType ;
189import org .hibernate .Length ;
1910import org .hibernate .QueryTimeoutException ;
2011import org .hibernate .boot .model .FunctionContributions ;
3425import org .hibernate .dialect .temptable .TemporaryTableKind ;
3526import org .hibernate .dialect .unique .CreateTableUniqueDelegate ;
3627import org .hibernate .dialect .unique .UniqueDelegate ;
28+ import org .hibernate .engine .config .spi .ConfigurationService ;
29+ import org .hibernate .engine .config .spi .StandardConverters ;
3730import org .hibernate .engine .jdbc .dialect .spi .DialectResolutionInfo ;
3831import org .hibernate .engine .jdbc .env .spi .IdentifierHelper ;
3932import org .hibernate .engine .jdbc .env .spi .IdentifierHelperBuilder ;
4740import org .hibernate .exception .spi .ViolatedConstraintNameExtractor ;
4841import org .hibernate .internal .util .config .ConfigurationHelper ;
4942import org .hibernate .mapping .AggregateColumn ;
43+ import org .hibernate .mapping .CheckConstraint ;
5044import org .hibernate .mapping .Table ;
5145import org .hibernate .mapping .UserDefinedType ;
52- import org .hibernate .mapping .CheckConstraint ;
5346import org .hibernate .metamodel .mapping .EntityMappingType ;
5447import org .hibernate .metamodel .spi .RuntimeModelCreationContext ;
5548import org .hibernate .persister .entity .mutation .EntityMutationTarget ;
5649import org .hibernate .procedure .internal .OracleCallableStatementSupport ;
5750import org .hibernate .procedure .spi .CallableStatementSupport ;
5851import org .hibernate .query .SemanticException ;
52+ import org .hibernate .query .common .FetchClauseType ;
53+ import org .hibernate .query .common .TemporalUnit ;
5954import org .hibernate .query .spi .QueryOptions ;
6055import org .hibernate .query .sqm .CastType ;
61- import org .hibernate .query .common .FetchClauseType ;
6256import org .hibernate .query .sqm .IntervalType ;
63- import org .hibernate .query .common .TemporalUnit ;
6457import org .hibernate .query .sqm .mutation .internal .temptable .GlobalTemporaryTableInsertStrategy ;
6558import org .hibernate .query .sqm .mutation .internal .temptable .GlobalTemporaryTableMutationStrategy ;
6659import org .hibernate .query .sqm .mutation .spi .SqmMultiTableInsertStrategy ;
9285import org .hibernate .type .descriptor .jdbc .SqlTypedJdbcType ;
9386import org .hibernate .type .descriptor .jdbc .spi .JdbcTypeRegistry ;
9487import org .hibernate .type .descriptor .sql .internal .ArrayDdlTypeImpl ;
88+ import org .hibernate .type .descriptor .sql .internal .CapacityDependentDdlType ;
9589import org .hibernate .type .descriptor .sql .internal .DdlTypeImpl ;
9690import org .hibernate .type .descriptor .sql .internal .NamedNativeEnumDdlTypeImpl ;
9791import org .hibernate .type .descriptor .sql .internal .NamedNativeOrdinalEnumDdlTypeImpl ;
9892import org .hibernate .type .descriptor .sql .spi .DdlTypeRegistry ;
9993import org .hibernate .type .spi .TypeConfiguration ;
10094
101- import jakarta .persistence .GenerationType ;
102- import jakarta .persistence .TemporalType ;
95+ import java .sql .CallableStatement ;
96+ import java .sql .DatabaseMetaData ;
97+ import java .sql .ResultSet ;
98+ import java .sql .SQLException ;
99+ import java .sql .Types ;
100+ import java .time .temporal .ChronoField ;
101+ import java .time .temporal .TemporalAccessor ;
102+ import java .util .TimeZone ;
103+ import java .util .regex .Matcher ;
104+ import java .util .regex .Pattern ;
103105
104106import static java .util .regex .Pattern .CASE_INSENSITIVE ;
105107import static org .hibernate .LockOptions .NO_WAIT ;
106108import static org .hibernate .LockOptions .SKIP_LOCKED ;
107109import static org .hibernate .LockOptions .WAIT_FOREVER ;
110+ import static org .hibernate .cfg .DialectSpecificSettings .ORACLE_USE_BINARY_FLOATS ;
108111import static org .hibernate .dialect .OracleJdbcHelper .getArrayJdbcTypeConstructor ;
109112import static org .hibernate .dialect .OracleJdbcHelper .getNestedTableJdbcTypeConstructor ;
110113import static org .hibernate .exception .spi .TemplatedViolatedConstraintNameExtractor .extractUsingTemplate ;
@@ -200,11 +203,9 @@ protected void applyAggregateColumnCheck(StringBuilder buf, AggregateColumn aggr
200203
201204 // Is the database accessed using a database service protected by Application Continuity.
202205 protected final boolean applicationContinuity ;
203-
204206 protected final int driverMajorVersion ;
205-
206207 protected final int driverMinorVersion ;
207-
208+ private boolean useBinaryFloat ;
208209
209210 public OracleDialect () {
210211 this ( MINIMUM_VERSION );
@@ -770,11 +771,11 @@ protected String columnType(int sqlTypeCode) {
770771 return "number(19,0)" ;
771772 case REAL :
772773 // Oracle's 'real' type is actually double precision
773- return "float(24)" ;
774+ return useBinaryFloat ? "binary_float" : "float(24)" ;
774775 case DOUBLE :
775776 // Oracle's 'double precision' means float(126), and
776777 // we never need 126 bits (38 decimal digits)
777- return "float(53)" ;
778+ return useBinaryFloat ? "binary_double" : "float(53)" ;
778779
779780 case NUMERIC :
780781 case DECIMAL :
@@ -959,6 +960,9 @@ public Exporter<UserDefinedType> getUserDefinedTypeExporter() {
959960
960961 @ Override
961962 public void contributeTypes (TypeContributions typeContributions , ServiceRegistry serviceRegistry ) {
963+ final ConfigurationService configurationService = serviceRegistry .requireService ( ConfigurationService .class );
964+ useBinaryFloat = configurationService .getSetting ( ORACLE_USE_BINARY_FLOATS , StandardConverters .BOOLEAN , true );
965+
962966 super .contributeTypes ( typeContributions , serviceRegistry );
963967 if ( ConfigurationHelper .getPreferredSqlTypeCodeForBoolean ( serviceRegistry , this ) == BIT ) {
964968 typeContributions .contributeJdbcType ( OracleBooleanJdbcType .INSTANCE );
@@ -972,6 +976,15 @@ public void contributeTypes(TypeContributions typeContributions, ServiceRegistry
972976 typeContributions .contributeJdbcType ( OracleReflectionStructJdbcType .INSTANCE );
973977 }
974978
979+ if ( useBinaryFloat ) {
980+ // Override the descriptor for float to produce binary_float or binary_double based on precision
981+ typeContributions .getTypeConfiguration ().getDdlTypeRegistry ().addDescriptor (
982+ CapacityDependentDdlType .builder ( FLOAT , columnType ( DOUBLE ), this )
983+ .withTypeCapacity ( getFloatPrecision (), columnType ( REAL ) )
984+ .build ()
985+ );
986+ }
987+
975988 if ( getVersion ().isSameOrAfter ( 21 ) ) {
976989 typeContributions .contributeJdbcType ( OracleJsonJdbcType .INSTANCE );
977990 typeContributions .contributeJdbcTypeConstructor ( OracleJsonArrayJdbcTypeConstructor .NATIVE_INSTANCE );
0 commit comments