Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cascade-delete Question

 
Gemini Moses
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Mudi Appu
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Gemini Moses:
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?


does it mean bean A has been removed by cascade delete?
[ April 26, 2005: Message edited by: Kanishtha Kramalekhaka ]
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the following example satisfy the question?

Students (many) <-> Courses. (many)

If one student drops out of a course, that course will still return references to other students enrolled for that course.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic