> From: A mailing list for Enterprise JavaBeans development
> [mailto:[EMAIL PROTECTED]]On Behalf Of Jim Archer
> I have been studying the EJB 2.0 spec and some other material I have found
> and I am confused about entity bean relationships in CMP.
>
> It seems clear that I can define a dependant object, such that any eb can
> have a reference to a dependant object and that instances of dependant
> objects can live in their own database tables. Also, these dependant
> objects are removed from the database when the parent object is. This seems
> to me to represent an implementation of composition.
Actually, no. It used to be so, but this part of the specification has been
revised in the latest version. By default, the deletion of a dependent object
will not trickle down to other objects that have a relationship with it,
unless you have specified "cascade-delete" in its deployment descriptor.
Section 9.4.4.2 explains this in details.
> However, what if I want to have an entity bean that has a one-to-one or a
> one-to-many reference to another entity bean? If I have an Emploiee entity
> bean, this bean could have things like Address as a dependant object, but
> what if I want to have a reference to an Office object? The Office object
> represents where the Emploiee works, but many emploiees would work in that
> office and so I don't want the office deleted when the Emploiee is removed.
> What if the Emploiee travles between several offices, so that he or she
> needs a Collection of Office entity bean objects?
I think section 9.4.4.2 addresses this exact question. Note that since deletes
are no longer "cascaded" by default, your graph of dependent objects might end
up with unreachable objects. However, they will only be unreachable through
standard navigation accessors. You will still be able to find them through
EJB-QL.
--
Cedric
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".