Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HF-EJB cmr confusion

 
Chris Stokes
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Looking at the entity bean relationships chapter in the head first ejb book I have a question concerning the MovieBean/Director example.
In the MovieBean instead of mapping the directorId db field to an abstract getter/setter it has used a cmr field for director so you can link to the Director bean instead of just the db foreign key id. This is great, but I'm just wondering when you create a new MovieBean (and a new row in the db), the ejbPostCreate method is called (where you call the setDirector with the corresponding Director entity) how the db will know to insert the directorId from the DirectorBean into the newly created Movie db row (giving it the correct fk).
Hope this is clear, not overly sure if its clear in my head to be honest!!
Thanks
Chris
 
Anthony Watson
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Director entity bean will know what its primary key is. The container can simply call the getPrimaryKey method on the Director entity to set the movie table's fk.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic