• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

HF-EJB cmr confusion

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic