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
.By default, the field marked with
@Id
maps to the field_id
in the database. However, this can vary depending on the NoSQL provider. Certain databases may use a different field name for the identifier, such as_key
, or allow users to override this value based on the specific database implementation. It is recommended to consult the documentation of the database provider to understand its requirements for primary key fields.Example of customization:
@Entity public class User { @Id("userId") private String userName; }
- Returns:
- the entity ID name
- Default:
"_id"
-