Skip to content

CMT vs BMT

December 15, 2010

Container Managed Transaction (CMT)

  • annotation:  @TransactionManagement(TransactionManagementType.CONTAINER)
  • automatically begins and commits transactions based on declarative metadata provided by the bean developer (all the logic for synchronizing the bean’s state with the database is handled automatically by the container)
  • supports the following transactions attributes:
    • Required: TransactionAttributeType.REQUIRED (bean’s method invocation is made within a transactional context. If a client is not associated with a transaction, a new transaction is invoked automatically.)
    • RequiresNew: TransactionAttributeType.REQUIRES_NEW (a method is invoked in a new transaction context.)
    • Mandatory: TransactionAttributeType.MANDATORY ( if a transactional context exists, a Container acts like the transaction attribute is Required, else it throws a javax.ejb.TransactionRequiredException.)
    • NotSupported: TransactionAttributeType.NOT_SUPPORTED (transaction context is unspecified)
    • Supports: TransactionAttributeType.SUPPORTS (if a transactional context exists, a Container acts like the transaction attribute is Required, else – like NotSupported.)
    • Never: TransactionAttributeType.NEVER (a method executes only if no transaction context is specified.)

Bean Managed Transactions:

  • Uses the javax.transaction.UserTransaction methods begin and commit to demarcate transactions. (the bean-provider is responsible for ensuring that a transaction is started and committed when appropriate)
  • Only session and message-driven beans may use BMT
  • A stateless session bean instance must commit any transactions that it started before a business method or timeout callback method returns.
Advertisements

From → EJB, JAVA

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: