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

  • 相关阅读:
    Spring Boot日志管理
    JProfiler
    JProfiler学习笔记
    jprofiler安装图解
    方便!C++ builder快捷键大全
    QuickFix/N简介
    QuickFIX/N入门:(三)如何配置QuickFIX/N
    java自带线程池和队列详细讲解
    SQLYog快捷键大全
    DBCP连接池配置参数说明
  • 原文地址:https://www.cnblogs.com/foxting/p/9230525.html
Copyright © 2011-2022 走看看