Hi,
I would like to use primary key classes in a hierarchy:
Code:
@Embeddable (access=AccessType.PROPERTY)
public class Cls1PK implements Serializable {
int id1;
public int getID1() {
return id1;
}
.... hashCode, equals ...
}
and
Code:
@Embeddable (access=AccessType.PROPERTY)
public class Cls2PK extends Cls1PK {
int id2;
public int getID2() {
return id2;
}
}
but it doesn't seem to work.
If I use Cls2PK as @Id in some class like Cls2 Hibernate uses ID2 of class Cls2PK but ignores property ID1. That leeds to too short where clauses in update statements.
Is it just not specified to work that way? Every example file in Hibernate seems to use PK
base classes without any hierarchy.
If I rewrite my class as
Code:
@Embeddable (access=AccessType.PROPERTY)
public class Cls2PK extends Cls1PK {
int id2;
public int getID1() {
return super.getID1();
}
public int getID2() {
return id2;
}
}
everything works fine. But that's redundant code, isn't it?
The Annotation Version is "Version: 3.0beta1 Preview" based on EJB3 EDR2.
Thank you
Carsten