I'm using Hibernate 3.3 and Spring 3.2 through java configuration. I would like to create a session factory in my application context. I'm trying something like this
@Bean
public SessionFactory sessionFactory() throws Exception {
AnnotationSessionFactoryBean sessionFactoryBean = new AnnotationSessionFactoryBean();
sessionFactoryBean.setDataSource(dataSource());
sessionFactoryBean.setPackagesToScan(new String[] { "org.package" });
Properties hibernateProperties = new Properties();
hibernateProperties.put("hibernate.show_sql", true);
hibernateProperties.put("hibernate.bytecode.use_reflection_optimizer", false);
hibernateProperties.put("hibernate.check_nullability", false);
hibernateProperties.put("hibernate.dialect", "org.hibernate.dialect.DB2Dialect");
hibernateProperties.put("hibernate.search.autoregister_listeners", false);
sessionFactoryBean.setHibernateProperties(hibernateProperties);
return sessionFactoryBean.getObject();
}
But in the last line it returns null ¿What am I doing wrong?