• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

BMP Vs CMP

 
kri shan
Ranch Hand
Posts: 1453
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Performane wise which is better BMP / CMP ??
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
kri shan
Ranch Hand
Posts: 1453
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Paul, out of these two which is better?
CMP supports DB portability. BMP supports Application Server portability.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 33691
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
kri shan
Ranch Hand
Posts: 1453
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeanne, instead of re-inventing the wheel, i would like to use existence persistence mechnaism
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33691
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1453
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whether Hibernate, Toplink, OJB, JDO provides all EJB container provided services(Security,Tranasaction,..) other than Persistence?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. But why would you need them in a persitance layer?
 
kri shan
Ranch Hand
Posts: 1453
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. You just call your persistance layer methods from an EJB.
 
steven peh
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 425
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic