在使用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的更多相关文章

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

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

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

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

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

    原先跑TEST CASE的时候没有出错 但是跑到整个程序里面,除了这个问题, 网上也找了下资料,说是用merge之类的可以解决,因为你这个update的obj和session里面的不用,所以导致此问题 ...

  6. 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"?> ...

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

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

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

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

随机推荐

  1. Zabbix——自动发现

    前提条件: Zabbix版本为4.0 固定网段寻找网络设备,并添加组.添加模板.添加proxy. 设置完毕,等待~~ 如果没有问题,将会直接出现在host中.

  2. js函数和window对象

  3. Linux中Zookeeper部署和集群部署

    自己网上下载安装包,我下载的是tar.gz安装包直接解压,也可以下载rpm格式 1.下载zookeeper安装包,放到/usr/local/zookeeper安装包网上下载 2.解压文件tar -zx ...

  4. vue的监听键盘事件的快捷方法

    在我们的项目经常需要监听一些键盘事件来触发程序的执行,而Vue中允许在监听的时候添加关键修饰符: <input v-on:keyup.13="submit"> 对于一些 ...

  5. UEditor代码实现高亮显示

    在公司开发一个论坛系统,由于用的是UEditor(百度编辑器),单独使用的话,里面的代码不会高亮,网上找了很多,最后决定使用 highlight.js 实现代码高亮显示.效果如下: 这个是我修改其他的 ...

  6. Docker学习——gitlab部署

    Gitlab 下载镜像 docker pull hub.c.163.com/gutenye/gitlab-ce:latest 查看镜像 docker images 启动容器 宿主机和docker的端口 ...

  7. 最小生成树——Kruscal(克鲁斯卡尔算法)

    一.核心思想 ​ 将输入的数据由小到大进行排序,再使用并查集算法(传送门)将每个点连接起来,同时求和. ​ 个人认为这个算法比较偏向暴力,有些题可能会超时. 二.例题 洛谷-P3366 题目地址:ht ...

  8. 安装cuda9.0+cudnn v7+python3.5.3+tensorflow

    本机设备 windows10 gtx1060 安装软件及下载地址 python-3.5.3-amd64  链接:https://pan.baidu.com/s/1I3oIDatMgvDLEtaPtvu ...

  9. NoSQL入门第五天——Java连接与整合操作

    一.测试联通 1.新建个web工程 2.导入jar:当然实际使用的时候肯定是通过maven来构建(如果有机会,可以尝试学习gradle进行构建) 3.建个测试类:好久没开eclipse了,希望后面可以 ...

  10. c++中string (MFC)

    题目:UVALive - 6439    https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid= ...