EJB CMP 2.0 and Referential Integrity. 2004-10-31 - By Markus Fuchs
Back Hi Vikram,
Having a Many To One relationship between A and B means that the foreign key must be defined in B's table, so removing Entity B has no effect on A's representation in the database. The EJB Spec. defines relationships to be "managed", i.e. the container must remove Entity B from the relationship to Entity A in memory. (See for instance EJB 2.1 Spec, sec. 10.3.7.5).
B's cascadeDelete setting or foreign keys in the database have no influence on this behavior. The container will handle the described situation automatically.
Regards,
-- markus.
"Naik, Vikram ( eBiz Mumbai )" wrote:
> Thanks for your response. > > Thats, true container does take care of cascade delete, but what happens in the following scenario: > > Say we have a Many to One aggregate uni-directional CMR relation between Entity A and Entity B. > > Now, if we try to delete Entity B which is still be referred/ referenced by Entity A, the container just deletes the Entity B. unless we define a foreign key constraint at database level, that would restrict the deletion. > > Can container handle this stiuation, even if we dont defined foreign key constraints at database level ? > Is this something that developer has to take care of ? > > > > -- --Original Message-- -- > From: Guy Katz [mailto:gkatz@(protected)] > Sent: Sun 10/31/2004 7:54 AM > To: J2EE-INTEREST@(protected) > Cc: > Subject: Re: EJB CMP 2.0 and Referential Integrity. > > > > if you use CMR > referential intergrity is a built in part of the game. > depending on the nature of your CMR definition (multiplicity etc..) > the container will take care of it as long as you call your CMR methods. > > > -- --Original Message-- -- > From: A mailing list for Java(tm) 2 Platform, Enterprise Edition > [mailto:J2EE-INTEREST@(protected)]On Behalf Of Naik, Vikram ( eBiz > Mumbai ) > Sent: Saturday, October 30, 2004 7:47 PM > To: J2EE-INTEREST@(protected) > Subject: EJB CMP 2.0 and Referential Integrity. > > > Hello, > > What are the different ways to have referential integrity for your data, > when the persistence is done using EJB CMP 2.0 ? > > We are using database foreign key constraints along with CMR to achieve the > same ? > > Would appreciate all your thoughts on the above. > > Regards, > Vikram. > > ===================================================================== ====== > To unsubscribe, send email to listserv@(protected) and include in the body > of the message "signoff J2EE-INTEREST". For general help, send email to > listserv@(protected) and include in the body of the message "help". >
=========================================================================== To unsubscribe, send email to listserv@(protected) and include in the body of the message "signoff J2EE-INTEREST". For general help, send email to listserv@(protected) and include in the body of the message "help".
|
|