-->
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: lazy loaded list contains a deleted object
PostPosted: Thu Sep 21, 2006 9:29 pm 
Newbie

Joined: Mon Apr 03, 2006 1:38 am
Posts: 11
Hello,

If I session.delete an object and then I access a lazy loaded list that should contain the item, had I not deleted it, it appears in the list. Am I doing something wrong?

This list was previously not loaded. When I access the list NHibernate initializes it.

I've stepped through the code and noticed that the delete doesn't get flushed before the lazy load of the collection is performed. If I session.flush straight after the delete the item doesn't appear in the lazy loaded list, which is the desired behaviour, but putting session.flush after the delete seems like a bit of a hack to me.

Any suggestions on a nicer fix for this? I'll post the mapping file and code if anyone thinks it will help.

Thanks!

For the sake of clarity:
1) session.delete(post)
2) iterate through blog.Posts
3) blog.Posts is lazy loaded by NHibernate
4) blog.Posts contains post
5) :(

1) session.delete(post)
2) session.flush()
3) iterate through blog.Posts
4) blog.Posts is lazy loaded by NHibernate
5) blog.Posts no longer contains post
6) :)


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.