We can call getStatus of UserTransaction to know the status and see if we should do commit or rollback.
... and to avoid execution of a lot of code if the transaction is already deemed to death.
What happens when we call commit after doing setRollbackOnly on UserTransaction?
Even if it would be a bit stupid (but it is often instructive to
test stupid things

) should it work if the setRollbackOnly in UserTransaction just only modifies the flag for getStatus() and the container not care of that flag.
But IF the container care of that flag would an error occur and in that case, would it not be enough to just skip the call of rollback()? But with bean managed transactions is it the bean that has to manage the transaction and my guess is therefore that the container not care and that it would be an error to not call rollback() because that would leave the method with an open transaction. And I therefore also think it would work with a call to commit() instead of rollback() despite it would be somewhat stupid.
But someone that really know about this are welcome to confirm what is true according to bean law!
[ June 21, 2007: Message edited by: Jonny Andersson ]