Fix a nullPointerException when calling relations in entity classes