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

attempt to create delete event with null entity 包这样的错

阅读更多

UserActionForm uaf = (UserActionForm)form;
   
              //用户标识
int userId = uaf.getId();

//角色标识
int roleId = uaf.getRoleId();

System.out.println("------------"+userId);
System.out.println("-------------"+roleId);


userManager.delUserRole(userId, roleId);

return mapping.findForward("pub_del_success");
我从页面接收userid 和roleid  我的打印语句能测试到 这两个值
  但是执行这句删除语句错误,包 这种异常
java.lang.IllegalArgumentException: attempt to create delete event with null entity
at org.hibernate.event.DeleteEvent.<init>(DeleteEvent.java:24)
at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:744)
at org.springframework.orm.hibernate3.HibernateTemplate$25.doInHibernate(HibernateTemplate.java:848)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.delete(HibernateTemplate.java:842)
at org.springframework.orm.hibernate3.HibernateTemplate.delete(HibernateTemplate.java:838)
at com.edu.oa.managerImpl.UserManagerImpl.delUserRole(UserManagerImpl.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy5.delUserRole(Unknown Source)
at com.edu.oa.web.action.UserAction.delUserRole(UserAction.java:133)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
at org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:110)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.edu.oa.web.PagerFilter.doFilter(PagerFilter.java:29)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:866)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:716)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1498)
at java.lang.Thread.run(Thread.java:619)


我的删除语句是:
       public void delUserRole(int userId, int roleId) {
getHibernateTemplate().delete(findUsersRoles(userId,roleId));

}


        private UsersRoles findUsersRoles(int userId, int roleId){

return (UsersRoles)getSession().createQuery(
"select ur from UsersRoles ur where ur.role.id = ? and ur.user.id = ?")
.setParameter(0, userId)
.setParameter(1, roleId)
.uniqueResult();

}


我的映射文件时
  user映射文件<hibernate-mapping>
  <class table="t_user" name="com.edu.oa.model.User" >
    <id name="id">
      <generator class="native"/>
    </id>
    <property name="username" not-null="true" unique="true"/>
    <property name="password" not-null="true"/>
    <property name="createTime" update="false"/>
    <property name="expireTime"/>
    <many-to-one unique="true" name="person" />
  </class>
</hibernate-mapping>

role映射文件
<hibernate-mapping>
  <class table="t_role" name="com.edu.oa.model.Role">
    <id name="id">
      <generator class="native"/>
    </id>
    <property name="name"/>
  </class>
</hibernate-mapping>


userrole映射文件
   <hibernate-mapping>
  <class table="t_usersRoles" name="com.edu.oa.model.UsersRoles" >
    <id name="id">
      <generator class="native"/>
    </id>
    <many-to-one name="role" />
    <many-to-one name="user" />
    <property name="orderNo"/>
  </class>
</hibernate-mapping>


找到答案了是那的错
                   private UsersRoles findUsersRoles(int userId, int roleId){

return (UsersRoles)getSession().createQuery(
"select ur from UsersRoles ur where ur.role.id = ? and ur.user.id = ?")
.setParameter(0, userId)
.setParameter(1, roleId)   红色地方有顺序不一样, 教训啊!紧记
.uniqueResult();

}

分享到:
评论

相关推荐

    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.

    Ionic日期选择插件

    1. 添加依赖:通过 npm 或者其他包管理工具将插件添加到项目中,如 `npm install timerpicker4.0`。 2. 引入模块:在 AngularJS 的应用模块中引入插件所需的模块。 3. 配置服务:在控制器中配置插件,如设置默认值、...

    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…

    AT89C2051 RS232

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

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

    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

    接着,我们需要检查操作系统的版本号和服务包(SP)版本号。根据IBM的建议,如果遇到上述错误,应该将SP升级到5300-05-CSP,而其他部分保持不变。这样可以确保修复已知的bug,同时避免对系统其他部分产生影响。 在...

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

    这样,系统在执行PB相关命令时能找到对应的可执行文件。 3. **兼容性模式**:有时,运行PB的兼容性模式可能会解决打开错误。右击PB图标,选择“属性”,在“兼容性”选项卡下进行设置。 4. **管理员权限**:有些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....

    Winlicense v2.0.6.0

    WinLicense combines the same protection-level as Themida with the power of advanced license control, offering the most powerful and flexible technology that allows developers to securely distribute ...

    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