HHH-18150 Fix for Informix float and double precision in decimal digits
This commit is contained in:
parent
abf07078d8
commit
0fd9edc501
|
@ -7,6 +7,8 @@
|
||||||
package org.hibernate.community.dialect;
|
package org.hibernate.community.dialect;
|
||||||
|
|
||||||
import org.hibernate.boot.Metadata;
|
import org.hibernate.boot.Metadata;
|
||||||
|
import java.sql.Types;
|
||||||
|
|
||||||
import org.hibernate.boot.model.FunctionContributions;
|
import org.hibernate.boot.model.FunctionContributions;
|
||||||
import org.hibernate.boot.model.TypeContributions;
|
import org.hibernate.boot.model.TypeContributions;
|
||||||
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
|
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
|
||||||
|
@ -27,6 +29,7 @@ import org.hibernate.dialect.sequence.SequenceSupport;
|
||||||
import org.hibernate.dialect.temptable.TemporaryTable;
|
import org.hibernate.dialect.temptable.TemporaryTable;
|
||||||
import org.hibernate.dialect.temptable.TemporaryTableKind;
|
import org.hibernate.dialect.temptable.TemporaryTableKind;
|
||||||
import org.hibernate.dialect.unique.UniqueDelegate;
|
import org.hibernate.dialect.unique.UniqueDelegate;
|
||||||
|
import org.hibernate.engine.jdbc.Size;
|
||||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||||
import org.hibernate.engine.spi.LoadQueryInfluencers;
|
import org.hibernate.engine.spi.LoadQueryInfluencers;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
|
@ -62,6 +65,8 @@ import org.hibernate.sql.exec.spi.JdbcOperation;
|
||||||
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;
|
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;
|
||||||
import org.hibernate.tool.schema.internal.StandardForeignKeyExporter;
|
import org.hibernate.tool.schema.internal.StandardForeignKeyExporter;
|
||||||
import org.hibernate.tool.schema.spi.Exporter;
|
import org.hibernate.tool.schema.spi.Exporter;
|
||||||
|
import org.hibernate.type.descriptor.java.JavaType;
|
||||||
|
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
||||||
import org.hibernate.type.descriptor.sql.internal.CapacityDependentDdlType;
|
import org.hibernate.type.descriptor.sql.internal.CapacityDependentDdlType;
|
||||||
import org.hibernate.type.descriptor.sql.spi.DdlTypeRegistry;
|
import org.hibernate.type.descriptor.sql.spi.DdlTypeRegistry;
|
||||||
import org.hibernate.type.spi.TypeConfiguration;
|
import org.hibernate.type.spi.TypeConfiguration;
|
||||||
|
@ -114,6 +119,24 @@ public class InformixDialect extends Dialect {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private final SizeStrategy sizeStrategy = new SizeStrategyImpl() {
|
||||||
|
@Override
|
||||||
|
public Size resolveSize(
|
||||||
|
JdbcType jdbcType,
|
||||||
|
JavaType<?> javaType,
|
||||||
|
Integer precision,
|
||||||
|
Integer scale,
|
||||||
|
Long length) {
|
||||||
|
switch ( jdbcType.getDdlTypeCode() ) {
|
||||||
|
case Types.FLOAT:
|
||||||
|
// Informix allows FLOAT with a precision up to 16
|
||||||
|
if ( precision != null ) {
|
||||||
|
return Size.precision( Math.min( Math.max( precision, 1 ), 16 ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.resolveSize( jdbcType, javaType, precision, scale, length );
|
||||||
|
}
|
||||||
|
};
|
||||||
public InformixDialect(DialectResolutionInfo info) {
|
public InformixDialect(DialectResolutionInfo info) {
|
||||||
this( info.makeCopyOrDefault( DEFAULT_VERSION ) );
|
this( info.makeCopyOrDefault( DEFAULT_VERSION ) );
|
||||||
registerKeywords( info );
|
registerKeywords( info );
|
||||||
|
@ -179,7 +202,7 @@ public class InformixDialect extends Dialect {
|
||||||
//double precision.
|
//double precision.
|
||||||
ddlTypeRegistry.addDescriptor(
|
ddlTypeRegistry.addDescriptor(
|
||||||
CapacityDependentDdlType.builder( FLOAT, "float($p)", this )
|
CapacityDependentDdlType.builder( FLOAT, "float($p)", this )
|
||||||
.withTypeCapacity( 24, "smallfloat" )
|
.withTypeCapacity( 8, "smallfloat" )
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -226,6 +249,21 @@ public class InformixDialect extends Dialect {
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFloatPrecision() {
|
||||||
|
return 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDoublePrecision() {
|
||||||
|
return 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SizeStrategy getSizeStrategy() {
|
||||||
|
return sizeStrategy;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initializeFunctionRegistry(FunctionContributions functionContributions) {
|
public void initializeFunctionRegistry(FunctionContributions functionContributions) {
|
||||||
super.initializeFunctionRegistry(functionContributions);
|
super.initializeFunctionRegistry(functionContributions);
|
||||||
|
|
Loading…
Reference in New Issue