identifier of an instance of Object is altered from 2 to 5
来源:互联网 发布:淘宝文翼多论文怎么样 编辑:程序博客网 时间:2024/06/07 18:24
HibernateJava
Hibernate的提示错误
Caused by: org.hibernate.HibernateException:
identifier of an instance of ... is alterde from 1 to 5
是下面这段代码报的错
这个错误是由于在一个事务中更新了主键,而主键是不能被更新的.
这段代码的错误在Object obj= new Object ();
这句代码放在for循环的外面,因此每次循环插入的时候,Hibernate认为只是一个对象,主键被更新,因此报错,如果放在for循环里面,就正常了,每次插入都是一个新的对象.
正确的代码如下
Caused by: org.hibernate.HibernateException:
identifier of an instance of ... is alterde from 1 to 5
是下面这段代码报的错
- public void insertRelation(Object obj,List list1)
- {
- Object obj= new Object ();
- for (int i = 0; i < list1.size(); i++)
- {
- service.insert(obj);
- }
- }
public void insertRelation(Object obj,List list1){Object obj= new Object ();for (int i = 0; i < list1.size(); i++) { service.insert(obj);}}
这个错误是由于在一个事务中更新了主键,而主键是不能被更新的.
这段代码的错误在Object obj= new Object ();
这句代码放在for循环的外面,因此每次循环插入的时候,Hibernate认为只是一个对象,主键被更新,因此报错,如果放在for循环里面,就正常了,每次插入都是一个新的对象.
正确的代码如下
- public void insertRelation(Object obj,List list1)
- {
- for (int i = 0; i < list1.size(); i++)
- {
- Object obj= new Object ();
- service.insert(obj);
- }
- }
- identifier of an instance of Object is altered from 2 to 5
- identifier of an instance ...... altered from ** to **
- identifier of an instance of was altered from to null
- identifier of an instance of was altered from to null
- 关于identifier of an instance of Object was altered from 6 to 6异常解决问题
- identifier of an instance ... altered from num1 to num2
- 异常:identifier of an instance of cn.ebank.pojo.News was altered from 2 to 2;
- identifier of an instance of XXX was altered from 75
- org.hibernate.HibernateException: identifier of an instance of XXX was altered from X to X
- org.hibernate.HibernateException: identifier of an instance of XXX was altered from X to X
- merge对比引发的identifier of an instance of entity was altered from .. to ..报错
- identifier of an instance of com.you.hibernate.model.TStudentInfo was altered from 6 to 7
- org.hibernate.HibernateException: identifier of an instance of XXX was altered from X to X
- identifier of an instance of .. altered to null ---- hibernate exception
- EJB3 Exception:identifier of an instance of net.model.entity.Role was altered from 2 to 0
- identifier of an instance of bean was altered from 1 to 2(持久化对象ID变更)
- identifier of an instance was altered from XXXX to XXXX解决
- identifier of an instance of com.jh.oa.bpm.model.JhBpmFormdata was altered from 266 to 267
- ICMP报文
- CSDN新版下载频道介绍之三——用户权限及积分规则详解
- form的提交时检验
- Ubuntu10.04自带Document Viewer看中文PDF的问题解决
- Flash/Flex中旋转文字,但不嵌入字体的研究
- identifier of an instance of Object is altered from 2 to 5
- js和php的异步传输
- vc6.0 打开文件的时候出现Microsoft Visual C++:MSDEV.EXE 应用程序错误
- 第一个设备驱动hello
- union all和union
- 提交表单的数组形式单元值
- Windows 7 快捷键大全 (转载收藏一下)
- 多级反向代理[Squid]下获取客户端真实IP地址
- VMware安装Mac调整分辨率