Hibernate和JPA有什么区别? [英] What are the differences between Hibernate and JPA?

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

问题描述

当我在大学学习网络编程时,他们告诉我们有关休眠的知识。

我们用了一段时间,甚至有机会在一家公司的真实场景中使用它将近8个月。
现在我完全切换到Java EE 6( Im in love:)),我使用JPA来满足ORM需求。

自从我使用它以来已有几个月了,但我并不真正了解其中的差异。为什么有些人说一个或另一个更好或更坏?
我在这两种方式中进行映射和注释的方式几乎是一样的......



也许你可以解决我的疑惑:



- 各自的优点和缺点是什么?

- Hibernate使用JPA还是其他方式从功能的角度来看,有什么功能没有其他功能?



- 两者之间的其他区别是什么?JPA(Java Persistence API)是一个API,JPA 2.0是JSR 317组的成员。基本上它是一个通过使用ORM(对象关系映射)来管理关系数据的框架,用于数据持久化。

Hibernate是一个ORM库,它将POJO / JavaBeans映射到数据持久性。 ORM和JPA都有用于将POJO映射到数据库表的对象/关系元数据(XML,Annotations)。
$ b


Hibernate使用JPA还是使用JPA其他
方式(他们是否依赖于每个
其他)?

Hibernate 3现在支持JPA 2.0。 JPA是一个使用Object模型描述关系数据关系和管理的规范。由于JPA是一个API,Hibernate实现了这个API。您只需使用JPA API类/接口编写您的程序,将Hibernate配置为JPA资源,并且您可以运行JPA。


<每种优势和
有什么优势?

优点:$ b​​
$ b


  • 避免低级JDBC和SQL代码。 > JPA是EJB3和Java EE的标准和部分。



这就是我对Hibernate的了解。


When i was in college learning about web programming, they told us about hibernate.

We used it for a while, i even had the chance to work with it in a real scenario in a company for almost 8 months. Now that i completely switching to Java EE 6 (Im in love :) ), I use JPA for my ORM needs.

It is being a few months since i use it, but i dont really understand what are the differences between one and other. Why some people say one or other is better or worse? The way i do my mappings and annotations in both is almost the same...

Maybe you can solve some of my doubts:

-What are the advantages and dissadvantages of each?

-Does Hibernate uses JPA or the other way around(Do they depend on each other)?

-From the point of view of features, what features does one have that does not have the other?

-Any other differences between both?

解决方案

JPA (Java Persistence API) is an API, JPA 2.0 is of the JSR 317 group. Basically it's a framework to manage relational data by using ORM (Object Relational Mapping) for data persistence.

Hibernate is a ORM library that maps your POJO/JavaBeans to your data persistence. Both ORM and JPA have a object/relational metadata (XML, Annotations) for mapping POJO's to DB tables.

Does Hibernate uses JPA or the other way around (Do they depend on each other)?

Hibernate 3 now supports JPA 2.0. JPA is a specification describing the relation and management of relational data using Object model. Since JPA is an API, Hibernate implements this API. All you have to do is write your program using JPA API classes/interfaces, configure Hibernate as a JPA resource and voila, you got JPA running.

What are the advantages and disadvantages of each?

Advantages:

  • Avoids low level JDBC and SQL code.
  • It's free (EclipseLink e.g. for JPA).
  • JPA is a standard and part of EJB3 and Java EE.

That's all I know of Hibernate.

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

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