views:

149

answers:

1

Hi,

I read that EJB 2.x spec does not support nested transactions. But logically think we can call an EJB method that has REQUIRES_NEW txn attribute from another EJB method that acutally started a transaction Isn't this a valid case. If valid isn't this what is called nested transactions.

Please point me if I am missing anything here.

+1  A: 

The REQUIRES_NEW propagation means:

Create a new transaction, suspend the current transaction if one exists.

So the transactions would not be nested - the first one is suspended, shunted out of the way, and a new, unrelated, transaction is started.

You don't really need to nest the transactions themselves, you just need to ensure that each time you pass through a transactional boundary, you inherit the existing transaction (or start a new one). The default propagation PROPAGATION_REQUIRED is generally good enough.

Interestingly, JDBC 3.0 did introduce the concept of nested transactions, but the EBJ spec has yet to catch up.

skaffman