当Spring批量尝试提交记录时,我正在获取提交失败,而步骤执行数据已经更新错误。任何帮助将不胜感激。 我正在使用HIbernate JPA。
它适用于较少数量的记录。记录计数很高时抛出错误。
堆栈追踪:
2016-01-20 08:49:45 INFO TaskletStep:359 - Commit failed while step execution data was already updated. Reverting to old version.
2016-01-20 08:49:45 ERROR TaskletStep:370 - Rolling back with transaction in unknown state
2016-01-20 08:49:45 ERROR AbstractStep:225 - Encountered an error executing step uploadFiles in job fileUploadJob
org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Transaction marked as rollbackOnly
at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:524)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:757)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:726)
答案 0 :(得分:1)
我遇到了同样的错误“步骤执行数据已更新时提交失败。恢复为旧版本”,我通过在提交记录的方法上方使用“ @Transactional(propagation = Propagation.REQUIRES_NEW)”注释解决了该错误。