This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am noticing one problem after calling setRollbackOnly method. here is the scenario. ================================= SomeBean bean1; initialize etc.. ...
_ctx.setRollbackOnly();//_ctx is entity Context in this example. throw new MyException("Exception info..."+bean1.getMethod1()); ===================================
The throws clause is failing to execute bean1.getMethod1() after the roll back method. Where as if I move bean1.getMethod1() to above roll back method and pass the result of bean1.getMethod1() as a variable (someData) in throws clause, it works. Below is the working code. ===================================== SomeBean bean1; initialize etc.. ...
String someData = bean1.getMethod1(); _ctx.setRollbackOnly(); throw new MyException("Exception info..."+someData); =========================================
My guess is that getMethod1() is defined with CMT REQUIRED, REQUIRESNEW or MANDATORY, requiring that a valid transactional context be available. Since you've marked the context for rollback only, it cannot continue the transaction. Perhaps REQUIRESNEW is okay since it will suspend the current transaction to start a new one for that method.
This is a guess; I've been lucky to not come across that, and now we've moved to Spring + Hibernate.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com