Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If we are using annotation based hibernate then do we require hbm.xml?

Tags:

hibernate

I am new to hibernate.I saw in my project we are using annotation for hibernate and we have not defined mapping class anywhere.In this project we are using spring also.so my question is If we are using annotation based hibernate then do we require hbm.xml?

like image 429
Geek Avatar asked Oct 20 '25 04:10

Geek


1 Answers

If you're referring to Hibernate XML mapping files, they're definitely not required if you're using Hibernate Annotations.

Hibernate Annotations is an alternative to Hibernate XML Mapping files. They've got the same goal, which is among other things to define how an Entity maps to database columns, and how it relates to other Entities.

Actually you'd need to decide for a model or the other (Annotations or XML mappings). It is also possible to use an hybrid model, where some Entities are mapped with Annotations and some are mapped with XML mapping files. As explained for instance in Is it possible to use both annotations and hbm.xml files in the same project in Hibernate?

like image 169
Xavi López Avatar answered Oct 26 '25 18:10

Xavi López



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!