Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

hibernate datatype confusion?

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?

What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!