In one scenario, I'm using EJB 3 SSB's talking to a JDBC layer to insert and read data. I'm using the default Transaction attribute which it Required on the SSB. Now when and how could my transaction rollback? I want the transaction to rollback when my JDBC inserts throw an SQLException. What I have to do is catch the SQLException in my JDBC layer and rethrow a RuntimeException which will propogate to my Session Bean. Would this suffice for the transaction to rollback?
So is the above one just enough for the transaction to rollback in case of an SQLException?
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
If MyRuntimeException isn't declared as application exception, this will lead to a rollback. However, I don't think this is a good solution in general, because the bean instance will be discarded and pre destroy methods aren't executed. Using setRollbackOnly() in myMethod seems to be a better alternative to me.
So if the Container discards the bean instance (for a Stateless session bean) what happens to the instance pool of Stateless beans the Container maintains? would it be recreated? or how does the Container manages such a situation?