From 1b8d94ddba8f38a812db65ddf7ba44eced45c6c9 Mon Sep 17 00:00:00 2001 From: Chris Cranford Date: Wed, 26 Oct 2016 11:09:20 -0400 Subject: [PATCH] HHH-11205 - Added test case. --- .../UseNationalizedCharDataSettingTest.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/hibernate-core/src/test/java/org/hibernate/test/nationalized/UseNationalizedCharDataSettingTest.java b/hibernate-core/src/test/java/org/hibernate/test/nationalized/UseNationalizedCharDataSettingTest.java index 6c9736df6a..ce9be6ac78 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/nationalized/UseNationalizedCharDataSettingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/nationalized/UseNationalizedCharDataSettingTest.java @@ -19,6 +19,8 @@ import org.hibernate.cfg.AvailableSettings; import org.hibernate.dialect.PostgreSQL81Dialect; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.Property; +import org.hibernate.type.CharacterNCharType; +import org.hibernate.type.CharacterType; import org.hibernate.type.StringNVarcharType; import org.hibernate.type.StringType; @@ -62,6 +64,32 @@ public class UseNationalizedCharDataSettingTest extends BaseUnitTestCase { } } + @Test + @TestForIssue( jiraKey = "HHH-11205" ) + public void testSettingOnCharType() { + 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( "flag" ); + if(metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect ){ + assertSame( CharacterType.INSTANCE, nameAttribute.getType() ); + }else { + assertSame( CharacterNCharType.INSTANCE, nameAttribute.getType() ); + } + + } + finally { + StandardServiceRegistryBuilder.destroy( ssr ); + } + } + @Entity(name = "NationalizedBySettingEntity") @Table(name = "nationalized_by_setting_entity") public static class NationalizedBySettingEntity { @@ -70,5 +98,6 @@ public class UseNationalizedCharDataSettingTest extends BaseUnitTestCase { private long id; String name; + char flag; } }