treat integral types as equivalent for purposes of schema validation/update
This commit is contained in:
parent
a2272be61c
commit
70114d30ec
|
@ -1293,6 +1293,7 @@ public abstract class Dialect implements ConversionContext {
|
|||
public boolean equivalentTypes(int typeCode1, int typeCode2) {
|
||||
return typeCode1==typeCode2
|
||||
|| isNumericOrDecimal(typeCode1) && isNumericOrDecimal(typeCode2)
|
||||
|| isIntegral(typeCode1) && isIntegral(typeCode2)
|
||||
|| isFloatOrRealOrDouble(typeCode1) && isFloatOrRealOrDouble(typeCode2)
|
||||
|| isVarcharType(typeCode1) && isVarcharType(typeCode2)
|
||||
|| isVarbinaryType(typeCode1) && isVarbinaryType(typeCode2);
|
||||
|
@ -1309,6 +1310,13 @@ public abstract class Dialect implements ConversionContext {
|
|||
|| typeCode == Types.DOUBLE;
|
||||
}
|
||||
|
||||
private static boolean isIntegral(int typeCode) {
|
||||
return typeCode == Types.INTEGER
|
||||
|| typeCode == Types.BIGINT
|
||||
|| typeCode == Types.SMALLINT
|
||||
|| typeCode == Types.TINYINT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a set of default Hibernate properties for this database.
|
||||
*
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.hibernate.dialect.Dialect;
|
|||
import org.hibernate.type.descriptor.WrapperOptions;
|
||||
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
||||
import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptorIndicators;
|
||||
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
||||
|
||||
/**
|
||||
* Describes a Java Enum type.
|
||||
|
@ -27,19 +28,20 @@ public class EnumJavaTypeDescriptor<T extends Enum<T>> extends AbstractClassJava
|
|||
|
||||
@Override
|
||||
public JdbcType getRecommendedJdbcType(JdbcTypeDescriptorIndicators context) {
|
||||
JdbcTypeRegistry registry = context.getTypeConfiguration().getJdbcTypeDescriptorRegistry();
|
||||
if ( context.getEnumeratedType() != null && context.getEnumeratedType() == EnumType.STRING ) {
|
||||
if ( context.getColumnLength() == 1 ) {
|
||||
return context.isNationalized()
|
||||
? context.getTypeConfiguration().getJdbcTypeDescriptorRegistry().getDescriptor( Types.NCHAR )
|
||||
: context.getTypeConfiguration().getJdbcTypeDescriptorRegistry().getDescriptor( Types.CHAR );
|
||||
? registry.getDescriptor( Types.NCHAR )
|
||||
: registry.getDescriptor( Types.CHAR );
|
||||
}
|
||||
|
||||
return context.isNationalized()
|
||||
? context.getTypeConfiguration().getJdbcTypeDescriptorRegistry().getDescriptor( Types.NVARCHAR )
|
||||
: context.getTypeConfiguration().getJdbcTypeDescriptorRegistry().getDescriptor( Types.VARCHAR );
|
||||
? registry.getDescriptor( Types.NVARCHAR )
|
||||
: registry.getDescriptor( Types.VARCHAR );
|
||||
}
|
||||
else {
|
||||
return context.getTypeConfiguration().getJdbcTypeDescriptorRegistry().getDescriptor( Types.TINYINT );
|
||||
return registry.getDescriptor( Types.TINYINT );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue