Announcement Announcement Module
Collapse
No announcement yet.
Can not catch exception ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can not catch exception ?

    I have code like below,when Line 4 has a StaleObjectStateException, it will give me 11 22 44. It will be same as when there is NO exception.

    But what I want is when there is an exception, output will be 11 33.

    Please help. Thanks.

    Code:
       1. public Case updateCase(Case thisCase) throws Exception{           
       2.         try {  
       3.             System.out.println("11");  
       4.             this.getHibernateTemplate().update(thisCase);   // throw RuntimeException: org.hibernate.StaleObjectStateException  
       5.             System.out.println("22");  
       6.         } catch (Exception e) {  
       7.             System.out.println("33");  
       8.           
       9.             throw e;  
      10.         }  
      11.           
      12.         System.out.println("44");  
      13.           
      14.       
      15.         return thisCase;          
      16.     }

  • #2
    Use the search this question has been answerend numerous times before.

    Transaction is committed AFTER the method has ended so not INSIDE your method.

    Comment

    Working...
    X