-->
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: Refresh cascades to deleted objects
PostPosted: Tue Sep 28, 2010 2:40 pm 
Newbie

Joined: Fri Sep 14, 2007 2:02 pm
Posts: 10
Location: New York, NY
This is basically a post relating to an issue logged here. There hasn't been any progress made on the ticket in 4 years, so I thought I'd see if anyone has any advice.

The situation involves two entity objects, in our case Bond and Coupons. Bond has a reference to Coupons, with Cascade.ALL set. In an effort to not have a lot of obsolete information in our database, our code calls .delete() on Coupons objects that are no longer used.

Problem occurs when you've got two SessionFactory objects. Both have all the data cached in second level entity caches. One of them creates a new Coupons object, and makes the Bond refers to it, then cleans up by deleting the original Coupons object. The other creates a session, calls Session.get(Bond.class, id), then Session.refresh(bond) in an effort to get the latest content. Refresh blows up, because it tries to cascade the operation to the old Coupons object, which no longer exists in the database.

I would think that what refresh would do is first refresh the Bond object, then cascade the refresh to entities that are referenced in up-to-date version of the Bond. Instead, it does the reverse, cascading the refresh down to entities that are potentially not referenced any more, and perhaps no longer exist at all.

Right now the workaround we've come up with is to not delete obsolete Coupons objects. Then the refresh does more work than is strictly necessarily, but we do get the correct up-to-date contents for Bond and all it's referenced objects.

Is this in fact a bug, or are we thinking about .refresh() incorrectly?


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.