-->
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: No delete triggered by Map.clear()
PostPosted: Tue Nov 28, 2006 5:11 pm 
Newbie

Joined: Sat May 14, 2005 11:19 am
Posts: 14
I got a persistent, attached map (cascade: all, delete-orphan) on an entity. When I clear() this map and fill in new objects with the same key I get unique constraints violations on the map key when committing, because hibernate does NOT issue any sql deletes. When I manually do a Session.flush() after the Map.clear() (what I want to avoid), hibernate generates the deletes and all is fine. What have I to do to get these sql deletes without a manual flush?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 29, 2006 7:04 am 
Senior
Senior

Joined: Mon Oct 23, 2006 5:12 am
Posts: 141
Location: Galicia, Spain
From

10.10. Flushing the Session

the order in which hibernate executes pending sql senteces is:
The SQL statements are issued in the following order

1. all entity insertions, in the same order the corresponding objects were saved using Session.save()
2. all entity updates
3. all collection deletions
4. all collection element deletions, updates and insertions
5. all collection insertions
6. all entity deletions, in the same order the corresponding objects were deleted using Session.delete()

so it should work when you do the commit...

Could you try to do "map.remove()" for each object you want to delete instead of the clear() and see if it works?

_________________
andresgr (--don't forget to rate)


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.