Hi,
I have a class X with an autogenerated primary key. Also there is a
class Y which has a composite
primary key of X's id and two other string.
X has one to many relationship to Y and Y has many-to-one relationship
to X.
I am trying to use openjpa to model these two classes. But using the
autogenerated id as a foreign key
is giving me headache. The openjpa requires a default constructor, and
class Y cannot have a default constructor,
because part of its composite primary key is a generated id of the
parent class X.
Would openjpa properly work if I remove Y's foreign key from its
composite pk ? What is the best way to
model these objects in openjpa?
public class X {
private long id; // autogenerated pk
private Y attrs;
}
public class Y {
private long id; // foreign key to X.id and part of Y's composite pk
private String a; // pk
private String b; // pk
}