Is there a way to create a composite key in Hibernate, with annotations, without creating a new PK class (ie, @EmbeddedId)?
My problem is, I have a abstract class CommonClass that have many attributes, and I neen to inherit it for many Entity classes. Each class has an different type of id, but all of them need to be a composite key with a attribute that is at CommonClass.
Example:
@MappedSuperclass
abstract class CommonClass {
@Id
int typed;
int a0;
int a1;
//many other attributes
}
@Entity
class EntityString extends CommonClass {
@Id
String id;
//ID need to be id+typed from CommonClass
//other attributes
}
@Entity
class EntityInteger extends CommonClass {
@Id
Integer id;
//ID need to be id+typed from CommonClass
//other attributes
}
So, what is the best way to do this?
Section 2.2.3.2.2 of the following hibernate doc.