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.
If I'm inside a transaction context and call two methods after each
other that have TransactionAttributeType.REQUIRED specified and the
first one of which throws an exception: the second one cannot be called
anymore even if you handle the exception from the first one.
Apparently when the exception is thrown from the first one, it closes
the transaction it is in, which is the enclosing transaction, i.e. the
transaction the enclosing method, t() runs in. In my opinion this is not
correct, but as I cannot change JTA, the question is more like: is there
TransactionAttributeType.REQUIRES_NEW is not really an option, because
that would mean that if t1() doesn't throw an exception, it will commit
the changes it has made to the DB immediately when it returns, which is
obviously not what I want. (Which would be to run t() in a big
transaction that commits if and only if t() didn't throw an exception.)