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

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

Introduction

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

Prototype

public void setJpaProperties(Properties jpaProperties) 

Source Link

Document

Specify JPA properties, to be passed into Persistence.createEntityManagerFactory (if any).

Usage

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:org.axiom_tools.storage.PersistenceContext.java

@Profile("direct")
@Bean(name = "entityManagerFactory")
public LocalContainerEntityManagerFactoryBean directEntityManagerFactory() {
    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    em.setDataSource(directDataSource.dataSource());
    em.setPackagesToScan(directDataSource.modelPackages());
    em.setJpaProperties(directDataSource.additionalProperties());
    return em;//from   w  ww  .  ja va2s.  c  o m
}

From source file:com.urservices.urerp.ecole.config.context.PersistenceJPAConfig.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource());/*  ww  w.j  ava2s .c o m*/
    em.setPackagesToScan(new String[] { "com.urservices.urerp.ecole.adresse.entity", });

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

    return em;
}

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.mycompany.spring2explore.config.PersistenceJPAConfig.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource());/*from   w w  w .ja va2s .c om*/
    em.setPackagesToScan(new String[] { "com.mycompany.spring2explore.entities" });

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

    return em;
}

From source file:ch.thp.proto.ws.spring.batch.infrastructure.DatabaseConfig.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(Environment env) throws Exception {

    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setShowSql(Boolean.TRUE);

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setPersistenceUnitName("sample");
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("ch.thp.proto");
    factory.setDataSource(dataSource(env));

    factory.setJpaProperties(jpaProperties());

    return factory;
}

From source file:se.ivankrizsan.messagecowboy.PersistenceConfiguration.java

/**
 * JPA entity manager factory bean.//from w w w.  ja v  a2 s .c  o m
 * Depends on the hsqlDbServer bean, in order to create the embedded
 * database, if one is to be used, before the entity manager factory.
 */
@Bean
@DependsOn("hsqlDbServer")
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    /* JPA entity manager factory. */
    final LocalContainerEntityManagerFactoryBean theJpaEntityManagerFactory = new LocalContainerEntityManagerFactoryBean();
    theJpaEntityManagerFactory.setDataSource(dataSource());
    theJpaEntityManagerFactory.setPersistenceUnitName("message-cowboy");
    theJpaEntityManagerFactory.setJpaProperties(jpaProperties());

    /* JPA vendor adapter. */
    final EclipseLinkJpaVendorAdapter theJpaVendorAdapter = new EclipseLinkJpaVendorAdapter();
    theJpaVendorAdapter.setShowSql(true);

    theJpaEntityManagerFactory.setJpaVendorAdapter(theJpaVendorAdapter);

    return theJpaEntityManagerFactory;
}

From source file:com.alejandroszlv.mock.repository.config.RepositoryConfig.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource());/*from   w w  w  .  jav  a 2s .c o  m*/
    em.setPackagesToScan(new String[] { "com.alejandroszlv.mock.entity" });

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

    return em;
}

From source file:ch.thp.proto.spring.time.infra.config.DatabaseConfig.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(Environment env) throws Exception {

    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setShowSql(Boolean.TRUE);

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setPersistenceUnitName("sample");
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("ch.thp.proto.spring.time");
    factory.setDataSource(dataSource(env));

    factory.setJpaProperties(jpaProperties());

    return factory;
}

From source file:io.springagora.store.ApplicationConfig.java

@Bean
@Autowired/*from  w ww  . j  a  va 2s .  c om*/
public EntityManagerFactory entityManagerFactory(DataSource dataSource) {
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setGenerateDdl(generateDDL.booleanValue());
    vendorAdapter.setShowSql(showSQL.booleanValue());
    vendorAdapter.setDatabasePlatform("org.hibernate.dialect.MySQL5InnoDBDialect");
    vendorAdapter.setDatabase(Database.MYSQL);

    Properties properties = new Properties();
    properties.setProperty("hibernate.cache.use_second_level_cache", "true");
    properties.setProperty("hibernate.cache.region.factory_class",
            "org.hibernate.cache.ehcache.EhCacheRegionFactory");
    properties.setProperty("hibernate.cache.use_query_cache", "true");
    properties.setProperty("hibernate.generate_statistics", showStatistics.toString());

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("io.springagora.core.domain");
    factory.setDataSource(dataSource);
    factory.setJpaProperties(properties);
    factory.afterPropertiesSet();

    return factory.getObject();
}