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

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

Introduction

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

Prototype

public void setShowSql(boolean showSql) 

Source Link

Document

Set whether to show SQL in the log (or in the console).

Usage

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

/**
 * Get the {@link LocalContainerEntityManagerFactoryBean}.
 *
 * @return the {@link LocalContainerEntityManagerFactoryBean}.
 *///from  w  w w. ja  va 2 s  .c  om
@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 ava 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/*from   w w  w  . j ava  2s . c  o  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;
}