This is a migrated thread and some comments may be shown as answers.

[Solved] On Cascade Delete

1 Answer 85 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Panji
Top achievements
Rank 1
Panji asked on 07 Mar 2011, 10:01 AM
Hi All, I have some beginner questions. Apologize if these have been discussed before or the information can be found easily in the online help.

  1. Is it still necessary to use DBMS' on cascade delete option for foreign key, given that I am using OpenAccess and there is a Depend attribute to set it at ORM level?
  2. What will happen if I use DBMS' on cascade delete option for foreign key without using Depend attribute? My guess is there will be objects in OA's cache/scope without the corresponding entry in database. 

TIA for your anwers.


1 Answer, 1 is accepted

Sort by
0
Ady
Telerik team
answered on 08 Mar 2011, 11:52 AM
Hi Panji,

  1. The 'Depend' attribute has a slightly different meaning than CASCADE DELETE,depending on it's usage. Consider a simple example - A 'Person' with an 'Address' reference. If the 'Depend' attribute is applied on the 'address' reference field, when the 'Person' instance is deleted, OpenAccess will try and delete the referenced 'Address' instance also. In case you have a collection of 'Person' instances in the 'Address' class (call it, 'residents'), if you apply the 'Depend' attribute to the collection field and delete an 'Address' instance, all the referencing 'Person' instances will be deleted - similar to the CASCADE DELETE on the database.
  2. In case the CASCADE DELETE is specified on the datbase, you are right, there would be instance in the OpenAccess cache that would have no corresponding row in the database. You would need to evict the object from the scope and the 2nd Level Cache (if it is enabled) explicitly.

Best wishes,
Ady
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
General Discussions
Asked by
Panji
Top achievements
Rank 1
Answers by
Ady
Telerik team
Share this question
or