Example usage for org.springframework.orm.jpa.vendor HibernateJpaVendorAdapter setDatabase

List of usage examples for org.springframework.orm.jpa.vendor HibernateJpaVendorAdapter setDatabase

Introduction

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

Prototype

public void setDatabase(Database database) 

Source Link

Document

Specify the target database to operate on, as a value of the Database enum: DB2, DERBY, H2, HANA, HSQL, INFORMIX, MYSQL, ORACLE, POSTGRESQL, SQL_SERVER, SYBASE

NOTE: This setting will override your JPA provider's default algorithm.

Usage

From source file:ch.javaee.basicMvc.config.StandaloneDataConfig.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {

    LocalContainerEntityManagerFactoryBean lcemfb = new LocalContainerEntityManagerFactoryBean();

    lcemfb.setDataSource(this.hsqlInMemory());
    lcemfb.setPackagesToScan(new String[] { "ch.javaee.basicMvc.domain" });

    lcemfb.setPersistenceUnitName("MyPU");

    HibernateJpaVendorAdapter va = new HibernateJpaVendorAdapter();
    lcemfb.setJpaVendorAdapter(va);//from w  w  w. j a  v  a2  s.com
    va.setDatabase(Database.HSQL);
    va.setGenerateDdl(true);
    va.setShowSql(true);
    va.setDatabasePlatform("org.hibernate.dialect.HSQLDialect");

    Properties ps = new Properties();
    ps.put("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
    ps.put("hibernate.hbm2ddl.auto", "create");
    lcemfb.setJpaProperties(ps);

    lcemfb.afterPropertiesSet();

    return lcemfb;

}

From source file:com.MockGatewayApplication.java

@Bean
public JpaVendorAdapter jpaVendorAdapter() {
    HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
    adapter.setDatabase(Database.valueOf(dbType));
    adapter.setShowSql(true);// w w w . j  a v a2  s.  co  m
    adapter.setGenerateDdl(true);
    adapter.setDatabasePlatform(dbDialect);
    return adapter;
}

From source file:com.MockGatewayApplication.java

@Bean
public EntityManagerFactory entityManagerFactory() {

    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setDatabase(Database.valueOf(dbType));
    vendorAdapter.setShowSql(true);/*  ww w  .  j a va2s  . c om*/
    vendorAdapter.setGenerateDdl(false); //true value not for production !!! update db after entityManager instantiation based on entities
    vendorAdapter.setDatabasePlatform(dbDialect);

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("com.entity");
    factory.setDataSource(dataSource());
    factory.afterPropertiesSet();

    return factory.getObject();
}

From source file:org.springsource.greenbeans.examples.edawithspring.etailer.store.StoreConfiguration.java

@Bean
public HibernateJpaVendorAdapter hibernateJpaVendorAdapter() {
    HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter();
    hibernateJpaVendorAdapter.setDatabase(Database.H2);
    hibernateJpaVendorAdapter.setShowSql(true);
    hibernateJpaVendorAdapter.setDatabasePlatform(H2Dialect.class.getName());
    return hibernateJpaVendorAdapter;
}

From source file:uk.gov.hscic.common.config.LegacyJPATransactionalConfig.java

@Bean
public EntityManagerFactory legacyEntityManagerFactory() {
    final Database database = Database.valueOf(vendor.toUpperCase());

    final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setShowSql(showSql);//  w  w  w.jav a  2s  .  c  o  m
    vendorAdapter.setGenerateDdl(true);
    vendorAdapter.setDatabase(database);

    final LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("uk.gov.hscic");
    factory.setDataSource(legacyDataSource);
    factory.afterPropertiesSet();

    return factory.getObject();
}

From source file:config.DomainAndPersistenceConfig.java

@Bean
public JpaVendorAdapter jpaVendorAdapter() {
    HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter();
    hibernateJpaVendorAdapter.setShowSql(false);
    hibernateJpaVendorAdapter.setGenerateDdl(false);
    hibernateJpaVendorAdapter.setDatabase(Database.MYSQL);
    return hibernateJpaVendorAdapter;
}

From source file:cput.codez.angorora.eventstar.app.conf.ConnectionConfig.java

@Bean
public JpaVendorAdapter jpaVendorAdapter() {
    HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter();
    hibernateJpaVendorAdapter.setShowSql(false);
    hibernateJpaVendorAdapter.setGenerateDdl(true);
    hibernateJpaVendorAdapter.setDatabase(Database.MYSQL);
    return hibernateJpaVendorAdapter;
}

From source file:ConnectionConfigTest.java

@Bean
public JpaVendorAdapter jpaVendorAdapter() {
    HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter();
    hibernateJpaVendorAdapter.setShowSql(false);
    hibernateJpaVendorAdapter.setGenerateDdl(true);
    hibernateJpaVendorAdapter.setDatabase(Database.DERBY);
    return hibernateJpaVendorAdapter;
}

From source file:com.app.config.App2Config.java

@Bean
public JpaVendorAdapter jpaVendorAdapter() {
    HibernateJpaVendorAdapter adaptor = new HibernateJpaVendorAdapter();
    adaptor.setShowSql(false);// w w w  . j a v a 2s  .  com
    adaptor.setGenerateDdl(false);
    adaptor.setDatabase(Database.MYSQL);
    return adaptor;
}

From source file:br.eti.danielcamargo.backend.common.config.context.CoreConfig.java

@Bean
public HibernateJpaVendorAdapter jpaVendorAdapter() {
    HibernateJpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();
    jpaVendorAdapter.setShowSql(true);/*from  w  w  w .j  a  v  a2s . c  om*/
    jpaVendorAdapter.setDatabase(Database.POSTGRESQL);
    return jpaVendorAdapter;
}