Made sorting implementation use getters and updated PdoRepository to be EntityState aware.