Fix Sybase issue storing negative values for Byte attributes

This commit is contained in:
Andrea Boriero 2021-08-31 14:11:09 +02:00 committed by Christian Beikov
parent f3ff509095
commit c223ea16cb
1 changed files with 13 additions and 0 deletions

View File

@ -39,6 +39,8 @@ import org.hibernate.type.descriptor.jdbc.BlobTypeDescriptor;
import org.hibernate.type.descriptor.jdbc.ClobTypeDescriptor;
import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptor;
import org.hibernate.type.descriptor.jdbc.NClobTypeDescriptor;
import org.hibernate.type.descriptor.jdbc.SmallIntTypeDescriptor;
import org.hibernate.type.descriptor.jdbc.TinyIntTypeDescriptor;
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeDescriptorRegistry;
import java.sql.DatabaseMetaData;
@ -91,10 +93,21 @@ public class SybaseDialect extends AbstractTransactSQLDialect {
if ( precision == 19 && scale == 0 ) {
return jdbcTypeDescriptorRegistry.getDescriptor( Types.BIGINT );
}
case Types.TINYINT:
if ( jtdsDriver ) {
return jdbcTypeDescriptorRegistry.getDescriptor( Types.SMALLINT );
}
}
return super.resolveSqlTypeDescriptor( jdbcTypeCode, precision, scale, jdbcTypeDescriptorRegistry );
}
public JdbcTypeDescriptor remapSqlTypeDescriptor(JdbcTypeDescriptor jdbcTypeDescriptor) {
if ( jtdsDriver && TinyIntTypeDescriptor.INSTANCE == jdbcTypeDescriptor ) {
return SmallIntTypeDescriptor.INSTANCE;
}
return super.remapSqlTypeDescriptor( jdbcTypeDescriptor );
}
@Override
public SqmTranslatorFactory getSqmTranslatorFactory() {
return new StandardSqmTranslatorFactory() {