- ACID
- Put all transactions in your EJBs (not in servlets)
- Container or Bean Managed (default in Seam)
- Container-managed-transactions (CMTs) preferred in Java EE. The Java EE container will handle comitting, rolling back, starting the transaction, etc. (no coding for the transactions).
- 6 types of transactions to choose from (default is REQUIRED)
- MANDATORY
- REQUIRED
- REQUIRES_NEW
- SUPPORTS
- NOT_SUPPORTED
- NEVER
- Example: Set this annotation before a method to use a transaction independent of an already-active transaction. Will attempt to commit in the end of the method.
@TransactionAttribute(Transacti
onAttributeType.REQUIRES_NEW)
public void addUser(User user) {
em.persist(user);
} - Bean-managed transactions (BMTs) allows a much more fine-grained control of transactions. (It is recommended to not use BMTs unless you cannot achieve the goals you are looking for using the CMT option.
This blog, as so many others is basically for me to keep and share ideas and solved problems. I can probably say that the context of this blog will be about 80% programming, 10% other related IT stuff and 10% nonsens. I have found it nice to have the possiblity to share ideas and help out with problems that I have bumped into.
Friday, September 14, 2007
Transactions (EJB3)
Transactions in EJB3 and Seam
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment