This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hello Support, I have control in the designer for one-to-many associations over whether cascading deletes should occur (Persistence: IsDependent). Is there similar cascading delete control for one-to-one associations ? Some explanation of how they behave when deleted (with reference to source and target) would be useful. Cheers, Simon. |
|
|
One to one associations behind the scenes are treated as a special type of one to many where there is only ever one child in the many collection. If the association is set to be not nullable it will enforce a delete of the other entity. However that said the FK is only actually set on one side of the association so this is the side which will trigger this behaviour (as it is the parent in the relationship). The way to check this is to look at the underlying schema to check which table has the FK column.
|
|
|
Hi Jeremy, Thanks for the prompt reply. I now have my one-to-one relationships set up correctly for cascading deletes. One issue left - I have a one-to-one relationship where the child is optional (ie. cardinality 0..1). If the child is present then it should be deleted when the parent is deleted. I implemented this as a private one-to-many (for the cascading delete that handles 0 or 1 children), with a public property handling the singleton nature of the collection. Is there a better way to get a cascading delete for a 0..1 relationship ? |
|
|
Hi Simon, If the relationship is not nullable (e.g. childs parent FK is not null) or the IsDependant attribute is specified on the association then a cascade delete will be triggered.
|
|