Hibernate库和Hibernate JPA库的区别 [英] Difference between Hibernate library and Hibernate JPA library

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

问题描述

在可以将Hibernate库添加到项目的屏幕中,有两个选项,Hibernate和Hibernate JPA。



2之间的区别是什么?谷歌搜索没有提供解释。

解决方案

我发现这个提供了一个很好的解释。
http://elope.wordpress。 com / 2007/09/06 / difference-between-jpa-and-hibernate /

从上面的博客:
所以如果我需要a)JPA是您的代码应该使用的持久性Api。

b) JPA Api会将调用传递给实际的持久性提供者(例如:Hibernate / TopLink)来完成实际的工作。



c)如果您从Performance预期看,将依赖于实际的生存提供者(Hibernate / TopLink),而不是JPA,因为它只是一个包装层。



d)如果您从代码依赖关系角度来看,JPA因为你的代码依赖于标准的Java Api。

如果你使用过Hibernate,那么你会发现某些特性在JPA中缺少,比如条件查询等这并不意味着你不能在你的应用程序中编写标准查询您需要从JPA实体管理器中获取Session对象,现在您可以像在hibernate项目中一样好。



但是现在您的代码依赖于特定的impl(Hibernate) ,向前看,你可以看到更多的东西在JPA(2.0)中被添加。f)如果你使用JPA:我认为你应该,API是干净的,虽然不是everthing你需要的是他们,但是向前迈进了一步。

In the screen where you can add the Hibernate library to a project, there are two options, Hibernate and Hibernate JPA.

What is the difference between the 2? Googling did not provide an explanation.

解决方案

I found this to provide a good explanation. http://elope.wordpress.com/2007/09/06/difference-between-jpa-and-hibernate/

From the above blog: So if i need to put in Concise words:

a) JPA is Persistence Api which your code should use.

b) JPA Api will pass on the call to actual peristence provider (ex:Hibernate/TopLink) to do the actual work.

c) If you are looking from Performance prespective ,it will be dependent on actual peristence provider (Hibernate/TopLink) and not on JPA as its just a wrapper layer.

d) If you are looking from code dependency prespective ,JPA makes more sense as your code is dependent on standard Java Api.

e) If you have used Hibernate then you will find that certain features are missing in JPA like criteria queries etc.This does not mean that you can’t write criteria query in your application, you need to get Session object from JPA Entity manager and now you are as good as in hibernate project.

But now your code is dependent on Specific impl (Hibernate),going forward you can see more things getting added in JPA (2.0)

f) Should you use JPA: My take is you should ,API is clean and although not everthing you need is their but is a good step forward.

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

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