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
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "CMP vs BMP" Watch "CMP vs BMP" New topic
Author

CMP vs BMP

Rahul Devgan
Greenhorn

Joined: Aug 04, 2004
Posts: 24
Hi All,
I have a design related question.
When should one go for CMP and whn should one for BMP? Many authors suggest using CMP only with EJB2.0 but are there situations when design considerations should force us to use BMP. I know of one such situation, where in we have a legacy DB service and our vendo server provider does not support pesistence on that service. There we have to manag persistence on our own using BMP.

Are there other situations also, which demand use of BMP and CMP, even when using RDBMS which all server vendors support or any other situation?


Rahul Devgan<br />SCJP<br />--- one must be willing to let go of small pleasures in life to achieve greater things ---
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


When should one go for CMP and whn should one for BMP? Many authors suggest using CMP only with EJB2.0

A glib answer would be: never use BMP and use CMP only in very rare occasions. I'd not use Entity Beans pre EJB2.0 full stop (no local interfaces == unnecessarily slow performance). As is said often in these forums (and more often than not by me) you might want to consider other persistance strategies than Entity Beans.
[ November 08, 2004: Message edited by: Paul Sturrock ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Rahul Devgan
Greenhorn

Joined: Aug 04, 2004
Posts: 24
Thanks for the reply. Other persistence startegies that i know off:
1. JDO Implementations like Hibernate
2. Direct persistence from Session beans, if one is not too bothered about working in relational world then purely OO world.

Are these what you were refering too or you had something else in mind, please share the same.

Also, if the choice is between CMP and BMP, what should be the choice especially for complex SQLs and multi table SQLs?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


JDO Implementations like Hibernate

Well, Hibernate is not a JDO implementation but that's the sort of thing I'd suggest. Any good ORM technology will be better than Entity Beans.

BMP is probably your only option if you want beans spaning multiple tables (thoug has I remember, there are venodor-specific CMP implementations which can handle multitable CMP - I'm not sure though, someone might shout me about that).
Rahul Devgan
Greenhorn

Joined: Aug 04, 2004
Posts: 24
Thanks again for correcting me there and for initiating me on a trail...
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

if you want beans spaning multiple tables


You could consider creating a view that joins multiple tables and map your entity bean to the view.


Groovy
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

A word of warning about that approach: you may well end up forcing your entity bean to be read only - since you have to be careful how you create your view to make it an updateable view (i.e. no set operators, can't use distinct, no group aggregate functions, no group by clause, no subquery in a select list, no join queries etc.).
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Originally posted by Paul Sturrock:
A word of warning about that approach: you may well end up forcing your entity bean to be read only - since you have to be careful how you create your view to make it an updateable view (i.e. no set operators, can't use distinct, no group aggregate functions, no group by clause, no subquery in a select list, no join queries etc.).


Agreed but I think it is rare case where set operators,distinct etc would be used.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: CMP vs BMP