Is this possible to annotate a mapping where a relationship should be OR-ed between two (or more) possible target columns. My usecase:
Code:
@Table(name="cables")
class Cable {
@Id
private Long id;
@Column(name="dstport_id")
private Port dstPort;
@Column(name="srcport_id")
private Port srcPort;
}
@Table(name="ports")
class Port {
@Id
private Long id;
private Cable cable; // Here's the mapping that should point to cables.dstport_id or cables.srcport_id whatever is present
}
So, in my case, a cable can be connected to 2 ports the same time (or just one, or none of them). This is a One-to-One mapping in my application. In SQL I'd select a cable corresponding this certain port like ' left join cables as c on c.srcport_id = id or c.dstport_id = id' or something like that. Is this possible to map the same way in Hibernate?