{"record":{"id":"3cbf4c08d8b19e00","repo":"hibernate/hibernate-orm","slug":"validate-is-not-valid-schemamanagementtool-action","errorCode":null,"errorMessage":"VALIDATE is not valid SchemaManagementTool action for script output","messagePattern":"VALIDATE is not valid SchemaManagementTool action for script output","errorType":"exception","errorClass":"SchemaManagementException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/tool/schema/spi/SchemaManagementToolCoordinator.java","lineNumber":462,"sourceCode":"\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase UPDATE: {\n\t\t\t\tfinal var migrateDescriptor = buildScriptTargetDescriptor(\n\t\t\t\t\t\tconfigurationValues,\n\t\t\t\t\t\tMigrateSettingSelector.INSTANCE,\n\t\t\t\t\t\tserviceRegistry,\n\t\t\t\t\t\tconfigurationService\n\t\t\t\t);\n\t\t\t\ttool.getSchemaMigrator( configurationValues ).doMigration(\n\t\t\t\t\t\tmetadata,\n\t\t\t\t\t\texecutionOptions,\n\t\t\t\t\t\tcontributed -> true,\n\t\t\t\t\t\tmigrateDescriptor\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase VALIDATE: {\n\t\t\t\tthrow new SchemaManagementException( \"VALIDATE is not valid SchemaManagementTool action for script output\" );\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static JpaTargetAndSourceDescriptor buildScriptTargetDescriptor(\n\t\t\tMap<?,?> configuration,\n\t\t\tSettingSelector settingSelector,\n\t\t\tServiceRegistry serviceRegistry,\n\t\t\tConfigurationService configurationService) {\n\n\t\tfinal Object scriptTargetSetting = settingSelector.getScriptTargetSetting( configuration );\n\t\tfinal Object scriptSourceSetting = settingSelector.getScriptSourceSetting( configuration );\n\n\t\tfinal var sourceType = sourceType( configuration, settingSelector, scriptSourceSetting );\n\t\tfinal boolean includesScripts = sourceType != SourceType.METADATA;\n\t\tif ( includesScripts && scriptSourceSetting == null ) {\n\t\t\tthrow new SchemaManagementException(\n\t\t\t\t\t\"Schema generation configuration indicated to include CREATE scripts, but no script was specified\"","sourceCodeStart":444,"sourceCodeEnd":480,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/SchemaManagementToolCoordinator.java#L444-L480","documentation":"Thrown by SchemaManagementToolCoordinator.performScriptAction (SchemaManagementToolCoordinator.java:461) when the script-generation action group reaches the VALIDATE case. 'validate' is a meaningful action for the database target (compare mapped model with live schema), but writing a 'validation' to a script file makes no sense, so Hibernate rejects jakarta.persistence.schema-generation.scripts.action=validate with a SchemaManagementException instead of producing garbage output.","triggerScenarios":"Setting jakarta.persistence.schema-generation.scripts.action=validate (or the deprecated javax.persistence.schema-generation.scripts.action=validate) while any script target is configured. Any other scripts.action value (none, create, drop, drop-and-create, create-only) routes to a valid case; only 'validate' hits the throwing branch.","commonSituations":"Teams that set both database.action and scripts.action to 'validate' for symmetry in test persistence-unit configs; Spring Boot tests adding jakarta.persistence.schema-generation.scripts.* properties for generated-DDL exports while also enabling validation; property templating loops that assign 'validate' to every schema-generation action key.","solutions":["Remove jakarta.persistence.schema-generation.scripts.action=validate or set it to none/create/drop as appropriate.","If you want schema validation, use jakarta.persistence.schema-generation.database.action=validate or hibernate.hbm2ddl.auto=validate instead of the scripts.action key.","If you intended to export DDL scripts, keep scripts.action=create (or create-only) and configure jakarta.persistence.schema-generation.scripts.create-target.","Audit property files for templated values applied uniformly to all schema-generation keys."],"exampleFix":"// before\n<property name=\"jakarta.persistence.schema-generation.scripts.action\" value=\"validate\"/>\n<property name=\"jakarta.persistence.schema-generation.scripts.create-target\" value=\"create.sql\"/>\n\n// after\n<property name=\"jakarta.persistence.schema-generation.scripts.action\" value=\"create\"/>\n<property name=\"jakarta.persistence.schema-generation.scripts.create-target\" value=\"create.sql\"/>\n<property name=\"jakarta.persistence.schema-generation.database.action\" value=\"validate\"/>","handlingStrategy":"validation","validationCode":"String scriptsAction = (String) props.get(\"jakarta.persistence.schema-generation.scripts.action\");\nif (\"validate\".equalsIgnoreCase(scriptsAction)) {\n    throw new IllegalStateException(\n        \"scripts.action=validate is not supported; use database.action=validate\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    emf = Persistence.createEntityManagerFactory(\"pu\", props);\n} catch (PersistenceException e) {\n    if (e.getCause() instanceof SchemaManagementException sme\n            && sme.getMessage().contains(\"VALIDATE is not valid\")) {\n        props.remove(\"jakarta.persistence.schema-generation.scripts.action\");\n        // retry once with corrected config\n        emf = Persistence.createEntityManagerFactory(\"pu\", props);\n    } else throw e;\n}","preventionTips":["Never template the same action value across database.action and scripts.action.","Document in the project config that validation belongs to database.action only."],"tags":["hibernate","hbm2ddl","schema-generation","validation","configuration"],"backgroundTag":"schema-generation-misconfiguration","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}