| Author |
CMP entity bean bi-directional / local view
|
Edward Chen
Ranch Hand
Joined: Dec 23, 2003
Posts: 758
|
|
Hi, all, I read a book , it says this "a CMP entity bean can have bi-directional relationship with other entity beans IF AND ONLY IF it provides local component interface " What is its meaning ? Why? let's say, A <----> B has bi-directional relationship, so A should AT LEAST local view, B is same. Am I right? why? Thanks. Edward
|
 |
Seetesh Hindlekar
Ranch Hand
Joined: Feb 13, 2004
Posts: 244
|
|
Hi, Bidirectional relationship means Many-Many relationships. Read EJB specs pdf for EJB 2.0 or 2.1 to get more details. Seetesh
|
 |
Vishwa Kumba
Ranch Hand
Joined: Aug 27, 2003
Posts: 1064
|
|
Originally posted by Edward Chen: "a CMP entity bean can have bi-directional relationship with other entity beans IF AND ONLY IF it provides local component interface " What is its meaning ? Why? let's say, A <----> B has bi-directional relationship, so A should AT LEAST local view, B is same.
A source entity bean X can have a relationship with another target entity bean Y, only if target entity bean Y has local interfaces. In the similar way, if entity bean Y would like to have relationship with X, then X should have local interfaces. Is it confusing?
|
 |
Edward Chen
Ranch Hand
Joined: Dec 23, 2003
Posts: 758
|
|
Hi, I check the spec. In the Page 137, it has "One-to-one bidirectional relationship". in the page 131, it says bidirectional just mean it can navigate both ways. So, I think your point is not right. please correct me. Thanks. Edward
|
 |
Edward Chen
Ranch Hand
Joined: Dec 23, 2003
Posts: 758
|
|
Hi, Vish, thanks for your responses. But why? what about a target bean is in the remote another server ? Thanks Edward
|
 |
Michael D. Brown
Greenhorn
Joined: Nov 22, 2003
Posts: 29
|
|
Originally posted by Edward Chen: Hi, Vish, thanks for your responses. But why? what about a target bean is in the remote another server ? Thanks Edward
That's precisely what the spec is trying to avoid, the overhead of navigating a bi-di relationship over the network. If I use bean X to get an instance of bean Y and make changes, this is trivial to maintain. In a bi-di relationship I can use bean X to get an instance of bean Y and then use bean Y to get an instance of bean X. This is a monster to manage unless the assumption can be made that all of this is being done locally. And that part of the spec allows the EJB container developers to make that assumption. Hope this clears it up for you. Michael ps read my post here to learn why you most likely shouldn't be developing entity beans.
|
 |
Vishwa Kumba
Ranch Hand
Joined: Aug 27, 2003
Posts: 1064
|
|
The spec doesn't allow us to maintain entity bean relationships for remote interfaces, atleast not in ver EJB2.0. for example: We cannot have an OrderEJB running on machine A to have a bi-directional relationship with OrderLinesEJB running on machine B at a different location. I liked this interesting discussion : http://www.theserverside.com/discussions/thread.jsp?thread_id=13664
|
 |
Michael D. Brown
Greenhorn
Joined: Nov 22, 2003
Posts: 29
|
|
If you like that thread, check out my treatise on excluding entity beans from all in house (ie not a packaged app) development right here. [ February 24, 2004: Message edited by: Michael D. Brown ] [ February 24, 2004: Message edited by: Michael D. Brown ]
|
 |
 |
|
|
subject: CMP entity bean bi-directional / local view
|
|
|