• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

CMR doubts (Head first EJB)

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a doubt about CMR example (Page 396, Head First EJB, MovieBean code).
Movie bean has a CMR field directorID. In the relational database schema, directorID is a foreign key in the Movie table. ejbCreate method in Movie bean takes directorID as a parameter but it is not set using abstract CMP methods being a CMR field. If a record is inserted in Movie table by container after completion of ejbCreate, is directorID attribute for that record set to null? What if there is a NOT NULL constraint on directorID column of the Movie table?
The setDirector is called during ejbPostCreate to link the Movie Bean with the Director Bean at this point who is responsible for updating the foreing key(Movie.directorID) in the underlying database?
If a client gets a reference to an existing Movie bean by calling a finder method, how does container establish the link between Movie and Director bean since directorID is not being supplied from client in this case?

thanks
Devendra
 
Devendra Inamdar
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am still waiting on this. Anyone?
regards,
Devendra
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Devendra,
 
Hemavathy Viswanathan
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Devendra,
To answer the 2nd part of your question: how does the container establish the link between the Movie bean and the director bean? This is the answer:

The whole point of having the CMR field (Director) in the Movie bean should answer your question. Container managed relationship fields are those that explain how the two beans are associated to each other.
 
He does not suffer fools gladly. But this tiny ad does:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic