I have the following model
@Entity
@Table(name = "GRAPH")
public class Graph {
[...]
@ElementCollection
@CollectionTable(name = "ROOT", joinColumns = @JoinColumn(name = "GRAPH", nullable = false))
private Set<Root> roots;
}
@Entity
@Table(name = "NODE")
public class Node {
[...]
}
@Embeddable
public class Root {
[...]
@ManyToOne(optional = false)
@JoinColumn(name = "NODE", nullable = false)
private Node node;
}
I use EclipseLink as the JPA Provider. When letting EclipseLink generate the DDL for this structure, the following stuff happens:
- The is no primary key on the ROOT table (OK, it is an @Embeddable, and it does not have an identity)
- A foreign key is generated from ROOT.GRAPH to GRAPH.ID (As expected)
- There is no foreign key from ROOT.NODE to NODE.ID (That's something I can not understand)
Can you help explain me the cause for this behavior? Is there something that can be done about the primary key and the missing foreign key?
Thanks, M.