Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

how cascade delete works?

Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lets take Movie and Director entities from HF book.

This has many-one relationship(from Movie to Director) and Movie bean has set cascade-delete in DD. If we take this picture on database, DirectorId will be the FK in Movie table.

My question is if i call remove method on Director entity bean, how the deletion actually works? The spec says(Page:132)
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 in container-managed relationships for which the cascade-delete option was specified.

Doest it mean, first Director entity will be deleted and then all its associated Movies will be deleted?But, how this is possible?Unless and until all referred Movies are deleted a particular Director bean cannot be deleted.

Need comments, pls.

Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I don't have a definitive answer but from my reading of the spec I think it means as you mention that the Directory entity bean will be deleted followed by associated Movie entity beans.
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

You have to remember that they are two steps performed by the container when deleting an entity bean i.e. Entity Bean relationship is removed followed by the persistent representation. The container maintains the relationships, so you have to think of it a little different then if you where writing the SQL to remove data directly.
One other thing though � it could be a container implementation on the sequences of data been removed !!! In any case the spec have outlined the outcome from calling entity bean or its accessor method after a cascade-delete.
I hope this helps ��
keep an eye out for scorpions and black widows. But the tiny ads are safe.
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic