hibernate/hibernate-orm · error · PersistenceException
Property {} was set to '{}', which is not compatible with th
Error message
Property {} was set to '{}', which is not compatible with the expected type {} What it means
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.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java:529
final Object propertyValue = configurationValues.remove( propertyName );
return propertyValue != null && parseBoolean( propertyValue.toString() );
}
/**
* Builds the context to be used in runtime bytecode enhancement
*
* @param dirtyTrackingEnabled To enable dirty tracking feature
* @param lazyInitializationEnabled To enable lazy initialization feature
* @param associationManagementEnabled To enable association management feature
* @return An enhancement context for classes managed by this EM
*/
protected EnhancementContext getEnhancementContext(
final boolean dirtyTrackingEnabled,
final boolean lazyInitializationEnabled,
final boolean associationManagementEnabled ) {
final Object propValue = configurationValues.get( BYTECODE_PROVIDER_INSTANCE );
if ( propValue != null && ( ! ( propValue instanceof BytecodeProvider ) ) ) {
throw new PersistenceException( "Property " + BYTECODE_PROVIDER_INSTANCE + " was set to '" + propValue
+ "', which is not compatible with the expected type " + BytecodeProvider.class );
}
final var overriddenBytecodeProvider = (BytecodeProvider) propValue;
return new DefaultEnhancementContext() {
@Override
public boolean isEntityClass(UnloadedClass classDescriptor) {
return managedResources.getAnnotatedClassNames().contains( classDescriptor.getName() )
&& super.isEntityClass( classDescriptor );
}
@Override
public boolean isCompositeClass(UnloadedClass classDescriptor) {
return managedResources.getAnnotatedClassNames().contains( classDescriptor.getName() )
&& super.isCompositeClass( classDescriptor );
}
@OverrideView on GitHub (pinned to fad1729dce)
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
Example fix
// before
configurationValues.put("hibernate.enhancer.bytecodeprovider.instance", "bytebuddy");
// after
configurationValues.put("hibernate.bytecode.provider", "bytebuddy"); // name-based
// or
// configurationValues.put("hibernate.enhancer.bytecodeprovider.instance", myBytecodeProvider); Defensive patterns
Strategy: type-guard
Validate before calling
Object candidate = configurationValues.get("hibernate.enhancer.bytecodeprovider.instance");
if (candidate != null && !(candidate instanceof org.hibernate.bytecode.spi.BytecodeProvider)) {
configurationValues.put("hibernate.bytecode.provider", String.valueOf(candidate));
configurationValues.remove("hibernate.enhancer.bytecodeprovider.instance");
} Type guard
static boolean isBytecodeProviderInstance(Object v) {
return v == null || v instanceof org.hibernate.bytecode.spi.BytecodeProvider;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Property %s was set to `%s`, which is not compatible with th
- [persistence unit: %s] Enhancement requires a temp class loa
- Enhancement requires a temp class loader, but none was given
- The provided {} setting value [{}] is not supported
- The {storageEngine} storage engine is not supported
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/b9aa12ac85abc5c4.
Report an issue: GitHub.