hibernate 异常a different object with the same identifier value was already associated with the session
在使用hibernate的时候发现了一个问题,记录一下解决方案。
前提开启了事务和事务间并无commit,进行两次save,第二次的时候爆出下面的异常a different object with the same identifier value was already associated with the session
翻译一下session中已经存在了拥有该标识的对象,不能新建另外一个了。
这里的identifier(标识)指的就是表的主键,而后发现主键是自增的,但是并没有在Entity中增加自增配置
@Id主键自增的方法
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name = "id")
private Integer id;
hibernate 异常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 already associated with the session异常解决办法
org.hibernate.NonUniqueObjectException: a different object with the same identifier value was alread ...
- 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 ...
- 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 ...
- Hibernate Error: a different object with the same identifier value was already associated with the session
在执行Hibernate的Update操作时,报错:a different object with the same identifier value was already associated w ...
- rg.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session:
原先跑TEST CASE的时候没有出错 但是跑到整个程序里面,除了这个问题, 网上也找了下资料,说是用merge之类的可以解决,因为你这个update的obj和session里面的不用,所以导致此问题 ...
- hibernate中一种导致a different object with the same identifier value was already associated with the session错误方式及解决方法
先将自己出现错误的全部代码都贴出来: hibernate.cfg.xml <?xml version="1.0" encoding="UTF-8"?> ...
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was alread---------程序报错
今天遇到了这个问题: org.hibernate.NonUniqueObjectException: a different object with the same identifier value ...
- Hibernate更新数据报错:a different object with the same identifier value was already associated with the session: [com.elec.domain.ElecCommonMsg#297e35035c28c368015c28c3e6780001]
使用hibernate更新数据时,报错 Struts has detected an unhandled exception: Messages: a different object with th ...
- a different object with the same identifier value was already associated with the session解决方案
org.springframework.orm.hibernate3.HibernateSystemException: a different ]; nested exception ] at or ...
随机推荐
- 08 Oracle表碎片查询以及整理(高水位线)
Oracle表碎片查询以及整理(高水位线) 1.表碎片的来源 当针对一个表的删除操作很多时,表会产生大量碎片.删除操作释放的空间不会被插入操作立即重用,甚至永远也不会被重用. 2.怎样确定是否有表碎片 ...
- Linux下安装 Redis
一.部署前准备 1.首先上官网下载Redis 最新稳定的压缩包 2.通过远程管理工具,将压缩包拷贝到Linux服务器中,执行解压操作 [root@CentOS6 ~]# tar zxvf redis- ...
- 关于Hibernate的部分知识总结
[部分内容参考地址:https://www.cnblogs.com/woniu2219/p/7111857.html] Hibernate Hibernate是一个开放源代码的对象关系映射框架,它对J ...
- mysql学习记录,CASE WHEN THEN ELSE END用法
记mysql,case when then else end用法 用法1:搜索函数 SELECT r.order_no, r.golds, r.pay_tool, , ) ) END AS price ...
- Shell中的${}、##和%%使用范例
假设定义了一个变量为,代码如下: file=/dir1/dir2/dir3/my.file.txt 可以用${ }分别替换得到不同的值: ${file#*/}: 删掉第一个 / 及其左边的字符串:di ...
- es6-----部分新特性详解
ES6(ECMAScript 6)是即将到来的新版本JavaScript语言的标准,代号harmony(和谐之意,显然没有跟上我国的步伐,我们已经进入中国梦版本了).上一次标准的制订还是2009年出台 ...
- python反射怎么用
反射: 通过字符串的形式对 对象 进行增删改查 setattr 设置某个属性的值 class A(object): def __init__(self): self.name = "sath ...
- 在多字节的目标代码页中,没有此 Unicode 字符可以映射到的字符。 (#1113)
报错 在使用MySQL-Front导入sql文件时报错1113:在多字节的目标代码页中,没有此 Unicode 字符可以映射到的字符. (#1113) 解决方案 导入.sql文件时,单击 选择文件对话 ...
- python学习笔记:第12天 列表推导式和生成器
目录 1. 迭代器 2. 推导式 1. 迭代器 什么是生成器呢,其实生成器的本质就是迭代器:在python中有3中方式来获取生成器(这里主要介绍前面2种) 通过生成器函数获取 通过各种推导式来实现生成 ...
- JVM培训序幕篇
明天老王要给我们讲JVM的知识,提前发了一个小Demo给我们看,代码如下: package demo; import java.util.*; public class Demo { public s ...