It's an issue a collegue of mine entered some times ago (HBI-31). But it
wasn't well explained (and initially wasn't talking about hibernate 2 so
don't even read it, it will makes things harder to explain).

But anyway. I'm talking about the fact that hibernate is causing constraint
violations if a foreign key is not null.
(Very important note section 6.4 in the documentation)

Sometime we need to remove a valid integrity constraint to prevent this.
I understand that when you remove an object from a collection, since the
object is not related to any parent anymore, that the foreign key should be
set to null.
But when you have a containment relation and so a all-delete-orphan cascade,
it will never happen that objects will stay in the database having a null
foreign key.

But you still need to remove the constraint because hibernate consider the
all-delete-orphan only at the end of the flushing process.
So first all foreign keys are set to null and then all objects in the
collection are deleted.
This could be optimized by seeing there's an all-delete-orphan and so by
deleting the contained objects directly.

But now we have a delete cascade, so I just guessed that since all objects
will be deleted by the DB in one shot, that I won't have my constraint
problem anymore. Am I right?

I don't know if I made myself clear.
I can provide a test case if needed (and continue the discussion in the
forum which is probably a more appropriate place I think).

Sorry to have made you jump a little,
Henri

----- Original Message ----- 
From: "Christian Bauer" <[EMAIL PROTECTED]>
To: "Henri Tremblay" <[EMAIL PROTECTED]>
Cc: "hibernate-devel" <[EMAIL PROTECTED]>
Sent: Thursday, July 22, 2004 12:07 AM
Subject: Re: [Hibernate] support for ON CASCADE DELETE


>
> On Jul 21, 2004, at 10:42 PM, Henri Tremblay wrote:
>
> > Does this remove the hibernate limitation on nullable foreign keys?
> > (that
> > foreign keys of collections need to be nullable even if there is a
> > cascade
> > all-delete-orphan). If yes, great! If no, still great! (but I'll be
> > back on
> > this issue).
>
> What? There is no Hibernate limitation like this.
>
> -- 
> Christian Bauer
> +49 171 455 66 53
>
> Hibernate
> [EMAIL PROTECTED]
> http://hibernate.org
>
> JBoss Inc
> [EMAIL PROTECTED]
> http://jboss.com
>
>


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to