This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes CMP Entity Beans Vs BMP Entity Beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "CMP Entity Beans Vs BMP Entity Beans" Watch "CMP Entity Beans Vs BMP Entity Beans" New topic
Author

CMP Entity Beans Vs BMP Entity Beans

Asuthosh Borikar
Ranch Hand

Joined: Sep 29, 2000
Posts: 75
When is it appropriate(rather, the only choice) to use a BMP Entity Bean as against a CMP Entity Bean? We have a table which also has a child table. For each row in the parent table, there will be one or more rows in the child table. If I want to develop an entity Bean for the parent table, can I use a CMP Bean? Is it possible to depict this relation correctly, using the Deployment Descriptors, according to EJB1.1? Please help. Thanks!
Jim Baiter
Ranch Hand

Joined: Jan 05, 2001
Posts: 532
If you have more than one table involved you need to use BMP
or if your database supports updateable views you could use
CMP and create a view to reference.
Asuthosh Borikar
Ranch Hand

Joined: Sep 29, 2000
Posts: 75
Thanks Jim. That's what I thought, but wanted to confirm my thoughts.
svoropay
Greenhorn

Joined: Feb 19, 2001
Posts: 2
It is a common misconception to think that CMP is limited to only one-table database schemas. Yes, with CMP you can map your bean to only one database table/view, but doesn't necessarily mean that you are limited to one-table schemas.
Matt Midcap
Sheriff

Joined: Jan 07, 1999
Posts: 440
svoropay,
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please choose a new name which meets the requirements.
Thanks,
Matt


Best Regards,<br />Matt Midcap
Michael Hildner
Ranch Hand

Joined: Oct 13, 2000
Posts: 297
Dear svoropay,
Would you please provide and example or online resource that explains how to use CMP with more that one table?
Thank you,
Michael
Sergei Voropay
Ranch Hand

Joined: Feb 20, 2001
Posts: 31
It is hard to come up with any good online resource on this topic, but a very good printed resource would be "Enterprise Java Beans 2d Ed." by Richard Monson-Haefel. A whole section called "Entity beans relationships" in chapter 9 is devoted to this topic, where the author suggests a few possible ways of dealing with relationships between EJBs.
Regards,
Sergei
Asuthosh Borikar
Ranch Hand

Joined: Sep 29, 2000
Posts: 75
Sergie,
I've read that topic from Richard's book. He does specify the CMP way of dealing with relationships between EJBs, but he also states that UNLESS your App.Server supports Object-to-Relational data mapping, the only way of dealing with many-to-one relationships is to use BMP. I just wanted to make sure that this issue is cleared out, and that I've understood that book correctly. Your comments are welcome. Thanks!
Sergei Voropay
Ranch Hand

Joined: Feb 20, 2001
Posts: 31
It looks like people have mixed opinions on this topic. Some say it is ok to mimic one-to-many relationships with CMP ejbs through bean references, some say that it's too costly and inefficient in terms of performance and alternative solutions (o/r mapping) should be used. I'm a supporter of the former approach considering the benefits CMP provides even if I have to sacrifice some performance. For small to medium complexity database schemas involving one-to-many relationships, mimicking the relationships between beans through references is very easy -- just extend the concept provided in the book to collections of objects. Here is a little example on one-to-many relationships between CMP ejbs from the Borland web site: http://www.borland.com/techpubs/books/appserver/appserver40/examples/ejb/pigs/README.html.
sarah00
Greenhorn

Joined: Feb 27, 2001
Posts: 5
Sergei,
That web site is not exist anymore, do you know the
correct one?
Thanks a lot,
Sarah
Matt Midcap
Sheriff

Joined: Jan 07, 1999
Posts: 440
Hi "sarah00",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp .
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please choose a new name which meets the requirements.
Thanks.
George Toronto
Ranch Hand

Joined: Dec 30, 2000
Posts: 78
http://www.borland.com/techpubs/books/appserver/appserver40/examples/ejb/pigs/README. html
But this sample is not object of the discussion, right?
[This message has been edited by George Toronto (edited March 04, 2001).]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: CMP Entity Beans Vs BMP Entity Beans
 
Similar Threads
Doubt in Composite Entity
Entity Beans must use CMP?
Writing test case without database operations
BMT with Entity beans
Can I map single table to different Entity Bean?