Annotation to join columns with OR condition instead of AND condition
问题 I have 2 java classes, Relation and Person , which both are present in my database. Person: @Entity @Table(name = "persons") public class Person { @Id @Column private int id; @Column private String name; @OneToMany(fetch = FetchType.EAGER) @JoinColumns({ @JoinColumn(name = "slave_id", referencedColumnName="id"), @JoinColumn(name = "master_id", referencedColumnName="id") }) private List<Relation> relations; //Getters and setters } Relation: @Entity @Table(name = "relations") public class