关于Hibernate的报错org.hibernate.MappingException: Unknown entity
部分异常,如下
org.hibernate.MappingException: Unknown entity: com.zcd.hibernate.oneToMany.Team
at org.hibernate.internal.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:1141)
at org.hibernate.internal.SessionImpl.getEntityPersister(SessionImpl.java:1433)
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId
原因:如果没有把实体类的相应的映射文件添加到 SessionFactory 的mappingLocations 属性中,就会抛出Unknown entity 的异常。