Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

hibernate datatype confusion?  RSS feed

Brendon Woodford
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Hibernate provides its own types which we are supposed to use in hibernate mapping file.
While mapping a java class to a database table we use

<class name="book.hibernatebook.chapter06.User">
<id name="id" type="int">
<generator class="native"/>
<property name="username" type="string" length="32"/>

Here in this code <id name="id" type="int"> the type has been mentioned as int ,a java primitive whereas we are supposed to use Hibernate predefined types and the value of the type attribute should have been "integer" but the above code works fine.

What's the reason behind that ? Is using the hibernate types optional and we can use the java primitives instead?

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!