use of org.hibernate.metamodel.mapping.AttributeMapping in project hibernate-orm by hibernate.
the class ImmutableNaturalIdTest method verifyMetamodel.
@Test
@TestForIssue(jiraKey = "HHH-10360")
public void verifyMetamodel(SessionFactoryScope scope) {
final SessionFactoryImplementor sessionFactory = scope.getSessionFactory();
final EntityMappingType entityMappingType = sessionFactory.getRuntimeMetamodels().getEntityMappingType(User.class);
final AttributeMapping userNameMapping = entityMappingType.findAttributeMapping("userName");
assertFalse(userNameMapping.getAttributeMetadataAccess().resolveAttributeMetadata(null).isNullable());
final EntityPersister persister = entityMappingType.getEntityPersister();
final int propertyIndex = persister.getEntityMetamodel().getPropertyIndex("userName");
// nullability is not specified, so it should be non-nullable by hbm-specific default
assertFalse(persister.getPropertyNullability()[propertyIndex]);
}
Aggregations