为什么 jpa 和 hibernate 都有“实体"?和“表"注释? [英] Why jpa and hibernate both have "Entity" and "Table" annotations?
本文介绍了为什么 jpa 和 hibernate 都有“实体"?和“表"注释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用的是hibernate 3.6,发现有这样的注解:
I use hibernate 3.6, and found there are such annotations:
javax.persistence.Entity
org.hibernate.annotations.Entity
javax.persistence.Table
org.hibernate.annotations.Table
为什么hibernate提供自己的?它是jpa的替代品,还是只是补充?应该(可以)我同时使用它们,例如:
Why hibernate provides its own? Is it a replacement of jpa one, or just a complement? Should(Can) I use them both together, like:
@javax.persistence.Entity
@org.hibernate.annotations.Entity
public class User {}
推荐答案
org.hibernate.annotations.Entity 使用休眠特性扩展 javax.persistence.Entity.
org.hibernate.annotations.Entity extends javax.persistence.Entity with hibernate features.
参见:http://docs.jboss.org/hibernate/core/3.6/javadocs/org/hibernate/annotations/Entity.html
这篇关于为什么 jpa 和 hibernate 都有“实体"?和“表"注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文