HHH-15768 Don't set deprecated settings from PUI

This commit is contained in:
Marco Belladelli 2022-12-13 18:05:19 +01:00 committed by Christian Beikov
parent 540b8ec684
commit 3c287d4429
2 changed files with 17 additions and 4 deletions

View File

@ -627,7 +627,6 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
mergedSettings.configurationValues.put( JPA_VALIDATION_MODE, intgValidationMode );
}
else if ( persistenceUnit.getValidationMode() != null ) {
mergedSettings.configurationValues.put( JPA_VALIDATION_MODE, persistenceUnit.getValidationMode() );
mergedSettings.configurationValues.put( JAKARTA_VALIDATION_MODE, persistenceUnit.getValidationMode() );
}
@ -643,7 +642,6 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
}
else if ( persistenceUnit.getSharedCacheMode() != null ) {
mergedSettings.configurationValues.put( JAKARTA_SHARED_CACHE_MODE, persistenceUnit.getSharedCacheMode() );
mergedSettings.configurationValues.put( JPA_SHARED_CACHE_MODE, persistenceUnit.getSharedCacheMode() );
}
// Apply all "integration overrides" as the last step. By specification,

View File

@ -37,6 +37,7 @@ import jakarta.persistence.ValidationMode;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.fail;
/**
@ -88,7 +89,14 @@ public class ConfigurationObjectSettingTest {
adapter,
null
);
assertEquals( SharedCacheMode.ENABLE_SELECTIVE, builder.getConfigurationValues().get( settingName ) );
Object value = builder.getConfigurationValues().get( settingName );
// PUI should only set non-deprecated setting
if (AvailableSettings.JPA_SHARED_CACHE_MODE.equals( settingName )) {
assertNull( value );
}
else {
assertEquals( SharedCacheMode.ENABLE_SELECTIVE, value );
}
}
builder.cancel();
@ -145,7 +153,14 @@ public class ConfigurationObjectSettingTest {
adapter,
null
);
assertThat( builder.getConfigurationValues().get( settingName ) ).isEqualTo( ValidationMode.CALLBACK );
Object value = builder.getConfigurationValues().get( settingName );
// PUI should only set non-deprecated settings
if (AvailableSettings.JPA_VALIDATION_MODE.equals( settingName )) {
assertNull( value );
}
else {
assertThat( value ).isEqualTo( ValidationMode.CALLBACK );
}
}
builder.cancel();