Top Description Methods
javax.persistence

public @Interface MapKeyEnumerated

extends Annotation
Annotations
@Target:METHOD, FIELD
@Retention:RUNTIME
Imports
java.lang.annotation.Target, .Retention

Specifies the enum type for a map key whose basic type is an enumerated type. The MapKeyEnumerated annotation can be applied to an element collection or relationship of type java.util.Map, in conjunction with the ElementCollection, OneToMany, or ManyToMany annotation. If the enumerated type is not specified or the MapKeyEnumerated annotation is not used, the enumerated type is assumed to be ORDINAL.
  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() {...}
      ...
  }
Since
Java Persistence 2.0
See Also
ElementCollection, OneToMany, ManyToMany

Method Summary

Modifier and TypeMethod and Description
public EnumType
value()

(Optional) The type used in mapping a map key enum type.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

valueback to summary
public EnumType value()

(Optional) The type used in mapping a map key enum type.