identifier of an instance of bean was altered from 1 to 2(持久化物件ID變更)
阿新 • • 發佈:2018-12-29
今天遇到個怪問題,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,問題解決。希望對大家有幫助