The NHibernate documentation clearly states that "NHibernate treats unidirectional one-to-many and many-to-many associations owned by a read-only entity the same as when owned by an entity that is not read-only."
My question is: Why? If I loaded an object as readonly, I would expect all of its collections to be readonly and not dirty checked. Why did nHibernate decide to not implement it this way? I ask this because a of a project I've inherited has issues with unnecessary SELECT statements happening when a session transaction closes. I discovered this was because the object in question had a lot of child collections where the getter called a function on the underlying data (self-changing entities) to mitigate an issue where nhibernate inserts null objects into lists with a sequence field where there's a gap in the sequence. I understand the right way to fix this is to not to call a function on the getter, but I was trying to avoid that by calling the parent object as read-only. But also, in these cases, I *know* I am only loading the parent object to access data and I am not changing it. I don't need NHibernate to check if it's dirty, I know it's not, similar to using AsNoTracking() in Entity Framework. So, back to the question: Why was NHibernate implemented this way? -- --- You received this message because you are subscribed to the Google Groups "nhibernate-development" group. To unsubscribe from this group and stop receiving emails from it, send an email to nhibernate-development+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/nhibernate-development/3760f3af-1b2f-4563-8643-12db2323753co%40googlegroups.com.