Marks a field as the primary key of an entity. This annotation can also specify the database column name
for the primary key using either
value() or name(). These attributes are aliases:
if both are provided, they must have the same value.
Usage examples:
@PK("id")@PK(name="id")@PK @DbColumn("id")
"id".
If no value is specified (i.e., both value() and name() are ""),
the automatic column name resolution strategy will be applied.
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanWhether the primary key is auto generated.The database column name for the primary key.The database column name for the primary key.
-
Element Details
-
value
String valueThe database column name for the primary key. Acts as an alias forname().- Default:
""
-
name
String nameThe database column name for the primary key. Acts as an alias forvalue().- Default:
""
-
autoGenerated
boolean autoGeneratedWhether the primary key is auto generated.- Returns:
- true if the primary key is auto generated, false otherwise.
- Default:
true
-