原来我用hibernate生成的持久化类都在com.po下,后来由于需要改为com.xfy.model.pojo目录下,当然hibernate.cfg.xml文件中的*.hbm.xml重新加了一遍,可当我用到一个持久化类的findById方法时就出现这个错误org.hibernate.MappingException: Unknown entity: com.po.Dept
,明明路径已经在com.xfy.model.pojo下了,找了一个小时,都没错啊,hibernate.cfg.xml中配置文件的路径也对,其他的也没错,重启Eclipse N次,没用!
最后有到DAO中报错的位置看了一下,问题找到了
public Dept findById( java.lang.Integer id) {
log.debug("getting Dept instance with id: " + id);
try {
Dept instance = (Dept) getSession()
.get("com.po.Dept", id); ========问题在这======
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
原来findById方法中路径没改过来,还要findByExample方法中也需要改