diff --git a/api/src/main/java/jakarta/persistence/MapKey.java b/api/src/main/java/jakarta/persistence/MapKey.java index 31bd83e3..ec10a95d 100644 --- a/api/src/main/java/jakarta/persistence/MapKey.java +++ b/api/src/main/java/jakarta/persistence/MapKey.java @@ -63,7 +63,7 @@ * public class Department { * ... * @OneToMany(mappedBy = "department") - * @MapKey(name = "name") + * @MapKey("name") * public Map getEmployees() {... } * ... * } @@ -95,5 +95,19 @@ * mapped as {@link IdClass}, an instance of the primary key * class is used as the key. */ + String value() default ""; + + /** + * (Optional) The name of the persistent field or property of + * the associated entity that is used as the map key. + *

Default: If the {@code name} element is not specified, + * the primary key of the associated entity is used as the map + * key. If the primary key is a composite primary key and is + * mapped as {@link IdClass}, an instance of the primary key + * class is used as the key. + * + * @deprecated Use {@link #value} instead + */ + @Deprecated(since = "4.0") String name() default ""; }