mariadb nationalization support

This commit is contained in:
Steve Ebersole 2021-05-13 12:43:59 -05:00
parent 2bc9c52c4b
commit c17396521c
4 changed files with 31 additions and 1 deletions

View File

@ -258,6 +258,16 @@ of the specific database support for nationalized data and allows the applicatio
work portably across databases with varying support. work portably across databases with varying support.
==== ====
[IMPORTANT]
====
For databases that do not support `NCLOB` data-types, it is unsupported to map
the attribute using `java.sql.NClob`. Use `java.sql.Clob` (which `NClob` extends)
or use a materialized mapping (`String`, `char[]`, ...) instead.
See also <<basic-lob>> regarding similar limitation for databases which do not support
explicit `CLOB` data-type.
====
Considering we have the following database table: Considering we have the following database table:
[[basic-nationalized-sql-example]] [[basic-nationalized-sql-example]]
@ -300,6 +310,13 @@ However, some drivers (i.e. PostgreSQL) are trickier and, in such cases, you may
extra steps to get LOBs working. Such discussions are beyond the scope of this guide. extra steps to get LOBs working. Such discussions are beyond the scope of this guide.
==== ====
[IMPORTANT]
====
For databases that do not support `CLOB` data-types, it is unsupported to map
the attribute using `java.sql.Clob`. Use a materialized mapping (`String`,
`char[]`, ...) instead.
====
Mapping basic values to LOB types comes in 2 forms... Mapping basic values to LOB types comes in 2 forms...
===== LOB Locator ===== LOB Locator

View File

@ -33,7 +33,9 @@ import static org.junit.Assert.fail;
@Jpa(annotatedClasses = NClobTest.Product.class) @Jpa(annotatedClasses = NClobTest.Product.class)
@RequiresDialectFeature( @RequiresDialectFeature(
feature = DialectFeatureChecks.SupportsNationalizedDataTypes.class, feature = DialectFeatureChecks.SupportsNationalizedDataTypes.class,
comment = "@see https://hibernate.atlassian.net/browse/HHH-10693 and https://hibernate.atlassian.net/browse/HHH-10695 and https://hibernate.atlassian.net/browse/HHH-10473" comment = "This is different from other tests checking generalized nationalization support; " +
"because we explicitly map this attribute to the `NClob` java type the database really" +
" has to support those types"
) )
public class NClobTest { public class NClobTest {
@Test @Test

View File

@ -54,6 +54,11 @@ public class MariaDBDialect extends MySQLDialect {
return version; return version;
} }
@Override
public NationalizationSupport getNationalizationSupport() {
return NationalizationSupport.IMPLICIT;
}
@Override @Override
public void initializeFunctionRegistry(QueryEngine queryEngine) { public void initializeFunctionRegistry(QueryEngine queryEngine) {
super.initializeFunctionRegistry(queryEngine); super.initializeFunctionRegistry(queryEngine);

View File

@ -45,12 +45,18 @@ abstract public class DialectFeatureChecks {
} }
} }
/**
* Does the database support nationalized data in any form
*/
public static class SupportsNationalizedData implements DialectFeatureCheck { public static class SupportsNationalizedData implements DialectFeatureCheck {
public boolean apply(Dialect dialect) { public boolean apply(Dialect dialect) {
return dialect.getNationalizationSupport() != NationalizationSupport.UNSUPPORTED; return dialect.getNationalizationSupport() != NationalizationSupport.UNSUPPORTED;
} }
} }
/**
* Does the database specifically support the explicit nationalized data types
*/
public static class SupportsNationalizedDataTypes implements DialectFeatureCheck { public static class SupportsNationalizedDataTypes implements DialectFeatureCheck {
public boolean apply(Dialect dialect) { public boolean apply(Dialect dialect) {
return dialect.getNationalizationSupport() == NationalizationSupport.EXPLICIT; return dialect.getNationalizationSupport() == NationalizationSupport.EXPLICIT;