[#6960] flush the session before flushing the BatchIndexer, so it has all objects