I have an existing database and raw JDBC based project that I would like to transfer over to Hibernate with Annotations. I have so far written a very simple class to simluate the real project.
Code:
@Id @GeneratedValue
BigInteger id;
@Column(length = 100)
String forename;
@Column(length = 100)
String surname;
@Column(scale = 10, precision = 2)
BigDecimal money;
BigInteger bigNumber;
I am using MySQL dialect against MySQL 4.1. The ID column is "ID BIGINT UNSIGNED NOT NULL AUTO_INCREMENT".
The type of the current ID field on all tables is mapped to java.math.BigInteger.
When I try to persist an object I recieve the following error.
Quote:
this id generator generates long, integer, short or string; nested exception is org.hibernate.id.IdentifierGenerationException: this id generator generates long, integer, short or string
Caused by: org.hibernate.id.IdentifierGenerationException: this id generator generates long, integer, short or string
When I follow the advice given in the exception and use Long everything is happy and the object persists. However the MySQL documentation shows BigInteger as the recommended type to map to[1], so I would like to stick with it. Also I have a large number of references to these objects already and would prefer not to have to refactor so much code. Is there a way to continue to use BigInteger for my ID columns?
Thank you,
Martin.
[1]http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-type-conversions.html