views:

73

answers:

2

i have a table with id field type BIGINT in MySQL

in hibernate object, i use java Long type for this field

but when run program, it throw exception: Expected: class java.lang.Long, got class java.lang.Integer

how to map MySQL BINGINT datatype in hibernate ?

+1  A: 

Does it help if you add a columnDefinition like columnDefinition = “bigint(20)″ to your mapping parameters?

mosterme
QuanNH
I'm sorry but how could this possibly help?
Pascal Thivent
Sometimes hibernate can not figure out how to correctly map the sql-type, but you are right, in that case the error message looks slightly different. Caused by: org.hibernate.HibernateException: Wrong column type in TEST.EXAMPLE for column FOO. Found: long, expected: integer
mosterme
A: 

but when run program, it throw exception: Expected: class java.lang.Long, got class java.lang.Integer

Using a Long for a BIGINT is correct and the above error suggests that you are somehow passing an Integer where a Long is expected somewhere in your code. Double check your code.

Pascal Thivent