• 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

EJB2.0 CMP - with a BMP cmr field

 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can an EJB2.0 CMP entity bean have a CMR field that is a BMP entity bean and vice-versa?
 
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vish,
I don't see any reason for preventing you of doing that. BMP vs CMP is a question of implementation, while CMR fields refer to a component interface, where the distinction BMP vs CMP doesn't exist. Moreover, BMP and CMP entity beans are compatible at the implementation level too : same interface implemented, same callbacks (even the ejbCreate() BTW).
Regards,
Phil.
 
Cowgirl and Author
Posts: 1589
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy -- unfortunately, you cannot have a CMR relationship with a BMP bean... a CMR relationship means demands that *both* sides of the relationship are managed by the Container, so there's just no way you can do it. Although as Phillipe said, a CMR field is the component interface of an entity bean, and there's nothing in that interface that explicitly makes it a CMP vs. BMP bean, Bean Law (i.e. the spec rules) insists that one bean can have a relationship only with other CMP beans.
Unless the Container is "in charge" of both sides of the relationship (and it doesn't really matter if it is uni- or bi-directional), it would not be able to maintain referential integrity, or handle things like cascading deletes.
So, just remember that CMR = Container-Managed Relationship and Container-Managed Relationship means you MUST use Container-Managed Persistence on BOTH sides of the relationship. Both partners must use CMP.
The Container is a control freak
Now, that doesn't mean that you can't mix and match CMP and BMP beans in an app--only that they can't be in an official CMR relationship with one another.
cheers,
Kathy
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Kathy ! You just made one more demonstration of the big difference between knowing a bit and mastering...
What's nice on this forum is that even when the exam is behind you, you still learn a lot !
Best,
Phil.
 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Kathy and Phillipe,
Another good thing about this forum is, I can expect replies on a Sunday evening too...

Cheers,
Vish
reply
    Bookmark Topic Watch Topic
  • New Topic