views:

257

answers:

1

Hibernate generates column of type “numeric” in SQL Server for properties of type Long of Java class. Is there a way to make Hibernate generate bigint (or int) column instead of numeric using the Hibernate hbm2ddl?

+1  A: 

Taken from the hibernate forums: https://forum.hibernate.org/viewtopic.php?p=2377674#2377674

Looks like you're going to have to roll your own SQL server dialect. While that doesn't seem right, there doesn't seem to be any action in hibernate's JIRA that makes me think this is fixed.

Oh, or it could be driver type. I'm not sure what driver you're using but jTDS appears to map Long to BigInt.

zmf
Besides roll-your-own dialect, is there a way (maybe a hint in mappings) to tell hibernate what data type is should use for column?
Dan
you could try a different driver, which are you using?
zmf
i am using jtds
Dan
By default, Hibernate maps long to the sql type bigint. But the SQL Server dialect subclasses the Sybase dialect which maps bigint to numeric(19,0). As suggested, just create MySQLServerDialect that extends SQLServerDialect with one line in the constructor (after super()) that does registerColumnType( Types.BIGINT, "bigint" );
Brian Deterling