Search in sources :

Example 31 with HibernateJpaVendorAdapter

use of org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter in project workbench by all-of-us.

the class TestJpaConfig method entityManagerFactory.

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource());
    em.setPackagesToScan(new String[] { "org.pmiops.workbench.cdr", "org.pmiops.workbench.db" });
    em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    em.setJpaProperties(additionalProperties());
    return em;
}
Also used : HibernateJpaVendorAdapter(org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Example 32 with HibernateJpaVendorAdapter

use of org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter in project av-service by dvoraka.

the class DbCommonConfig method entityManagerFactory.

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource, Properties hibernateProperties) {
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
    entityManagerFactoryBean.setDataSource(dataSource);
    entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    entityManagerFactoryBean.setPackagesToScan("dvoraka.avservice.db.model");
    entityManagerFactoryBean.setJpaProperties(hibernateProperties);
    return entityManagerFactoryBean;
}
Also used : HibernateJpaVendorAdapter(org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Example 33 with HibernateJpaVendorAdapter

use of org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter in project spring-boot by spring-projects.

the class CustomHibernateJpaAutoConfigurationTests method defaultDatabaseIsSet.

@Test
void defaultDatabaseIsSet() {
    this.contextRunner.withPropertyValues("spring.datasource.url:jdbc:h2:mem:testdb", "spring.datasource.initialization-mode:never").run((context) -> {
        HibernateJpaVendorAdapter bean = context.getBean(HibernateJpaVendorAdapter.class);
        Database database = (Database) ReflectionTestUtils.getField(bean, "database");
        assertThat(database).isEqualTo(Database.DEFAULT);
    });
}
Also used : HibernateJpaVendorAdapter(org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter) Database(org.springframework.orm.jpa.vendor.Database) Test(org.junit.jupiter.api.Test)

Example 34 with HibernateJpaVendorAdapter

use of org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter in project tutorials by eugenp.

the class MySQLAutoconfiguration method entityManagerFactory.

@Bean
@ConditionalOnBean(name = "dataSource")
@ConditionalOnMissingBean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource());
    em.setPackagesToScan("com.baeldung.autoconfiguration.example");
    em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    if (additionalProperties() != null) {
        em.setJpaProperties(additionalProperties());
    }
    return em;
}
Also used : HibernateJpaVendorAdapter(org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Example 35 with HibernateJpaVendorAdapter

use of org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter in project tutorials by eugenp.

the class H2JpaConfig method entityManagerFactory.

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource());
    em.setPackagesToScan(new String[] { "org.baeldung.boot.domain", "org.baeldung.boot.model", "org.baeldung.boot.boottest", "org.baeldung.model" });
    em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    em.setJpaProperties(additionalProperties());
    return em;
}
Also used : HibernateJpaVendorAdapter(org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Aggregations

HibernateJpaVendorAdapter (org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter)55 LocalContainerEntityManagerFactoryBean (org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)46 Bean (org.springframework.context.annotation.Bean)45 JpaVendorAdapter (org.springframework.orm.jpa.JpaVendorAdapter)6 Properties (java.util.Properties)5 Database (org.springframework.orm.jpa.vendor.Database)4 HashMap (java.util.HashMap)2 DatabaseManager (com.fredboat.backend.quarterdeck.db.DatabaseManager)1 DataSourceBean (de.alpharogroup.springconfig.DataSourceBean)1 JdbcUrlBean (de.alpharogroup.springconfig.JdbcUrlBean)1 Field (java.lang.reflect.Field)1 HashSet (java.util.HashSet)1 DataSource (javax.sql.DataSource)1 lombok.val (lombok.val)1 HSQLDialect (org.hibernate.dialect.HSQLDialect)1 Test (org.junit.Test)1 Test (org.junit.jupiter.api.Test)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Primary (org.springframework.context.annotation.Primary)1