4
4
*/
5
5
package org .hibernate .dialect ;
6
6
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 ;
18
9
import org .hibernate .Length ;
19
10
import org .hibernate .QueryTimeoutException ;
20
11
import org .hibernate .boot .model .FunctionContributions ;
34
25
import org .hibernate .dialect .temptable .TemporaryTableKind ;
35
26
import org .hibernate .dialect .unique .CreateTableUniqueDelegate ;
36
27
import org .hibernate .dialect .unique .UniqueDelegate ;
28
+ import org .hibernate .engine .config .spi .ConfigurationService ;
29
+ import org .hibernate .engine .config .spi .StandardConverters ;
37
30
import org .hibernate .engine .jdbc .dialect .spi .DialectResolutionInfo ;
38
31
import org .hibernate .engine .jdbc .env .spi .IdentifierHelper ;
39
32
import org .hibernate .engine .jdbc .env .spi .IdentifierHelperBuilder ;
47
40
import org .hibernate .exception .spi .ViolatedConstraintNameExtractor ;
48
41
import org .hibernate .internal .util .config .ConfigurationHelper ;
49
42
import org .hibernate .mapping .AggregateColumn ;
43
+ import org .hibernate .mapping .CheckConstraint ;
50
44
import org .hibernate .mapping .Table ;
51
45
import org .hibernate .mapping .UserDefinedType ;
52
- import org .hibernate .mapping .CheckConstraint ;
53
46
import org .hibernate .metamodel .mapping .EntityMappingType ;
54
47
import org .hibernate .metamodel .spi .RuntimeModelCreationContext ;
55
48
import org .hibernate .persister .entity .mutation .EntityMutationTarget ;
56
49
import org .hibernate .procedure .internal .OracleCallableStatementSupport ;
57
50
import org .hibernate .procedure .spi .CallableStatementSupport ;
58
51
import org .hibernate .query .SemanticException ;
52
+ import org .hibernate .query .common .FetchClauseType ;
53
+ import org .hibernate .query .common .TemporalUnit ;
59
54
import org .hibernate .query .spi .QueryOptions ;
60
55
import org .hibernate .query .sqm .CastType ;
61
- import org .hibernate .query .common .FetchClauseType ;
62
56
import org .hibernate .query .sqm .IntervalType ;
63
- import org .hibernate .query .common .TemporalUnit ;
64
57
import org .hibernate .query .sqm .mutation .internal .temptable .GlobalTemporaryTableInsertStrategy ;
65
58
import org .hibernate .query .sqm .mutation .internal .temptable .GlobalTemporaryTableMutationStrategy ;
66
59
import org .hibernate .query .sqm .mutation .spi .SqmMultiTableInsertStrategy ;
92
85
import org .hibernate .type .descriptor .jdbc .SqlTypedJdbcType ;
93
86
import org .hibernate .type .descriptor .jdbc .spi .JdbcTypeRegistry ;
94
87
import org .hibernate .type .descriptor .sql .internal .ArrayDdlTypeImpl ;
88
+ import org .hibernate .type .descriptor .sql .internal .CapacityDependentDdlType ;
95
89
import org .hibernate .type .descriptor .sql .internal .DdlTypeImpl ;
96
90
import org .hibernate .type .descriptor .sql .internal .NamedNativeEnumDdlTypeImpl ;
97
91
import org .hibernate .type .descriptor .sql .internal .NamedNativeOrdinalEnumDdlTypeImpl ;
98
92
import org .hibernate .type .descriptor .sql .spi .DdlTypeRegistry ;
99
93
import org .hibernate .type .spi .TypeConfiguration ;
100
94
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 ;
103
105
104
106
import static java .util .regex .Pattern .CASE_INSENSITIVE ;
105
107
import static org .hibernate .LockOptions .NO_WAIT ;
106
108
import static org .hibernate .LockOptions .SKIP_LOCKED ;
107
109
import static org .hibernate .LockOptions .WAIT_FOREVER ;
110
+ import static org .hibernate .cfg .DialectSpecificSettings .ORACLE_USE_BINARY_FLOATS ;
108
111
import static org .hibernate .dialect .OracleJdbcHelper .getArrayJdbcTypeConstructor ;
109
112
import static org .hibernate .dialect .OracleJdbcHelper .getNestedTableJdbcTypeConstructor ;
110
113
import static org .hibernate .exception .spi .TemplatedViolatedConstraintNameExtractor .extractUsingTemplate ;
@@ -200,11 +203,9 @@ protected void applyAggregateColumnCheck(StringBuilder buf, AggregateColumn aggr
200
203
201
204
// Is the database accessed using a database service protected by Application Continuity.
202
205
protected final boolean applicationContinuity ;
203
-
204
206
protected final int driverMajorVersion ;
205
-
206
207
protected final int driverMinorVersion ;
207
-
208
+ private boolean useBinaryFloat ;
208
209
209
210
public OracleDialect () {
210
211
this ( MINIMUM_VERSION );
@@ -770,11 +771,11 @@ protected String columnType(int sqlTypeCode) {
770
771
return "number(19,0)" ;
771
772
case REAL :
772
773
// Oracle's 'real' type is actually double precision
773
- return "float(24)" ;
774
+ return useBinaryFloat ? "binary_float" : "float(24)" ;
774
775
case DOUBLE :
775
776
// Oracle's 'double precision' means float(126), and
776
777
// we never need 126 bits (38 decimal digits)
777
- return "float(53)" ;
778
+ return useBinaryFloat ? "binary_double" : "float(53)" ;
778
779
779
780
case NUMERIC :
780
781
case DECIMAL :
@@ -959,6 +960,9 @@ public Exporter<UserDefinedType> getUserDefinedTypeExporter() {
959
960
960
961
@ Override
961
962
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
+
962
966
super .contributeTypes ( typeContributions , serviceRegistry );
963
967
if ( ConfigurationHelper .getPreferredSqlTypeCodeForBoolean ( serviceRegistry , this ) == BIT ) {
964
968
typeContributions .contributeJdbcType ( OracleBooleanJdbcType .INSTANCE );
@@ -972,6 +976,15 @@ public void contributeTypes(TypeContributions typeContributions, ServiceRegistry
972
976
typeContributions .contributeJdbcType ( OracleReflectionStructJdbcType .INSTANCE );
973
977
}
974
978
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
+
975
988
if ( getVersion ().isSameOrAfter ( 21 ) ) {
976
989
typeContributions .contributeJdbcType ( OracleJsonJdbcType .INSTANCE );
977
990
typeContributions .contributeJdbcTypeConstructor ( OracleJsonArrayJdbcTypeConstructor .NATIVE_INSTANCE );
0 commit comments