use of org.hibernate.dialect.NationalizationSupport in project hibernate-orm by hibernate.
the class MapKeyJdbcTypeTests method verifyResolutions.
@Test
public void verifyResolutions(DomainModelScope scope) {
final MetadataImplementor domainModel = scope.getDomainModel();
final Dialect dialect = domainModel.getDatabase().getDialect();
final NationalizationSupport nationalizationSupport = dialect.getNationalizationSupport();
final JdbcTypeRegistry jdbcTypeRegistry = domainModel.getTypeConfiguration().getJdbcTypeRegistry();
final PersistentClass entityBinding = domainModel.getEntityBinding(MyEntity.class.getName());
verifyJdbcTypeCodes(entityBinding.getProperty("baseMap"), jdbcTypeRegistry.getDescriptor(Types.INTEGER).getJdbcTypeCode(), jdbcTypeRegistry.getDescriptor(Types.VARCHAR).getJdbcTypeCode());
verifyJdbcTypeCodes(entityBinding.getProperty("sqlTypeCodeMap"), jdbcTypeRegistry.getDescriptor(Types.TINYINT).getJdbcTypeCode(), jdbcTypeRegistry.getDescriptor(nationalizationSupport.getVarcharVariantCode()).getJdbcTypeCode());
verifyJdbcTypeCodes(entityBinding.getProperty("sqlTypeMap"), Types.TINYINT, jdbcTypeRegistry.getDescriptor(nationalizationSupport.getVarcharVariantCode()).getJdbcTypeCode());
}
use of org.hibernate.dialect.NationalizationSupport in project hibernate-orm by hibernate.
the class StringNationalizedMappingTests method testMappings.
@Test
public void testMappings(SessionFactoryScope scope) {
// first, verify the type selections...
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory().getRuntimeMetamodels().getMappingMetamodel();
final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor(EntityOfStrings.class);
final JdbcTypeRegistry jdbcTypeRegistry = mappingMetamodel.getTypeConfiguration().getJdbcTypeRegistry();
final Dialect dialect = scope.getSessionFactory().getJdbcServices().getDialect();
final NationalizationSupport nationalizationSupport = dialect.getNationalizationSupport();
{
final BasicAttributeMapping attribute = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("nstring");
final JdbcMapping jdbcMapping = attribute.getJdbcMapping();
assertThat(jdbcMapping.getJavaTypeDescriptor().getJavaTypeClass(), equalTo(String.class));
assertThat(jdbcMapping.getJdbcType(), is(jdbcTypeRegistry.getDescriptor(nationalizationSupport.getVarcharVariantCode())));
}
{
final BasicAttributeMapping attribute = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("nclobString");
final JdbcMapping jdbcMapping = attribute.getJdbcMapping();
assertThat(jdbcMapping.getJavaTypeDescriptor().getJavaTypeClass(), equalTo(String.class));
assertThat(jdbcMapping.getJdbcType(), is(jdbcTypeRegistry.getDescriptor(nationalizationSupport.getClobVariantCode())));
}
// and try to use the mapping
scope.inTransaction((session) -> session.persist(new EntityOfStrings(1, "nstring", "nclob")));
scope.inTransaction((session) -> session.get(EntityOfStrings.class, 1));
}
use of org.hibernate.dialect.NationalizationSupport in project hibernate-orm by hibernate.
the class CharacterArrayNationalizedMappingTests method verifyMappings.
@Test
public void verifyMappings(SessionFactoryScope scope) {
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory().getRuntimeMetamodels().getMappingMetamodel();
final EntityPersister entityDescriptor = mappingMetamodel.getEntityDescriptor(EntityWithCharArrays.class);
final JdbcTypeRegistry jdbcTypeRegistry = mappingMetamodel.getTypeConfiguration().getJdbcTypeRegistry();
final Dialect dialect = scope.getSessionFactory().getJdbcServices().getDialect();
final NationalizationSupport nationalizationSupport = dialect.getNationalizationSupport();
{
final BasicAttributeMapping attributeMapping = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("primitiveNVarchar");
final JdbcMapping jdbcMapping = attributeMapping.getJdbcMapping();
assertThat(jdbcMapping.getJdbcType(), is(jdbcTypeRegistry.getDescriptor(nationalizationSupport.getVarcharVariantCode())));
}
{
final BasicAttributeMapping attributeMapping = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("wrapperNVarchar");
final JdbcMapping jdbcMapping = attributeMapping.getJdbcMapping();
assertThat(jdbcMapping.getJdbcType(), is(jdbcTypeRegistry.getDescriptor(nationalizationSupport.getVarcharVariantCode())));
}
{
final BasicAttributeMapping attributeMapping = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("primitiveNClob");
final JdbcMapping jdbcMapping = attributeMapping.getJdbcMapping();
assertThat(jdbcMapping.getJdbcType(), is(jdbcTypeRegistry.getDescriptor(nationalizationSupport.getClobVariantCode())));
}
{
final BasicAttributeMapping attributeMapping = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("wrapperNClob");
final JdbcMapping jdbcMapping = attributeMapping.getJdbcMapping();
assertThat(jdbcMapping.getJdbcType(), is(jdbcTypeRegistry.getDescriptor(nationalizationSupport.getClobVariantCode())));
}
}
use of org.hibernate.dialect.NationalizationSupport in project hibernate-orm by hibernate.
the class JdbcTypeTests method verifyResolutions.
@Test
public void verifyResolutions(DomainModelScope scope) {
final MetadataImplementor domainModel = scope.getDomainModel();
final Dialect dialect = domainModel.getDatabase().getDialect();
final NationalizationSupport nationalizationSupport = dialect.getNationalizationSupport();
final JdbcTypeRegistry jdbcTypeRegistry = domainModel.getTypeConfiguration().getJdbcTypeRegistry();
final PersistentClass entityBinding = domainModel.getEntityBinding(SimpleEntity.class.getName());
verifyJdbcTypeCode(entityBinding.getProperty("materializedClob"), jdbcTypeRegistry.getDescriptor(Types.CLOB).getJdbcTypeCode());
verifyJdbcTypeCode(entityBinding.getProperty("materializedNClob"), jdbcTypeRegistry.getDescriptor(nationalizationSupport.getClobVariantCode()).getJdbcTypeCode());
verifyJdbcTypeCode(entityBinding.getProperty("jpaMaterializedClob"), jdbcTypeRegistry.getDescriptor(Types.CLOB).getJdbcTypeCode());
verifyJdbcTypeCode(entityBinding.getProperty("jpaMaterializedNClob"), jdbcTypeRegistry.getDescriptor(nationalizationSupport.getClobVariantCode()).getJdbcTypeCode());
verifyJdbcTypeCode(entityBinding.getProperty("nationalizedString"), jdbcTypeRegistry.getDescriptor(nationalizationSupport.getVarcharVariantCode()).getJdbcTypeCode());
verifyJdbcTypeCode(entityBinding.getProperty("nationalizedClob"), jdbcTypeRegistry.getDescriptor(nationalizationSupport.getClobVariantCode()).getJdbcTypeCode());
verifyResolution(entityBinding.getProperty("customType"), CustomJdbcType.class);
verifyResolution(entityBinding.getProperty("customTypeRegistration"), RegisteredCustomJdbcType.class);
}
Aggregations