See this link: When does @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) commit?
How can B be the correct answer? I would thought that a method annotated with REQUIRES_NEW would commit before the outer, suspended transaction, continues.
I'm asking about this because I have seen strange behaviors when it comes to transactions started with requires_new from another bean in a for-loop. Like if Aby calls bob in a for-loop. If one of these transactions is rolled back because of, for example a UniqueConstraintViolation, HSQLDB and db2 intermittently rolls back also the previous transactions, and intermittently only the transaction failed, and commits the others. And the behavior only changes when I restart my jboss. When a transaction fails and I get the behavior where also the previous transaction rolls back I also get a jdbcException: Connection closed in the next call from the loop. So, first I wonder about the expected behavior of requires_new. I'm using Hibernate, jboss 5, CMT, db2 and an in-memory HSQLDB(I've tried both 1.8 version and 2.2.9) Thank You!
So I found that this was the reason for the strange behavior
jboss ignores requires_new after restart
And in the link:
When does @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) commit?
the alternative a is the correct answer so it's the wrong answer in that post.