{"record":{"id":"fbf632e66639cfc2","repo":"hibernate/hibernate-orm","slug":"property-s-was-set-to-s-which-is-not-compatib","errorCode":null,"errorMessage":"Property %s was set to `%s`, which is not compatible with the expected type %s","messagePattern":"Property (.+?) was set to `(.+?)`, which is not compatible with the expected type (.+?)","errorType":"exception","errorClass":"PersistenceException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/jpa/HibernatePersistenceProvider.java","lineNumber":432,"sourceCode":"\n\t\t\t@Override\n\t\t\tpublic BytecodeProvider getBytecodeProvider() {\n\t\t\t\treturn overriddenBytecodeProvider;\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate BytecodeProvider getExplicitBytecodeProvider(\n\t\t\tMap<?, ?> integrationSettings,\n\t\t\tPersistenceUnitInfo persistenceUnit) {\n\t\t// again, prefer integration settings\n\t\tvar setting = integrationSettings.get( BYTECODE_PROVIDER_INSTANCE );\n\t\tif ( setting == null ) {\n\t\t\tsetting = persistenceUnit.getProperties().get( BYTECODE_PROVIDER_INSTANCE );\n\t\t}\n\n\t\tif ( setting != null && ! (setting instanceof BytecodeProvider) ) {\n\t\t\tthrow new PersistenceException( String.format( Locale.ROOT,\n\t\t\t\t\t\"Property %s was set to `%s`, which is not compatible with the expected type %s\",\n\t\t\t\t\tBYTECODE_PROVIDER_INSTANCE,\n\t\t\t\t\tsetting,\n\t\t\t\t\tBytecodeProvider.class.getName()\n\t\t\t) );\n\t\t}\n\n\t\treturn (BytecodeProvider) setting;\n\t}\n\n\n\tprivate static class ProviderUtilImpl implements ProviderUtil {\n\t\tpublic static final ProviderUtilImpl INSTANCE = new ProviderUtilImpl();\n\n\t\tprivate final MetadataCache cache = new MetadataCache();\n\n\t\t@Override\n\t\tpublic LoadState isLoadedWithoutReference(Object proxy, String property) {","sourceCodeStart":414,"sourceCodeEnd":450,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/jpa/HibernatePersistenceProvider.java#L414-L450","documentation":"The setting hibernate.enhancer.bytecodeprovider.instance (BytecodeSettings.BYTECODE_PROVIDER_INSTANCE) must hold an actual org.hibernate.bytecode.spi.BytecodeProvider INSTANCE, not a name. getExplicitBytecodeProvider checks the integration settings and persistence-unit properties, and any non-null value that is not a BytecodeProvider throws this PersistenceException at EntityManagerFactory creation, echoing the offending value.","triggerScenarios":"props.put(\"hibernate.enhancer.bytecodeprovider.instance\", \"bytebuddy\") - a String instead of an instance; likewise passing a Class object or a fully-qualified class name string.","commonSituations":"Copy-pasting the NAME-based setting into the INSTANCE slot; migrating from hibernate.bytecode.provider (name string) to the instance setting without changing the value type; configuration frameworks coercing the value to String.","solutions":["To select a provider by name, use hibernate.bytecode.provider = \"bytebuddy\" instead","To inject a pre-built provider, pass the instance: props.put(\"hibernate.enhancer.bytecodeprovider.instance\", myBytecodeProvider)","Remove the setting entirely if the default provider is fine"],"exampleFix":"// before\nprops.put(\"hibernate.enhancer.bytecodeprovider.instance\", \"bytebuddy\"); // String -> PersistenceException\n\n// after\nprops.put(\"hibernate.bytecode.provider\", \"bytebuddy\"); // select by name\n// or inject an instance:\n// props.put(\"hibernate.enhancer.bytecodeprovider.instance\", myBytecodeProvider);","handlingStrategy":"type-guard","validationCode":"Object candidate = props.get(\"hibernate.enhancer.bytecodeprovider.instance\");\nif (candidate != null && !(candidate instanceof org.hibernate.bytecode.spi.BytecodeProvider)) {\n    // switch to the name-based setting\n    props.put(\"hibernate.bytecode.provider\", String.valueOf(candidate));\n    props.remove(\"hibernate.enhancer.bytecodeprovider.instance\");\n}","typeGuard":"static org.hibernate.bytecode.spi.BytecodeProvider asBytecodeProvider(Object v) {\n    return (v == null || v instanceof org.hibernate.bytecode.spi.BytecodeProvider p)\n            ? (org.hibernate.bytecode.spi.BytecodeProvider) v\n            : null; // null -> drop the setting, use name-based selection\n}","tryCatchPattern":null,"preventionTips":["Use hibernate.bytecode.provider for name-based selection","Reserve the ...instance setting for pre-built BytecodeProvider objects you constructed yourself","Never put class-name strings in the instance setting"],"tags":["configuration","bytecode-enhancement","jpa","bootstrap"],"backgroundTag":"invalid-config-value","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}