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 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).Methods
public abstract String name() default "" | Column name. |
public abstract boolean nullable() default true | When false the column gets a NOT NULL constraint at table-create time. |
public abstract boolean unique() default false | Creates a unique index when the managed schema is created. |
public abstract String type() default "" | Optional explicit SQL type. |
Method details
name
public abstract String name() default ""Column name. Defaults to the field name when blank.
nullable
public abstract boolean nullable() default trueWhen false the column gets a
NOT NULL constraint at table-create time.unique
public abstract boolean unique() default falseCreates a unique index when the managed schema is created.
type
public abstract String type() default ""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).