On 22 Oct 01, at 14:42, Dain Sundstrom wrote:

> > I think, you are right .. should have read the spec more 
> > deeply .. but 
> > this restriction implies, that foreign keys must never have a 
> > "NOT NULL" 
> > constraint. I wonder, if that was an intended behaviour?!

Hi guys,

You can have "not null" foreign keys in EJB 2.0 persistence. The 
trick is to defer the insert into the database as allowed in 10.3.5:

"The container may create the representation of the entity in the 
database immediately, or it can defer it to a later time (for example 
to the time after the matching ejbPostCreate<METHOD>(...) has 
been called, or to the end of the transaction), depending on the 
caching strategy that it uses."

If you defer the insert, you can have enough information to set the 
foreign key during that insert. The MVCSoft Persistence Manager 
supports all three strategies (insert after ejbCreate, insert after 
ejbPostCreate, and insert at transaction completion), and also will 
allow "not null" foreign keys to represent relationships (currently 
only with the "insert at transaction completion" strategy).

-Dan



_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to