@Target(value=FIELD)
@Retention(value=RUNTIME)
public @interface GeneratedValue
The annotated field must be a member of an Entity annotated class and the field must
be annotated with Id.
The additional annotation is required according to the strategy value:
SequenceGenerator annotation is required, if GenerationType.SEQUENCE is
specified.
TableGenerator annotation is required, if GenerationType.TABLE is
specified.
@Entity
public class Employee {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@SequenceGenerator(sequence = "EMPLOYEE_SEQ")
Integer id;
...
}
GenerationType,
SequenceGenerator,
TableGenerator| Modifier and Type | Required Element and Description |
|---|---|
GenerationType |
strategy |
public abstract GenerationType strategy