• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

CMP versus CMT

 
Nath White
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

  •  
    Rama Raghavan
    Ranch Hand
    Posts: 116
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    CMT
    - Transaction in Entity beans are (almost) always Container managed
    - Transactions in Session beans may be bean or container managed
    Rama
     
    Chris Mathews
    Ranch Hand
    Posts: 2712
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Greenhorn
    Posts: 3
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic