hibernate/hibernate-orm · error · IllegalArgumentException
Unrecognized schema generation source type: '%s'
Error message
Unrecognized schema generation source type: '%s'
What it means
The schema generation source type, interpreted by SourceType (used for jakarta.persistence.schema-generation create-source/drop-source style settings), must name one of metadata, script, metadata-then-script, or script-then-metadata. Hyphens are normalized to underscores and an empty value defaults to METADATA; every other value throws this IllegalArgumentException.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/tool/schema/SourceType.java:85
public static SourceType interpret(Object value, SourceType defaultValue) {
if ( value == null ) {
return defaultValue;
}
if ( value instanceof SourceType sourceType ) {
return sourceType;
}
final String name = value.toString().trim().replace('-', '_');
if ( name.isEmpty() ) {
return METADATA;
}
for ( var sourceType: values() ) {
if ( sourceType.toString().equalsIgnoreCase(name) ) {
return sourceType;
}
}
throw new IllegalArgumentException( "Unrecognized schema generation source type: '" + value + "'");
}
}
View on GitHub (pinned to fad1729dce)
Solutions
- Use one of the exact values: metadata, script, metadata-then-script, script-then-metadata.
- Omit the property to fall back to the default (metadata-only generation).
Example fix
# before <property name="jakarta.persistence.schema-generation.create-source" value="database"/> # after <property name="jakarta.persistence.schema-generation.create-source" value="metadata-then-script"/>
Defensive patterns
Strategy: validation
Validate before calling
private static final Set<String> VALID_SOURCES = Set.of(
"metadata", "script", "metadata-then-script", "script-then-metadata");
String token = source == null ? "" : source.trim().toLowerCase(Locale.ROOT);
if (!token.isEmpty() && !VALID_SOURCES.contains(token)) {
throw new IllegalStateException("Bad schema generation source type: " + source);
} Prevention
- Distinguish the source type (where schema comes from) from the action (what to do).
- Copy JPA schema-generation property tokens verbatim from the spec, not from memory.
When it happens
Trigger: SourceType.interpret receiving "database", "scripts", "both", or a misspelled token: no enum constant's toString matches case-insensitively after normalization, so interpretation fails.
Common situations: Confusing the source type with the schema action; hand-copying JPA schema-generation properties with wrong tokens; unclear which of script/metadata ordering tokens the provider expects.
Related errors
- Unrecognized JPA schema management action setting: '%s'
- Duplicate generator name '%s'; you will likely want to set t
- Duplicate generator name %s; you will likely want to set the
- Can't load class: {}
- The provided {} setting value [{}] is not supported
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/1681ca09fe617374.
Report an issue: GitHub.