identifier of an instance of bean was altered from 1 to 2(持久化对象ID变更)

今天遇到个怪问题,hibernate修改外键id时出现:

org.springframework.orm.hibernate3.HibernateSystemException: identifier of an instance of xx altered from 2677 to 2672; 
nested exception is org.hibernate.HibernateException: identifier of an instance of com.yongjun.tdms.model.CustomerRelationship.contactArchives.ContactArchives altered from 2677 to 2672

Caused by: org.hibernate.HibernateException: identifier of an instance of xx altered from 2677 to 2672
	at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:51)
	...
	at java.lang.Thread.run(Thread.java:619)


结果在网上看到大神的解决方法

引用:

应该是缓存导致,save前先clear()试试
dao.clear();
dao.save(entity);

自己加了个:

	public void storeContractAdditionalInfo(ContractAdditionalInfo ai){
		super.getHibernateTemplate().clear();//加的清缓存
		super.store(ai);
	}

ok,问题解决。希望对大家有帮助

                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值