I have a requirement to have a compound key for my database schema.
Below is my compound key:
@Embeddable public class CompoundPK implements Serializable {
@Column(name="REGION_ID") private long regionId;
private long id;
//omitted constructors, getters, setters for brevity. }
My entity hierarchy is below @Entity @Table(name="table1") @Inheritance(strategy=InheritanceType.JOINED) public abstract class NamedEntity{ @EmbeddedId protected CompoundPK id;
@Column(name="LAST_NAME") protected String lastName;
}
@Entity @Table(name="table2") public class Person extends NamedEntity{
@Column(name = "DATE_OF_BIRTH) private Date dob;
....
}
However I'm unable to use the compound primary key. Is this a Hibernate limitation, where compound keys can't be used in Inheritance?
Thanks in advance
|