关于映射异常org.hibernate.MappingException: An association from the table DUTY_INFO refers to an unmapped class: com.pms.entities.other.Department的原因。
在编程过程当中由于修改过了包名。
原来的包名是: com.pms.entities.base
然后改为了:com.pms.entities.other
当我重新映射生成数据表的时候就报错:org.hibernate.MappingException: An association from the table DUTY_INFO refers to an unmapped class: com.pms.entities.other.Department
我明明已经修改过了类对应的映射文件,而且准确无误。一直找不到原因。
最后发现是,IOC容器中的配置没有改。
原来的配置如下。
<!-- 配置SessionFactory --> <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource"></property> <property name="configLocation" value="classpath:hibernate.cfg.xml"></property> <property name="mappingLocations" > <list> <value>classpath:com/pms/entities/base/*.hbm.xml</value> <!-- 这里原来的包名应该也要改,这里只要改成other就好了。 --> <value>classpath:com/pms/entities/personnelManagement/*.hbm.xml</value> <value>classpath:com/pms/entities/treatmentManagement/*.hbm.xml</value> </list> </property> </bean>