标签:transient role known port 应该 pojo gen main default
org.hibernate.MappingException: Unknown entity: org.dao.po.Role
at org.hibernate.internal.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:1096)
at org.hibernate.internal.SessionImpl.getEntityPersister(SessionImpl.java:1443)
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:116)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:209)
at org.hibernate.event.internal.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:55)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:194)
at org.hibernate.event.internal.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:49)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90)
at org.hibernate.internal.SessionImpl.fireSave(SessionImpl.java:715)
at org.hibernate.internal.SessionImpl.save(SessionImpl.java:707)
at org.hibernate.internal.SessionImpl.save(SessionImpl.java:702)
at org.dao.HibernateTest.main(HibernateTest.java:18)
import javax.persistence.Entity;
<mapping class="org.dao.po.Role" />
如果使用配置文件配置pojo,那么在hibernate.cfg.xml文件中应该是引入文件<mapping resource="org/dao/po/Role.hbm.xml"></mapping>
如果是使用注解,参考上面第二条
hibernate提示Unknown entity: :xxx
标签:transient role known port 应该 pojo gen main default
原文地址:https://www.cnblogs.com/donfaquir/p/9403776.html