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) :)
|