I ran into the same problem and tracked it down in Hibernate 3.2.5.GA. Here I want to share the straightforward solution with you.
From my understanding, this is a historical issue from the days where MS SQL Server did not understand SQL BIGINTS. SQL Server 2000 and later do!
The problem is in the SQLServerDialect class (inside the Hibernate jar) where the SQL Server Dialect is an extension of the Sybase Dialect, which in turn defines BIGINT as follows:
Code:
registerColumnType( Types.BIGINT, "numeric(19,0)" );
So there is no doubt, that a numeric column will be created for every Long value you use in your persisten classes (Long will be mapped to bigint, bigint for SQL Server or Sybase becomes numeric).
To correct this I implemented a custom Dialect that fixes it:
Code:
package it.infocube.draft.persistence;
import java.sql.Types;
import org.hibernate.dialect.SQLServerDialect;
/**
* This class implements our custom Hibernate Dialect that fixes the mapping of
* Hibernate Type BIGINT (default is NUMERIC(19,0)) to a SQL BIGINT
*
* @author Dominik Enkelmann, 25/february/2008
*/
public class InfocubeMSSQLDialect extends SQLServerDialect {
public InfocubeMSSQLDialect() {
super();
registerColumnType( Types.BIGINT, "bigint" ); // Overwrite SQL Server datatype BIGINT
}
}
In your
hibernate.cfg.xml file you'll have to use the new Dialect, in my case
Code:
<!property name="hibernate.dialect">it.infocube.draft.persistence.InfocubeMSSQLDialect</property>
The same approach could be taken for the BIT type (add a line like
registerColumnType( Types.BIT, "bit" ); I will submit this also as a bug since I belive that pre-SQL Server 2000 compatibility should be handled differently.[/code][/i]