We are using JPA to load some stuff from a database. Some entities may have optional relationships between them, e.g.
@Entity public class First { .... @
What about adding a test in the correspondent entity class:
public boolean getHasSecond() { if (this.Second != null) { return true; } else { return false; } }
Like this, you can check if the relation exists...