Added toArray() for entity