posted 17 years ago
I am a little confused on the answer to the following question from this book.
Given 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 runs?
f2.setBar(f1.getBar());
a.) f1.getBar() == null
b.) b2.getFoo() == null
c.) b1.getBar() == null
e.) none of the above
Here is my thought process:
I understand this to mean..
Foo (0-1) -> Bar (0-1)
For Foo, it can have zero or 1 bar.
For each Bar, it can have zero or 1 foos.
AKA here is my table structure.
FOO TABLE
Foo PK, Foo Num, Bar PK (can be null)
Bar Table
Bar PK, Bar Num, Foo PK (can be null)
I understand this to mean..
f1->b1
f2->b2
F1 has a bar(called 1)
F2 has a bar(called 2)
So if this code is called
f2.setBar(f1.getBar());
You will have
F1 has a bar(called 1)
F2 has a bar(called 1)
What I am missing is where does it say that each bar has a foo?
The answer by the way is A
I think I just don't understand the syntax of the question. Any ideas on how I should read this?
If you build a man a fire, you warm him for a day. But if you set a man on fire, you warm him for the rest of his life.