Search in sources :

Example 41 with BasicAttributeMapping

use of org.hibernate.metamodel.mapping.internal.BasicAttributeMapping 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

BasicAttributeMapping (org.hibernate.metamodel.mapping.internal.BasicAttributeMapping)41 Test (org.junit.jupiter.api.Test)40 EntityPersister (org.hibernate.persister.entity.EntityPersister)39 MappingMetamodelImplementor (org.hibernate.metamodel.spi.MappingMetamodelImplementor)36 JdbcMapping (org.hibernate.metamodel.mapping.JdbcMapping)29 JdbcTypeRegistry (org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry)17 BitSet (java.util.BitSet)7 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)4 JpaAttributeConverter (org.hibernate.metamodel.model.convert.spi.JpaAttributeConverter)4 ZoneOffset (java.time.ZoneOffset)2 Dialect (org.hibernate.dialect.Dialect)2 NationalizationSupport (org.hibernate.dialect.NationalizationSupport)2 EntityMappingType (org.hibernate.metamodel.mapping.EntityMappingType)2 ModelPart (org.hibernate.metamodel.mapping.ModelPart)2 BasicValueConverter (org.hibernate.metamodel.model.convert.spi.BasicValueConverter)2 Duration (java.time.Duration)1 Instant (java.time.Instant)1 LocalDate (java.time.LocalDate)1 LocalDateTime (java.time.LocalDateTime)1 LocalTime (java.time.LocalTime)1