Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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 annotations ? What are the pros and cons of it ? Please help me in understanding.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
253 views
Welcome To Ask or Share your Answers For Others

1 Answer

  • 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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...