org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [org.fzegplat.hibernate.po.BAction#50]
    at org.hibernate.engine.StatefulPersistenceContext.checkUniqueness(StatefulPersistenceContext.java:556)
    at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:70)
    at org.hibernate.impl.SessionImpl.fireDelete(SessionImpl.java:761)
    at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:739)
    at org.fzegplat.hibernate.dao.BActionDao.delete(BActionDao.java:55)
    at org.fzegplat.hibernate.delegate.BActionDelegate.delAction(BActionDelegate.java:71)
    at org.fzegplat.struts.basicaction.B_action_delAction.execute(B_action_delAction.java:45)
    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
    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:252)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    at java.lang.Thread.run(Thread.java:595)
org.fzegplat.well.exception.DaoException: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [org.fzegplat.hibernate.po.BAction#50]
    at org.fzegplat.hibernate.dao.BActionDao.delete(BActionDao.java:59)
    at org.fzegplat.hibernate.delegate.BActionDelegate.delAction(BActionDelegate.java:71)
    at org.fzegplat.struts.basicaction.B_action_delAction.execute(B_action_delAction.java:45)
    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
    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:252)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    at java.lang.Thread.run(Thread.java:595)
Caused by: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [org.fzegplat.hibernate.po.BAction#50]
    at org.hibernate.engine.StatefulPersistenceContext.checkUniqueness(StatefulPersistenceContext.java:556)
    at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:70)
    at org.hibernate.impl.SessionImpl.fireDelete(SessionImpl.java:761)
    at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:739)
    at org.fzegplat.hibernate.dao.BActionDao.delete(BActionDao.java:55)
    ... 22 more

这个异常发生当你用session.load 或 session.get加载一个对象时 而又尝试着 
session.update or session.lock 操作此对象

解决:
请不要用session加载对对象当你引用或再次使用该对象

由于我在做删除或修改数据操作时,而同时又查询,在查询中我没有关闭session 而造成 a different object with the same identifier value was already associated with the session

NonUniqueObjectException 问题的更多相关文章

  1. org.hibernate.NonUniqueObjectException: a different object with the same identifier value was alread---------程序报错

    今天遇到了这个问题: org.hibernate.NonUniqueObjectException: a different object with the same identifier value ...

  2. hibernate异常:org.hibernate.NonUniqueObjectException

    异常:org.hibernate.NonUniqueObjectException 提示:a different object with the same identifier value was a ...

  3. opensessioninviewFilter导致org.hibernate.NonUniqueObjectException

    起因: 公司业务需求,增加了一个新的数据源,增加之后,起初一切正常,但是发现后台管理系统所有Ajax请求获取信息没有问题,但是涉及到保存操作就抛出异常. 异常: org.hibernate.NonUn ...

  4. org.hibernate.NonUniqueObjectException

    错误如下: 2017-3-29 15:17:52~ERROR~org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV ...

  5. Exception 06 : org.hibernate.NonUniqueObjectException: A different object with the same identifier value was already associated with the session :

    异常名称: org.hibernate.NonUniqueObjectException: A different object with the same identifier value was ...

  6. org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session:

    保存实体异常 https://blog.csdn.net/zzzz3621/article/details/9776539 org.hibernate.NonUniqueObjectException ...

  7. org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session异常解决办法

    org.hibernate.NonUniqueObjectException: a different object with the same identifier value was alread ...

  8. 解决org.hibernate.NonUniqueObjectException的问题

    不知道是不是之前处理懒加载的问题对session工厂进行了处理,导致了之前没有问题的地方出现了错误. 当修改班级操作时出现了错误 前端错误信息 后台处理以及报错信息 16:37:36,034 ERRO ...

  9. sh NonUniqueObjectException

    话题引入: 使用hibernate进行更新操作时,首先调用了findById方法获取要修改的对象,此时session没有被关闭,接着重新创建一个对象,将要修改的属性值赋值给这个对象.调用修改方法抛出如 ...

随机推荐

  1. mongodb学习(1) 第一次开启 mongdb

    1.启动mongdb 可以设置为开机启动 mongod -dbpath=/data/mongodb --fork --port 27017 --logpath=/usr/local/mongodb/l ...

  2. Java编程之字符集问题研究

    1. 概述 本文主要包括以下几个方面:编码基本知识,java,系统软件,url,工具软件等. 在下面的描述中,将以"中文"两个字为例,经查表可以知道其GB2312编码是" ...

  3. 在windows下搭建linux-c学习环境

    下载virtualbox并安装: https://www.virtualbox.org/wiki/Downloads 现在vagrant并安装: https://www.vagrantup.com/d ...

  4. 隐藏NGINX服务器名称 和版本号

    隐藏NGINX服务器名称: 修改或隐藏服务器名称需要修改源码nginx.h,nginx.h在src/core/目录下 .具体操作如下: 把下面两个宏的值修改为自己设定的值,例如"NGX&qu ...

  5. python常用数据结构的常用操作

    作为基础练习吧.列表LIST,元组TUPLE,集合SET,字符串STRING等等,显示,增删,合并... #===========List===================== shoplist ...

  6. libCurl的C++引用

    I believe I have gotten LibCurl to work with Visual Studio 2013 now. Persistence ftw! Although, afte ...

  7. 说说自己对RESTful API的理解s

    REST不是英文上的rest单词,其英文缩写为presentational State Transfer ,直译为表现状态转移,咋看起来很学术,不懂,其实不用去死抠这个词的意思.REST是一种约束和架 ...

  8. CDN和双线机房相比有何优势

    1.什么类型的网站最需要CDN? 适合目标客户覆盖全国范围的网站,不论是南方电信.还是北方网通用户.铁通用户,均要求能快速访问到客户网站,彻底解决电信.网通之间的互访瓶颈. 另外国外的网站,如果需要提 ...

  9. C# 利用反射查看类的信息

    using System; using System.Collections; using System.Collections.Generic; using System.Reflection; u ...

  10. JavaScript 对象属性的遍历

    ES6一共有5种方法可以遍历对象的属性. (1)for...in for...in循环遍历对象自身的和继承的可枚举属性(不含Symbol属性). (2)Object.keys(obj) Object. ...