Sep 30th, 2008, 03:07 AM
MySQL - Java data types mapping
I'm confused when creating a Hibernate's persistent class.
MySQL's unsigned int value ranges from 0 to 4,294,967,295.
Java's int value ranges from -2,147,483,648 to of 2,147,483,647.
Java's long value ranges from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
Which Java primitive data type (int or long) we should map to the MySQL unsigned int?
Sep 30th, 2008, 09:29 AM
The easiest way to answer this is to map a class with an int and a long on, and then let Hibernate autocreate the table for you, and see what MySQL types they map to.
Originally Posted by hezjing
My guess is int->int and long->bigint though now I wonder how you store negative numbers !
Sep 30th, 2008, 10:56 AM
The MySQL reference manual suggests using a Long - see http://dev.mysql.com/doc/refman/5.0/...nversions.html
Tags for this Thread