Search in sources :

Example 6 with BasicValueConverter

use of org.hibernate.metamodel.model.convert.spi.BasicValueConverter in project hibernate-orm by hibernate.

the class NativeQueryResultBuilderTests method verifyModel.

@BeforeAll
public void verifyModel(SessionFactoryScope scope) {
    final EntityMappingType entityDescriptor = scope.getSessionFactory().getRuntimeMetamodels().getEntityMappingType(EntityOfBasics.class);
    final JdbcTypeRegistry jdbcTypeRegistry = scope.getSessionFactory().getTypeConfiguration().getJdbcTypeRegistry();
    final ModelPart part = entityDescriptor.findSubPart("convertedGender", null);
    assertThat(part, instanceOf(BasicAttributeMapping.class));
    final BasicAttributeMapping attrMapping = (BasicAttributeMapping) part;
    assertThat(attrMapping.getJavaType().getJavaTypeClass(), equalTo(EntityOfBasics.Gender.class));
    final BasicValueConverter valueConverter = attrMapping.getValueConverter();
    assertThat(valueConverter, instanceOf(JpaAttributeConverter.class));
    assertThat(valueConverter.getDomainJavaType(), is(attrMapping.getJavaType()));
    assertThat(valueConverter.getRelationalJavaType().getJavaTypeClass(), equalTo(Character.class));
    assertThat(attrMapping.getJdbcMapping().getJdbcType(), is(jdbcTypeRegistry.getDescriptor(Types.CHAR)));
}
Also used : ModelPart(org.hibernate.metamodel.mapping.ModelPart) JpaAttributeConverter(org.hibernate.metamodel.model.convert.spi.JpaAttributeConverter) BasicAttributeMapping(org.hibernate.metamodel.mapping.internal.BasicAttributeMapping) EntityMappingType(org.hibernate.metamodel.mapping.EntityMappingType) JdbcTypeRegistry(org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry) BasicValueConverter(org.hibernate.metamodel.model.convert.spi.BasicValueConverter) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

BasicValueConverter (org.hibernate.metamodel.model.convert.spi.BasicValueConverter)6 Iterator (java.util.Iterator)2 List (java.util.List)2 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)2 JdbcMapping (org.hibernate.metamodel.mapping.JdbcMapping)2 ModelPart (org.hibernate.metamodel.mapping.ModelPart)2 BasicAttributeMapping (org.hibernate.metamodel.mapping.internal.BasicAttributeMapping)2 BasicType (org.hibernate.type.BasicType)2 JavaType (org.hibernate.type.descriptor.java.JavaType)2 JavaTypeRegistry (org.hibernate.type.descriptor.java.spi.JavaTypeRegistry)2 JdbcTypeRegistry (org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry)2 TypeConfiguration (org.hibernate.type.spi.TypeConfiguration)2 AttributeConverter (jakarta.persistence.AttributeConverter)1 Serializable (java.io.Serializable)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 IdentityHashMap (java.util.IdentityHashMap)1 Map (java.util.Map)1 Objects (java.util.Objects)1 SortedMap (java.util.SortedMap)1