`
gstarwd
  • 浏览: 1488266 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

attempt to create delete event with null entity

    博客分类:
  • SSH
阅读更多

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。

 

 

 

======

4月7日

连续删除的问题

jsp:
 
<ec:table items="result"
       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>
 
 
java:
Action:
 
String[] ids = request.getParameterValues("ids_allbox");
  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");
 
 
java:
Util:
public static boolean deleteConferenceType(String[] ids) {
  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();
  }  
 }
 
 
java:
DAO:
 
public void deleteConferenceType(String[] confTypeIds) throws HibernateException {
  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;
  }
 }
 
 
xml:
 
   <action path="/deleteconftype"
     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>
 
 
errors:
 
Hibernate: select tconferenc0_.TYPE_ID as TYPE1_0_, tconferenc0_.TYPE_NAME as TYPE2_7_0_, tconferenc0_.COMMENTS as COMMENTS7_0_ from ykt_conf.T_CONFERENCE_TYPE tconferenc0_ where tconferenc0_.TYPE_ID=?
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)

问题解决了!
问题是:eXtremeTable 在刷新页面时,将前一form提交的内容都作为hidden又全传了回来,且是不断累加的。
解决方法是:在转到新界面时,刷新界面,struts代码如下,注意着重部分:
<action path="/deleteconftype"
     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>

分享到:
评论

相关推荐

    Ionic日期选择插件

    感谢gocaizi贡献出来的代码,我在此基础上进行了一些修改 http://blog.csdn.net/u013276665/article/details/50001083

    VclZip pro v3.10.1

    Modified the SFX code (the code used to create the SFX stub distributed with VCLZip) so that it handles filenames that have been run through an OEM Conversion. The SFX was losing accented characters. ...

    A Practical Guide to Designing with Data.pdf

    Over the years, I have been digging through large data sets both for work and pleasure. I love numbers, charts, graphs, visualizations, ...and visualizations become easier to create.

    Easy Mobile

    Easy Mobile is our attempt to create a many-in-one Unity package that greatly simplifies the implementation of de facto standard features of mobile games including advertising, in-app purchasing, game...

    AT89C2051 RS232

    AT89C2051与上位机RS232通讯接口子程序

    Business Intelligence and the Cloud(Wiley,2014)

    It starts with a discussion of the media hype around cloud computing and attempt to pull together what industry experts are saying in order to create a unified definition. Once this foundation is ...

    Android代码-HeaderFooterGridView

    HeaderFooterGridView 头尾GridView 源码地址:ProjectX 介绍 支持AUTO_FIT模式,头尾模式有两种,无反射代码。 截图 先决条件 minSdkVersion 4 ...hfgContent.addHeaderItem(headerItem, null, true); hfgCont

    mksysb报错解决方法[归纳].pdf

    mksysb报错解决方法[归纳].pdf

    Economics_10E

    more money in an attempt to stimulate a flagging economy. And there is uncertainty about fiscal policy as a trillion dollar deficit interacts with an aging population to create a national debt time ...

    smoke dx10 Copyright 2007 NVIDIA Corporation

    IN NO EVENT SHALL NVIDIA扴 AGGREGATE LIABILITY TO DEVELOPER OR ANY OTHER PERSON OR ENTITY CLAIMING THROUGH OR UNDER DEVELOPER EXCEED THE AMOUNT OF MONEY ACTUALLY PAID BY DEVELOPER TO NVIDIA FOR THE ...

    Pro LINQ: Language Integrated Query in C# 2010 (含源码)

    How to query Databases with LINQ to SQL, write your own entity classes, and understand how to handle concurrency conflicts. Who this book is for This book is written for the proficient C# developer, ...

    Programming with GNU software 2

    This book is neither a...attempt to guide you through the process of choosing, configuring and using GNU tools. We will do this by developing an example project demonstrating the actual use of each tool.

    企业进销存管理系统 系统开发

    主要功能 进销存管理是企业日常经营管理中十分重要的一个组成部分,传统的手工管理方式呈现出越来越多的弊端。在手工管理模式下,统计、汇总处理时的工作量极其繁重,处理效率非常低,领导也无法及时了解企业资金...

    Test Driven Development with Python 2nd Edition.pdf

    This book is my attempt to share with the world the journey I’ve taken from “hack‐ ing” to “software engineering”. It’s mainly about testing, but there’s a lot more to it, as you’ll soon see....

    KafkaOffsetMonitor监控工具2017年1月发布的版本

    Created function tryParseOffsetMessage to attempt to parse a kafka offset message retrieved from the internal committed offset topic: Handles messages of other types and questionable correctness. ...

    Winlicense v2.0.6.0

    * Possibility to create Trial versions with multiple different expiration types like: expiration by days, by executions, by specific date, by minutes, by runtime, etc. * Possibility to extend the ...

Global site tag (gtag.js) - Google Analytics