This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Why we cannot assign the persistent relationship field in ejbCreate() ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Why we cannot assign the persistent relationship field in ejbCreate() ?" Watch "Why we cannot assign the persistent relationship field in ejbCreate() ?" New topic
Author

Why we cannot assign the persistent relationship field in ejbCreate() ?

Steven Gao Song
Ranch Hand

Joined: Oct 02, 2006
Posts: 78
Hi, Buddies,

I have a problem when I am reading the HFEJB Page 396.

It is said that we must NOT try to reference our own persistent
RELATIONSHIPS in ejbCreate(). But,it is safe to assign the persistent relationship field in ejbPostCreate().

I cannot understand that.

In ejbCreate() method, the container will use the persistent fields to make
the new row in the database. For the CMR field, there should be a
corresponding foreign key field in the row. Why, the foreign key field cannot be inserted into the row, together with the other persistent fields?


Thanks a lot!
Ugender Rekulampally
Ranch Hand

Joined: Nov 14, 2005
Posts: 130
Steven,

the row will be inserted in the database after ejbCreate() finishes. So while you are in ejbCreate(), you still dont have data that you are trying to refer. but that row/data will be available in ejbPostCreate() method.

Thanks,
Ugender
 
 
subject: Why we cannot assign the persistent relationship field in ejbCreate() ?
 
Similar Threads
When is "DirectorId" column populated for new movie record?
When does a CMR get inserted
ejbActivate in cmp entity bean
Question: HFEJB p.400 : Don't map DirectorID column
Part of foreign key in primary key