Annotation Type Id


@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).
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    When 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 autoIncrement

      When 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.

      Default:
      true