• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

CMR question

 
Jim Janssens
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following question:

- Two entity beans: BeanA and BeanB, in a one to one undirectional relationship with each other
- Two references: ba1 and ba2, to instance of BeanA and two references, bb1 and bb2, to instance of Bean2. ba1 is linked to bb1 and ba2 is linked to bb2

give the statement that will make sure that: ba2.getBean2() == null

My answer was: ba2.setBean2(null)
However, the correct answer appears to be: ba1.setBean2(ba2.getBean2())

----

First I was typing the 'correct' answer, but then I was thinking: it has a side effect so I changed it. If you go with the correct answer the requirement ba2.getBean2() is fullfilled, but the ba1 lost its reference to bb1, its now referencing bb2. So my solution does 100% what is asked to be done, while the correct answer does more.

Anyway, why is my answer wrong ? Technically this is correct no ?

The only place where null is not allowed is with CMR that require a collection (you should then pass an empty collection).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic