Changes to the getPropertyByName to return an entity if property is
instance of entity else return its value if its a property.