• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HF EJB question 4 on page 426

 
Li Xin
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone explain why option B is correct? Since the relationship is uni-directional, how come we can go from Bar to Foo by calling b2.getFoo()?
Thanks.
 
Anthony Watson
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that the question contains a mistake and that you shouldn't be able to call b2.getFoo() on the Bar bean because if you don't have a cmr-field-name of Foo for the Bar bean, then you should not have an abstract method getFoo() for the Bar bean.
 
Maggie Leber
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm glad somebody elss agrees with me on this one. I'm going to report it to booktech@oreilly.com, because it's still not in the official errata list.
 
Christopher Arthur
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I remember this one. I agree with you, too.
 
Walk Rustin
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer is correct. Don't let the unidirectional thing blurry your judgement. Look at the cardinality. A bar can have atmost only one foo.
After the operation, f2 is connected to b1.
If B is a wrong answer ( which is not) then b2 is still connected to some foo. What foo is that? The operation has left both f1 and b2 without any partner.
Hope it helps.
- walk rustin
 
Van Nguyen
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Walker,
Can you elaborate? I currently, agree with everyone else that there is no method b2.getFoo() since it is unidirectional but would like to hear more of your arguement.
Are u saying there is a be.getFoo() which returns the comp object for Foo? If so, how do you account for the relationship being unidirectional?
-Van
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic