-->
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.  [ 2 posts ] 
Author Message
 Post subject: delete DML operations on n to m associations
PostPosted: Wed Jan 10, 2007 9:39 am 
Newbie

Joined: Fri Nov 03, 2006 5:21 am
Posts: 14
Hibernate version: 3.2

Hi folks,

I want to clear some parts of my database using data manipulation language (DML). More specifically to I have a n to m relationship between EntityA and EntityB and I want to remove all EntityA objects including their associations to EntityB.

As I have an n:m relationship there exists a table AtoB that has to be emptied before all entries in table A can get removed.

Is there a way to achieve that?

When using
Code:
query = session.createQuery("delete EntityA");
query.executeUpdate();
I'm getting foreign key exceptions regardless of the cascade options I set in the mapping on the n:m association, and
Code:
query = session.createQuery("delete EntityA.entityBs");
query.executeUpdate();
cannot be resolved even though my relation to EntityB is named entityBs.

Is there any other way to delete the association effectively besides using native SQL statements or making an explicit class out of the n:m association table?

Thanks in advance,
Joern


Top
 Profile  
 
 Post subject: Same problem here
PostPosted: Wed Jan 10, 2007 3:59 pm 
Newbie

Joined: Sat Jan 24, 2004 7:55 am
Posts: 1
I have the same problem here. Thanks in advance for any help.


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

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.