【错误提示】
java.lang.IllegalArgumentException: attempt to create saveOrUpdate event with null entity
at org.hibernate.event.SaveOrUpdateEvent.<init>(SaveOrUpdateEvent.java:40)
at org.hibernate.event.SaveOrUpdateEvent.<init>(SaveOrUpdateEvent.java:23)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:518)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:514)
【解决方法】
错误原因有以下几个:
1、 Hibernate(*.hbm.xml)映射文件是否错误
2、DAO层代码是否错误
3、检查Action及视图层jsp页面等
把
<s:a href="savePaper.action">Save Papers</s:a> <br> <br> <br>
<s:a href="listPaper.action">List Papers</s:a> <br> <br> <br>
改成
<s:a href="save.jsp">Save Papers</s:a> <br> <br> <br>
<s:a href="listPaper.action">List Papers</s:a> <br> <br> <br>
常见的还有
把
<s:form action="saveEmployee.action">
<s:textfield name="empName" label="empName"></s:textfield>
<s:textfield name="age" label="age"></s:textfield>
<s:textfield name="sex" label="sex"></s:textfield>
<s:textfield name="context" label="context"></s:textfield>
<s:submit value="注册" theme="simple"></s:submit>
<s:reset value="取消" theme="simple"></s:reset>
</s:form>
改成
<s:form action="saveEmployee.action">
<s:textfield name="employee.empName" label="empName"></s:textfield>
<s:textfield name="employee.age" label="age"></s:textfield>
<s:textfield name="employee.sex" label="sex"></s:textfield>
<s:textfield name="employee.context" label="context" value=""></s:textfield>
<s:submit value="注册" theme="simple"></s:submit>
<s:reset value="取消" theme="simple"></s:reset>
</s:form>