HHH-10528 - use_nationalized_character_data global property is ignored

This commit is contained in:
Steve Ebersole 2016-02-16 09:35:12 -06:00
parent 409c5424a0
commit 0fccf6b7bd
3 changed files with 93 additions and 20 deletions

View File

@ -583,44 +583,44 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
// jandexView = (IndexView) configService.getSettings().get( AvailableSettings.JANDEX_INDEX );
scanOptions = new StandardScanOptions(
this.scanOptions = new StandardScanOptions(
(String) configService.getSettings().get( AvailableSettings.SCANNER_DISCOVERY ),
false
);
// ScanEnvironment must be set explicitly
scannerSetting = configService.getSettings().get( AvailableSettings.SCANNER );
if ( scannerSetting == null ) {
scannerSetting = configService.getSettings().get( AvailableSettings.SCANNER_DEPRECATED );
if ( scannerSetting != null ) {
this.scannerSetting = configService.getSettings().get( AvailableSettings.SCANNER );
if ( this.scannerSetting == null ) {
this.scannerSetting = configService.getSettings().get( AvailableSettings.SCANNER_DEPRECATED );
if ( this.scannerSetting != null ) {
DEPRECATION_LOGGER.logDeprecatedScannerSetting();
}
}
archiveDescriptorFactory = strategySelector.resolveStrategy(
this.archiveDescriptorFactory = strategySelector.resolveStrategy(
ArchiveDescriptorFactory.class,
configService.getSettings().get( AvailableSettings.SCANNER_ARCHIVE_INTERPRETER )
);
multiTenancyStrategy = MultiTenancyStrategy.determineMultiTenancyStrategy( configService.getSettings() );
this.multiTenancyStrategy = MultiTenancyStrategy.determineMultiTenancyStrategy( configService.getSettings() );
implicitDiscriminatorsForJoinedInheritanceSupported = configService.getSetting(
this.implicitDiscriminatorsForJoinedInheritanceSupported = configService.getSetting(
AvailableSettings.IMPLICIT_DISCRIMINATOR_COLUMNS_FOR_JOINED_SUBCLASS,
StandardConverters.BOOLEAN,
false
);
explicitDiscriminatorsForJoinedInheritanceSupported = !configService.getSetting(
this.explicitDiscriminatorsForJoinedInheritanceSupported = !configService.getSetting(
AvailableSettings.IGNORE_EXPLICIT_DISCRIMINATOR_COLUMNS_FOR_JOINED_SUBCLASS,
StandardConverters.BOOLEAN,
false
);
implicitlyForceDiscriminatorInSelect = configService.getSetting(
this.implicitlyForceDiscriminatorInSelect = configService.getSetting(
AvailableSettings.FORCE_DISCRIMINATOR_IN_SELECTS_BY_DEFAULT,
StandardConverters.BOOLEAN,
false
);
sharedCacheMode = configService.getSetting(
this.sharedCacheMode = configService.getSetting(
"javax.persistence.sharedCache.mode",
new ConfigurationService.Converter<SharedCacheMode>() {
@Override
@ -639,7 +639,7 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
SharedCacheMode.UNSPECIFIED
);
defaultCacheAccessType = configService.getSetting(
this.defaultCacheAccessType = configService.getSetting(
AvailableSettings.DEFAULT_CACHE_CONCURRENCY_STRATEGY,
new ConfigurationService.Converter<AccessType>() {
@Override
@ -665,13 +665,13 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
: serviceRegistry.getService( RegionFactory.class ).getDefaultAccessType()
);
specjProprietarySyntaxEnabled = configService.getSetting(
this.specjProprietarySyntaxEnabled = configService.getSetting(
"hibernate.enable_specj_proprietary_syntax",
StandardConverters.BOOLEAN,
false
);
implicitNamingStrategy = strategySelector.resolveDefaultableStrategy(
this.implicitNamingStrategy = strategySelector.resolveDefaultableStrategy(
ImplicitNamingStrategy.class,
configService.getSettings().get( AvailableSettings.IMPLICIT_NAMING_STRATEGY ),
new Callable<ImplicitNamingStrategy>() {
@ -686,13 +686,13 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
}
);
physicalNamingStrategy = strategySelector.resolveDefaultableStrategy(
this.physicalNamingStrategy = strategySelector.resolveDefaultableStrategy(
PhysicalNamingStrategy.class,
configService.getSettings().get( AvailableSettings.PHYSICAL_NAMING_STRATEGY ),
PhysicalNamingStrategyStandardImpl.INSTANCE
);
sourceProcessOrdering = resolveInitialSourceProcessOrdering( configService );
this.sourceProcessOrdering = resolveInitialSourceProcessOrdering( configService );
final boolean useNewIdentifierGenerators = configService.getSetting(
AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS,
@ -700,13 +700,19 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
true
);
if ( useNewIdentifierGenerators ) {
idGenerationTypeInterpreter.disableLegacyFallback();
this.idGenerationTypeInterpreter.disableLegacyFallback();
}
else {
idGenerationTypeInterpreter.enableLegacyFallback();
this.idGenerationTypeInterpreter.enableLegacyFallback();
}
reflectionManager = generateDefaultReflectionManager();
this.useNationalizedCharacterData = configService.getSetting(
AvailableSettings.USE_NATIONALIZED_CHARACTER_DATA,
StandardConverters.BOOLEAN,
false
);
this.reflectionManager = generateDefaultReflectionManager();
}
private ArrayList<MetadataSourceType> resolveInitialSourceProcessOrdering(ConfigurationService configService) {

View File

@ -192,7 +192,7 @@ public interface MetadataBuildingOptions {
*
* @return {@code true} if nationalized character data should be used by default; {@code false} otherwise.
*/
public boolean useNationalizedCharacterData();
boolean useNationalizedCharacterData();
boolean isSpecjProprietarySyntaxEnabled();

View File

@ -0,0 +1,67 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.nationalized;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.boot.Metadata;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.type.StringNVarcharType;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.junit.Test;
import static org.junit.Assert.assertSame;
/**
* Test the use of {@link org.hibernate.cfg.AvailableSettings#USE_NATIONALIZED_CHARACTER_DATA}
* to indicate that nationalized character data should be used.
*
* @author Steve Ebersole
*/
public class UseNationalizedCharDataSettingTest extends BaseUnitTestCase {
@Test
@TestForIssue( jiraKey = "HHH-10528" )
public void testSetting() {
final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder()
.applySetting( AvailableSettings.USE_NATIONALIZED_CHARACTER_DATA, true )
.build();
try {
final MetadataSources ms = new MetadataSources( ssr );
ms.addAnnotatedClass( NationalizedBySettingEntity.class );
final Metadata metadata = ms.buildMetadata();
final PersistentClass pc = metadata.getEntityBinding( NationalizedBySettingEntity.class.getName() );
final Property nameAttribute = pc.getProperty( "name" );
assertSame( StringNVarcharType.INSTANCE, nameAttribute.getType() );
}
finally {
StandardServiceRegistryBuilder.destroy( ssr );
}
}
@Entity(name = "NationalizedBySettingEntity")
@Table(name = "nationalized_by_setting_entity")
public static class NationalizedBySettingEntity {
@Id
@GeneratedValue
private long id;
String name;
}
}