• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Entity bean relationship

 
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
 
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!