Package javax.persistence
Annotation Type MapKeyEnumerated
-
@Target({METHOD,FIELD}) @Retention(RUNTIME) public @interface MapKeyEnumerated
Specifies the enum type for a map key whose basic type is an enumerated type. TheMapKeyEnumerated
annotation can be applied to an element collection or relationship of typejava.util.Map
, in conjunction with theElementCollection
,OneToMany
, orManyToMany
annotation. If the enumerated type is not specified or theMapKeyEnumerated
annotation is not used, the enumerated type is assumed to beORDINAL
.Example: public enum ProjectStatus {COMPLETE, DELAYED, CANCELLED, IN_PROGRESS} public enum SalaryRate {JUNIOR, SENIOR, MANAGER, EXECUTIVE} @Entity public class Employee { @ManyToMany public Projects<ProjectStatus, Project> getProjects() {...} @OneToMany @MapKeyEnumerated(STRING) public Map<SalaryRate, Employee> getEmployees() {...} ... }
- See Also:
ElementCollection
,OneToMany
,ManyToMany
- Since:
- 2.0
-
-
Element Detail
-
value
EnumType value
(Optional) The type used in mapping a map key enum type.- Default:
- javax.persistence.EnumType.ORDINAL
-
-