Annotation Type Id
Designates the primary-key field of an
@Entity. Exactly one field per
entity must carry @Id. The field type may be long, int, String, or
a Property wrapper of one of those (short is also accepted on the
backend).-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanWhen true (the default) the database assigns the key and the generated dao reads it back into the field after an insert.
-
Element Details
-
autoIncrement
boolean autoIncrementWhen true (the default) the database assigns the key and the generated dao reads it back into the field after an insert. Set false when the application assigns its own keys (UUIDs, server-issued ids, ...).
How the column is declared and how the key comes back is the engine's business: SQLite gets
INTEGER PRIMARY KEY AUTOINCREMENTandlast_insert_rowid(), MySQL getsAUTO_INCREMENTandLAST_INSERT_ID(), PostgreSQL gets aGENERATED BY DEFAULT AS IDENTITYcolumn and anINSERT ... RETURNING.- Default:
true
-