0

As per Spec, EJB doesn't support nested transactions, so what I wanted to know is, assume there are 2 classes (Parent and Child). Parent call is a stateless session bean and Child is a plain vanilla java service (not an EJB). Since EJB's by default use Container Managed Transaction, does adding @TransactionAttribute(REQUIRED_NEW) annotation in the method in Child cause a new Transaction to be created or is simply ignored by the container?

Shan
  • 521
  • 2
  • 8
  • 28

1 Answers1

0

Nested transactions, not supported by JEE, have an active relation between the outer and the inner (nested). According to Wikipedia they are "implemented differently in different databases", so cannot find a common definition or a set of common behaviors. Many databases do not even support them.

What JEE/EJBs do is (quoting from EJB spec v3.2, ch. 8.6.3.4, emphasis mine):

If a client calls with a transaction context, the container suspends the association of the transaction context with the current thread before starting the new transaction and invoking the business method. The container resumes the suspended transaction association after the business method and the new transaction have been completed.

Nikos Paraskevopoulos
  • 39,514
  • 12
  • 85
  • 90