hibernate 和 JPA之间的关系

本文解释了Java持久化API (JPA) 和Hibernate之间的区别。JPA作为一个规范,定义了一套标准注解和API用于Java应用程序的数据持久化,而Hibernate则是JPA的一种实现,提供了具体的实现细节和技术支持。使用Hibernate JPA实现时,可以灵活替换其他符合JPA规范的实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

内容摘自stackoverflow.url如下:

http://stackoverflow.com/questions/9881611/whats-the-difference-between-jpa-and-hibernate

As you state 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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值