-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Bulk delete on join table?
PostPosted: Tue Jul 24, 2007 1:47 pm 
Beginner
Beginner

Joined: Mon Jul 23, 2007 12:37 pm
Posts: 24
Hibernate version:
3.1.3

Hi, I don't want to get into the technical details here as my question is of a more general nature.

I have a many-to-many association between classes A and B. There are parents and children in the table A. So if I want to delete the associations to B's for a parent, I also want to delete them for it's children. Now I'd like to do this with only ONE delete statement send to the database.

To further illustrate this: Let's say, we have the following instances and associations:
Code:
parent: a1 -> b1, b2
child: a2 -> b2, b3

I want to delete these associations so that I have this in the end:
Code:
parent: a1 -> --
child: a2 -> --

So far, Hibernate issues two delete statements, one for each collection of B's in each A. Is there a possibility to get this down to just ONE statement, and how? No matter if I used a HQL query or a Criteria, I always ended with two delete statements whereas I'm looking for something which results in this kind of SQL: 'delete from JOINTABLE where ID_A in (select ID from A where PARENT_ID = '...' )'


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.