Type Exception Report
Message IllegalArgumentException occurred while calling setter for property [com.lys.entity.Employee.department (expected type = com.lys.entity.Department)]; target = [EmployeeDaoImpl{id=1, sex='女', birthday=null, joinDay=null, password='123456', eno='null', userName='李'}], property value = [EmployeeDaoImpl{id=1, sex='女', birthday=null, joinDay=null, password='123456', eno='null', userName='李'}] setter of com.lys.entity.Employee.department; nested exception is IllegalArgumentException occurred while calling setter for property [com.lys.entity.Employee.department (expected type = com.lys.entity.Department)]; target = [EmployeeDaoImpl{id=1, sex='女', birthday=null, joinDay=null, password='123456', eno='null', userName='李'}], property value = [EmployeeDaoImpl{id=1, sex='女', birthday=null, joinDay=null, password='123456', eno='null', userName='李'}]
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
org.springframework.orm.hibernate5.HibernateSystemException: IllegalArgumentException occurred while calling setter for property [com.lys.entity.Employee.department (expected type = com.lys.entity.Department)]; target = [EmployeeDaoImpl{id=1, sex='女', birthday=null, joinDay=null, password='123456', eno='null', userName='李'}], property value = [EmployeeDaoImpl{id=1, sex='女', birthday=null, joinDay=null, password='123456', eno='null', userName='李'}] setter of com.lys.entity.Employee.department; nested exception is IllegalArgumentException occurred while calling setter for property [com.lys.entity.Employee.department (expected type = com.lys.entity.Department)]; target = [EmployeeDaoImpl{id=1, sex='女', birthday=null, joinDay=null, password='123456', eno='null', userName='李'}], property value = [EmployeeDaoImpl{id=1, sex='女', birthday=null, joinDay=null, password='123456', eno='null', userName='李'}]
org.springframework.orm.hibernate5.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:219)
org.springframework.orm.hibernate5.HibernateTemplate.doExecute(HibernateTemplate.java:344)
org.springframework.orm.hibernate5.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:309)
org.springframework.orm.hibernate5.HibernateTemplate.find(HibernateTemplate.java:863)
com.lys.dao.impl.EmployeeDaoImpl.getEmployee(EmployeeDaoImpl.java:19)
Message IllegalArgumentException occurred while calling setter for property [com.lys.entity.Employee.department (expected type = com.lys.entity.Department)]; target = [EmployeeDaoImpl{id=1, sex='女', birthday=null, joinDay=null, password='123456', eno='null', userName='李'}], property value = [EmployeeDaoImpl{id=1, sex='女', birthday=null, joinDay=null, password='123456', eno='null', userName='李'}] setter of com.lys.entity.Employee.department; nested exception is IllegalArgumentException occurred while calling setter for property [com.lys.entity.Employee.department (expected type = com.lys.entity.Department)]; target = [EmployeeDaoImpl{id=1, sex='女', birthday=null, joinDay=null, password='123456', eno='null', userName='李'}], property value = [EmployeeDaoImpl{id=1, sex='女', birthday=null, joinDay=null, password='123456', eno='null', userName='李'}]
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
org.springframework.orm.hibernate5.HibernateSystemException: IllegalArgumentException occurred while calling setter for property [com.lys.entity.Employee.department (expected type = com.lys.entity.Department)]; target = [EmployeeDaoImpl{id=1, sex='女', birthday=null, joinDay=null, password='123456', eno='null', userName='李'}], property value = [EmployeeDaoImpl{id=1, sex='女', birthday=null, joinDay=null, password='123456', eno='null', userName='李'}] setter of com.lys.entity.Employee.department; nested exception is IllegalArgumentException occurred while calling setter for property [com.lys.entity.Employee.department (expected type = com.lys.entity.Department)]; target = [EmployeeDaoImpl{id=1, sex='女', birthday=null, joinDay=null, password='123456', eno='null', userName='李'}], property value = [EmployeeDaoImpl{id=1, sex='女', birthday=null, joinDay=null, password='123456', eno='null', userName='李'}]
org.springframework.orm.hibernate5.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:219)
org.springframework.orm.hibernate5.HibernateTemplate.doExecute(HibernateTemplate.java:344)
org.springframework.orm.hibernate5.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:309)
org.springframework.orm.hibernate5.HibernateTemplate.find(HibernateTemplate.java:863)
com.lys.dao.impl.EmployeeDaoImpl.getEmployee(EmployeeDaoImpl.java:19)
com.lys.service.impl.EmployeeServiceImpl.login(EmployeeServiceImpl.java:18)
非法数据异常:
映射文件出错,在Employee和Department中,Department和Employee是“一对多的关系”,在实体的两个映射文件中,
Employee.hbm.xml中(“多”的一方)
<many-to-one name="department" class="com.lys.entity.Employee" column="departmentId" lazy="false"> </many-to-one>
Department.hbm.xml中(“一”的一方)
<set name="employeeSet"> <key column="departmentId"></key> <one-to-many class="com.lys.entity.Employee"></one-to-many> </set>
正确的是:
Employee.hbm.xml中(“多”的一方)
<many-to-one name="department" class="com.lys.entity.Dempartment" column="departmentId" lazy="false"> </many-to-one>
Department.hbm.xml中(“一”的一方)
<set name="employeeSet"> <key column="departmentId"></key> <one-to-many class="com.lys.entity.Employee"></one-to-many> </set>
colume:外键
class:对方实体类的相对路径