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

  • 相关阅读:
    wc 统计程序
    读C#程序
    VS2013 单元测试
    android开发心得之知识的量变到质变
    大学第一篇博客
    团队作业七
    团队作业六
    团队作业五
    团队作业四
    团队作业三
  • 原文地址:https://www.cnblogs.com/foxting/p/9230525.html
Copyright © 2011-2022 走看看