public virtual void Close() { if (closeEntityManager && entityManager != null && !entityManager.Open) { try { entityManager.Close(); } catch (InvalidOperationException ise) { throw new ActivitiException("Error while closing EntityManager, may have already been closed or it is container-managed", ise); } } }