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 string or an integer, where
EnumType enumerates the available options. The mapping
may be explicitly specified 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:
String
annotated EnumeratedValue, the enumerated type is
inferred to be EnumType#STRING;
EnumType#ORDINAL.
Example:
public enum EmployeeStatus {FULL_TIME, PART_TIME, CONTRACT}
public enum SalaryRate {JUNIOR, SENIOR, MANAGER, EXECUTIVE}
@Entity
public class Employee {
public EmployeeStatus getStatus() { ... }
...
@Enumerated(STRING)
public SalaryRate getPayScale() { ... }
...
}
EnumeratedValue, Basic, ElementCollection
| Modifier and Type | Method and Description |
|---|---|
| public EnumType |
| value | back to summary |
|---|---|
| public EnumType value() (Optional) The type used in mapping an enum type. | |