新しい PK クラス (つまり、@EmbeddedId) を作成せずに、アノテーションを使用して Hibernate で複合キーを作成する方法はありますか?
私の問題は、多くの属性を持つ抽象クラス CommonClass があり、それを多くのエンティティ クラスに継承する必要があることです。各クラスには異なるタイプの id がありますが、それらはすべて CommonClass にある属性を持つ複合キーである必要があります。例:
@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
}
それで、これを行う最善の方法は何ですか?