Spring + Hibernate与Spring Data JPA:它们有区别吗? [英] Spring + hibernate versus Spring Data JPA: Are they different?

查看:120
本文介绍了Spring + Hibernate与Spring Data JPA:它们有区别吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尽管不是新手,但我还是试图学习spring框架,以确保我真的了解这一点.我对核心Spring(DI)有一个很好的主意.现在,我专注于数据层.

Although not novice, I am trying to learn spring framework (again!) in order to be sure that I really understand this. I have got fair idea on core Spring (DI). Now, I am focusing on Data layer.

我遇到过"春季和冬眠"这个词.据我解释,这意味着将Spring Framework与Hibernate一起用作ORM工具/JPA提供程序.

I have come across the term "Spring and Hibernate". As I can interpret it would mean using Spring Framework with Hibernate as ORM tool/JPA provider.

现在,我遇到了" Spring Data JPA ".我在SO上澄清了有关Spring Data JPA的问题,它是JPA之上的抽象层(Spring Data JPA在后台使用Hibernate或任何其他JPA提供程序).

Now I have come across "Spring Data JPA". I clarified on SO about Spring Data JPA, that it is an abstraction layer on-top of JPA (and under the hood Spring Data JPA uses Hibernate or any other JPA provider).

现在这些术语是一样的吗?也就是说," Spring +休眠"与" Spring Data JPA "相同.如果没有,那么区别/相似之处是什么?

Now are these terms same? That is, is "Spring + hibernate" same as that of "Spring Data JPA". If not, then what is the difference / similarities?

我对如此多的术语/声明(如上)感到很困惑,这些术语/声明看似相似,但可能有所不同.

I am really confused on so many terms/statements (like above) seemingly to be similar, but may be different.

推荐答案

Spring-data-jpa提供的功能不只是经典的Spring-JPA集成.借助JPA/Hibernate集成,您可以获得

Spring-data-jpa, as you're saying, offers more that just the classical Spring-JPA integration. With JPA/Hibernate integration, you get mainly

  • 使用JPA/休眠事务的声明式事务管理
  • 例外翻译
  • 作为可注入bean的JPA EntityManager或Hibernate SessionFactory

使用Spring-data-jpa,您将获得所有这些,加上(除其他外)

With Spring-data-jpa, you get all that, plus (among other things)

  • 仅接口的存储库,使用方法名称自动推断查询
  • @Query注释定义接口方法应返回的查询
  • 可分页查询的自动处理
  • 标准Crud存储库的基类

这只是一个很小的介绍.如需更多帮助,请阅读文档.

This is just a tiny introduction. For more help, read the documentation.

这篇关于Spring + Hibernate与Spring Data JPA:它们有区别吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆