I have seen many tutorials where the hibernate is implemented using annotations (basically hibernate annotations or JPA annotations). There are tutorial which mainly focuses on using the hibernate configuration files(hbm.xml files). No use of annotations at all.
Now I am little bit confused, which one is better approach ?
I definitely prefer to use annotations to define my mapping metadata. And actually, annotations are the approach recommend by Hibernate developers. Quoting Gavin King in More XML than code?
Of course, Hibernate Annotations has been around since early 2005 and there is no longer any good reason for people to define mappings in XML.
Pros:
Cons:
In other words, use annotations if you can. If you can't (you can't change the code, for example when working with legacy code), use XML mappings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With