OpenAccess ORM supports dependent references. That is, if the referencing instance is deleted then the dependent, referenced instance is also deleted. This is often called as cascading deletes. This feature must be used with caution as OpenAccess ORM does not check for other references to the deleted referenced instances. If there are other references to the deleted dependent references, at best you will get an exception when you commit the transaction (e.g., if there is a constraint). Or worse, the transaction will succeed and you will get errors when you later attempt to traverse a reference to a deleted instance.
Cascading deletes are disabled by default and are only enabled for references specified as dependent, by adding the [OpenAccess.Depend] attribute to the referenced persistent class.
In the following example, the Address reference in Employee is specified as dependent. So, the referenced Address instance is deleted when Employee instance is deleted:
public class Employee
private Address address;
. . .
Public Class Employee
Private address As Address
In case of maps, for dependent referenced value object(s) and referenced key object(s), the dependent and keys-dependent metadata extension entries are added to the App.config file.
The <delete-orphans> extension is a class level extension (See delete-orphans) for one-to-many relationships implemented using an inverse foreign key (for e.g. the Order and OrderLine classes in the One-to-many Mapping section). If <delete-orphans> is true for a child class OrderLine then any instance that ends with a null Order reference (parent) when a transaction is committed is deleted. This is very useful when the child class can have more than one parent class. All the parents must be null before it is deleted.