List of usage examples for org.springframework.orm.jpa.vendor AbstractJpaVendorAdapter setGenerateDdl
public void setGenerateDdl(boolean generateDdl)
From source file:com.qpark.eip.core.model.analysis.config.EipModelAnalysisPersistenceConfig.java
/** * Get the {@link LocalContainerEntityManagerFactoryBean}. * * @return the {@link LocalContainerEntityManagerFactoryBean}. */// www.j ava2s. c o m @Bean(name = ENTITY_MANAGER_FACTORY_NAME) public EntityManagerFactory getEntityManagerFactory() { AbstractJpaVendorAdapter jpaVendorAdapter = this.getJpaVendorAdapter(); if (jpaVendorAdapter == null) { throw new RuntimeException(String.format("%s jpaVendorAdpater not set properly %s.", ENTITY_MANAGER_FACTORY_NAME, String.valueOf(jpaVendorAdapter))); } String jpaVendorAdapterDatabasePlatform = this.jpaVendorAdapterConfiguration .getJpaVendorAdpaterDatabasePlatform(); if (jpaVendorAdapterDatabasePlatform == null || jpaVendorAdapterDatabasePlatform.trim().length() == 0) { throw new RuntimeException(String.format("%s jpaVendorAdpaterDatabasePlatform not set properly %s.", ENTITY_MANAGER_FACTORY_NAME, String.valueOf(jpaVendorAdapterDatabasePlatform))); } LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean(); bean.setPersistenceXmlLocation( String.format("classpath:/META-INF/%s/persistence.xml", PERSISTENCE_UNIT_NAME)); bean.setPersistenceUnitName(PERSISTENCE_UNIT_NAME); bean.setDataSource(this.dataSource); jpaVendorAdapter.setDatabasePlatform(jpaVendorAdapterDatabasePlatform); jpaVendorAdapter.setShowSql(false); if (this.isJpaVendorAdapterGenerateDdl()) { jpaVendorAdapter.setGenerateDdl(true); if (HibernateJpaVendorAdapter.class.isInstance(jpaVendorAdapter)) { bean.getJpaPropertyMap().put("hibernate.hbm2ddl.auto", "update"); } } else { jpaVendorAdapter.setGenerateDdl(false); } bean.setJpaVendorAdapter(jpaVendorAdapter); bean.afterPropertiesSet(); return bean.getObject(); }
From source file:com.qpark.eip.core.spring.lockedoperation.config.EipLockedoperationConfig.java
/** * Get the {@link LocalContainerEntityManagerFactoryBean}. * * @return the {@link LocalContainerEntityManagerFactoryBean}. *///w ww .j a v a2 s.com @Bean(name = ENTITY_MANAGER_FACTORY_NAME) public EntityManagerFactory getEntityManagerFactory() { AbstractJpaVendorAdapter jpaVendorAdapter = this.getJpaVendorAdapter(); if (jpaVendorAdapter == null) { throw new RuntimeException(String.format("%s jpaVendorAdpater not set properly %s.", ENTITY_MANAGER_FACTORY_NAME, String.valueOf(jpaVendorAdapter))); } String jpaVendorAdapterDatabasePlatform = this.jpaVendorAdapterConfiguration .getJpaVendorAdpaterDatabasePlatform(); if (jpaVendorAdapterDatabasePlatform == null || jpaVendorAdapterDatabasePlatform.trim().length() == 0) { throw new RuntimeException(String.format("%s jpaVendorAdpaterDatabasePlatform not set properly %s.", ENTITY_MANAGER_FACTORY_NAME, String.valueOf(jpaVendorAdapterDatabasePlatform))); } LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean(); bean.setPersistenceXmlLocation(new StringBuffer(96).append("classpath:/META-INF/") .append(PERSISTENCE_UNIT_NAME).append("/persistence.xml").toString()); bean.setPersistenceUnitName(PERSISTENCE_UNIT_NAME); bean.setDataSource(this.datasource); jpaVendorAdapter.setDatabasePlatform(jpaVendorAdapterDatabasePlatform); jpaVendorAdapter.setShowSql(false); if (this.isJpaVendorAdapterGenerateDdl()) { jpaVendorAdapter.setGenerateDdl(true); if (HibernateJpaVendorAdapter.class.isInstance(jpaVendorAdapter)) { bean.getJpaPropertyMap().put("hibernate.hbm2ddl.auto", "update"); } } else { jpaVendorAdapter.setGenerateDdl(false); } bean.setJpaVendorAdapter(jpaVendorAdapter); bean.afterPropertiesSet(); return bean.getObject(); }
From source file:org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.java
@Bean @ConditionalOnMissingBean//from www . jav a2 s. com public JpaVendorAdapter jpaVendorAdapter() { AbstractJpaVendorAdapter adapter = createJpaVendorAdapter(); adapter.setShowSql(this.properties.isShowSql()); adapter.setDatabase(this.properties.determineDatabase(this.dataSource)); adapter.setDatabasePlatform(this.properties.getDatabasePlatform()); adapter.setGenerateDdl(this.properties.isGenerateDdl()); return adapter; }