attempt to create delete event with null entity 分析及解决
srtuts,spring连续删除的问题
很明显 你删除了 一条不存在的记录 这种错误 可能是你ID传值有误 还有可能就是你重复提交 删了一次 第二次 接着删 肯定报错了
1. 描述
删除一个对象后,按F5刷新 ,出现错误。MyEclispe控制台下异常显示:
java.lang.IllegalArgumentException: attempt to create delete event with null entity
并且浏览器地址还是指向那个被删除的对象。如删除id=30的实体后,浏览器地址为 http://122.204.85.183:8080/PKJava/delete.do?id=30
2. 分析
请参照:http://fengzi015.spaces.live.com/blog/cns!fc609e3f70f965cf!247.entry
返回查询结果部分的问题,也就是说,是:删除记录之后返回的记录集没有刷新。删除的实体在结果集中没有清除。在刷新页面时,将前一form提交的内容都作为hidden又全传了回来,且是不断累加的。
3. 解决方法
在转到新界面时,刷新界面。
只需要修改sttruts.xml中delete action的配置。在delete action的<forward />中加入一个参数redirect="true"。 redirect默认值是false。
======
连续删除的问题
var="pres"
filterable="false"
imagePath="${pageContext.request.contextPath}/html/commons/ximages/*.gif"
rowsDisplayed="10"
action=""
form="confTypeForm">
<ec:row highlightRow="true">
<ec:column property="typeId"
headerStyle="text-align:center"
title="<%=GetProperty.getProperties("conftype.id",getServletContext())%>" >
<input name="ids_allbox" type="checkbox" value="${pres.typeId}">
<a href="<%=ContextUtil.getCtxPath(request)%>/para/modifyconftype.do?id=${pres.typeId}">${pres.typeId}</a>
</ec:column>
<ec:column property="typeName" headerStyle="text-align:center"
style="text-align:center"
filterable="false"
sortable="false"
title="<%=GetProperty.getProperties("conftype.name",getServletContext())%>" />
<ec:column property="comments" headerStyle="text-align:center"
style="text-align:center"
filterable="false"
sortable="false"
title="<%=GetProperty.getProperties("conftype.comments",getServletContext())%>" />
</ec:row>
</ec:table>
if (ids != null) {
try {
ParameterUtil.deleteConferenceType(ids);
} catch (Exception e) {
e.printStackTrace();
return mapping.findForward("error");
}
}
request.setAttribute("result", ParameterUtil.getAllConferenceType());
return mapping.findForward("viewconftype");
ConferenceTypeDAO dao = ConferenceTypeDAO.getInstance();
Transaction t = beginTransaction();
try {
dao.deleteConferenceType(ids);
t.commit();
return true;
}catch (HibernateException he) {
he.printStackTrace();
t.rollback();
return false;
}finally{
closeSession();
}
}
Session s = getSession();
try {
for (int i=0, l=confTypeIds.length; i<l; i++) {
s.delete(s.get(TConferenceType.class, new Integer(confTypeIds[i])));
}
} catch (HibernateException ex) {
errlog.error(ex);
throw ex;
}
}
type="com.kingstargroup.conference.action.DeleteConferenceTypeAction"
name="confTypeForm"
validate="false"
scope="request"
input="/html/conference/parameter/viewconftype.jsp">
<forward name="viewconftype" path="/html/conference/parameter/viewconftype.jsp"></forward>
</action>
java.lang.IllegalArgumentException: attempt to create delete event with null entity
at org.hibernate.event.DeleteEvent.<init>(DeleteEvent.java:25)
at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:578)
at com.kingstargroup.conference.dao.ConferenceTypeDAO.deleteConferenceType(ConferenceTypeDAO.java:35)
at com.kingstargroup.conference.util.ParameterUtil.deleteConferenceType(ParameterUtil.java:252)
at com.kingstargroup.conference.action.DeleteConferenceTypeAction.execute(DeleteConferenceTypeAction.java:29)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.extremecomponents.table.filter.AbstractExportFilter.doFilter(AbstractExportFilter.java:49)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at com.kingstargroup.conference.filter.SetEncodingFilter.doFilter(SetEncodingFilter.java:38)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
type="com.kingstargroup.conference.action.parameter.DeleteConferenceTypeAction"
scope="request"
input="/html/conference/parameter/viewconftype.jsp">
<forward name="viewconftype" path="/viewconftype.do" redirect="true" ></forward>
</action>