On Tue, Jan 20, 2009 at 05:39, Wolverine <[email protected]> wrote:
>
> Gaetan de Menten pisze:
>> On Mon, Jan 19, 2009 at 14:14, Wolverine <[email protected]> wrote:
>>
>> This is only a guess since you don't produce quote the failing model,
>> but I suspect you are using 'ondelete' on the OneToMany relationship
>> instead of the ManyToOne. Yes, it's confusing: ondelete should be used
>> on the ManyToOne side, while cascade="xxx" is usually defined on the
>> OneToMany side...
>>
>>
> Oh. I get it. Thanks for the answer. But for me and I believe for other
> inexperienced users it is really counter-intuitive that "ondelete"
> should be on ManyToOne instead of OneToMany. Why is it so?

Because they are very different concepts: ondelete is something that
acts on definition of the ForeignKey constraint on the database. Since
the foreign key column and constraint is on the table of the Entity on
the ManyToOne side, it only makes sense to define ondelete there.

cascade="xxx" is an ORM behavior and basically configures what actions
on the local object (updates, deletes, ...), should be also done on
the linked objets. In this case, you want that when you delete a post,
its children are deleted too, not the other way around, hence you need
to specify the cascade on the OneToMany side.

> Also. I have done as you have said and there are no more errors
> regarding ondelete, but I'm still getting this "delete-orphan" error.

Not sure on this one. Maybe delete-orphan is incompatible with
passive-deletes. I don't really know. I'd have to test this but I
don't have time right now.

> Any ideas what may be causing it? I have not changed anything in this
> Post table, except for adding ondelete='cascade' to ManyToOne relationship.

-- 
Gaƫtan de Menten
http://openhex.org

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SQLElixir" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to