• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

bmp v/s cmp

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
I would like to know when one should use container managed persistence and when to use bean managed persistence.And the advantages of one over the other.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by saahil sinha:
Hi ,
I would like to know when one should use container managed persistence and when to use bean managed persistence.And the advantages of one over the other.


CMP gives you a lot of things for free--you don't need to write SQL, you don't need to manage database connections, etc.
On the other hand, if you need more complicated queries that CMP's Query Language (EJB-QL) cannot be bent to, then it's probably better to use raw JDBC or BMP. With BMP, you get life-cycle management for free but you need to write all database access code yourself.
 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Read this atricle:
http://dev2dev.bea.com/articles/334.jsp
[ July 07, 2003: Message edited by: Vinod John ]
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the real question is why someone would ever want to use BMP. The benefits of using CMP are very clear: persistance for free.
I've always liked this quote from Bruce Tate in his book Bitter Java:
My first question when I saw I could create entity beans with bean-managed persistance was, "Why would I?" Isn't that like ordering a hamburger without the meat? "Yes, I'm ready to order. I'll have a persistence framework, hold the persistence."
In my opinion there is no good reason to use BMP. They offer nothing over a simple Session Facade + JDBC.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

In my opinion there is no good reason to use BMP. They offer nothing over a simple Session Facade + JDBC.


Unless you count consistency. I haven't personally encountered a need to use BMP but I could imagine a situation where you'd like to preserve a degree of consistency among your persisted domain objects (i.e. the same API for all domain objects, which are either CMP or BMP). Does this "consistency" sound like a valid rationale for using BMP instead of raw JDBC?
 
Vinod John
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One reason we used BMP is because we needed a bean to represent fields in multiple database tables and our app server didn't support that. Those where pre 2.0 days, but with EJB 2.0 that is very little to vindicate the use of BMP.
 
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
BMPs, though much vilified, could prove useful where the relational database has been derived from a legacy application and there is a need to write a nice object layer over it.
In these instances, often a design nightmare, is to achieve the right object to relational mapping. where such design constraints do not allow for proper CMP design ( although, i must admit this argument is more tilted towards those who are in EJB1.1, which I suspect plenty still are), BMP provides the vehicle to obtain objectisation of a relational schema.
 
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If CMPs are so useful, why do we have DAOs coming into picture now... ?
As your app gets more and more complex, you will slowly move away from CMPs...to BMPs or even just plain SLSBs..
Usage of Entity Beans is fraught with problems, if not used wisely.
Consider a finder method, which returns just a few objects... your database size grows, and before you know , your finder method returns 10,000 objects.... and there goes away your performance and memory...out.
 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If stored procedures are used you will have to go for BMP.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
BMP is also useful if you are using a non RDBMS data store like LDAP, for example, where a DAO is pretty essential.
 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jitender,
if your findAll() is returning 10,000 objects; can we write our own finder method that will return selective subsets of data rather than 10,000 ? Displaying 10,000 records is not feasible. Does EJBQL (EJB2) support some sort of filtering syntax e.g. LIMIT in postgresql or TOP in Transact-sql. ?
Gavin
 
Pradeep bhatt
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It doesn't support but not sure that if any app server supports this as an proprietary feature.

Originally posted by Gavin Bong:
Jitender,
if your findAll() is returning 10,000 objects; can we write our own finder method that will return selective subsets of data rather than 10,000 ? Displaying 10,000 records is not feasible. Does EJBQL (EJB2) support some sort of filtering syntax e.g. LIMIT in postgresql or TOP in Transact-sql. ?
Gavin

 
Let me tell you a story about a man named Jed. He made this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic