{"record":{"id":"b9aa12ac85abc5c4","repo":"hibernate/hibernate-orm","slug":"property-was-set-to-which-is-not-compatib","errorCode":null,"errorMessage":"Property {} was set to '{}', which is not compatible with the expected type {}","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/boot/internal/EntityManagerFactoryBuilderImpl.java","lineNumber":529,"sourceCode":"\t\tfinal Object propertyValue = configurationValues.remove( propertyName );\n\t\treturn propertyValue != null && parseBoolean( propertyValue.toString() );\n\t}\n\n\t/**\n\t * Builds the context to be used in runtime bytecode enhancement\n\t *\n\t * @param dirtyTrackingEnabled To enable dirty tracking feature\n\t * @param lazyInitializationEnabled To enable lazy initialization feature\n\t * @param associationManagementEnabled To enable association management feature\n\t * @return An enhancement context for classes managed by this EM\n\t */\n\tprotected EnhancementContext getEnhancementContext(\n\t\t\tfinal boolean dirtyTrackingEnabled,\n\t\t\tfinal boolean lazyInitializationEnabled,\n\t\t\tfinal boolean associationManagementEnabled ) {\n\t\tfinal Object propValue = configurationValues.get( BYTECODE_PROVIDER_INSTANCE );\n\t\tif ( propValue != null && ( ! ( propValue instanceof BytecodeProvider ) ) ) {\n\t\t\tthrow new PersistenceException( \"Property \" + BYTECODE_PROVIDER_INSTANCE + \" was set to '\" + propValue\n\t\t\t\t\t\t\t+ \"', which is not compatible with the expected type \" + BytecodeProvider.class );\n\t\t}\n\t\tfinal var overriddenBytecodeProvider = (BytecodeProvider) propValue;\n\t\treturn new DefaultEnhancementContext() {\n\n\t\t\t@Override\n\t\t\tpublic boolean isEntityClass(UnloadedClass classDescriptor) {\n\t\t\t\treturn managedResources.getAnnotatedClassNames().contains( classDescriptor.getName() )\n\t\t\t\t\t&& super.isEntityClass( classDescriptor );\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic boolean isCompositeClass(UnloadedClass classDescriptor) {\n\t\t\t\treturn managedResources.getAnnotatedClassNames().contains( classDescriptor.getName() )\n\t\t\t\t\t&& super.isCompositeClass( classDescriptor );\n\t\t\t}\n\n\t\t\t@Override","sourceCodeStart":511,"sourceCodeEnd":547,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java#L511-L547","documentation":"Same contract as the provider-level check, thrown from EntityManagerFactoryBuilderImpl.getEnhancementContext during EntityManagerFactory build: the value under hibernate.enhancer.bytecodeprovider.instance must be an org.hibernate.bytecode.spi.BytecodeProvider instance. Any other non-null type (a name String like \"bytebuddy\", a Class, a map) fails with this PersistenceException before the enhancement context is created.","triggerScenarios":"configurationValues.put(\"hibernate.enhancer.bytecodeprovider.instance\", \"bytebuddy\") or a class-name string in persistence.xml properties, hitting the boot builder path (e.g. via EntityManagerFactoryBuilder or native bootstrapping) rather than HibernatePersistenceProvider.","commonSituations":"Migrating name-based provider config to the instance setting without switching the value type; shared config maps reused across provider and builder bootstraps; YAML config that coerces objects to strings.","solutions":["Use the name-based setting hibernate.bytecode.provider = \"bytebuddy\" for selection by string","Or put a real BytecodeProvider instance under hibernate.enhancer.bytecodeprovider.instance","Drop the setting if the default provider suffices"],"exampleFix":"// before\nconfigurationValues.put(\"hibernate.enhancer.bytecodeprovider.instance\", \"bytebuddy\");\n\n// after\nconfigurationValues.put(\"hibernate.bytecode.provider\", \"bytebuddy\"); // name-based\n// or\n// configurationValues.put(\"hibernate.enhancer.bytecodeprovider.instance\", myBytecodeProvider);","handlingStrategy":"type-guard","validationCode":"Object candidate = configurationValues.get(\"hibernate.enhancer.bytecodeprovider.instance\");\nif (candidate != null && !(candidate instanceof org.hibernate.bytecode.spi.BytecodeProvider)) {\n    configurationValues.put(\"hibernate.bytecode.provider\", String.valueOf(candidate));\n    configurationValues.remove(\"hibernate.enhancer.bytecodeprovider.instance\");\n}","typeGuard":"static boolean isBytecodeProviderInstance(Object v) {\n    return v == null || v instanceof org.hibernate.bytecode.spi.BytecodeProvider;\n}","tryCatchPattern":null,"preventionTips":["Select providers by name via hibernate.bytecode.provider","Only ever assign a BytecodeProvider instance to hibernate.enhancer.bytecodeprovider.instance","Centralize bytecode-provider configuration so both provider and builder bootstrap paths see the same validated value"],"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"}