Hibernate和JPA之间的@Entity有什么区别

jet*_*mba 14 java orm hibernate jpa hibernate-mapping

当我在做Hibernate独立程序示例时,在我的脑海中使用@Entity注释创建了一点混乱.

这里我的问题是,我有一个来自javax.persistence包的@Entity的持久化类,然后它工作正常但是当我用Hibernate API替换@Entity注释(即来自org.hibernate.annotations包)然后它给出了org.hibernate.MappingException :未知实体:com.jetti.test.Employee

给予更多解释,非常感谢.

Pre*_*ric 5

@ javax.persistence.Entity仍然是强制性的,@ org.hibernate.annotations.Entity不是替代品.

文档

所以,hibernate @Entity只补充了它javax.persistence.Entity,并提供了一些更精细的调整选项.

  • @hagubear JPA是一个规范,Hibernate(作为其他几个框架)实现了该规范.引用[this](http://en.wikibooks.org/wiki/Java_Persistence/What_is_JPA%3F)`JPA本身只是一个规范,而不是产品; 它本身不能执行持久性或其他任何事情.JPA只是一组接口,需要实现.在这个问题的上下文中,它意味着Hibernate实现了对`javax.persistence.Entity`的支持,但是使用`org.hibernate.annotations.Entity`添加了更多功能. (2认同)