don't call flush if entity manager is closed