Annotation Type Column


@Retention(CLASS) @Target(FIELD) public @interface Column
Renames or constrains an @Entity field's column. Optional -- when absent, the column name defaults to the field name and the type is inferred from the Java field type (String -> TEXT, int/long -> INTEGER, float/double -> REAL, boolean -> INTEGER, byte[] -> BLOB, java.util.Date -> INTEGER).
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Column name.
    boolean
    When false the column gets a NOT NULL constraint at table-create time.
    Optional explicit SQL type.
    boolean
    Creates a unique index when the managed schema is created.
  • Element Details

    • name

      String name
      Column name. Defaults to the field name when blank.
      Default:
      ""
    • nullable

      boolean nullable
      When false the column gets a NOT NULL constraint at table-create time.
      Default:
      true
    • unique

      boolean unique
      Creates a unique index when the managed schema is created.
      Default:
      false
    • type

      String type

      Optional explicit SQL type. Use the SQLite type names (TEXT, INTEGER, REAL, BLOB, NUMERIC). When blank the processor infers the type from the field's Java type.

      On the backend the value is written through to the CREATE TABLE unchanged, so it is engine specific by construction: a type only PostgreSQL understands makes the entity PostgreSQL-only. Leaving it blank keeps the entity portable, because the dialect then names the type each engine spells differently (TEXT/VARCHAR, REAL/DOUBLE PRECISION, BLOB/BYTEA).

      Default:
      ""