码迷,mamicode.com
首页 > 编程语言 > 详细

关于注解-Hebernate与JPA(java persistence api)

时间:2015-10-21 12:16:14      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:

The JPA spec. defines the JPA annotation in the javax.persistence package. Hibernate not only implements JPA spec , but extends it to adds more features . So , hibernate creates their own annotations which just extend the JPA annotation with the Hibernate features , and put these annotation inside the package org.hibernate.annotations

If there are no Hibernate specified features added for that JPA annotation (eg @OneToMany and @ManyToOne) , Hibernate will not make that annotation in their org.hibernate.annotations package and you have to use these annotation from javax.persistence according to the JPA specification.

Normally ,people will use JPA annotations until they come across a situation that requires to use hibernate features.

In one word: if you want to use hibernate with annotation, you must use some annotations in the javax.persistence package.
 
Extends:
    1,JPA(Java Persistence API)是Sun官方提出的Java持久化规范。它为Java开发人员提供了一种对象/关系映射工具来管理Java应用中的关系数据。,而Hibernate是它的一种实现。除了Hibernate,还有EclipseLink(曾经的toplink),OpenJPA等可供选择,所以使用Jpa的一个好处是,可以更换实现而不必改动太多代码。

    2,Hibernate作为JPA的一种实现,jpa的注解已经是hibernate的核心,hibernate只提供了一些补充,而不是两套注解。hibernate对jpa的支持够足量,在使用hibernate注解建议使用jpa。

关于注解-Hebernate与JPA(java persistence api)

标签:

原文地址:http://www.cnblogs.com/nickhan/p/4897087.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!