HHH-12827 Define a numeric type as decimal for DB2
DB2 converts the numeric type to decimal and returns Types.DECIMAL for a numeric. We change the type name used so that we have a match when comparing the type names as last resort.
This commit is contained in:
parent
19d31ea94d
commit
de4c356189
|
@ -40,6 +40,7 @@ import org.hibernate.internal.CoreLogging;
|
|||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.internal.util.JdbcExceptionHelper;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.descriptor.sql.DecimalTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.sql.SmallIntTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
|
||||
|
@ -100,7 +101,12 @@ public class DB2Dialect extends Dialect {
|
|||
registerColumnType( Types.TIME, "time" );
|
||||
registerColumnType( Types.TIMESTAMP, "timestamp" );
|
||||
registerColumnType( Types.VARBINARY, "varchar($l) for bit data" );
|
||||
registerColumnType( Types.NUMERIC, "numeric($p,$s)" );
|
||||
// DB2 converts numeric to decimal under the hood
|
||||
// Note that the type returned by DB2 for a numeric column will be Types.DECIMAL. Thus, we have an issue when
|
||||
// comparing the types during the schema validation, defining the type to decimal here as the type names will
|
||||
// also be compared and there will be a match. See HHH-12827 for the details.
|
||||
registerColumnType( Types.NUMERIC, "decimal($p,$s)" );
|
||||
registerColumnType( Types.DECIMAL, "decimal($p,$s)" );
|
||||
registerColumnType( Types.BLOB, "blob($l)" );
|
||||
registerColumnType( Types.CLOB, "clob($l)" );
|
||||
registerColumnType( Types.LONGVARCHAR, "long varchar" );
|
||||
|
@ -478,7 +484,14 @@ public class DB2Dialect extends Dialect {
|
|||
|
||||
@Override
|
||||
protected SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) {
|
||||
return sqlCode == Types.BOOLEAN ? SmallIntTypeDescriptor.INSTANCE : super.getSqlTypeDescriptorOverride( sqlCode );
|
||||
if ( sqlCode == Types.BOOLEAN ) {
|
||||
return SmallIntTypeDescriptor.INSTANCE;
|
||||
}
|
||||
else if ( sqlCode == Types.NUMERIC ) {
|
||||
return DecimalTypeDescriptor.INSTANCE;
|
||||
}
|
||||
|
||||
return super.getSqlTypeDescriptorOverride( sqlCode );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue