Preventing detached ORM entities in the session