`
gstarwd
  • 浏览: 1536288 次
  • 性别: 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日期选择插件

    Ionic框架是一款基于AngularJS和Apache Cordova的开源移动应用开发框架,它允许开发者使用Web技术(HTML、CSS、JavaScript)来构建跨平台的原生移动应用。在 Ionic 中,经常需要与用户交互处理日期和时间,这就需要...

    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. ...

    An attempt to read, understand, and implement the AUTOSAR SWS Po

    An attempt to read, understand, and implement the AUTOSAR SWS Port Driver according to the specification in a demo full-layered AUTOSAR a…

    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是一款8位微控制器,由美国Atmel公司生产,属于8051系列的单片机。它具有低功耗、高性能的特点,适用于各种嵌入式应用,包括工业控制、消费电子和家用电器等。RS232,则是一种常见的串行通信接口标准,用于...

    orcad15.7 破解方法

    orcad15.7 安装问题解决:An application has made an attempt to load the C runtime library incorrectly. Please ccontact the application"s support team for more information!

    Android代码-HeaderFooterGridView

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

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

    《mksysb报错解决方法的详细指南》 在软件开发过程中,系统备份是确保数据安全和系统稳定性的重要步骤。然而,有时在执行mksysb命令进行系统备份时,可能会遇到各种报错,这可能对系统的正常运行造成影响。...

    pb双击打开错误方式的修复

    PB,全称PowerBuilder,是一种流行的面向对象的编程环境,主要用于开发企业级应用程序,特别是数据库应用。当你在尝试双击打开PB项目时遇到错误,这可能是由于多种原因引起的,包括注册表问题、软件版本不兼容、环境...

    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, ...

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

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

    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....

    DB2数据库跨平台备份与恢复

    SQL2570N 错误的全称是“An attempt to restore on target OS from a backup created on source OS failed due to the incompatibility of operating systems or an incorrect specification of the restore command...

    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. ...

Global site tag (gtag.js) - Google Analytics