Search in sources :

Example 1 with EmbeddableRepresentationStrategy

use of org.hibernate.metamodel.spi.EmbeddableRepresentationStrategy 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)

Example 2 with EmbeddableRepresentationStrategy

use of org.hibernate.metamodel.spi.EmbeddableRepresentationStrategy 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

MappingMetamodel (org.hibernate.metamodel.MappingMetamodel)2 RuntimeMetamodels (org.hibernate.metamodel.RuntimeMetamodels)2 EmbeddableMappingType (org.hibernate.metamodel.mapping.EmbeddableMappingType)2 EmbeddedAttributeMapping (org.hibernate.metamodel.mapping.internal.EmbeddedAttributeMapping)2 EmbeddableRepresentationStrategy (org.hibernate.metamodel.spi.EmbeddableRepresentationStrategy)2 EntityPersister (org.hibernate.persister.entity.EntityPersister)2 Test (org.junit.jupiter.api.Test)2