最近学习Hiberante Annotations时遇到了该问题org.hibernate.MappingException: Unknown entity在baidu和googl上搜寻了 很久也没有找到适合我的解决方法,最后发现是import Entity类造成的(使用Eclipse自动提示导入的该包)

import  javax.persistence.Id;
import  javax.persistence.Table;
import  javax.persistence.Transient;
import  org.hibernate.annotations.Entity; // 这是就出问题了哦

@Entity
@Table(name
= " test_person " )
public   class  Person  implements  Serializable

后面修改了引入的Entity

import  javax.persistence.Id;
import  javax.persistence.Table;
import  javax.persistence.Transient;
import  javax.persistence.Entity; // 引入这个类就正确了

@Entity
@Table(name
= " test_person " )
public   class  Person  implements  Serializable

另外有些报org.hibernate.MappingException: Unknown entity,可能是没有在cfg文件中加入 *.hbm.xml造成的