use of org.hibernate.metamodel.mapping.internal.BasicEntityIdentifierMappingImpl in project hibernate-orm by hibernate.
the class AccessMappingTest method testDefaultPropertyAccessIsInherited.
@Test
public void testDefaultPropertyAccessIsInherited() {
Configuration cfg = new Configuration();
cfg.addAnnotatedClass(Horse.class);
cfg.addAnnotatedClass(Animal.class);
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory(serviceRegistry);
try {
EntityPersister entityPersister = factory.getRuntimeMetamodels().getMappingMetamodel().getEntityDescriptor(Animal.class.getName());
final BasicEntityIdentifierMappingImpl identifierMapping = (BasicEntityIdentifierMappingImpl) entityPersister.getIdentifierMapping();
assertTrue("Property access should be used since explicity configured via @Access", identifierMapping.getPropertyAccess().getGetter() instanceof GetterMethodImpl);
entityPersister = factory.getRuntimeMetamodels().getMappingMetamodel().getEntityDescriptor(Horse.class.getName());
assertTrue("Field access should be used since the default access mode gets inherited", entityPersister.getAttributeMapping(0).getPropertyAccess().getGetter() instanceof GetterFieldImpl);
} finally {
factory.close();
}
}
use of org.hibernate.metamodel.mapping.internal.BasicEntityIdentifierMappingImpl in project hibernate-orm by hibernate.
the class AccessMappingTest method testFieldAnnotationPlacement.
@Test
public void testFieldAnnotationPlacement() {
Configuration cfg = new Configuration();
Class<?> classUnderTest = Course6.class;
cfg.addAnnotatedClass(classUnderTest);
cfg.addAnnotatedClass(Student.class);
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory(serviceRegistry);
try {
final EntityPersister entityPersister = factory.getRuntimeMetamodels().getMappingMetamodel().getEntityDescriptor(classUnderTest.getName());
final BasicEntityIdentifierMappingImpl identifierMapping = (BasicEntityIdentifierMappingImpl) entityPersister.getIdentifierMapping();
assertTrue("Field access should be used.", identifierMapping.getPropertyAccess().getGetter() instanceof GetterFieldImpl);
} finally {
factory.close();
}
}
use of org.hibernate.metamodel.mapping.internal.BasicEntityIdentifierMappingImpl in project hibernate-orm by hibernate.
the class AccessMappingTest method testPropertyAnnotationPlacement.
@Test
public void testPropertyAnnotationPlacement() {
Configuration cfg = new Configuration();
Class<?> classUnderTest = Course7.class;
cfg.addAnnotatedClass(classUnderTest);
cfg.addAnnotatedClass(Student.class);
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory(serviceRegistry);
try {
final EntityPersister entityPersister = factory.getRuntimeMetamodels().getMappingMetamodel().getEntityDescriptor(classUnderTest.getName());
final BasicEntityIdentifierMappingImpl identifierMapping = (BasicEntityIdentifierMappingImpl) entityPersister.getIdentifierMapping();
assertTrue("Property access should be used.", identifierMapping.getPropertyAccess().getGetter() instanceof GetterMethodImpl);
} finally {
factory.close();
}
}
use of org.hibernate.metamodel.mapping.internal.BasicEntityIdentifierMappingImpl in project hibernate-orm by hibernate.
the class AccessMappingTest method testExplicitPropertyAccessAnnotationsWithHibernateStyleOverride.
@Test
public void testExplicitPropertyAccessAnnotationsWithHibernateStyleOverride() {
Configuration cfg = new Configuration();
Class<?> classUnderTest = Course3.class;
cfg.addAnnotatedClass(classUnderTest);
cfg.addAnnotatedClass(Student.class);
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory(serviceRegistry);
try {
final EntityPersister entityPersister = factory.getRuntimeMetamodels().getMappingMetamodel().getEntityDescriptor(classUnderTest.getName());
final BasicEntityIdentifierMappingImpl identifierMapping = (BasicEntityIdentifierMappingImpl) entityPersister.getIdentifierMapping();
assertTrue("Field access should be used.", identifierMapping.getPropertyAccess().getGetter() instanceof GetterFieldImpl);
assertTrue("Property access should be used.", entityPersister.getAttributeMapping(0).getPropertyAccess().getGetter() instanceof GetterMethodImpl);
} finally {
factory.close();
}
}
Aggregations