File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes CMP versus CMT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "CMP versus CMT" Watch "CMP versus CMT" New topic

CMP versus CMT

Nath White

Joined: Feb 18, 2003
Posts: 3
I understand what Container/Bean Managed Persistence are about, but what are Container/Bean Managed Transactions?
According to the Whizz Labs tests, CMP and CMT are different things.
Additionally, it seems to suggest that CMT might be necessary even if no data is being persisted. What kind of transaction is required if there is no data persistence??
Shankar Ranganathan
Ranch Hand

Joined: Sep 19, 2001
Posts: 71
I will tell in you short what is CMT.
When it is CMT all your commits and rollback are taken care of by container or in other words you don't have to explicitly write commit and rollback,in the case of bmt you have to do that.
My suggestion you can thru the ejb spec or edroman book for further details

Shankar<br />Post mock questions in<br /><a href="" target="_blank" rel="nofollow"></a>
Ajith Kallambella

Joined: Mar 17, 2000
Posts: 5782
CMP - Container Managed Persistence
  • Entity beans are mapped to tables using mapping tools provided by the container.
  • Container takes care of generating SQL statements and persisting bean state to database.
  • Programmer will not implement ejbLoad() and ejbStore().
  • No fine-grained control over SQL statements.
  • Rapid development, heavy deployment activities.
  • Alternative - BMP - Bean Managed Persistence.

  • CMT - Container Managed Transaction(s)
  • Where a bean method is transaction enabled in the deployment descriptor, container takes care of initiating, propagating, commiting and rolling back the transaction.
  • Alternative - BMT - Bean Managed Transaction(s).
  • Uses Java Transaction Service(JTS)
  • Programmer will not use explicit JTA transaction calls in the code.
  • Less error prone compared to BMT.

  • Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
    Rama Raghavan
    Ranch Hand

    Joined: Aug 22, 2001
    Posts: 116
    - Transaction in Entity beans are (almost) always Container managed
    - Transactions in Session beans may be bean or container managed
    Chris Mathews
    Ranch Hand

    Joined: Jul 18, 2001
    Posts: 2712
    Originally posted by Rama Raghavan:
    - Transaction in Entity beans are (almost) always Container managed

    Actually, there is no almost about it. Entity Beans will always be CMT.
    Section 17.3.1 of the EJB 2.0 Specification
    An Entity Bean must always be designed with container-managed transaction demarcation.
    Nath White

    Joined: Feb 18, 2003
    Posts: 3
    Actually, there is no almost about it. Entity Beans will always be CMT.

    In EJB 1.0, session and entity beans can both be BMT.
    In EJB 1.1, only session beans can be BMT.
    In either case only beans set to have BMP can declare BMT. (both persistence and transaction must be declared at the bean level rather than method level)
    phew! Thanks for the pointers guys. When I first read about it in my EJB book I didn't see the distinction, but it all makes sense now.
    It is sorta covered in the JavaRanch Style Guide.
    subject: CMP versus CMT
    It's not a secret anymore!