HHH-6795 unsupported Boolean type null value on Sybase causes hangs forever when doing bind parameter

This commit is contained in:
Strong Liu 2011-11-02 22:27:17 +08:00
parent e210537059
commit 16f0fa5373
2 changed files with 9 additions and 8 deletions

View File

@ -30,6 +30,9 @@ import org.hibernate.dialect.function.NoArgSQLFunction;
import org.hibernate.dialect.function.SQLFunctionTemplate; import org.hibernate.dialect.function.SQLFunctionTemplate;
import org.hibernate.dialect.function.VarArgsSQLFunction; import org.hibernate.dialect.function.VarArgsSQLFunction;
import org.hibernate.type.StandardBasicTypes; import org.hibernate.type.StandardBasicTypes;
import org.hibernate.type.descriptor.sql.SmallIntTypeDescriptor;
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
import org.hibernate.type.descriptor.sql.TinyIntTypeDescriptor;
/** /**
* An SQL dialect targeting Sybase Adaptive Server Enterprise (ASE) 15 and higher. * An SQL dialect targeting Sybase Adaptive Server Enterprise (ASE) 15 and higher.
@ -427,4 +430,9 @@ public class SybaseASE15Dialect extends AbstractTransactSQLDialect {
public String getCrossJoinSeparator() { public String getCrossJoinSeparator() {
return ", "; return ", ";
} }
@Override
protected SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) {
return sqlCode == Types.BOOLEAN ? TinyIntTypeDescriptor.INSTANCE : super.getSqlTypeDescriptorOverride( sqlCode );
}
} }

View File

@ -53,10 +53,7 @@ public class JdbcTypeNameMapper {
for ( Field field : fields ) { for ( Field field : fields ) {
try { try {
final int code = field.getInt( null ); final int code = field.getInt( null );
String old = map.put( String old = map.put( code, field.getName() );
Integer.valueOf( code ),
field.getName()
);
if (old != null) LOG.JavaSqlTypesMappedSameCodeMultipleTimes(code, old, field.getName()); if (old != null) LOG.JavaSqlTypesMappedSameCodeMultipleTimes(code, old, field.getName());
} }
catch ( IllegalAccessException e ) { catch ( IllegalAccessException e ) {
@ -66,10 +63,6 @@ public class JdbcTypeNameMapper {
return Collections.unmodifiableMap( map ); return Collections.unmodifiableMap( map );
} }
public static String getTypeName(int code) {
return getTypeName( Integer.valueOf( code ) );
}
public static String getTypeName(Integer code) { public static String getTypeName(Integer code) {
String name = JDBC_TYPE_MAP.get( code ); String name = JDBC_TYPE_MAP.get( code );
if ( name == null ) { if ( name == null ) {