首页 > 其他分享 >a different object with the same identifier value was already associated with the session

a different object with the same identifier value was already associated with the session

时间:2023-09-07 12:33:40浏览次数:38  
标签:different already associated update value session


数据库更新记录报错:

a different object with the same identifier value was already associated with the session: [com.miracle.dm.sysmgr.user.model.OrgUserProInfo#4028800b269cc2f301269cc959960007]; nested exception is org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.miracle.dm.sysmgr.user.model.OrgUserProInfo#4028800b269cc2f301269cc959960007]

临时解决办法:

在update之前先调用:  this.getHibernateTemplate().getSessionFactory().getCurrentSession().clear();

 

网上另有解决方法:

把数据访问层的更新方法中的update 改成merge就可以实现

public void update(Role r) {
  getHibernateTemplate().update(r);
 }
  
public void update(Role r) {
  getHibernateTemplate().merge(r);
 }

标签:different,already,associated,update,value,session
From: https://blog.51cto.com/u_2544485/7395918

相关文章

  • 信息: org.jbpm.JbpmException: closed JbpmContext in different order then they we
    刚接触jbpm 刚才遇到这个错误:closedJbpmContextindifferentorderthentheywerecreated...checkyourtry-finally'saroundJbpmContextsblocks我百思不得其解,网上说是hibernate的session没关闭,在搜索也就是javaeye那几个。查看了源代码有这句话:if(jbpmContext!=......
  • 微分平坦(differential flatness)的简易理解
    对于运动控制下的系统建模,如果规划控制的变量太多,产生的维度就太多,如无人机变量为12个,即12维空间,同时规划12个变量不现实,所以考虑使用少数几个变量及其有限阶导数代表其他变量,这样一来只需要对少数几个变量进行规划则可以达到对所有变量规划。  参考:https://zhuanlan.zhihu.c......
  • Proj CDeepFuzz Paper Reading: Automatic differentiation in PyTorch
    Abstract本文:描述automaticdifferentiationmoduleofPyTorch包括:LuaTorch,Chainer,HIPSAutogradTask:Providesahigh-performanceenvironmentondifferentdevices(bothCPUsandGPUs)方法:不用symbolicdifferentiation,而是使用differentiationonpurelyimper......
  • jetty报错: Open quote is expected for attribute "{1}" associated with an element
    这个错误是使用jetty作为容器,但是java代码中,servlet是使用注解的形式标记一个类为servlet的,可能是版本不兼容吧,会报这个莫名其妙的错,解决方法是将这个servlet类配置到web.xml文件中,不要用注解的形式。......
  • remote origin already exists
    如果你clone下来一个别人的仓库,在此基础上完成你的代码,推送到自己的仓库可能遇到如下问题:error:remoteoriginalreadyexists.表示远程仓库已存在。因此你要进行以下操作:1、先输入gitremotermorigin删除关联的origin的远程库2、关联自己的仓库gitremoteaddoriginhttps:......
  • A VNC server is already running as :1
    看到这一行字是不是很崩溃。当输入vncserver-kill:1,输出结果是:Can'tfindfile/home/ubuntu/.vnc/VM-0-11-ubuntu:1.pidYou'llhavetokilltheXtightvncprocessmanually是不是更崩溃。 不过,经过热心网友的分享,且最终亲测有效的解决方法就是:删除这两个文件。rm/......
  • 解决getOutputStream() has already been called for this response
    getOutputStream()hasalreadybeencalledforthisresponse异常出现的原因和解决方法:jsp中出现此错误一般都是在jsp中使用了输出流(如输出图片验证码,文件下载等),没有妥善处理好的原因。具体的原因:jsp编译成servlet之后在函数_jspService(HttpServletRequestrequest,HttpServlet......
  • Redundant declaration: @SpringBootApplication already applies given @ComponentSc
    报错提示内容: 解决:将启动类文件移动到com.atguigu.eduservice包。应该是EduApplication.java文件自带的@SpringBootApplication中包含@ComponentScan,默认是扫描该类所在的包和子包的,即@ComponentScan(basePackages={"com.atguigu"}),所以再写一遍就提示多余的。 ......
  • ethereum错误之already known
    根据提供的错误信息error(*github.com/ethereum/go-ethereum/rpc.jsonError)*{Code:-32000,Message:"alreadyknown",Data:interface{}nil},这是一个来自以太坊的JSON-RPC错误。该错误的含义是“alreadyknown”,即“已经存在”。在以太坊中,当您尝试发送一个已经存在于区......
  • vue报错 Multiple assets emit different content to the same filename index.html
    vue-cli版本:@vue/[email protected]报错现象:想把css和script全部内嵌到html文件中,就用了"HtmlInlineScriptPlugin"插件,打包后js代码被嵌到了head里,导致代码提前执行找不到#app,再配置HtmlWebpackPlugin插件通过inject:"body"指定代码内嵌到body,打包报错"Multipleassetsemitdiff......