AnnotationSessionFactoryBean factoryBean = new AnnotationSessionFactoryBean();
factoryBean.setDataSource(createTestDataSource());
factoryBean.setAnnotatedClasses(new Class [] {Account.class, Beneficiary.class});
factoryBean.setHibernateProperties(createHibernateProperties());
// initialize according to the Spring InitializingBean contract
factoryBean.afterPropertiesSet();
// get the created session factory
return (SessionFactory) factoryBean.getObject();
}
private DataSource createTestDataSource() {