Showing posts with label Transaction. Show all posts
Showing posts with label Transaction. Show all posts

EJB Transaction


Bean Type
Container-Managed
Bean-Managed
JTA
JDBC
EntityYNN
SessionYYY
Message-drivenYYY

JEE Transaction

2 types of transactions:
a. Container-managed transactions
b. Bean-managed transactions

Table 14-1 Transaction Attributes and Scope 
Transaction Attribute Client's Transaction Business Method's Transaction
Required None T2
T1 T1
RequiresNew None T2
T1 T2
Mandatory None error
T1 T1
NotSupported None None
T1 None
Supports None None
T1 T1
Never None None
T1 Error

Mandatory vs Never
NotSupported vs Supports
@TransactionAttribute(NOT_SUPPORTED)
@Stateful
public class TransactionBean implements Transaction {
...
    @TransactionAttribute(REQUIRES_NEW)
    public void firstMethod() {...}
 
    @TransactionAttribute(REQUIRED)
    public void secondMethod() {...}
 
    public void thirdMethod() {...}
 
    public void fourthMethod() {...}
}