Difference between Hibernate mapping file and annotation

后端 未结 6 1272
小蘑菇
小蘑菇 2020-12-16 06:08

Today I was trying to create a application using Hibernate as ORM. So while creating I had a doubt. What is the best practice to use, Hibernate mapping file (.hbm file) or a

6条回答
  •  庸人自扰
    2020-12-16 06:24

    • there is no functional difference. You can do (almost) the same things with both approaches
    • xml files were used before Java had annotations (added in 1.5), so they can be considered an outdated way of mapping
    • it is generally preferred to use JPA annotations rather than hibernate-specific ones; if using xml - there is a JPA xml format, which should be preferred to hibernate native one

提交回复
热议问题