added id validation in getEntityById()