1. Map an entity that contains a collection of child entities as list.
2. Reorder some child entries in the list or remove one, so that the later ones need to get a new index.
3. Flush the session and commit the transaction, but don't close the session.
4. Try to serialize the session.
This results in the following exception:
System.InvalidOperationException : Cannot serialize a Session while connected
The message of the exception is wrong. The session isn't connected. The real problem is that the AbstractBatcher still has entries in the _commandsToClose list and therefore returns true in the HasOpenResources property, which causes the ConnectionManager to return false in the IsReadyForSerialization property.
This is a regression in NHibernate 4.0 and is caused by NH-3072. To be more specific, the removal of the "if (st == null)" condition caused it. Since this was a pull request from me, I'd like to not just revert it without understanding what happens first.