Search in sources :

Example 16 with EmbeddableMappingType

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

the class InstantiationTests method runtimeModelTest.

@Test
public void runtimeModelTest(SessionFactoryScope scope) {
    final RuntimeMetamodels runtimeMetamodels = scope.getSessionFactory().getRuntimeMetamodels();
    final MappingMetamodel mappingMetamodel = runtimeMetamodels.getMappingMetamodel();
    final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor(Person.class);
    final EmbeddedAttributeMapping nameEmbedded = (EmbeddedAttributeMapping) entityDescriptor.findAttributeMapping("name");
    final EmbeddableMappingType nameEmbeddable = nameEmbedded.getEmbeddableTypeDescriptor();
    final EmbeddableRepresentationStrategy nameRepStrategy = nameEmbeddable.getRepresentationStrategy();
    assertThat(nameRepStrategy.getMode()).isEqualTo(RepresentationMode.POJO);
    assertThat(nameRepStrategy.getInstantiator()).isInstanceOf(NameInstantiator.class);
    nameEmbeddable.forEachAttributeMapping((position, attribute) -> {
        assertThat(attribute.getPropertyAccess().getSetter()).isNull();
    });
}
Also used : EntityPersister(org.hibernate.persister.entity.EntityPersister) MappingMetamodel(org.hibernate.metamodel.MappingMetamodel) EmbeddableRepresentationStrategy(org.hibernate.metamodel.spi.EmbeddableRepresentationStrategy) EmbeddedAttributeMapping(org.hibernate.metamodel.mapping.internal.EmbeddedAttributeMapping) RuntimeMetamodels(org.hibernate.metamodel.RuntimeMetamodels) EmbeddableMappingType(org.hibernate.metamodel.mapping.EmbeddableMappingType) Test(org.junit.jupiter.api.Test)

Aggregations

EmbeddableMappingType (org.hibernate.metamodel.mapping.EmbeddableMappingType)16 AttributeMapping (org.hibernate.metamodel.mapping.AttributeMapping)6 EntityPersister (org.hibernate.persister.entity.EntityPersister)4 Serializable (java.io.Serializable)3 MappingException (org.hibernate.MappingException)3 NotYetImplementedFor6Exception (org.hibernate.NotYetImplementedFor6Exception)3 SharedSessionContract (org.hibernate.SharedSessionContract)3 Dialect (org.hibernate.dialect.Dialect)3 CascadeStyle (org.hibernate.engine.spi.CascadeStyle)3 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)3 Any (org.hibernate.mapping.Any)3 BasicValue (org.hibernate.mapping.BasicValue)3 Property (org.hibernate.mapping.Property)3 Selectable (org.hibernate.mapping.Selectable)3 RuntimeMetamodels (org.hibernate.metamodel.RuntimeMetamodels)3 EntityMappingType (org.hibernate.metamodel.mapping.EntityMappingType)3 PluralAttributeMapping (org.hibernate.metamodel.mapping.PluralAttributeMapping)3 EmbeddedAttributeMapping (org.hibernate.metamodel.mapping.internal.EmbeddedAttributeMapping)3 Test (org.junit.jupiter.api.Test)3 JdbcEnvironment (org.hibernate.engine.jdbc.env.spi.JdbcEnvironment)2