我在刷新时收到以下休眠错误消息。我在 for 循环中进行迭代,从数据库中获取对象修改它并在每次迭代中保存对象。它不会对前 20 条记录给出任何错误。对于下一条记录,它会引发以下错误。有什么建议么 ?谢谢 !
WARN [main] (org.hibernate.util.JDBCExceptionReporter:233) - SQL Error: -803, SQLState: 23505
错误 [main] (org.hibernate.util.JDBCExceptionReporter:234) - DB2 SQL 错误:SQLCODE: -803, SQLSTATE: 23505, SQLERRMC: 3;REFERN.METHODOLOGY ERROR [main] (org.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) 在 org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2594) 在 org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java: 2476)在 org.hibernate.persister.entity.AbstractEntityPersister。update(AbstractEntityPersister.java:2803) at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:113) at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273) at org.hibernate.engine.ActionQueue .executeActions(ActionQueue.java:265) 在 org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:185) 在 org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321) 在 org.hibernate。 event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216) at 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)