Difference between Hibernate and Hibernate JPA

后端 未结 4 1808
没有蜡笔的小新
没有蜡笔的小新 2020-12-31 11:18

I found a lot of similar questions

  • Difference between Hibernate library and Hibernate JPA library
  • What's the difference between JPA and Hibernate?
4条回答
  •  無奈伤痛
    2020-12-31 12:07

    JPA is just a specification, meaning there is no implementation. You can annotate your classes as much as you would like with JPA annotations, however without an implementation nothing will happen. Think of JPA as the guidelines that must be followed or an interface, while Hibernate's JPA implementation is code that meets the API as defined by the JPA specification and provides the under the hood functionality.

    When you use Hibernate with JPA you are actually using the Hibernate JPA implementation. The benefit of this is that you can swap out Hibernate's implementation of JPA for another implementation of the JPA specification. When you use straight Hibernate you are locking into the implementation because other ORMs may use different methods/configurations and annotations, therefore you cannot just switch over to another ORM.

提交回复
热议问题