2012-08-07 74 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