zoukankan      html  css  js  c++  java
  • Hibernate乐观锁无法Catch到org.hibernate.StaleObjectStateException

    Hibernate乐观锁无法Catch到org.hibernate.StaleObjectStateException时,请Catch HibernateOptimisticLockingFailureException 试一下

    catch (HibernateOptimisticLockingFailureException e)
    {
            e.printStackTrace();
            if (((Exception) e.getMostSpecificCause()) instanceof StaleObjectStateException)
            {
                   e.getMostSpecificCause().printStackTrace();
            }
    }
    

      

    Judging from the stacktrace, I'd say that it is the second explanation. The original exception has been caught and a HibernateOptimisticLockingFailureException has been created that wraps it. It is the latter exception you are seeing.

    If you want to specifically handle the original exception, you probably need to catch HibernateOptimisticLockingFailureException (or a superclass), and then call the exception object's getMostSpecificCause() to extract the original exception for diagnosis.

    地址:https://stackoverflow.com/questions/30236145/not-able-to-catch-org-hibernate-staleobjectstateexception

  • 相关阅读:
    ansible语法
    hadoop本地模式安装及配置
    linux免密钥登录
    ansible配置文件
    ansible(安装)
    elasticsearch基本概念
    elasticsearch基本概念
    elasticsearch倒排索引介绍
    Flex tree展开节点问题!
    Oracle-Trigger-Insert tableA and tableB
  • 原文地址:https://www.cnblogs.com/foxting/p/9230525.html
Copyright © 2011-2022 走看看