HHH-10693 - Fix PostgreSQL failing tests

This commit is contained in:
Andrea Boriero 2016-08-15 09:09:52 +02:00
parent 8d86770dcc
commit f201d2829e
3 changed files with 53 additions and 10 deletions

View File

@ -19,8 +19,10 @@ import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.internal.MetadataImpl; import org.hibernate.boot.internal.MetadataImpl;
import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.dialect.PostgreSQL81Dialect;
import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.PersistentClass;
import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseUnitTestCase; import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.junit.Test; import org.junit.Test;
@ -32,6 +34,7 @@ import static org.junit.Assert.assertEquals;
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
//@SkipForDialect(value = PostgreSQL81Dialect.class, comment = "Postgres does not support ")
public class AndNationalizedTests extends BaseUnitTestCase { public class AndNationalizedTests extends BaseUnitTestCase {
@Test @Test
@TestForIssue( jiraKey = "HHH-9599") @TestForIssue( jiraKey = "HHH-9599")
@ -42,10 +45,18 @@ public class AndNationalizedTests extends BaseUnitTestCase {
( (MetadataImpl) metadata ).validate(); ( (MetadataImpl) metadata ).validate();
final PersistentClass entityBinding = metadata.getEntityBinding( TestEntity.class.getName() ); final PersistentClass entityBinding = metadata.getEntityBinding( TestEntity.class.getName() );
assertEquals( if(metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect){
Types.NVARCHAR, // See issue HHH-10693
entityBinding.getProperty( "name" ).getType().sqlTypes( metadata )[0] assertEquals(
); Types.VARCHAR,
entityBinding.getProperty( "name" ).getType().sqlTypes( metadata )[0]
);
}else {
assertEquals(
Types.NVARCHAR,
entityBinding.getProperty( "name" ).getType().sqlTypes( metadata )[0]
);
}
} }
finally { finally {
StandardServiceRegistryBuilder.destroy( ssr ); StandardServiceRegistryBuilder.destroy( ssr );

View File

@ -17,13 +17,18 @@ import org.hibernate.boot.Metadata;
import org.hibernate.boot.MetadataSources; import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.dialect.PostgreSQL81Dialect;
import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property; import org.hibernate.mapping.Property;
import org.hibernate.type.CharacterArrayType;
import org.hibernate.type.CharacterNCharType; import org.hibernate.type.CharacterNCharType;
import org.hibernate.type.CharacterType;
import org.hibernate.type.MaterializedClobType;
import org.hibernate.type.MaterializedNClobType; import org.hibernate.type.MaterializedNClobType;
import org.hibernate.type.NClobType; import org.hibernate.type.NClobType;
import org.hibernate.type.NTextType; import org.hibernate.type.NTextType;
import org.hibernate.type.StringNVarcharType; import org.hibernate.type.StringNVarcharType;
import org.hibernate.type.StringType;
import org.hibernate.testing.junit4.BaseUnitTestCase; import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.junit.Test; import org.junit.Test;
@ -76,11 +81,20 @@ public class SimpleNationalizedTest extends BaseUnitTestCase {
assertNotNull( pc ); assertNotNull( pc );
Property prop = pc.getProperty( "nvarcharAtt" ); Property prop = pc.getProperty( "nvarcharAtt" );
assertSame( StringNVarcharType.INSTANCE, prop.getType() ); if(metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect ){
// See issue HHH-10693
assertSame( StringType.INSTANCE, prop.getType() );
}else{
assertSame( StringNVarcharType.INSTANCE, prop.getType() );
}
prop = pc.getProperty( "materializedNclobAtt" ); prop = pc.getProperty( "materializedNclobAtt" );
assertSame( MaterializedNClobType.INSTANCE, prop.getType() ); if(metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect ){
// See issue HHH-10693
assertSame( MaterializedClobType.INSTANCE, prop.getType() );
}else {
assertSame( MaterializedNClobType.INSTANCE, prop.getType() );
}
prop = pc.getProperty( "nclobAtt" ); prop = pc.getProperty( "nclobAtt" );
assertSame( NClobType.INSTANCE, prop.getType() ); assertSame( NClobType.INSTANCE, prop.getType() );
@ -88,10 +102,21 @@ public class SimpleNationalizedTest extends BaseUnitTestCase {
assertSame( NTextType.INSTANCE, prop.getType() ); assertSame( NTextType.INSTANCE, prop.getType() );
prop = pc.getProperty( "ncharArrAtt" ); prop = pc.getProperty( "ncharArrAtt" );
assertSame( StringNVarcharType.INSTANCE, prop.getType() ); if(metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect ){
// See issue HHH-10693
assertSame( CharacterArrayType.INSTANCE, prop.getType() );
}else {
assertSame( StringNVarcharType.INSTANCE, prop.getType() );
}
prop = pc.getProperty( "ncharacterAtt" ); prop = pc.getProperty( "ncharacterAtt" );
assertSame( CharacterNCharType.INSTANCE, prop.getType() ); if ( metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect ) {
// See issue HHH-10693
assertSame( CharacterType.INSTANCE, prop.getType() );
}
else {
assertSame( CharacterNCharType.INSTANCE, prop.getType() );
}
} }
finally { finally {
StandardServiceRegistryBuilder.destroy( ssr ); StandardServiceRegistryBuilder.destroy( ssr );

View File

@ -16,9 +16,11 @@ import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.dialect.PostgreSQL81Dialect;
import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property; import org.hibernate.mapping.Property;
import org.hibernate.type.StringNVarcharType; import org.hibernate.type.StringNVarcharType;
import org.hibernate.type.StringType;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseUnitTestCase; import org.hibernate.testing.junit4.BaseUnitTestCase;
@ -47,7 +49,12 @@ public class UseNationalizedCharDataSettingTest extends BaseUnitTestCase {
final Metadata metadata = ms.buildMetadata(); final Metadata metadata = ms.buildMetadata();
final PersistentClass pc = metadata.getEntityBinding( NationalizedBySettingEntity.class.getName() ); final PersistentClass pc = metadata.getEntityBinding( NationalizedBySettingEntity.class.getName() );
final Property nameAttribute = pc.getProperty( "name" ); final Property nameAttribute = pc.getProperty( "name" );
assertSame( StringNVarcharType.INSTANCE, nameAttribute.getType() ); if(metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect ){
// See issue HHH-10693
assertSame( StringType.INSTANCE, nameAttribute.getType() );
}else {
assertSame( StringNVarcharType.INSTANCE, nameAttribute.getType() );
}
} }
finally { finally {