use of org.springframework.orm.hibernate3.LocalSessionFactoryBean in project druid by alibaba.
the class HibernateCRUDTest method setUp.
@Override
public void setUp() throws Exception {
/*init dataSource*/
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:h2:file:~/.h2/HibernateCRUDTest;AUTO_SERVER=TRUE");
dataSource.setUsername("sa");
dataSource.setPassword("");
dataSource.setDefaultAutoCommit(false);
dataSource.setFilters("log4j");
/*init sessionFactory*/
LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean();
factoryBean.setDataSource(dataSource);
Properties prop = new Properties();
prop.put("hibernate.show_sql", "true");
//prop.put("hibernate.format_sql", "true");
prop.put("hibernate.hbm2ddl.auto", "create");
prop.put("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
factoryBean.setHibernateProperties(prop);
factoryBean.setAnnotatedClasses(new Class<?>[] { Sample.class });
try {
factoryBean.afterPropertiesSet();
} catch (IOException e) {
e.printStackTrace();
}
sessionFactory = factoryBean.getObject();
}
use of org.springframework.orm.hibernate3.LocalSessionFactoryBean in project rhino by PLOS.
the class TestConfiguration method sessionFactory.
@Bean
public LocalSessionFactoryBean sessionFactory(DataSource dataSource) throws IOException {
LocalSessionFactoryBean bean = new LocalSessionFactoryBean();
bean.setDataSource(dataSource);
bean.setSchemaUpdate(true);
Properties hibernateProperties = new Properties();
hibernateProperties.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
bean.setHibernateProperties(hibernateProperties);
return bean;
}
Aggregations