How would you map a list of bar objects onto the Foo object, using ONLY the FOO_ID?
@Entity
@Table(name="FOO")
class Foo {
@EmbeddedId
private FooPK primaryKey;
@OneToMany
@JoinColumn(name="FOO_ID", referencedColumnName="FOO_ID") //does not work
private List<Bar> bars;
}
@Embeddable
class FooPK {
@Column(name="FOO_ID")
private String id;
@Column(name="FOO_SUB_ID")
private String subId;
}
@Entity
@Table(name="BAR")
class Bar {
@EmbeddedId
private BarPK primaryKey;
//other attributes and methods
}
@Embeddable
class BarPK {
@Column(name="FOO_ID")
private String id;
@Column(name="BAR_ID")
private String barId;
@Column(name="BAR_SUB_ID")
private String barSubId;
}
I've tried: @JoinColumn (as above) and @JoinTable on another table that contains the FOO_ID as the primary key. Neither works.