HHH-15035 Fix native query type discovery with h2 2.0.202+ with float(..) DDL type

This commit is contained in:
Christian Beikov 2022-01-17 19:12:28 +01:00
parent fb749b6b32
commit d0f6c3302c
1 changed files with 15 additions and 0 deletions

View File

@ -59,6 +59,7 @@ import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLe
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorNoOpImpl;
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;
import org.hibernate.type.SqlTypes;
import org.hibernate.type.descriptor.jdbc.JdbcType;
import org.hibernate.type.descriptor.jdbc.UUIDJdbcType;
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
@ -278,6 +279,20 @@ public class H2Dialect extends Dialect {
}
}
@Override
public JdbcType resolveSqlTypeDescriptor(
String columnTypeName,
int jdbcTypeCode,
int precision,
int scale,
JdbcTypeRegistry jdbcTypeRegistry) {
// As of H2 2.0 we get a FLOAT type code even though it is a DOUBLE
if ( jdbcTypeCode == FLOAT && "DOUBLE PRECISION".equals( columnTypeName ) ) {
return jdbcTypeRegistry.getDescriptor( DOUBLE );
}
return super.resolveSqlTypeDescriptor( columnTypeName, jdbcTypeCode, precision, scale, jdbcTypeRegistry );
}
@Override
public int getMaxVarcharLength() {
return 1_048_576;