-->
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: How to clear M:N link table with HQL?
PostPosted: Thu May 21, 2009 9:05 am 
Newbie

Joined: Thu Nov 13, 2008 9:21 pm
Posts: 2
Imaging that I have entities UserAccount and Role.
There is a relation "roles" declared as:

@ManyToMany()
@JoinTable(...)
Set<Roles> UserAccount.getRoles();
void UserAccount.setRoles(Set<Roles> roles);

Now I have a requirement to bulk delete a set of accounts. However, before this I have to remove all associations UserAccount->Role for all accounts involved, otherwise ConstraintViolationException is thrown (obviously). I mean, that I have to remove only associations, not Roles itself.

Are there any ways to implement this with bulk HQL?
I know that I can iterate over UserAccounts and call clear on corresponding collection, but this leads to unacceptable performance for use cases I have... Anything besides native SQL?


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.