Implementation for the getEntity and getEntities methods.