@TargetSE(valueSE={METHODSE,FIELDSE}) @RetentionSE(valueSE=RUNTIMESE) public @interface MapKeyClass
java.util.Map の関連付けのマップキーの型を指定します。マップキーは、基本型、埋め込み可能なクラス、エンティティにすることができます。マップが Java ジェネリクスを使用して指定されている場合、MapKeyClass アノテーションおよび関連する型を指定する必要はありません。それ以外の場合は指定する必要があります。MapKeyClass アノテーションは、ElementCollection またはコレクション値の関連アノテーションの 1 つ(OneToMany または ManyToMany)と組み合わせて使用されます。MapKeyClass が指定されている場合、MapKey アノテーションは使用されません。その逆も同様です。
Example 1:
@Entity
public class Item {
@Id int id;
...
@ElementCollection(targetClass=String.class)
@MapKeyClass(String.class)
Map images; // map from image name to image filename
...
}
Example 2:
// MapKeyClass and target type of relationship can be defaulted
@Entity
public class Item {
@Id int id;
...
@ElementCollection
Map<String, String> images;
...
}
Example 3:
@Entity
public class Company {
@Id int id;
...
@OneToMany(targetEntity=com.example.VicePresident.class)
@MapKeyClass(com.example.Division.class)
Map organization;
}
Example 4:
// MapKeyClass and target type of relationship are defaulted
@Entity
public class Company {
@Id int id;
...
@OneToMany
Map<Division, VicePresident> organization;
}
ElementCollection, OneToMany, ManyToManypublic abstract ClassSE value
Copyright © 2019 Eclipse Foundation.
Use is subject to license terms.