Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes 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

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

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