Hibernate的注解 [英] Hibernate annotation
问题描述
我们应该基于Hibernate应用程序使用@ org.hibernate.annotations.Entity代替@ javax.persistence.Entity?
Should we use @org.hibernate.annotations.Entity instead of @javax.persistence.Entity in Hibernate based applications?
或者是有没有这样的规则?
Or is there no such rule?
推荐答案
的 @ org.hibernate.annotations.Entity
互补的 @ javax.persistence.Entity
。
详见本密切相关的问题:JPA实体和Hibernate实体之间 差异。如前所述那里,你不应该使用 @ org.hibernate.annotations.Entity
没有 @ javax.persistence.Entity
。 Hibernate的注解让你添加一些额外的Hibernate的相关功能,在标准JPA 1已定义的值。
See this tightly related question for details: Difference between JPA Entity and Hibernate Entity. As stated there, you shouldn't be using @org.hibernate.annotations.Entity
without @javax.persistence.Entity
. The Hibernate annotation will let you add some extra hibernate-specific features to the ones already defined in the standard JPA one.
JPA的注释有来自您正在使用的具体引擎脱钩的code的advantange和Hibernate的注解增加了一些额外的功能/属性JPA标准注解,如 optimisticLock
。仅使用 @ org.hibernate.annotations.Entity
如果你需要使用这些属性。
The JPA annotation has the advantange of decoupling your code from the specific engine you're using, and the Hibernate annotation adds some extra features/attributes to the JPA standard annotation, like optimisticLock
. Only use @org.hibernate.annotations.Entity
if you need to use those attributes.
这篇关于Hibernate的注解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!