EntityManagerFactory factory = factories.get(key);
if (factory != null)
return factory;
Ejb3Configuration cfg = new Ejb3Configuration();
cfg.addAnnotatedClass(ch.hortis.sonar.model.ProjectSnapshot.class);
cfg.addAnnotatedClass(ch.hortis.sonar.model.MavenProject.class);
cfg.addAnnotatedClass(ch.hortis.sonar.model.Metric.class);
cfg.addAnnotatedClass(ch.hortis.sonar.model.ProjectMetricMeasure.class);
cfg.addAnnotatedClass(ch.hortis.sonar.model.SchemaInfo.class);
cfg.addAnnotatedClass(ch.hortis.sonar.model.SnapshotGroup.class);
Properties props = new Properties();
if ( jdbcData.getDatasource() == null ) {
props.put("hibernate.connection.url", jdbcData.getUrl());
props.put("hibernate.connection.driver_class", jdbcData.getDriverClassName());
props.put("hibernate.connection.username", jdbcData.getUsername());
props.put("hibernate.connection.password", jdbcData.getPassword());
props.put("hibernate.dialect", getHibernateDialect(jdbcData.getUrl()));
} else {
props.put("hibernate.connection.datasource", jdbcData.getDatasource());
props.put("hibernate.dialect", getHibernateDialect(jdbcData.getDsDialect()));
}
props.put("hibernate.hbm2ddl.auto", "validate");
props.put("hibernate.current_session_context_class", "thread");
if (configuration != null) {
props.putAll(configuration);
}
cfg.addProperties(props);
factory = cfg.createEntityManagerFactory ();
/*Map<String, String> settings = new HashMap<String, String>();
settings.put("hibernate.connection.url", jdbcData.getUrl());
settings.put("hibernate.connection.driver_class", jdbcData.getDriverClassName());
settings.put("hibernate.connection.username", jdbcData.getUsername());