在使用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. 开发类似"音速启动"的原创工具简码"万能助手"的过程中对ztree.js与win标准控件treeview、HTMLayout树形框等优缺点的比较

    在开发类似"音速启动"的桌面快捷方式管理软件简码"万能助手"的早期规划中,曾经考虑过几种树形框方案: ztree.js.win标准控件treeview.HTML ...

  2. C++分享笔记:5X5单词字谜游戏设计

    笔者在大学二年级刚学完C++程序设计后,做过一次课程设计,题目是:5X5单词字谜游戏设计.为了设计算法并编写程序,笔者在当时颇费了一番心力,最后还是成功地完成了.设计中不乏有精妙之处.该程序设计完全是 ...

  3. vi模式下的编辑、删除、保存和退出

    vi + 文件名:进入 vi 模式 编辑模式:shift+: 退出编辑模式:Esc 退出编辑模式后可进行光标的上下左右移动(偶尔会出现ABCD,还不知道怎么解决,目前只能出来一个删除一个) 光标处:按 ...

  4. php比较两个数组的差异array_diff()函数

    下面简单介绍php比较两个数组的差异array_diff()函数. 原文地址:小时刻个人技术博客 > http://small.aiweimeng.top/index.php/archives/ ...

  5. 『Python题库 - 填空题』151道Python笔试填空题

    『Python题库 - 填空题』Python笔试填空题 part 1. Python语言概述和Python开发环境配置 part 2. Python语言基本语法元素(变量,基本数据类型, 基础运算) ...

  6. centos配置NTP服务器

    时间服务器: NTP(Network Time Protocol,网络时间协议)是用来使用网络中的各个计算机时间同步的一种协议,NTP服务器就是利用NTP协议提供时间同步服务的. 一.环境准备: 1. ...

  7. Linux C语言编程基本原理与实践

    Linux C语言编程基本原理与实践(2018-06-16 19:12:15) Linux C语言编程基本原理与实践 高效的学习带着目的性: 是什么 -> 干什么 -> 怎么用 重识C语言 ...

  8. java四种访问权限

    java有四种访问权限,它们各自的范围如下图所示 当下列访问修饰符修饰字段和方法时: private 任意位置的子类不可以访问从父类继承的private字段和方法.这里所说的访问包括通过super关键 ...

  9. C++中引用的本质分析

    引用的意义 引用作为变量别名而存在,因此在一些场合可以代替指针 引用相对于指针来说具有更好的可读性和实用性 swap函数的实现对比: void swap(int* a, int* b) { int t ...

  10. VMWare虚拟机的网络类型配置选择详解

    VMWare虚拟机网络有三种类型,当然还有最后一种类型就是“不使用网络连接”,哈哈....... VMWare在安装会有让选择网络类型的选项,如果不确认使用那一种网络类型,也可以先随便选择一种网络类型 ...