File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Hibernate Mapping Types. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate Mapping Types." Watch "Hibernate Mapping Types." New topic

Hibernate Mapping Types.

Gundum Hoi
Ranch Hand

Joined: Nov 27, 2005
Posts: 34
When I have this in my mapping file (hbm.xml):

the generated SQL is :

But I want SMALLINT and not int(11)

How do I specifically specify the SQL types that I want ? Hibernate generates "approximate" datatypes for both the SQL and Java sides which, to me, is quite annoying. I think I know best which datatype to use ... for example, I want a field in my Java class to be Integer and map it to SMALLINT in the DB.

Also, I tried finding on the net a "mapping table" ... something like this:
Java DataType - Hibernate Mapping Type - MySQL datatype
String - string - varchar
etc etc

But, surprisingly I could not find any. Those that I found were very vague ... they go something like

I need a more "precise" table..showing which exact type map to which.


Thank you.
Arun Kumarr
Ranch Hand

Joined: May 16, 2005
Posts: 661

try using short.

If you are not laughing at yourself, then you just didn't get the joke.
I agree. Here's the link:
subject: Hibernate Mapping Types.
It's not a secret anymore!