I know this has been asked, but I can not solve this problem.
Lets say you have an nhibernate object that has a collection.
Problem is, if some object in the collection is updated in the database by a different user (i manually modifiy the database fot testing purposes), I can't seem to find a way to make nhibernate refresh the collection value.
I hace tried refresh, evict, Loading againg... Only closing the session and creating a new one works. But I find this solution problematic and, how hard can it be to tell nhibernate "dude, refresh the items in the collection"?
But anyhow I can't get it working.
Thanks a lot
This isn't actually supposed to work, that's why it doesn't.
NHibernate uses the a session level cache by default, to optimise reads and track modifications.
It sounds like you're not using a correct unit of work around your data access as your sessions should be scoped down and used only when you need them.
If this is part of a web app, it's recommended you follow a "session-per-request" approach.
If you really wanted this to work, you could probably evict entity and it's children from the session, forcing a re-fetch, but this is nasty and I'd really not advise it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With