JPA Annotation

Enumerated

Target: METHOD, FIELD
Implemented Interfaces:
Annotation

Specifies that a persistent property or field should be persisted as an enumerated type. This annotation is optional if the type of a persistent field or property is a Java enum type.

The Enumerated annotation may be used in conjunction with the Basic annotation, or in conjunction with the ElementCollection annotation when the element type of the collection is an enum type.

An enum can be mapped as either a plain or an plain, where EnumType enumerates the available options. The mapping may be plain by this annotation.

If a persistent field or property of enum type has no explicit Enumerated annotation, and if no converter is applied to the field or property:

Example:

 {@snippet :
 public enum EmployeeStatus {FULL_TIME, PART_TIME, CONTRACT}

 public enum SalaryRate {JUNIOR, SENIOR, MANAGER, EXECUTIVE}
See Also:
EnumeratedValue
Basic
ElementCollection
Since:
JPA 1.0
The JPA Persistable Types article explains how to use Enumerated.

Public Annotation Attributes

EnumType value default ORDINAL
(Optional) The type used in mapping an enum type.
Since:
JPA 1.0