use of org.hibernate.metamodel.mapping.internal.EmbeddedIdentifierMappingImpl in project hibernate-orm by hibernate.
the class DynamicCompositeIdBasicBindingTests method testBinding.
@Test
public void testBinding(ServiceRegistryScope scope) {
final SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) new MetadataSources(scope.getRegistry()).addResource("org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdBasic.hbm.xml").buildMetadata().buildSessionFactory();
try {
final EntityPersister entityDescriptor = sessionFactory.getRuntimeMetamodels().getMappingMetamodel().findEntityDescriptor("DynamicCompositeIdBasic");
assertThat(entityDescriptor.getNumberOfAttributeMappings(), is(1));
final EntityIdentifierMapping identifierMapping = entityDescriptor.getIdentifierMapping();
assertThat(identifierMapping, instanceOf(EmbeddedIdentifierMappingImpl.class));
final EmbeddedIdentifierMappingImpl cid = (EmbeddedIdentifierMappingImpl) identifierMapping;
assertThat(cid.getEmbeddableTypeDescriptor().getNumberOfAttributeMappings(), is(2));
final AttributeMapping key1 = cid.getEmbeddableTypeDescriptor().findAttributeMapping("key1");
assertThat(key1, notNullValue());
final AttributeMapping key2 = cid.getEmbeddableTypeDescriptor().findAttributeMapping("key2");
assertThat(key2, notNullValue());
final AttributeMapping attr1 = entityDescriptor.findAttributeMapping("attr1");
assertThat(attr1, notNullValue());
} finally {
sessionFactory.close();
}
}
use of org.hibernate.metamodel.mapping.internal.EmbeddedIdentifierMappingImpl in project hibernate-orm by hibernate.
the class DynamicCompositeIdManyToOneBindingTests method testBinding.
@Test
public void testBinding(ServiceRegistryScope scope) {
final SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) new MetadataSources(scope.getRegistry()).addResource("org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdManyToOne.hbm.xml").buildMetadata().buildSessionFactory();
try {
final EntityPersister entityDescriptor = sessionFactory.getRuntimeMetamodels().getMappingMetamodel().findEntityDescriptor("DynamicCompositeIdManyToOne");
assertThat(entityDescriptor.getNumberOfAttributeMappings(), is(1));
final EntityIdentifierMapping identifierMapping = entityDescriptor.getIdentifierMapping();
assertThat(identifierMapping, instanceOf(EmbeddedIdentifierMappingImpl.class));
final EmbeddedIdentifierMappingImpl cid = (EmbeddedIdentifierMappingImpl) identifierMapping;
assertThat(cid.getEmbeddableTypeDescriptor().getNumberOfAttributeMappings(), is(2));
final AttributeMapping key1 = cid.getEmbeddableTypeDescriptor().findAttributeMapping("key1");
assertThat(key1, notNullValue());
assertThat(key1, instanceOf(BasicAttributeMapping.class));
final AttributeMapping key2 = cid.getEmbeddableTypeDescriptor().findAttributeMapping("key2");
assertThat(key2, notNullValue());
assertThat(key2, instanceOf(ToOneAttributeMapping.class));
final AttributeMapping attr1 = entityDescriptor.findAttributeMapping("attr1");
assertThat(attr1, notNullValue());
assertThat(attr1, instanceOf(BasicAttributeMapping.class));
} finally {
sessionFactory.close();
}
}
Aggregations