• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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.
 
If a regular clown is funny, then a larger clown would be funnier. Math. Verified by this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic