@GeneratedValue
From CauchoWiki
The @GeneratedValue annotation specifies auto-generation parameters and methods for primary keys. The @GeneratedValue is used with the @Id annotation. For example, MySQL provides a auto_increment attribute and Postgres and Oracle provide sequences.
@Entity public class TestBean { @Id @GeneratedValue public int getId() ... }
[edit] Annotation Definition
public @interface GeneratedValue {
GenerationType strategy() default AUTO;
String generator() default "";
}
- Main article: GenerationType
public enum GenerationType {
TABLE,
SEQUENCE,
IDENTITY,
AUTO
}
| attribute | description | default |
|---|---|---|
| strategy | the auto-generation strategy Amber should use | AUTO |
| generator | sequence or table name | "" |
| strategy | description |
|---|---|
| AUTO | Choose type depending on database, e.g. IDENTITY for MySQL |
| IDENTITY | An auto-increment type of key generation, e.g. MySQL |
| SEQUENCE | Use a sequence for key generation, e.g. Postgres or Oracle |
| TABLE | Use a separate Amber-controlled table for key generation |
[edit] Related annotations
- @Id annotation for a primary key
