posted 20 years ago
HFEJB entity bean relationships chapter-
Page 432
5. If an entity bean A has been removed from a relationship with bean B, in which case(s) will bean A's accessor method for bean B return a non-null value?
ANswer is -
Many to Many
The answer tells you to refer to Spec 132.
10.3.4.2 Cascade-delete
The cascade-delete deployment descriptor element is contained within the ejb-relationship-
role element. The cascade-delete element can only be specified for an ejb-relationship-
role element contained in an ejb-relation element if the other
ejb-relationship-role element in the same ejb-relation element specifies a multiplicity
of One. The cascade-delete option cannot be specified for a many-to-many relationship.
The deletion of one entity object can only be cascaded to cause the deletion of other entity objects
if the first entity object is in a one-to-one or one-to-many relationship with those other entity objects.
If an entity is deleted, and the cascade-delete deployment descriptor element is specified for a
related entity bean, then the removal is cascaded to cause the removal of the related entity object or
objects. As with the remove operation, the removal triggered by the cascade-delete option
causes the container to invoke the ejbRemove() method on the entity bean instance that is to be
removed before the persistent representation of that entity object is removed. Once an entity has been
removed from a relationship because of a cascaded delete, the accessor methods for any relationships to
the entity will reflect this removal. An accessor method for a one-to-one or many-to-one relationship to
the entity will return null; and an accessor method for a many-to-many relationship to the entity will
return a collection from which the entity object has been removed. After removing the entity object
from all relationships and removing its persistent representation, the Container must then cascade the
removal to all entity beans with which the entity had been previously been in container-managed relationships
for which the cascade-delete option was specified.
My question is,
If cascade delete can not be specified for Many-to-Many relationship, how is the answer for this question Many -toMany
Thanks,
Gemini
[ April 01, 2005: Message edited by: Gemini Moses ]