docs / reference/entity-schemaspringboot-cli

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.

json
{
  "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 ​

PropertyRequiredDescription
tableNameYesValue used in @Table(name = "...").
idYesID field definition.
attributesNoObject of ordinary persisted fields, keyed by logical attribute name.
relationsNoObject 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 typeJava type
stringString
textString
intInteger
longLong
booleanBoolean
doubleDouble
bigdecimalBigDecimal
localdateLocalDate
localdatetimeLocalDateTime
instantInstant
uuidUUID

ID strategies ​

StrategyGenerated mapping
identity@GeneratedValue(strategy = GenerationType.IDENTITY)
uuid@GeneratedValue(strategy = GenerationType.UUID)
noneNo 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.

KindOptional properties used during generation
ManyToOnejoinColumn, required
OneToOnejoinColumn, mappedBy, required
OneToManymappedBy
ManyToManyjoinTable, 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.