Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.
@Retention(CLASS) @Target({FIELD})
public @interface 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).Methods
public abstract boolean autoIncrement() default true | When true (the default) the database assigns the key and the generated dao reads it back into the field after an insert. |
Method details
autoIncrement
public abstract boolean autoIncrement() default trueWhen 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 AUTOINCREMENT and
last_insert_rowid(), MySQL gets AUTO_INCREMENT and LAST_INSERT_ID(),
PostgreSQL gets a GENERATED BY DEFAULT AS IDENTITY column and an
INSERT ... RETURNING.