Example usage for org.springframework.orm.jpa LocalContainerEntityManagerFactoryBean setJpaVendorAdapter

List of usage examples for org.springframework.orm.jpa LocalContainerEntityManagerFactoryBean setJpaVendorAdapter

Introduction

In this page you can find the example usage for org.springframework.orm.jpa LocalContainerEntityManagerFactoryBean setJpaVendorAdapter.

Prototype

public void setJpaVendorAdapter(@Nullable JpaVendorAdapter jpaVendorAdapter) 

Source Link

Document

Specify the JpaVendorAdapter implementation for the desired JPA provider, if any.

Usage

From source file:com.javaetmoi.sample.config.InfrastructureConfig.java

@Bean
public EntityManagerFactory entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource);//w  w  w.  ja v a  2 s  .  c o  m
    em.setPersistenceUnitName("javaconfigSamplePersistenceUnit");
    em.setPackagesToScan("com.javaetmoi.sample.domain");
    em.setJpaVendorAdapter(jpaVendorAdaper());
    em.setJpaPropertyMap(additionalProperties());
    em.afterPropertiesSet();
    return em.getObject();
}

From source file:com.cfitzarl.cfjwed.core.config.DatabaseConfigurationContainer.java

@Bean(name = "entityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) {
    JpaVendorAdapter hibernateAdapter = new HibernateJpaVendorAdapter();

    Properties jpaProperties = new Properties();
    jpaProperties.setProperty("hibernate.dialect", dialect);

    LocalContainerEntityManagerFactoryBean entityManagerFactory = new LocalContainerEntityManagerFactoryBean();
    entityManagerFactory.setDataSource(dataSource);
    entityManagerFactory.setPackagesToScan("com.cfitzarl.cfjwed.data");
    entityManagerFactory.setJpaVendorAdapter(hibernateAdapter);
    entityManagerFactory.setJpaProperties(jpaProperties);

    return entityManagerFactory;
}

From source file:com.amuponda.estorehack.business.config.EstoreHackDataConfig.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean entityManagerFactory = new LocalContainerEntityManagerFactoryBean();
    entityManagerFactory.setDataSource(dataSource());
    entityManagerFactory.setPackagesToScan(new String[] { "com.amuponda.estorehack.business.domain" });
    entityManagerFactory.setJpaVendorAdapter(jpaVendorAdapter());
    entityManagerFactory.setJpaProperties(additionalProperties());
    return entityManagerFactory;
}

From source file:com.gondor.config.ApplicationContextConfig.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws ClassNotFoundException {
    LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
    factoryBean.setDataSource(getDataSource());
    factoryBean.setPackagesToScan("com.gondor.model.orm");
    factoryBean.setJpaVendorAdapter(jpaVendorAdapter());
    factoryBean.setJpaProperties(getHibernateProperties());

    return factoryBean;
}

From source file:br.com.projetotcc.conf.JPAConfiguration.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {

    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource());//from  w w  w.j  a v  a  2 s .  c  o  m
    em.setPackagesToScan(new String[] { "br.com.projetotcc.model" });

    JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();

    em.setJpaVendorAdapter(vendorAdapter);
    em.setJpaProperties(additionalProperties());

    return em;
}

From source file:uk.org.funcube.fcdw.config.PersistenceConfig.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSourceLookup());
    em.setPackagesToScan(new String[] { "uk.org.funcube.fcdw.domain" });

    JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    em.setJpaVendorAdapter(vendorAdapter);
    em.setJpaProperties(additionalProperties());

    return em;/*from   w  w  w.j  av a2 s . c  o  m*/
}

From source file:com.pojur.config.JPAConfig.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource());// w  w w. java 2s  .c o m
    em.setPackagesToScan(new String[] { "com.pojur.entity" });

    JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    em.setJpaVendorAdapter(vendorAdapter);
    em.setJpaProperties(additionalProperties());

    return em;
}

From source file:se.kth.csc.config.JpaConfig.java

/**
 * Creates a new entity manager factory bean using the provided settings.
 *
 * @param dataSource  The JDBC data source to use.
 * @param hbm2ddlAuto The Hibernate setting controlling how database schemas should be automatically migrated.
 * @param dialect     The SQL dialect that Hibernate should use.
 *///from w w  w . j a  v a  2  s  .  co  m
@Autowired
@Bean
public LocalContainerEntityManagerFactoryBean configureEntityManagerFactory(DataSource dataSource,
        @Value("${hibernate.hbm2ddl.auto}") String hbm2ddlAuto, @Value("${hibernate.dialect}") String dialect) {
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
    entityManagerFactoryBean.setDataSource(dataSource);
    entityManagerFactoryBean.setPackagesToScan(Application.class.getPackage().getName());
    entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());

    Properties jpaProperties = new Properties();
    jpaProperties.put(Environment.DIALECT, dialect);
    jpaProperties.put(Environment.HBM2DDL_AUTO, hbm2ddlAuto);
    entityManagerFactoryBean.setJpaProperties(jpaProperties);

    log.info(
            "Creating entity manager factory bean with automatic \"{}\" schema management and the {} SQL dialect",
            hbm2ddlAuto, dialect);
    return entityManagerFactoryBean;
}

From source file:com.devnexus.ting.web.config.PersistenceConfig.java

@Bean
@Profile({ SpringProfile.STANDALONE, SpringProfile.DEFAULT, SpringProfile.DEMO, "cloud" })
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    final LocalContainerEntityManagerFactoryBean entityManagerFactory = new LocalContainerEntityManagerFactoryBean();
    entityManagerFactory.setDataSource(dataSource());
    entityManagerFactory.setJpaVendorAdapter(hibernateJpaVendorAdapter());
    entityManagerFactory.setPackagesToScan("com/devnexus/ting/model");

    final Map<String, Object> jpaProperties = new HashMap<>();

    jpaProperties.put("hibernate.dialect", getHibernateDialect());
    jpaProperties.put("hibernate.generate_statistics", true);
    //jpaProperties.put("hibernate.cache.use_second_level_cache", false);
    //jpaProperties.put("hibernate.cache.use_query_cache", true);
    //jpaProperties.put("hibernate.cache.region.factory_class", "org.hibernate.cache.ehcache.EhCacheRegionFactory");
    jpaProperties.put("hibernate.show_sql", isShowHibernateSql());
    jpaProperties.put("hibernate.format_sql", true);
    jpaProperties.put("hibernate.ejb.naming_strategy",
            "com.devnexus.ting.core.hibernate.ImprovedPluralizedNamingStrategy");

    entityManagerFactory.setJpaPropertyMap(jpaProperties);

    return entityManagerFactory;
}

From source file:pl.edu.uksw.j2eecourse.configuration.LibraryConfig.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource());/*from  w w  w. java 2 s .c o  m*/
    em.setPackagesToScan(new String[] { "pl.edu.uksw.j2eecourse" });

    JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    em.setJpaVendorAdapter(vendorAdapter);
    em.setJpaProperties(additionalProperties());

    return em;
}