List of usage examples for org.springframework.orm.jpa LocalContainerEntityManagerFactoryBean getDataSource
@Override
public DataSource getDataSource()
From source file:com.brienwheeler.apps.schematool.SchemaToolBean.java
public void afterPropertiesSet() throws Exception { try {/*from ww w.j av a 2 s . c o m*/ // set based on default values in schematool properties file if not already set PropertyPlaceholderConfigurer.setProperty(emfPersistenceLocationsPropName, emfPersistenceLocationsPropValue); Configuration configuration = determineHibernateConfiguration(); Settings settings = null; if (exec || mode == Mode.UPDATE) { ClassPathXmlApplicationContext newContext = new SmartClassPathXmlApplicationContext( emfContextLocation); try { // get a reference to the factory bean, don't have it create a new EntityManager LocalContainerEntityManagerFactoryBean factoryBean = newContext .getBean("&" + emfContextBeanName, LocalContainerEntityManagerFactoryBean.class); SettingsFactory settingsFactory = new InjectedDataSourceSettingsFactory( factoryBean.getDataSource()); settings = settingsFactory.buildSettings(new Properties()); } finally { newContext.close(); } } if (mode == Mode.UPDATE) { SchemaUpdate update = new SchemaUpdate(configuration, settings); update.execute(true, exec); } else { SchemaExport export = exec ? new SchemaExport(configuration, settings) : new SchemaExport(configuration); export.create(true, exec); } } catch (Exception e) { log.error("Error running SchemaTool", e); throw e; } }