Annotation Type Column
@Entity field's column. Optional -- when absent,
the column name defaults to the field name (in snake case on the backend)
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 ElementsModifier and TypeOptional ElementDescriptionThe collation of the column, appended to its DDL asCOLLATE <name>(quoted on PostgreSQL), and the one the schema report then holds an existing column to instead of requiring a case-sensitive key collation.booleanWhen false the column is left out of everyINSERTthe ORM writes, so the row starts with the column's database default.Column name.booleanWhen false the column gets aNOT NULLconstraint at table-create time.Optional explicit SQL type.booleanCreates a unique index when the managed schema is created.booleanWhen false the column is left out of everyUPDATEthe ORM writes for a changed entity, so a save never overwrites it.
-
Element Details
-
name
String nameColumn name. When blank the app uses the field name and the backend the field name in snake case (fareCentsbecomesfare_cents), the default Spring Boot applies.- Default:
""
-
nullable
boolean nullableWhen false the column gets aNOT NULLconstraint at table-create time.- Default:
true
-
unique
boolean uniqueCreates a unique index when the managed schema is created.- Default:
false
-
type
String typeOptional 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 TABLEunchanged, 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:
""
-
insertable
boolean insertableWhen false the column is left out of everyINSERTthe ORM writes, so the row starts with the column's database default. The field's value at insert time is ignored, not written.- Default:
true
-
updatable
boolean updatableWhen false the column is left out of everyUPDATEthe ORM writes for a changed entity, so a save never overwrites it. The column can still be written by a query of the application's own -- a@Modifying @Querythat claims a row with a compare-and-swap, for example -- which is what makesinsertable = false, updatable = falsea column only that statement owns. A change made to the field alone is ignored: it neither writes the column nor marks the entity dirty.- Default:
true
-
collation
String collationThe collation of the column, appended to its DDL as
COLLATE <name>(quoted on PostgreSQL), and the one the schema report then holds an existing column to instead of requiring a case-sensitive key collation. Letters, digits and underscores only, asutf8mb4_0900_ai_cion MySQL,NOCASEon SQLite or a collation created on PostgreSQL.A case-insensitive collation on a key makes the database treat
"A"and"a"as one key. The session's identity cache still compares ids withString.equals, so look an entity up by the spelling it is stored with: another one finds the row but loads a second instance of it. Hibernate has the same caveat.- Default:
""
-