Identifies the primary key of an entity.
Specifies the mapped field of an entity as the entity’s ID, or the Key in Key-Value databases.
The field or property to which the
Id
annotation is
applied should have one of the following types:
- any Java primitive type;
- any primitive wrapper type;
String
;UUID
;BigDecimal
;BigInteger
.
Convert
to convert the type to one of the above types.
The mapped column for the primary key of the entity is assumed to be the primary key of the database structure.
Example:
@Id
public Long id;
An insertion with an ID value might vary from the vendor, where vendors can throw a NullPointerException, for example, a Key-value database, or apply a strategy of auto generating value, for example, UUID or auto-increment.
- Since:
- 1.0.0
- See Also:
-
Optional Element Summary
Optional Elements
-
Element Details
-
value
String valueThe name of the entity ID. Default value is_id
. This value might be ignored if the NoSQL database has a keyword reserved for keys. For example:@Entity public class User { @Id private String userName; }
- Returns:
- the entity ID name
- Default:
"_id"
-