简体   繁体   English

org.springframework.orm.hibernate4.HibernateOptimisticLockingFailureException

[英]org.springframework.orm.hibernate4.HibernateOptimisticLockingFailureException

When running the getsession.update(data) getting below error; 运行getsession.update(data)以下错误;

org.springframework.orm.hibernate4.HibernateOptimisticLockingFailureException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

Please help me resolve the issue. 请帮助我解决问题。

issue is occuring becouse batch update supposed to update atlest one row, but it did not update any row. 发生问题是因为批处理更新应该更新至少一行,但没有更新任何行。 becouse your are trying to update row that row is deleted, so batch update is not updating the row and throwing exception. 因为您正在尝试更新该行,所以该行被删除,因此批量更新不会更新该行并抛出异常。

From documentation: 从文档:

public class StaleStateException extends HibernateException 公共类StaleStateException扩展了HibernateException
Thrown when a version number or timestamp check failed, indicating that the Session contained stale data (when using long transactions with versioning). 当版本号或时间戳检查失败时抛出,表明会话包含陈旧数据 (当使用带有版本控制的长事务时)。 Also occurs if we try delete or update a row that does not exist . 如果我们尝试删除或更新不存在的行,也会发生这种情况
Note that this exception often indicates that the user failed to specify the correct unsaved-value strategy for a class! 请注意,此异常通常表明用户未能为类指定正确的未保存值策略!

So, check: 因此,请检查:

  1. Does updating entity exist in a DB? 数据库中是否存在更新实体?
  2. Are there any modifications of the entity which may make it stale? 是否对实体进行过任何修改以使其过时?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法在服务或外观层中捕获 org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException - not able to catch org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException in Service or Facade Layer org.springframework.orm.hibernate4.annotation.AnnotationSessionFactoryBean - org.springframework.orm.hibernate4.annotation.AnnotationSessionFactoryBean Spring 4 + Hibernate 5 = org.springframework.orm.jpa.EntityManagerHolder无法转换为org.springframework.orm.hibernate5.SessionHolder - Spring 4 + Hibernate 5 = org.springframework.orm.jpa.EntityManagerHolder cannot be cast to org.springframework.orm.hibernate5.SessionHolder org.springframework.orm.hibernate3.HibernateTemplate是纯休眠还是JPA实现? - org.springframework.orm.hibernate3.HibernateTemplate is pure hibernate or JPA implemenation? ClassCastException:org.springframework.orm.jpa.EntityManagerHolder无法强制转换为org.springframework.orm.hibernate5.SessionHolder - ClassCastException: org.springframework.orm.jpa.EntityManagerHolder cannot be cast to org.springframework.orm.hibernate5.SessionHolder 哪个JAR包含org.springframework.orm.hibernate.HibernateTransactionManager? - Which JAR contains org.springframework.orm.hibernate.HibernateTransactionManager? 创建bean org.springframework.orm.hibernate4.HibernateTransactionManager时出错 - error while creating bean org.springframework.orm.hibernate4.HibernateTransactionManager 无法初始化类 org.springframework.orm.hibernate5.LocalSessionFactoryBuilder - Could not initialize class org.springframework.orm.hibernate5.LocalSessionFactoryBuilder org.springframework.orm.hibernate3.HibernateSystemException:未知实体 - org.springframework.orm.hibernate3.HibernateSystemException: Unknown entity 带有查询的org.springframework.orm.hibernate4.HibernateQueryException(Spring mvc) - org.springframework.orm.hibernate4.HibernateQueryException with Query (Spring mvc)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM