HHH-10528 - use_nationalized_character_data global property is ignored
This commit is contained in:
parent
409c5424a0
commit
0fccf6b7bd
|
@ -583,44 +583,44 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
|
||||||
|
|
||||||
// jandexView = (IndexView) configService.getSettings().get( AvailableSettings.JANDEX_INDEX );
|
// jandexView = (IndexView) configService.getSettings().get( AvailableSettings.JANDEX_INDEX );
|
||||||
|
|
||||||
scanOptions = new StandardScanOptions(
|
this.scanOptions = new StandardScanOptions(
|
||||||
(String) configService.getSettings().get( AvailableSettings.SCANNER_DISCOVERY ),
|
(String) configService.getSettings().get( AvailableSettings.SCANNER_DISCOVERY ),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
// ScanEnvironment must be set explicitly
|
// ScanEnvironment must be set explicitly
|
||||||
scannerSetting = configService.getSettings().get( AvailableSettings.SCANNER );
|
this.scannerSetting = configService.getSettings().get( AvailableSettings.SCANNER );
|
||||||
if ( scannerSetting == null ) {
|
if ( this.scannerSetting == null ) {
|
||||||
scannerSetting = configService.getSettings().get( AvailableSettings.SCANNER_DEPRECATED );
|
this.scannerSetting = configService.getSettings().get( AvailableSettings.SCANNER_DEPRECATED );
|
||||||
if ( scannerSetting != null ) {
|
if ( this.scannerSetting != null ) {
|
||||||
DEPRECATION_LOGGER.logDeprecatedScannerSetting();
|
DEPRECATION_LOGGER.logDeprecatedScannerSetting();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
archiveDescriptorFactory = strategySelector.resolveStrategy(
|
this.archiveDescriptorFactory = strategySelector.resolveStrategy(
|
||||||
ArchiveDescriptorFactory.class,
|
ArchiveDescriptorFactory.class,
|
||||||
configService.getSettings().get( AvailableSettings.SCANNER_ARCHIVE_INTERPRETER )
|
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,
|
AvailableSettings.IMPLICIT_DISCRIMINATOR_COLUMNS_FOR_JOINED_SUBCLASS,
|
||||||
StandardConverters.BOOLEAN,
|
StandardConverters.BOOLEAN,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
explicitDiscriminatorsForJoinedInheritanceSupported = !configService.getSetting(
|
this.explicitDiscriminatorsForJoinedInheritanceSupported = !configService.getSetting(
|
||||||
AvailableSettings.IGNORE_EXPLICIT_DISCRIMINATOR_COLUMNS_FOR_JOINED_SUBCLASS,
|
AvailableSettings.IGNORE_EXPLICIT_DISCRIMINATOR_COLUMNS_FOR_JOINED_SUBCLASS,
|
||||||
StandardConverters.BOOLEAN,
|
StandardConverters.BOOLEAN,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
implicitlyForceDiscriminatorInSelect = configService.getSetting(
|
this.implicitlyForceDiscriminatorInSelect = configService.getSetting(
|
||||||
AvailableSettings.FORCE_DISCRIMINATOR_IN_SELECTS_BY_DEFAULT,
|
AvailableSettings.FORCE_DISCRIMINATOR_IN_SELECTS_BY_DEFAULT,
|
||||||
StandardConverters.BOOLEAN,
|
StandardConverters.BOOLEAN,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
sharedCacheMode = configService.getSetting(
|
this.sharedCacheMode = configService.getSetting(
|
||||||
"javax.persistence.sharedCache.mode",
|
"javax.persistence.sharedCache.mode",
|
||||||
new ConfigurationService.Converter<SharedCacheMode>() {
|
new ConfigurationService.Converter<SharedCacheMode>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -639,7 +639,7 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
|
||||||
SharedCacheMode.UNSPECIFIED
|
SharedCacheMode.UNSPECIFIED
|
||||||
);
|
);
|
||||||
|
|
||||||
defaultCacheAccessType = configService.getSetting(
|
this.defaultCacheAccessType = configService.getSetting(
|
||||||
AvailableSettings.DEFAULT_CACHE_CONCURRENCY_STRATEGY,
|
AvailableSettings.DEFAULT_CACHE_CONCURRENCY_STRATEGY,
|
||||||
new ConfigurationService.Converter<AccessType>() {
|
new ConfigurationService.Converter<AccessType>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -665,13 +665,13 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
|
||||||
: serviceRegistry.getService( RegionFactory.class ).getDefaultAccessType()
|
: serviceRegistry.getService( RegionFactory.class ).getDefaultAccessType()
|
||||||
);
|
);
|
||||||
|
|
||||||
specjProprietarySyntaxEnabled = configService.getSetting(
|
this.specjProprietarySyntaxEnabled = configService.getSetting(
|
||||||
"hibernate.enable_specj_proprietary_syntax",
|
"hibernate.enable_specj_proprietary_syntax",
|
||||||
StandardConverters.BOOLEAN,
|
StandardConverters.BOOLEAN,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
implicitNamingStrategy = strategySelector.resolveDefaultableStrategy(
|
this.implicitNamingStrategy = strategySelector.resolveDefaultableStrategy(
|
||||||
ImplicitNamingStrategy.class,
|
ImplicitNamingStrategy.class,
|
||||||
configService.getSettings().get( AvailableSettings.IMPLICIT_NAMING_STRATEGY ),
|
configService.getSettings().get( AvailableSettings.IMPLICIT_NAMING_STRATEGY ),
|
||||||
new Callable<ImplicitNamingStrategy>() {
|
new Callable<ImplicitNamingStrategy>() {
|
||||||
|
@ -686,13 +686,13 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
physicalNamingStrategy = strategySelector.resolveDefaultableStrategy(
|
this.physicalNamingStrategy = strategySelector.resolveDefaultableStrategy(
|
||||||
PhysicalNamingStrategy.class,
|
PhysicalNamingStrategy.class,
|
||||||
configService.getSettings().get( AvailableSettings.PHYSICAL_NAMING_STRATEGY ),
|
configService.getSettings().get( AvailableSettings.PHYSICAL_NAMING_STRATEGY ),
|
||||||
PhysicalNamingStrategyStandardImpl.INSTANCE
|
PhysicalNamingStrategyStandardImpl.INSTANCE
|
||||||
);
|
);
|
||||||
|
|
||||||
sourceProcessOrdering = resolveInitialSourceProcessOrdering( configService );
|
this.sourceProcessOrdering = resolveInitialSourceProcessOrdering( configService );
|
||||||
|
|
||||||
final boolean useNewIdentifierGenerators = configService.getSetting(
|
final boolean useNewIdentifierGenerators = configService.getSetting(
|
||||||
AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS,
|
AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS,
|
||||||
|
@ -700,13 +700,19 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
if ( useNewIdentifierGenerators ) {
|
if ( useNewIdentifierGenerators ) {
|
||||||
idGenerationTypeInterpreter.disableLegacyFallback();
|
this.idGenerationTypeInterpreter.disableLegacyFallback();
|
||||||
}
|
}
|
||||||
else {
|
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) {
|
private ArrayList<MetadataSourceType> resolveInitialSourceProcessOrdering(ConfigurationService configService) {
|
||||||
|
|
|
@ -192,7 +192,7 @@ public interface MetadataBuildingOptions {
|
||||||
*
|
*
|
||||||
* @return {@code true} if nationalized character data should be used by default; {@code false} otherwise.
|
* @return {@code true} if nationalized character data should be used by default; {@code false} otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean useNationalizedCharacterData();
|
boolean useNationalizedCharacterData();
|
||||||
|
|
||||||
boolean isSpecjProprietarySyntaxEnabled();
|
boolean isSpecjProprietarySyntaxEnabled();
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue