File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes CMP vs. BMP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "CMP vs. BMP" Watch "CMP vs. BMP" New topic
Author

CMP vs. BMP

Shubhashis Dasgupta
Greenhorn

Joined: Jul 27, 2001
Posts: 9
Can anybody tell me when to use CMP and when to use BMP. If u can give a real example it will be helpful.
Thnx.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15632
    
  15

It's largely a matter of preference. CMP's require less coding, and thus less debugging, but they are limited in what you can supply as far a selection criteria. BMP's allow you to do things like post-SQL filtering and creating finders which return ordered enumerations of beans. On the downside for BMP's, you're coding raw SQL directly into the bean code, and that makes the program code more or less dependent on what brand of DBMS you're using.
I understand that no few people are prefer to work exclusively with BMP's. I usually do CMP unless I know I need the extra power. Since the client can't tell which I'm using, if it turns out I'm wrong, all I have to do is refactor the bean.


Customer surveys are for companies who didn't pay proper attention to begin with.
Shubhashis Dasgupta
Greenhorn

Joined: Jul 27, 2001
Posts: 9
Thnx Tim. But is there any design issue like for a single functionality, can mix CMP & BMP beans. Or will there be any transcation related problem if within a transactional context, two setter methods of separate CMP & BMP beans are called? Can we use declarative transaction attribute or isolation level in case of BMP just like CMP?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15632
    
  15

From a client side, you should be able to use them interchangably. If you're referring to a situation where different types of beans are representing the same items in a table, you shouldn't depend on the EJB server to maintain database integrity - it only guarantees interactions between the beans themselves - EJBs actually aren't required to even USE a DBMS for their persistent store.
I've learned to my great pain that it's never good to have more than one path to update anything - it can be extremely frustrating when you have to figure out which one's clobbering info (or worse, when they interact in unforseen ways). For that reason, I try to delegate to a common object.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: CMP vs. BMP
 
Similar Threads
CMP vs BMP
One WHIZLabs Question
EJB 1.1 Vs EJB 2.0 Question
CMP Vs BMP Which one is better
BMT with Entity beans