2012-08-07 79 views
0

我正在接收低於hibernate的錯誤消息,同時flush.I在for循環中迭代,從DB獲取對象修改它並在每次迭代中保存對象。它不會爲前20條記錄提供任何錯誤。對於下一個記錄,它會拋出錯誤。有什麼建議麼 ?謝謝 !休眠錯誤無法在刷新時同步數據庫狀態與會話

WARN [main] (org.hibernate.util.JDBCExceptionReporter:233) - SQL Error: -803, SQLState: 23505 

ERROR [主要](org.hibernate.util.JDBCExceptionReporter:234) - DB2 SQL錯誤:SQLCODE:-803,SQLSTATE:23505,則sqlerrmc:3; REFERN.METHODOLOGY ERROR [主要](有機.hibernate.event.def.AbstractFlushingEventListener:324) - 無法使數據庫狀態與會話同步 org.hibernate.exception.ConstraintViolationException:無法更新:[com.MethodologyDO#1396] at org.hibernate.exception.SQLStateConverter.convert (SQLStateConverter.java:96) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java VA:2594) 在org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2476) 在org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2803) 在org.hibernate作爲。 action.EntityUpdateAction.execute(EntityUpdateAction.java:113) 在org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273) 在org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:265) 在org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:185) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321) at org.hibernate.event.def.DefaultFlushEventListener.onFlush( DefaultFlushEventListener.java:51) 在org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216) 在org.springframework.orm.hibernate3.HibernateTemplate $ 28.doInHibernate(HibernateTemplate.java:892) 在org.springframework.orm.hibernate3.HibernateTemplate .doExecute(HibernateTemplate.java:419) at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374) at org.springframework.orm.hibernate3.HibernateTemplate.flush(HibernateTemplate.java:890)

回答

1

谷歌搜索SQLState中提到的錯誤導致我到以下頁面:http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/core/r0sttmsg.htm

獨特的約束被打破。您試圖插入/更新數據,並且兩行最終在具有唯一約束的列中具有相同的值。

+0

其實唯一的約束被刪除。但我仍然得到這個錯誤。後來發現該列有一個唯一的索引。當我刪除它時,它很有用。 – Harish 2012-08-07 20:13:52