{"record":{"id":"1ac1cfa57c4212fc","repo":"hibernate/hibernate-orm","slug":"schema-generation-configuration-indicated-to-inclu","errorCode":null,"errorMessage":"Schema generation configuration indicated to include CREATE scripts, but no script was specified","messagePattern":"Schema generation configuration indicated to include CREATE scripts, but no script was specified","errorType":"exception","errorClass":"SchemaManagementException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/tool/schema/spi/SchemaManagementToolCoordinator.java","lineNumber":339,"sourceCode":"\t\t\t}\n\t\t}\n\t}\n\n\tprivate static SourceType sourceType(Map<?, ?> configuration, SettingSelector settingSelector, Object scriptSourceSetting) {\n\t\treturn SourceType.interpret( settingSelector.getSourceTypeSetting( configuration ),\n\t\t\t\tscriptSourceSetting != null ? SourceType.SCRIPT : SourceType.METADATA );\n\t}\n\n\tprivate static JpaTargetAndSourceDescriptor buildDatabaseTargetDescriptor(\n\t\t\tMap<?,?> configuration,\n\t\t\tSettingSelector settingSelector,\n\t\t\tServiceRegistry serviceRegistry) {\n\n\t\tfinal Object scriptSourceSetting = settingSelector.getScriptSourceSetting( configuration );\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\"\n\t\t\t);\n\t\t}\n\n\t\tfinal var scriptSourceInput =\n\t\t\t\tincludesScripts\n\t\t\t\t\t\t? interpretScriptSourceSetting( scriptSourceSetting,\n\t\t\t\t\t\t\t\tserviceRegistry.getService( ClassLoaderService.class ),\n\t\t\t\t\t\t\t\t(String) configuration.get( HBM2DDL_CHARSET_NAME ) )\n\t\t\t\t\t\t: null;\n\n\t\treturn new JpaTargetAndSourceDescriptor() {\n\t\t\t@Override\n\t\t\tpublic EnumSet<TargetType> getTargetTypes() {\n\t\t\t\treturn EnumSet.of( TargetType.DATABASE );\n\t\t\t}\n\n\t\t\t@Override","sourceCodeStart":321,"sourceCodeEnd":357,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/SchemaManagementToolCoordinator.java#L321-L357","documentation":"Hibernate throws this SchemaManagementException at SessionFactory bootstrap when JPA schema generation is told to build the database schema partly or wholly from DDL scripts, but no script location was provided. SchemaManagementToolCoordinator.sourceType() derives a SourceType from jakarta.persistence.schema-generation.create-source (or drop-source); when that is 'script', 'metadata-then-script' or 'script-then-metadata' while the matching create-script-source/drop-script-source setting is null, buildDatabaseTargetDescriptor() (SchemaManagementToolCoordinator.java:338) fails fast instead of silently generating nothing.","triggerScenarios":"Setting jakarta.persistence.schema-generation.database.action to create/create-drop/drop (or hibernate.hbm2ddl.auto equivalent) together with jakarta.persistence.schema-generation.create-source=script (or drop-source=script, metadata-then-script, script-then-metadata) while omitting jakarta.persistence.schema-generation.create-script-source (or drop-script-source). Legacy keys hibernate.hbm2ddl.create_source / hibernate.hbm2ddl.create_script_source are read too, so the same mix with old-style keys also triggers it.","commonSituations":"Copy-pasting a partial JPA 2.1 schema-generation example into persistence.xml; migrating javax.persistence.* to jakarta.persistence.* and misspelling the new key so the script-source lookup silently misses; a CI property file defining create-source in one profile but the script path in another; typos like 'create-source-script' instead of 'create-script-source'.","solutions":["Add jakarta.persistence.schema-generation.create-script-source (or drop-script-source) pointing to a loadable script, e.g. 'create.sql' (classpath resource) or 'file:/opt/db/create.sql'.","If you only want metadata-driven DDL, set jakarta.persistence.schema-generation.create-source=metadata (or simply remove the create-source/drop-source entry).","Verify the exact key names: it is 'create-script-source' and 'drop-script-source', not 'create-source-script'; confirm jakarta.* spelling on Hibernate 6+.","If a property placeholder supplies the script path, check it resolves to a non-null value at bootstrap time."],"exampleFix":"// persistence.xml (before)\n<property name=\"jakarta.persistence.schema-generation.database.action\" value=\"drop-and-create\"/>\n<property name=\"jakarta.persistence.schema-generation.drop-source\" value=\"script\"/>\n<!-- missing: drop-script-source -->\n\n// persistence.xml (after)\n<property name=\"jakarta.persistence.schema-generation.database.action\" value=\"drop-and-create\"/>\n<property name=\"jakarta.persistence.schema-generation.drop-source\" value=\"script\"/>\n<property name=\"jakarta.persistence.schema-generation.drop-script-source\" value=\"drop.sql\"/>","handlingStrategy":"validation","validationCode":"// Validate JPA schema-gen settings before building the EMF\nboolean sourceIncludesScripts = Stream.of(\"script\", \"metadata-then-script\", \"script-then-metadata\")\n    .anyMatch(v -> v.equalsIgnoreCase((String) props.getOrDefault(\n        \"jakarta.persistence.schema-generation.create-source\", \"\")))\n    || Stream.of(\"script\", \"metadata-then-script\", \"script-then-metadata\")\n    .anyMatch(v -> v.equalsIgnoreCase((String) props.getOrDefault(\n        \"jakarta.persistence.schema-generation.drop-source\", \"\")));\nif (sourceIncludesScripts\n        && props.get(\"jakarta.persistence.schema-generation.create-script-source\") == null\n        && props.get(\"jakarta.persistence.schema-generation.drop-script-source\") == null) {\n    throw new IllegalStateException(\n        \"create-source/drop-source includes scripts but no *-script-source is configured\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    EntityManagerFactory emf = Persistence.createEntityManagerFactory(\"pu\", props);\n} catch (PersistenceException e) {\n    if (e.getCause() instanceof SchemaManagementException sme\n            && sme.getMessage().contains(\"no script was specified\")) {\n        throw new ConfigurationException(\"Fix schema-generation script-source settings\", sme);\n    }\n    throw e;\n}","preventionTips":["Keep schema-generation create-source/drop-source and their *-script-source settings in the same properties block so they cannot drift apart.","Use jakarta.persistence.* key names on Hibernate 6+; treat javax.* leftovers as smells.","Add a startup assertion in test configs that any *-source=script has a matching script file that exists."],"tags":["hibernate","hbm2ddl","schema-generation","configuration","bootstrap","persistence-xml"],"backgroundTag":"schema-generation-misconfiguration","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}