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

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

Introduction

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

Prototype

public void setPackagesToScan(String... packagesToScan) 

Source Link

Document

Set whether to use Spring-based scanning for entity classes in the classpath instead of using JPA's standard scanning of jar files with persistence.xml markers in them.

Usage

From source file:com.mycompany.cputauctionnew.app.config.ConnectionConfig.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource,
        JpaVendorAdapter jpaVendorAdapter) {
    LocalContainerEntityManagerFactoryBean lef = new LocalContainerEntityManagerFactoryBean();
    lef.setDataSource(dataSource);/*from  ww  w.j av a2s.  c om*/
    lef.setJpaVendorAdapter(jpaVendorAdapter);
    lef.setPackagesToScan("com.mycompany.cputauctionnew.domain");
    return lef;
}

From source file:pl.softech.eav.example.JpaConfig.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(JpaVendorAdapter jpaVendorAdapter,
        DataSource ds, @Value("${hibernate.show_sql}") String showSql,
        @Value("${hibernate.format_sql}") String formatSql,
        @Value("${hibernate.cache.use_second_level_cache}") String useSecondLevelCache) {
    LocalContainerEntityManagerFactoryBean lemfb = new LocalContainerEntityManagerFactoryBean();
    lemfb.setDataSource(ds);//  w  w w. j  a v  a 2s.  c o m
    lemfb.setJpaVendorAdapter(jpaVendorAdapter);
    lemfb.setPackagesToScan("pl.softech.eav.domain");
    Properties jpaProperties = new Properties();
    jpaProperties.setProperty("hibernate.cache.region.factory_class",
            "org.hibernate.cache.ehcache.EhCacheRegionFactory");
    jpaProperties.setProperty("hibernate.cache.use_second_level_cache", useSecondLevelCache);
    jpaProperties.setProperty("hibernate.show_sql", showSql);
    jpaProperties.setProperty("hibernate.format_sql", formatSql);
    /* See https://hibernate.atlassian.net/browse/HHH-8796 */
    jpaProperties.setProperty("hibernate.schema_update.unique_constraint_strategy", "RECREATE_QUIETLY");
    lemfb.setJpaProperties(jpaProperties);
    return lemfb;
}

From source file:com.cemeterylistingswebtest.test.ConnectionConfigTest.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource,
        JpaVendorAdapter jpaVendorAdapter) {
    LocalContainerEntityManagerFactoryBean lefb = new LocalContainerEntityManagerFactoryBean();
    lefb.setDataSource(dataSource);/*from w  w w.java2s  . c o m*/
    lefb.setJpaVendorAdapter(jpaVendorAdapter);
    lefb.setPackagesToScan("com.cemeterylistingsweb.domain");
    return lefb;
}

From source file:com.nkosy.propertymanager.app.ConnectionConfig.java

/**
 *
 * @param dataSource//from   w w  w  . ja  v  a 2 s  . co m
 * @param jpaVendorAdapter
 * @return
 */
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource,
        JpaVendorAdapter jpaVendorAdapter) {
    LocalContainerEntityManagerFactoryBean lef = new LocalContainerEntityManagerFactoryBean();
    lef.setDataSource(dataSource);
    lef.setJpaVendorAdapter(jpaVendorAdapter);
    lef.setPackagesToScan("com.nkosy.propertymanager.domain");
    return lef;
}

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

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws PropertyVetoException {
    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setPackagesToScan("br.com.danielcamargo.backend.hsnpts.core.domain");
    factory.setDataSource(dataSource());
    factory.setJpaVendorAdapter(jpaVendorAdapter());

    Map<String, String> map = new HashMap<>();

    map.put("hibernate.dialect", env.getProperty("database.dialect"));
    map.put("hibernate.hbm2ddl.auto", env.getProperty("database.ddlgen"));
    map.put("hibernate.connection.charSet", "UTF-8");
    map.put("hibernate.show_sql", "true");

    map.put("hibernate.hbm2ddl.import_files", "import.sql");

    factory.setJpaPropertyMap(map);//from   w ww  .j a v  a 2 s . co  m
    return factory;
}

From source file:com.tchouyangoko.humain.app.config.ConnectionConfig.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource,
        JpaVendorAdapter jpaVendorAdapter) {
    LocalContainerEntityManagerFactoryBean lef = new LocalContainerEntityManagerFactoryBean();
    lef.setDataSource(dataSource);//  w w w.j a  v a2 s  . co  m
    lef.setJpaVendorAdapter(jpaVendorAdapter);
    lef.setPackagesToScan("com.tchouyangoko.humain.domain");
    return lef;
}

From source file:com.sg.domain.jpa.spring.PersistenceContextConfig.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) {

    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("com.sg.domain.entities.jpa");
    factory.setDataSource(dataSource);//from   w w w  . j  a va  2 s  .  c  o m

    Properties jpaProperties = new Properties();
    jpaProperties.put(org.hibernate.cfg.Environment.SHOW_SQL, hibernateShowSql);
    jpaProperties.put(org.hibernate.cfg.Environment.FORMAT_SQL, hibernateFormatSql);
    jpaProperties.put(org.hibernate.cfg.Environment.DIALECT, hibernateDialect);
    if (hibernateHbm2ddlAuto != null && !hibernateHbm2ddlAuto.isEmpty()) {
        jpaProperties.put(org.hibernate.cfg.Environment.HBM2DDL_AUTO, hibernateHbm2ddlAuto);
    }

    factory.setJpaProperties(jpaProperties);

    return factory;
}

From source file:com.iluwatar.repository.AppConfig.java

/**
 * Factory to create a especific instance of Entity Manager
 *//* ww w .  ja  v  a 2s.co  m*/
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean entityManager = new LocalContainerEntityManagerFactoryBean();
    entityManager.setDataSource(dataSource());
    entityManager.setPackagesToScan("com.iluwatar");
    entityManager.setPersistenceProvider(new HibernatePersistenceProvider());
    entityManager.setJpaProperties(jpaProperties());

    return entityManager;
}

From source file:com.sdl.odata.example.persistent.entities.PersistentDataSourceConfiguration.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource,
        JpaVendorAdapter jpaVendorAdapter) {
    LocalContainerEntityManagerFactoryBean emfb = new LocalContainerEntityManagerFactoryBean();
    emfb.setDataSource(dataSource);//from   w ww .j av a2s. co m
    emfb.setJpaVendorAdapter(jpaVendorAdapter);
    emfb.setPackagesToScan("com.sdl.odata.example.persistent.entities");
    return emfb;
}

From source file:br.com.devmedia.cleancode.spring.ConfiguracaoTesteIntegracao.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
    factoryBean.setPersistenceUnitName("integration");
    factoryBean.setDataSource(dataSource());
    factoryBean.setPackagesToScan("br.com.devmedia.cleancode.modelo");
    return factoryBean;
}