use of org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean in project rhino by PLOS.
the class RhinoConfiguration method sessionFactory.
@Bean
public AnnotationSessionFactoryBean sessionFactory(DataSource hibernateDataSource) throws IOException {
// May be switched to true in a dev environment to log SQL code generated by Hibernate.
// Could be replaced with environmental config if needed.
final boolean hibernateIsInDebugMode = false;
AnnotationSessionFactoryBean bean = new AnnotationSessionFactoryBean();
bean.setDataSource(hibernateDataSource);
Properties hibernateProperties = new Properties();
hibernateProperties.setProperty("hibernate.dialect", org.hibernate.dialect.MySQLDialect.class.getName());
hibernateProperties.setProperty("hibernate.show_sql", Boolean.toString(hibernateIsInDebugMode));
hibernateProperties.setProperty("hibernate.format_sql", Boolean.toString(hibernateIsInDebugMode));
bean.setHibernateProperties(hibernateProperties);
bean.setPackagesToScan("org.ambraproject.rhino.model");
return bean;
}
use of org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean in project simple-java by angryziber.
the class HibernatePhotoSpotRepositoryIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
dataSource = new DriverManagerDataSource("jdbc:h2:mem:hibernate;DB_CLOSE_DELAY=-1", "sa", "sa");
System.setProperty("hibernate.dialect", H2Dialect.class.getName());
System.setProperty("hibernate.hbm2ddl.auto", "create-drop");
AnnotationSessionFactoryBean sessionFactory = new AnnotationSessionFactoryBean();
sessionFactory.setDataSource(dataSource);
sessionFactory.setAnnotatedClasses(new Class[] { PhotoSpot.class });
sessionFactory.afterPropertiesSet();
repo.hibernate = new HibernateTemplate(sessionFactory.getObject());
}
Aggregations