Win a copy of Practice Tests for OCP Java 17 Certification Exam (1Z0-829) this week in the OCPJP forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

EJB unidirectional CMR

 
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
How should I implement unidirectional relationship? Let's say I have this kind of relationship (btw from page 432):
Foo (0-1) -> Bar (0-1)
Do I have to have CMR fields in both Foo and Bar? If so then what does "unidirectional relationship" means in terms of implementation? Or maybe the only difference is I do not put Foo accessor methods into Bar class remote(or local) interface(s). In that case... does it makes any difference is it unidirectional or bidirectional to container?
My best regards
 
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vladas,
The <cmr-field> element is optional. To describe a unidirectional relationship, you simply define a <cmr-field> in *only one* of both <ejb-relationship-role> elements.
Best,
Phil.
 
Bartender
Posts: 3768
39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Vladas,
Let's look at relationship Customer-HomeAddress.
Customer must know his/her address, but Address does not need to know anything about it's customer.
Here is the piece of DD for this relationship:

It was taken from SCBCD Study Guide web-site.
As you can see, Address definition does not have cmr-field element. This means, Address have no idea about customer (the relation is unidirectional)
This and much-much more you can find there
Cheers!!!
 
Vladas Razas
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks !
And likewise if I don't have CMR field it means I do NOT put abstract setter/getter for it
Nice site Mikalai! Now I see that bean with only remote interface may only have unidirectional relationship from one side.
My best regards
 
Mikalai Zaikin
Bartender
Posts: 3768
39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Now I see that bean with only remote interface may only have unidirectional relationship from one side.


yeah, you are absolutely right, bean with only Remote interface
can have [unidirectional] relationship to other bean (with local interface), but nobody can access it in CMR.

 
It is no measure of health to be well adjusted to a profoundly sick society. -Krishnamurti Tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic