Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hibernate map java Long to MySQL BIGINT error

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 ?

like image 876
QuanNH Avatar asked Jul 23 '10 06:07

QuanNH


2 Answers

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.

like image 157
Pascal Thivent Avatar answered Sep 30 '22 03:09

Pascal Thivent


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

like image 26
mosterme Avatar answered Sep 30 '22 02:09

mosterme