11

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 ?

2
  • 2
    Using a Long for a BIGINT is correct. Please show your mapping, the code you're running and the full stacktrace. Commented Jul 23, 2010 at 7:39
  • ok, i defi wrong param for my method cellDao.get(Integer id). i fix it & now it run well. thanks Commented Jul 23, 2010 at 7:55

2 Answers 2

15

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.

Sign up to request clarification or add additional context in comments.

Comments

6

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

3 Comments

i use hibernate xml config file, & dont know how to config columnDefinition param :|
I'm sorry but how could this possibly help?
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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.