RE: [Hibernate] support for ON CASCADE DELETE

2004-07-21 Thread Joe Shevland

 Sounds like a nice and performant feature.
 
 By doing this we are now skipping/ignoring the LifeCycle stuff on
 these objects, correct ?
   
 
 Nope, all semantics are preserved. This *only* optimizes away the delete 
 statements.

Perfect :) Sorry for the other post, just sent as these arrived.

Cheers,
Joe


---
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=4721alloc_id=10040op=click
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


Re: [Hibernate] support for ON CASCADE DELETE

2004-07-21 Thread Henri Tremblay
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).

Henri

- Original Message - 
From: Gavin King [EMAIL PROTECTED]
To: hibernate-devel [EMAIL PROTECTED]
Sent: Wednesday, July 21, 2004 6:32 AM
Subject: [Hibernate] support for ON CASCADE DELETE


 I've implemented support for ON DELETE CASCADE foreign key
 definitions for parent/child associations (ie. for inverse
 one-to-many).

 You map this like:

 set name=children inverse=true cascade=all
 key name=PARENT_ID on-delete=cascade/
 one-to-many class=Child/
 /set

 So, when the Parent instance is deleted, Hibernate
 does not need to perform n+1 deletes; instead, we
 leave that to the database to take care of.

 Any comments?

 -- 
 Gavin King
 +61 41 053 4454
 +1 404 822 8349

 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=4721alloc_id=10040op=click
 ___
 hibernate-devel mailing list
 [EMAIL PROTECTED]
 https://lists.sourceforge.net/lists/listinfo/hibernate-devel



---
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=4721alloc_id=10040op=click
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


Re: [Hibernate] support for ON CASCADE DELETE

2004-07-21 Thread Christian Bauer
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=4721alloc_id=10040op=click
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


Re: [Hibernate] support for ON CASCADE DELETE

2004-07-21 Thread Henri Tremblay
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=4721alloc_id=10040op=click
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


[Hibernate] support for ON CASCADE DELETE

2004-07-20 Thread Gavin King
I've implemented support for ON DELETE CASCADE foreign key
definitions for parent/child associations (ie. for inverse
one-to-many).
You map this like:
set name=children inverse=true cascade=all
   key name=PARENT_ID on-delete=cascade/
   one-to-many class=Child/
/set
So, when the Parent instance is deleted, Hibernate
does not need to perform n+1 deletes; instead, we
leave that to the database to take care of.
Any comments?
--
Gavin King
+61 41 053 4454
+1 404 822 8349
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=4721alloc_id=10040op=click
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


Re: [Hibernate] support for ON CASCADE DELETE

2004-07-20 Thread Gavin King
Max Rydahl Andersen wrote:
Sounds like a nice and performant feature.
By doing this we are now skipping/ignoring the LifeCycle stuff on
these objects, correct ?
 

Nope, all semantics are preserved. This *only* optimizes away the delete 
statements.

And this is also a step in the direction of supporting efficient
delete and update by query. 

Ah, not especially
--
Gavin King
+61 41 053 4454
+1 404 822 8349
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=4721alloc_id=10040op=click
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel