Hibernate和Spring Data JPA有什么区别? [英] What is the difference between Hibernate and Spring Data JPA

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

问题描述

Hibernate和Spring Data JPA之间的主要区别是什么?我们何时不应该使用Hibernate或Spring Data JPA?另外,什么时候Spring JDBC模板可以比Hibernate / Spring Data JPA执行得更好?

Hibernate是一个JPA实现,而Spring Data JPA是JPA数据访问抽象。 Spring Data为 GenericDao 自定义实现提供了一个解决方案。它也可以通过方法名称约定代表JPA查询。

使用Spring Data,您可以使用Hibernate,Eclipse Link或任何其他JPA提供程序。一个非常有趣的好处是,你可以控制交易声明性地使用 @Transactional 注释。



Spring JDBC更轻量化,对于本地查询,如果你只打算单独使用JDBC,那么最好使用Spring JDBC来处理JDBC的详细信息。

因此,Hibernate和Spring数据是互补的,而不是竞争对手。

What are the main differences between Hibernate and Spring Data JPA? When should we not use Hibernate or Spring Data JPA? Also, when may Spring JDBC template perform better than Hibernate / Spring Data JPA?

解决方案

Hibernate is a JPA implementation, while Spring Data JPA is a JPA Data Access Abstraction. Spring Data offers a solution to GenericDao custom implementations. It can also generate JPA queries on your behalf through method name conventions.

With Spring Data, you may use Hibernate, Eclipse Link or any other JPA provider. A very interesting benefit is that you can control transaction boundaries declaratively using the @Transactional annotation.

Spring JDBC is much more lightweight, and it's intended for native querying, and if you only intend to use JDBC alone, then you are better off using Spring JDBC to deal with the JDBC verbosity.

So, Hibernate,and Spring Data are complementary rather than competitors.

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

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