• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

HFEJB - question page 426 - # 4.

 
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
4 - Give the container-managed unidirectional relationship:

Foo(0-1) --> Bar (0-1)

And the object relations:

F1 --> B1
F2 --> B2

What will be true after the following code returns (Choose all)

f2.setBar(f1.getBar());

A - f1.getBar() == null
B - b2.getFoo() == null
C - b1.getBar() == null
D - none of the above

OK, here are my comments:

C - wrong - it does not make sense since b1 has getFoo() instead of getBar().

D - wrong, because A is correct and makes sense!

At last, my question is about letter B.

- Why b2.getFoo() istn't equals to null since the b1 Bar object took its place over ?

Tks in advance!!
 
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It will be null? A and B are the correct answers.
 
Steven Colley
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI Amol!!

Right...in my point of view the both A and B would be correct!

A - f1.getBar() == null
B - b2.getFoo() == null

I was taking a look at the HFEJB errata, and i can see this:

[426] q4, ANSWER C;
--> b1.getBar() = null should be b1.getFoo() - right it makes sense and that's correct too!!

BUT anyway...in my understanding the option B and A are still correct since the relationship between these objects are one to one bidirectional and the B2 reference would receive null after having F2 assigning B1, right?

Please...help us on this!!!

Tks in advance!! ;-)
 
Steven Colley
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no one?
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Felipe
I believe the answer should only be A as the relationship is unidirectional so the bar does not know anything about the foo it won't have a CMR feild getfoo() defined in the bar bean class..

Let me know if i am wrong..
 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Felipe,

I totaly agree with your understanding.
Even I think both A and B options are correct,
as the relationship is given one to one from both the side. So once b1 is assigned to f2,both f1 and b2 will loose there earlier assignments(because of the given one to one relationship) and become null.
[ September 10, 2007: Message edited by: Neetika Sood ]
 
Awishek sinha
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But this is unidirectional one to one relationship .. so in this case bar does not know anything about foo so i think it won't have a getfoo() cmr feild defined in bar bean class.
 
neetika sharma
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Awishek,

I think you have analysed it correctly. Statement is clearly telling, that it is a unidirectional one to one relationship.
Then, in this case both the B and C option will give errors.

Thanks for clarifying:-)
 
The government thinks you are too stupid to make your own lightbulb choices. But this tiny ad thinks you are smart:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic