Example usage for org.springframework.orm.jpa.vendor AbstractJpaVendorAdapter setDatabasePlatform

List of usage examples for org.springframework.orm.jpa.vendor AbstractJpaVendorAdapter setDatabasePlatform

Introduction

In this page you can find the example usage for org.springframework.orm.jpa.vendor AbstractJpaVendorAdapter setDatabasePlatform.

Prototype

public void setDatabasePlatform(@Nullable String databasePlatform) 

Source Link

Document

Specify the name of the target database to operate on.

Usage

From source file:com.qpark.eip.core.model.analysis.config.EipModelAnalysisPersistenceConfig.java

/**
 * Get the {@link LocalContainerEntityManagerFactoryBean}.
 *
 * @return the {@link LocalContainerEntityManagerFactoryBean}.
 *//*from  ww w. jav  a2  s . 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}.
 *//*from  w w w  .  j av a 2  s .  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(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/*  www  . j av a 2  s  .co m*/
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;
}