use of org.hibernate.engine.spi.SessionFactoryImplementor in project hibernate-orm by hibernate.
the class AccessMappingTest method testPropertyAnnotationPlacement.
@Test
public void testPropertyAnnotationPlacement() throws Exception {
Configuration cfg = new Configuration();
Class<?> classUnderTest = Course7.class;
cfg.addAnnotatedClass(classUnderTest);
cfg.addAnnotatedClass(Student.class);
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory(serviceRegistry);
try {
EntityTuplizer tuplizer = factory.getEntityPersister(classUnderTest.getName()).getEntityMetamodel().getTuplizer();
assertTrue("Property access should be used.", tuplizer.getIdentifierGetter() instanceof GetterMethodImpl);
} finally {
factory.close();
}
}
use of org.hibernate.engine.spi.SessionFactoryImplementor in project hibernate-orm by hibernate.
the class AccessMappingTest method testDefaultFieldAccessIsInherited.
@Test
public void testDefaultFieldAccessIsInherited() throws Exception {
Configuration cfg = new Configuration();
Class<?> classUnderTest = User.class;
cfg.addAnnotatedClass(classUnderTest);
cfg.addAnnotatedClass(Person.class);
cfg.addAnnotatedClass(Being.class);
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory(serviceRegistry);
try {
EntityTuplizer tuplizer = factory.getEntityPersister(classUnderTest.getName()).getEntityMetamodel().getTuplizer();
assertTrue("Field access should be used since the default access mode gets inherited", tuplizer.getIdentifierGetter() instanceof GetterFieldImpl);
} finally {
factory.close();
}
}
use of org.hibernate.engine.spi.SessionFactoryImplementor in project hibernate-orm by hibernate.
the class AccessMappingTest method testExplicitPropertyAccessAnnotationsWithJpaStyleOverride.
@Test
public void testExplicitPropertyAccessAnnotationsWithJpaStyleOverride() throws Exception {
Configuration cfg = new Configuration();
Class<?> classUnderTest = Course5.class;
cfg.addAnnotatedClass(classUnderTest);
cfg.addAnnotatedClass(Student.class);
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory(serviceRegistry);
try {
EntityTuplizer tuplizer = factory.getEntityPersister(classUnderTest.getName()).getEntityMetamodel().getTuplizer();
assertTrue("Field access should be used.", tuplizer.getIdentifierGetter() instanceof GetterFieldImpl);
assertTrue("Property access should be used.", tuplizer.getGetter(0) instanceof GetterMethodImpl);
} finally {
factory.close();
}
}
use of org.hibernate.engine.spi.SessionFactoryImplementor in project hibernate-orm by hibernate.
the class XmlAccessTest method testAccessOnEntityXmlElement.
@Test
public void testAccessOnEntityXmlElement() throws Exception {
Class<?> classUnderTest = Tourist.class;
List<Class<?>> classes = new ArrayList<Class<?>>();
classes.add(classUnderTest);
List<String> configFiles = Collections.emptyList();
SessionFactoryImplementor factory = buildSessionFactory(classes, configFiles);
// without any xml configuration we have field access
assertAccessType(factory, classUnderTest, AccessType.FIELD);
factory.close();
// now with an additional xml configuration file changing the default access type for Tourist using entity level config
configFiles = new ArrayList<String>();
configFiles.add("org/hibernate/test/annotations/access/xml/Tourist4.xml");
factory = buildSessionFactory(classes, configFiles);
assertAccessType(factory, classUnderTest, AccessType.PROPERTY);
factory.close();
}
use of org.hibernate.engine.spi.SessionFactoryImplementor in project hibernate-orm by hibernate.
the class XmlAccessTest method testAccessOnElementCollectionXmlElement.
@Test
public void testAccessOnElementCollectionXmlElement() throws Exception {
Class<?> classUnderTest = Boy.class;
List<Class<?>> classes = new ArrayList<Class<?>>();
classes.add(classUnderTest);
List<String> configFiles = new ArrayList<String>();
configFiles.add("org/hibernate/test/annotations/access/xml/Boy.xml");
SessionFactoryImplementor factory = buildSessionFactory(classes, configFiles);
assertAccessType(factory, classUnderTest, AccessType.PROPERTY);
factory.close();
}
Aggregations