use of org.hibernate.metamodel.mapping.ForeignKeyDescriptor in project hibernate-orm by hibernate.
the class EntityWithOneToOneSharingPrimaryKeyTest method basicTest.
@Test
public void basicTest(SessionFactoryScope scope) {
final EntityPersister entityDescriptor = scope.getSessionFactory().getMappingMetamodel().findEntityDescriptor(EntityWithOneToOneSharingPrimaryKey.class);
final ModelPart otherAssociation = entityDescriptor.findSubPart("other");
assertThat(otherAssociation, instanceOf(ToOneAttributeMapping.class));
final ToOneAttributeMapping otherAttributeMapping = (ToOneAttributeMapping) otherAssociation;
ForeignKeyDescriptor foreignKeyDescriptor = otherAttributeMapping.getForeignKeyDescriptor();
foreignKeyDescriptor.visitKeySelectables((columnIndex, selection) -> {
assertThat(selection.getContainingTableExpression(), is("entity_o2o_sharepk"));
assertThat(selection.getSelectionExpression(), is("id"));
});
foreignKeyDescriptor.visitTargetSelectables((columnIndex, selection) -> {
assertThat(selection.getContainingTableExpression(), is("SIMPLE_ENTITY"));
assertThat(selection.getSelectionExpression(), is("id"));
});
}
Aggregations