HHH-12850 Sybase Anywhere - Explicitly map Java booleans to SQL bits

This commit is contained in:
Guillaume Smet 2018-11-07 12:21:08 +01:00
parent ea42f43881
commit e4c964fb36
1 changed files with 17 additions and 1 deletions

View File

@ -7,8 +7,12 @@
package org.hibernate.dialect; package org.hibernate.dialect;
import java.sql.Types;
import org.hibernate.dialect.identity.IdentityColumnSupport; import org.hibernate.dialect.identity.IdentityColumnSupport;
import org.hibernate.dialect.identity.SybaseAnywhereIdentityColumnSupport; import org.hibernate.dialect.identity.SybaseAnywhereIdentityColumnSupport;
import org.hibernate.type.descriptor.sql.BitTypeDescriptor;
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
/** /**
* SQL Dialect for Sybase Anywhere * SQL Dialect for Sybase Anywhere
@ -16,6 +20,13 @@ import org.hibernate.dialect.identity.SybaseAnywhereIdentityColumnSupport;
* (Tested on ASA 8.x) * (Tested on ASA 8.x)
*/ */
public class SybaseAnywhereDialect extends SybaseDialect { public class SybaseAnywhereDialect extends SybaseDialect {
public SybaseAnywhereDialect() {
super();
registerColumnType( Types.BOOLEAN, "bit" );
}
/** /**
* Sybase Anywhere syntax would require a "DEFAULT" for each column specified, * Sybase Anywhere syntax would require a "DEFAULT" for each column specified,
* but I suppose Hibernate use this syntax only with tables with just 1 column * but I suppose Hibernate use this syntax only with tables with just 1 column
@ -44,4 +55,9 @@ public class SybaseAnywhereDialect extends SybaseDialect {
public IdentityColumnSupport getIdentityColumnSupport() { public IdentityColumnSupport getIdentityColumnSupport() {
return new SybaseAnywhereIdentityColumnSupport(); return new SybaseAnywhereIdentityColumnSupport();
} }
@Override
protected SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) {
return sqlCode == Types.BOOLEAN ? BitTypeDescriptor.INSTANCE : super.getSqlTypeDescriptorOverride( sqlCode );
}
} }