|
|
Can not catch exception ?
I have code like below,when Line 4 has a StaleObjectStateException#65292; 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(quot;11quot;); 4. this.getHibernateTemplate().update(thisCase); // throw RuntimeException: org.hibernate.StaleObjectStateException 5. System.out.println(quot;22quot;); 6. } catch (Exception e) { 7. System.out.println(quot;33quot;); 8. 9. throw e; 10. } 11. 12. System.out.println(quot;44quot;); 13. 14. 15. return thisCase; 16. }Use the search this question has been answerend numerous times before.
Transaction is committed AFTER the method has ended so not INSIDE your method. |
|