Search in sources :

Example 1 with BasicValuedCollectionPart

use of org.hibernate.metamodel.mapping.internal.BasicValuedCollectionPart in project hibernate-orm by hibernate.

the class YearMappingTests method basicAssertions.

@Test
public void basicAssertions(SessionFactoryScope scope) {
    final SessionFactoryImplementor sessionFactory = scope.getSessionFactory();
    final EntityPersister entityDescriptor = sessionFactory.getMappingMetamodel().getEntityDescriptor(YearMappingTestEntity.class);
    {
        final BasicAttributeMapping yearAttribute = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("year");
        assertThat(yearAttribute.getJdbcMapping().getJdbcType().getJdbcTypeCode()).isEqualTo(Types.INTEGER);
        assertThat(yearAttribute.getJdbcMapping().getJavaTypeDescriptor().getJavaTypeClass()).isEqualTo(Year.class);
    }
    {
        final PluralAttributeMapping yearsAttribute = (PluralAttributeMapping) entityDescriptor.findAttributeMapping("years");
        final BasicValuedCollectionPart elementDescriptor = (BasicValuedCollectionPart) yearsAttribute.getElementDescriptor();
        assertThat(elementDescriptor.getJdbcMapping().getJdbcType().getJdbcTypeCode()).isEqualTo(Types.INTEGER);
        assertThat(elementDescriptor.getJdbcMapping().getJavaTypeDescriptor().getJavaTypeClass()).isEqualTo(Year.class);
    }
    {
        final PluralAttributeMapping countByYearAttribute = (PluralAttributeMapping) entityDescriptor.findAttributeMapping("countByYear");
        final BasicValuedCollectionPart keyDescriptor = (BasicValuedCollectionPart) countByYearAttribute.getIndexDescriptor();
        assertThat(keyDescriptor.getJdbcMapping().getJdbcType().getJdbcTypeCode()).isEqualTo(Types.INTEGER);
        assertThat(keyDescriptor.getJdbcMapping().getJavaTypeDescriptor().getJavaTypeClass()).isEqualTo(Year.class);
    }
}
Also used : EntityPersister(org.hibernate.persister.entity.EntityPersister) Year(java.time.Year) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) BasicAttributeMapping(org.hibernate.metamodel.mapping.internal.BasicAttributeMapping) PluralAttributeMapping(org.hibernate.metamodel.mapping.PluralAttributeMapping) BasicValuedCollectionPart(org.hibernate.metamodel.mapping.internal.BasicValuedCollectionPart) Test(org.junit.jupiter.api.Test)

Aggregations

Year (java.time.Year)1 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)1 PluralAttributeMapping (org.hibernate.metamodel.mapping.PluralAttributeMapping)1 BasicAttributeMapping (org.hibernate.metamodel.mapping.internal.BasicAttributeMapping)1 BasicValuedCollectionPart (org.hibernate.metamodel.mapping.internal.BasicValuedCollectionPart)1 EntityPersister (org.hibernate.persister.entity.EntityPersister)1 Test (org.junit.jupiter.api.Test)1