Entity schema reference
The file consumed by springboot-cli schema validate and springboot-cli schema apply is a JSON object with a required entities object. Each property name is an entity key used to derive the Java class name and to identify relation targets.
{
"entities": {
"product": {
"tableName": "products",
"id": {
"name": "id",
"type": "long",
"strategy": "identity"
},
"attributes": {
"name": {
"databaseColumn": "name",
"type": "string",
"required": true
}
},
"relations": {
"category": {
"kind": "ManyToOne",
"target": "category",
"joinColumn": "category_id",
"required": true
}
}
},
"category": {
"tableName": "categories",
"id": {
"name": "id",
"type": "long",
"strategy": "identity"
}
}
}
}Entity fields
| Property | Required | Description |
|---|---|---|
tableName | Yes | Value used in @Table(name = "..."). |
id | Yes | ID field definition. |
attributes | No | Object of ordinary persisted fields, keyed by logical attribute name. |
relations | No | Object of JPA relationships, keyed by logical relation name. |
Each id object requires a non-empty name and a supported type. Its strategy is optional and defaults to none when generating the class.
Each attribute requires databaseColumn and type. required: true generates a non-null column mapping. If omitted or false, no non-null constraint is added.
Supported Java types
| Schema type | Java type |
|---|---|
string | String |
text | String |
int | Integer |
long | Long |
boolean | Boolean |
double | Double |
bigdecimal | BigDecimal |
localdate | LocalDate |
localdatetime | LocalDateTime |
instant | Instant |
uuid | UUID |
ID strategies
| Strategy | Generated mapping |
|---|---|
identity | @GeneratedValue(strategy = GenerationType.IDENTITY) |
uuid | @GeneratedValue(strategy = GenerationType.UUID) |
none | No generated-value annotation |
If strategy is omitted, the generated class uses none.
Relations
Each relation requires kind and target. target must match another key in the entities object.
| Kind | Optional properties used during generation |
|---|---|
ManyToOne | joinColumn, required |
OneToOne | joinColumn, mappedBy, required |
OneToMany | mappedBy |
ManyToMany | joinTable, mappedBy |
required: true marks supported to-one relationships as non-optional. For OneToOne, set mappedBy on the inverse side; otherwise, joinColumn can name the owning-side column. For ManyToMany, use joinTable on the owning side or mappedBy on the inverse side.
schema apply generates JPA mappings and JavaBean accessors; it does not create or migrate a database schema. Review the generated entity relationships for your persistence design.
Validation
Run springboot-cli schema validate to check the configured schema without generating files. Missing IDs, unsupported types, invalid relation mappings, unknown relation targets, and Java class or field name collisions are blocking errors. Duplicate database table or column mappings and existing generated entity files are warnings; warnings do not fail validation. Use schema apply --force when you intend to overwrite an existing entity file.