I´m trying to build functional location hierarchy and I started by Country model/entity. One level down is Province entity with ManyToOne relationship to Country (bidirectional). Now I have City entity which is ManyToOne tied to Province (bidirectional) but this relationship is nullable. But now, if City-Province relationship is empty I need City-Country relationship (nullable as well). So at least one is required But if one of those two is already in place, other cannot be entered.
So basically, those two relationships in city (city-province, city-country) are mutually exclusive but at least one of them is required. I´m working with Java and JPA (Hibernate) and I haven´t found any special functionality for implementation of this. Is there any proven or "right" way how to do it?