HHH-18314 NCHAR,NVARCHAR,NCLOB on Db2
1. Db2 driver now supports setNString() and friends 2. Hibernate SchemaValidator + SchemaMigrator now consider NUMERIC and DECIMAL equivalent We may therefore roll back HHH-12753 and HHH-12827 respectively. Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
e841c8387f
commit
755c93c9f1
|
@ -95,7 +95,6 @@ import org.hibernate.type.descriptor.java.JavaType;
|
||||||
import org.hibernate.type.descriptor.java.PrimitiveByteArrayJavaType;
|
import org.hibernate.type.descriptor.java.PrimitiveByteArrayJavaType;
|
||||||
import org.hibernate.type.descriptor.jdbc.CharJdbcType;
|
import org.hibernate.type.descriptor.jdbc.CharJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.ClobJdbcType;
|
import org.hibernate.type.descriptor.jdbc.ClobJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.DecimalJdbcType;
|
|
||||||
import org.hibernate.type.descriptor.jdbc.InstantJdbcType;
|
import org.hibernate.type.descriptor.jdbc.InstantJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.LocalDateJdbcType;
|
import org.hibernate.type.descriptor.jdbc.LocalDateJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.LocalDateTimeJdbcType;
|
import org.hibernate.type.descriptor.jdbc.LocalDateTimeJdbcType;
|
||||||
|
@ -889,9 +888,6 @@ public class DB2LegacyDialect extends Dialect {
|
||||||
jdbcTypeRegistry.addDescriptor( Types.BOOLEAN, SmallIntJdbcType.INSTANCE );
|
jdbcTypeRegistry.addDescriptor( Types.BOOLEAN, SmallIntJdbcType.INSTANCE );
|
||||||
// Binary literals were only added in 11. See https://www.ibm.com/support/knowledgecenter/SSEPGG_11.1.0/com.ibm.db2.luw.sql.ref.doc/doc/r0000731.html#d79816e393
|
// Binary literals were only added in 11. See https://www.ibm.com/support/knowledgecenter/SSEPGG_11.1.0/com.ibm.db2.luw.sql.ref.doc/doc/r0000731.html#d79816e393
|
||||||
jdbcTypeRegistry.addDescriptor( Types.VARBINARY, VarbinaryJdbcType.INSTANCE_WITHOUT_LITERALS );
|
jdbcTypeRegistry.addDescriptor( Types.VARBINARY, VarbinaryJdbcType.INSTANCE_WITHOUT_LITERALS );
|
||||||
if ( getDB2Version().isBefore( 9, 7 ) ) {
|
|
||||||
jdbcTypeRegistry.addDescriptor( Types.NUMERIC, DecimalJdbcType.INSTANCE );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// See HHH-12753
|
// See HHH-12753
|
||||||
// It seems that DB2's JDBC 4.0 support as of 9.5 does not
|
// It seems that DB2's JDBC 4.0 support as of 9.5 does not
|
||||||
|
@ -901,7 +897,6 @@ public class DB2LegacyDialect extends Dialect {
|
||||||
jdbcTypeRegistry.addDescriptor( Types.NCHAR, CharJdbcType.INSTANCE );
|
jdbcTypeRegistry.addDescriptor( Types.NCHAR, CharJdbcType.INSTANCE );
|
||||||
jdbcTypeRegistry.addDescriptor( Types.NCLOB, ClobJdbcType.STREAM_BINDING );
|
jdbcTypeRegistry.addDescriptor( Types.NCLOB, ClobJdbcType.STREAM_BINDING );
|
||||||
jdbcTypeRegistry.addDescriptor( Types.NVARCHAR, VarcharJdbcType.INSTANCE );
|
jdbcTypeRegistry.addDescriptor( Types.NVARCHAR, VarcharJdbcType.INSTANCE );
|
||||||
jdbcTypeRegistry.addDescriptor( Types.NUMERIC, DecimalJdbcType.INSTANCE );
|
|
||||||
|
|
||||||
jdbcTypeRegistry.addDescriptor( XmlJdbcType.INSTANCE );
|
jdbcTypeRegistry.addDescriptor( XmlJdbcType.INSTANCE );
|
||||||
jdbcTypeRegistry.addDescriptor( DB2StructJdbcType.INSTANCE );
|
jdbcTypeRegistry.addDescriptor( DB2StructJdbcType.INSTANCE );
|
||||||
|
|
|
@ -73,7 +73,6 @@ import org.hibernate.type.BasicTypeRegistry;
|
||||||
import org.hibernate.type.JavaObjectType;
|
import org.hibernate.type.JavaObjectType;
|
||||||
import org.hibernate.type.StandardBasicTypes;
|
import org.hibernate.type.StandardBasicTypes;
|
||||||
import org.hibernate.type.descriptor.java.BigDecimalJavaType;
|
import org.hibernate.type.descriptor.java.BigDecimalJavaType;
|
||||||
import org.hibernate.type.descriptor.jdbc.DecimalJdbcType;
|
|
||||||
import org.hibernate.type.descriptor.jdbc.ObjectNullResolvingJdbcType;
|
import org.hibernate.type.descriptor.jdbc.ObjectNullResolvingJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.SmallIntJdbcType;
|
import org.hibernate.type.descriptor.jdbc.SmallIntJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.TimestampJdbcType;
|
import org.hibernate.type.descriptor.jdbc.TimestampJdbcType;
|
||||||
|
@ -686,7 +685,6 @@ public class DerbyLegacyDialect extends Dialect {
|
||||||
if ( getVersion().isBefore( 10, 7 ) ) {
|
if ( getVersion().isBefore( 10, 7 ) ) {
|
||||||
jdbcTypeRegistry.addDescriptor( Types.BOOLEAN, SmallIntJdbcType.INSTANCE );
|
jdbcTypeRegistry.addDescriptor( Types.BOOLEAN, SmallIntJdbcType.INSTANCE );
|
||||||
}
|
}
|
||||||
jdbcTypeRegistry.addDescriptor( Types.NUMERIC, DecimalJdbcType.INSTANCE );
|
|
||||||
jdbcTypeRegistry.addDescriptor( Types.TIMESTAMP_WITH_TIMEZONE, TimestampJdbcType.INSTANCE );
|
jdbcTypeRegistry.addDescriptor( Types.TIMESTAMP_WITH_TIMEZONE, TimestampJdbcType.INSTANCE );
|
||||||
|
|
||||||
// Derby requires a custom binder for binding untyped nulls that resolves the type through the statement
|
// Derby requires a custom binder for binding untyped nulls that resolves the type through the statement
|
||||||
|
|
|
@ -84,9 +84,6 @@ import org.hibernate.type.StandardBasicTypes;
|
||||||
import org.hibernate.type.descriptor.ValueExtractor;
|
import org.hibernate.type.descriptor.ValueExtractor;
|
||||||
import org.hibernate.type.descriptor.java.JavaType;
|
import org.hibernate.type.descriptor.java.JavaType;
|
||||||
import org.hibernate.type.descriptor.java.PrimitiveByteArrayJavaType;
|
import org.hibernate.type.descriptor.java.PrimitiveByteArrayJavaType;
|
||||||
import org.hibernate.type.descriptor.jdbc.CharJdbcType;
|
|
||||||
import org.hibernate.type.descriptor.jdbc.ClobJdbcType;
|
|
||||||
import org.hibernate.type.descriptor.jdbc.DecimalJdbcType;
|
|
||||||
import org.hibernate.type.descriptor.jdbc.InstantJdbcType;
|
import org.hibernate.type.descriptor.jdbc.InstantJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.LocalDateJdbcType;
|
import org.hibernate.type.descriptor.jdbc.LocalDateJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.LocalDateTimeJdbcType;
|
import org.hibernate.type.descriptor.jdbc.LocalDateTimeJdbcType;
|
||||||
|
@ -96,7 +93,6 @@ import org.hibernate.type.descriptor.jdbc.OffsetDateTimeJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.OffsetTimeJdbcType;
|
import org.hibernate.type.descriptor.jdbc.OffsetTimeJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.SmallIntJdbcType;
|
import org.hibernate.type.descriptor.jdbc.SmallIntJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.VarbinaryJdbcType;
|
import org.hibernate.type.descriptor.jdbc.VarbinaryJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.VarcharJdbcType;
|
|
||||||
import org.hibernate.type.descriptor.jdbc.XmlJdbcType;
|
import org.hibernate.type.descriptor.jdbc.XmlJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.ZonedDateTimeJdbcType;
|
import org.hibernate.type.descriptor.jdbc.ZonedDateTimeJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
||||||
|
@ -984,19 +980,7 @@ public class DB2Dialect extends Dialect {
|
||||||
jdbcTypeRegistry.addDescriptor( Types.BOOLEAN, SmallIntJdbcType.INSTANCE );
|
jdbcTypeRegistry.addDescriptor( Types.BOOLEAN, SmallIntJdbcType.INSTANCE );
|
||||||
// Binary literals were only added in 11. See https://www.ibm.com/support/knowledgecenter/SSEPGG_11.1.0/com.ibm.db2.luw.sql.ref.doc/doc/r0000731.html#d79816e393
|
// Binary literals were only added in 11. See https://www.ibm.com/support/knowledgecenter/SSEPGG_11.1.0/com.ibm.db2.luw.sql.ref.doc/doc/r0000731.html#d79816e393
|
||||||
jdbcTypeRegistry.addDescriptor( Types.VARBINARY, VarbinaryJdbcType.INSTANCE_WITHOUT_LITERALS );
|
jdbcTypeRegistry.addDescriptor( Types.VARBINARY, VarbinaryJdbcType.INSTANCE_WITHOUT_LITERALS );
|
||||||
if ( getDB2Version().isBefore( 9, 7 ) ) {
|
|
||||||
jdbcTypeRegistry.addDescriptor( Types.NUMERIC, DecimalJdbcType.INSTANCE );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// See HHH-12753
|
|
||||||
// It seems that DB2's JDBC 4.0 support as of 9.5 does not
|
|
||||||
// support the N-variant methods like NClob or NString.
|
|
||||||
// Therefore here we overwrite the sql type descriptors to
|
|
||||||
// use the non-N variants which are supported.
|
|
||||||
jdbcTypeRegistry.addDescriptor( Types.NCHAR, CharJdbcType.INSTANCE );
|
|
||||||
jdbcTypeRegistry.addDescriptor( Types.NCLOB, ClobJdbcType.STREAM_BINDING );
|
|
||||||
jdbcTypeRegistry.addDescriptor( Types.NVARCHAR, VarcharJdbcType.INSTANCE );
|
|
||||||
jdbcTypeRegistry.addDescriptor( Types.NUMERIC, DecimalJdbcType.INSTANCE );
|
|
||||||
|
|
||||||
jdbcTypeRegistry.addDescriptor( XmlJdbcType.INSTANCE );
|
jdbcTypeRegistry.addDescriptor( XmlJdbcType.INSTANCE );
|
||||||
jdbcTypeRegistry.addDescriptor( DB2StructJdbcType.INSTANCE );
|
jdbcTypeRegistry.addDescriptor( DB2StructJdbcType.INSTANCE );
|
||||||
|
|
|
@ -68,7 +68,6 @@ import org.hibernate.type.BasicTypeRegistry;
|
||||||
import org.hibernate.type.JavaObjectType;
|
import org.hibernate.type.JavaObjectType;
|
||||||
import org.hibernate.type.StandardBasicTypes;
|
import org.hibernate.type.StandardBasicTypes;
|
||||||
import org.hibernate.type.descriptor.java.BigDecimalJavaType;
|
import org.hibernate.type.descriptor.java.BigDecimalJavaType;
|
||||||
import org.hibernate.type.descriptor.jdbc.DecimalJdbcType;
|
|
||||||
import org.hibernate.type.descriptor.jdbc.ObjectNullResolvingJdbcType;
|
import org.hibernate.type.descriptor.jdbc.ObjectNullResolvingJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.TimestampJdbcType;
|
import org.hibernate.type.descriptor.jdbc.TimestampJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
||||||
|
@ -78,8 +77,6 @@ import org.hibernate.type.spi.TypeConfiguration;
|
||||||
|
|
||||||
import jakarta.persistence.TemporalType;
|
import jakarta.persistence.TemporalType;
|
||||||
|
|
||||||
import static org.hibernate.query.sqm.produce.function.FunctionParameterType.INTEGER;
|
|
||||||
import static org.hibernate.query.sqm.produce.function.FunctionParameterType.STRING;
|
|
||||||
import static org.hibernate.type.SqlTypes.BINARY;
|
import static org.hibernate.type.SqlTypes.BINARY;
|
||||||
import static org.hibernate.type.SqlTypes.BLOB;
|
import static org.hibernate.type.SqlTypes.BLOB;
|
||||||
import static org.hibernate.type.SqlTypes.CHAR;
|
import static org.hibernate.type.SqlTypes.CHAR;
|
||||||
|
@ -663,7 +660,6 @@ public class DerbyDialect extends Dialect {
|
||||||
super.contributeTypes( typeContributions, serviceRegistry );
|
super.contributeTypes( typeContributions, serviceRegistry );
|
||||||
final JdbcTypeRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration()
|
final JdbcTypeRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration()
|
||||||
.getJdbcTypeRegistry();
|
.getJdbcTypeRegistry();
|
||||||
jdbcTypeRegistry.addDescriptor( Types.NUMERIC, DecimalJdbcType.INSTANCE );
|
|
||||||
jdbcTypeRegistry.addDescriptor( Types.TIMESTAMP_WITH_TIMEZONE, TimestampJdbcType.INSTANCE );
|
jdbcTypeRegistry.addDescriptor( Types.TIMESTAMP_WITH_TIMEZONE, TimestampJdbcType.INSTANCE );
|
||||||
|
|
||||||
// Derby requires a custom binder for binding untyped nulls that resolves the type through the statement
|
// Derby requires a custom binder for binding untyped nulls that resolves the type through the statement
|
||||||
|
|
|
@ -16,7 +16,6 @@ import java.sql.Types;
|
||||||
import org.hibernate.type.descriptor.ValueBinder;
|
import org.hibernate.type.descriptor.ValueBinder;
|
||||||
import org.hibernate.type.descriptor.ValueExtractor;
|
import org.hibernate.type.descriptor.ValueExtractor;
|
||||||
import org.hibernate.type.descriptor.WrapperOptions;
|
import org.hibernate.type.descriptor.WrapperOptions;
|
||||||
import org.hibernate.type.descriptor.java.BasicJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.JavaType;
|
import org.hibernate.type.descriptor.java.JavaType;
|
||||||
import org.hibernate.type.descriptor.jdbc.internal.JdbcLiteralFormatterNumericData;
|
import org.hibernate.type.descriptor.jdbc.internal.JdbcLiteralFormatterNumericData;
|
||||||
import org.hibernate.type.spi.TypeConfiguration;
|
import org.hibernate.type.spi.TypeConfiguration;
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class NationalizedTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
final Product product = new Product();
|
final Product product = new Product();
|
||||||
product.setId(1);
|
product.setId(1);
|
||||||
product.setName("Mobile phone");
|
product.setName("Mobile phone");
|
||||||
product.setWarranty("My product warranty");
|
product.setWarranty("My product®™ warranty 😍");
|
||||||
|
|
||||||
entityManager.persist(product);
|
entityManager.persist(product);
|
||||||
//end::basic-nationalized-persist-example[]
|
//end::basic-nationalized-persist-example[]
|
||||||
|
@ -46,7 +46,7 @@ public class NationalizedTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
doInJPA(this::entityManagerFactory, entityManager -> {
|
doInJPA(this::entityManagerFactory, entityManager -> {
|
||||||
Product product = entityManager.find(Product.class, productId);
|
Product product = entityManager.find(Product.class, productId);
|
||||||
|
|
||||||
assertEquals("My product warranty", product.getWarranty());
|
assertEquals("My product®™ warranty 😍", product.getWarranty());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,10 +69,14 @@ public class StringNationalizedMappingTests {
|
||||||
|
|
||||||
// and try to use the mapping
|
// and try to use the mapping
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
(session) -> session.persist(new EntityOfStrings(1, "nstring", "nclob"))
|
(session) -> session.persist(new EntityOfStrings(1, "nstring 🦑", "nclob 🦀"))
|
||||||
);
|
);
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
(session) -> session.get(EntityOfStrings.class, 1)
|
(session) -> {
|
||||||
|
EntityOfStrings entity = session.get(EntityOfStrings.class, 1);
|
||||||
|
assertThat( entity.nstring, is("nstring 🦑") );
|
||||||
|
assertThat( entity.nclobString, is("nclob 🦀") );
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue