PostgreSQL should not use nvarchar when using Nationalization

Description

When running the org.hibernate.userguide.mapping.basic.NationalizedTest using PostgreSQL, we get the following exception:

org.hibernate.tool.schema.spi.CommandAcceptanceException: Unable to execute command [ create table Product ( id int4 not null, name varchar(255), warranty nvarchar(255), primary key (id) )] at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:63) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlString(SchemaCreatorImpl.java:434) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlStrings(SchemaCreatorImpl.java:419) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.createFromMetadata(SchemaCreatorImpl.java:310) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.performCreation(SchemaCreatorImpl.java:165) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:134) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:120) at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:148) at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:64) at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:458) at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:465) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:881) at org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase.buildEntityManagerFactory(BaseEntityManagerFunctionalTestCase.java:79) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.internal.runners.statements.FailOnTimeout$StatementThread.run(FailOnTimeout.java:74) Caused by: org.postgresql.util.PSQLException: ERROR: type "nvarchar" does not exist

Second, the PostgreSQL driver does not support Statement.setNVarChar either, and so we cannot use the NVarcharTypeDescriptor for PostgreSQL.

Caused by: java.sql.SQLFeatureNotSupportedException: Method org.postgresql.jdbc4.Jdbc4PreparedStatement.setNString(int, String) is not yet implemented. at org.postgresql.Driver.notImplemented(Driver.java:670) at org.postgresql.jdbc4.AbstractJdbc4Statement.setNString(AbstractJdbc4Statement.java:101) at org.hibernate.type.descriptor.sql.NVarcharTypeDescriptor$1.doBind(NVarcharTypeDescriptor.java:46)

Accodring to this site and this SO question, The PostgreSQL VARCHAR plays the role of an NVARCHAR in other DBs,

Activity

Show:

Former user July 25, 2017 at 5:22 AM

Unit tests failures on PostgreSQL were not fixed for 5.1 by this jira; instead they are fixed by HHH-10693.

Former user August 9, 2016 at 11:24 PM

Fixed in master and 5.1 branches.

Andrea Boriero April 18, 2016 at 10:35 AM

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Created April 18, 2016 at 8:38 AM
Updated July 25, 2017 at 5:22 AM
Resolved August 9, 2016 at 11:24 PM