aspose file tools*
The moose likes Performance and the fly likes BMP    Vs    CMP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "BMP    Vs    CMP" Watch "BMP    Vs    CMP" New topic
Author

BMP Vs CMP

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1382
Performane wise which is better BMP / CMP ??
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Both are bad.

BMP of course requires you to write the actual persistance code, so it could be better, or it could be worse. Who knows. Depends how you write it.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1382
HI Paul, out of these two which is better?
CMP supports DB portability. BMP supports Application Server portability.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


HI Paul, out of these two which is better?


This is a unhelpful answer I know, but I'd say neither. Both are bad.

Any answer to your question will be very subjective - there are situations where one might be better than the other and viceversa.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30973
    
159

Kri,
Why are BMP and CMP the only two options. If CMP does not perform acceptably, you have to write code yourself. Then you are better off using some other persistance mechanism behind a session facade.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1382
Hi Jeanne, instead of re-inventing the wheel, i would like to use existence persistence mechnaism
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Then why not use an persistance mechanism other than Entity Beans? Hibernate, Toplink, OJB, JDO etc. are all better than Entity Beans.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30973
    
159

Originally posted by kri shan:
Hi Jeanne, instead of re-inventing the wheel, i would like to use existence persistence mechnaism

I agree completely. Note that while BMP provides a persistance framework, you still end up writing most of the code yourself. I think it is really between CMP and one of the technologies Paul listed.


CMP supports DB portability. BMP supports Application Server portability.

This implies that CMP is not portable across app servers. You have to regenerate the deployed code, but it isn't inheritently unportable. That said, I would go with Hibernate if I was starting a new project, could choose and didn't need the security/transaction/scalability support of CMPs.
kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1382
Whether Hibernate, Toplink, OJB, JDO provides all EJB container provided services(Security,Tranasaction,..) other than Persistence?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

No. But why would you need them in a persitance layer?
kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1382
If i use Hibernate, Toplink, OJB, JDO, i have to use EJB container provided services / i have to write the code for Tr,Security... Hence one more extra layer/tier comes here ( Tr Layer + Persistence Layer). Whether is it a good design ?
This is my doubt.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

No. You just call your persistance layer methods from an EJB.
steven peh
Greenhorn

Joined: Sep 25, 2002
Posts: 5
Its seems to a lot of ppl are confused and seem to think that BMP means EJB + handwritten SQLs. It does not.

BMP just means EJB + manual persistence, whether i handwrite the SQL or use an OR Mapping tool (hibernate, ibatis, custom made, etc). If you use hibernate from your EJB, then you still get CMT provided by the app server plus the nifty OR Map provided by hibernate, so its a win win.

Here's where we typically apply the DAO pattern. So if one day you feel like switching from hibernate to handwritten SQLs or some other OR solution, just implement a new DAO to wrap that and plug it in. Your EJBs working on the DAO interface wont even know you switched implementation and the container could care less, it calls your EJBs with whatever txn attribute you declared and commit/rollback/resume/etc the txn after your ejb method completes.

Cheers.
Rahul Juneja
Ranch Hand

Joined: Aug 03, 2002
Posts: 425
Infact what is suggested is you can use the persistence layer of Hibernate and call those methods from a Stateless Session bean and there you can put your transaction attributes also.

Cheers,
Rahul


Rahul Juneja
ThoughtClicks - http://techlabs.thoughtclicks.com
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: BMP Vs CMP