HHH-17466 Fix HANA test issues

This commit is contained in:
Christian Beikov 2023-12-01 19:04:38 +01:00
parent c67ea33206
commit 314c621f7b
1 changed files with 10 additions and 3 deletions

View File

@ -15,6 +15,8 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.NationalizationSupport;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
@ -44,13 +46,16 @@ public class LocaleMappingTests {
@Test
public void basicAssertions(SessionFactoryScope scope) {
final SessionFactoryImplementor sessionFactory = scope.getSessionFactory();
final Dialect dialect = sessionFactory.getJdbcServices().getDialect();
final NationalizationSupport nationalizationSupport = dialect.getNationalizationSupport();
final EntityPersister entityDescriptor = sessionFactory.getMappingMetamodel().getEntityDescriptor(
LocaleMappingTestEntity.class );
{
final BasicAttributeMapping localeAttribute = (BasicAttributeMapping) entityDescriptor.findAttributeMapping(
"locale" );
assertThat( localeAttribute.getJdbcMapping().getJdbcType().getJdbcTypeCode() ).isEqualTo( Types.VARCHAR );
assertThat( localeAttribute.getJdbcMapping().getJdbcType().getJdbcTypeCode() )
.isEqualTo( nationalizationSupport.getVarcharVariantCode() );
assertThat( localeAttribute.getJdbcMapping().getJavaTypeDescriptor().getJavaTypeClass() ).isEqualTo(
Locale.class );
}
@ -59,7 +64,8 @@ public class LocaleMappingTests {
final PluralAttributeMapping yearsAttribute = (PluralAttributeMapping) entityDescriptor.findAttributeMapping(
"locales" );
final BasicValuedCollectionPart elementDescriptor = (BasicValuedCollectionPart) yearsAttribute.getElementDescriptor();
assertThat( elementDescriptor.getJdbcMapping().getJdbcType().getJdbcTypeCode() ).isEqualTo( Types.VARCHAR );
assertThat( elementDescriptor.getJdbcMapping().getJdbcType().getJdbcTypeCode() )
.isEqualTo( nationalizationSupport.getVarcharVariantCode() );
assertThat( elementDescriptor.getJdbcMapping().getJavaTypeDescriptor().getJavaTypeClass() ).isEqualTo(
Locale.class );
}
@ -68,7 +74,8 @@ public class LocaleMappingTests {
final PluralAttributeMapping countByYearAttribute = (PluralAttributeMapping) entityDescriptor.findAttributeMapping(
"countByLocale" );
final BasicValuedCollectionPart keyDescriptor = (BasicValuedCollectionPart) countByYearAttribute.getIndexDescriptor();
assertThat( keyDescriptor.getJdbcMapping().getJdbcType().getJdbcTypeCode() ).isEqualTo( Types.VARCHAR );
assertThat( keyDescriptor.getJdbcMapping().getJdbcType().getJdbcTypeCode() )
.isEqualTo( nationalizationSupport.getVarcharVariantCode() );
assertThat( keyDescriptor.getJdbcMapping().getJavaTypeDescriptor().getJavaTypeClass() ).isEqualTo(
Locale.class );
}