Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Entity bean relationship

 
Jack Lau
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

The following question is copied from Head first EJB.

Q) If an entity bean A has been removed from a relationship with bean B, in which case(s) will bean A's accessor method for bean B return a non-null value ? (Choose all that apply)

A. one-to-one
B. many-to-one
C. many-to-many
D. all of the above
E. none of the above

Answer is C only.

Could anyone tell me why B is not correct ?

Thanks,
Jack
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jack Lau:
Could anyone tell me why B is not correct ?


Note that the answer to Q5 on page 432 of HFEJB also refers you
to page 138 of the EJB 2.0 specification for clarification.

10.3 The entity bean provider´┐Żs view of container-managed persistence
10.3.7 Assignment rules for relationships
10.3.7.2 One-to-one unidirectional relationships

An A has a relationship with only a single B in a many-to-one relationship.

So if an A is removed from its one and only B then "A's accessor for bean B" returns null. Its the B that may have many more "other" A's.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic