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.store.PersistenceJPAConfig.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource());/*from  w w w. j  ava  2s . co  m*/
    em.setPackagesToScan(new String[] { "com.store.model" });

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

    return em;
}

From source file:com.space.data.DomainStoreConfiguration.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource());// w w w  .jav  a  2  s  . co  m
    em.setPackagesToScan(new String[] { "com.space.data.model" });

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

    return em;
}

From source file:br.com.gumga.academia.aplicacao.Aplicacao.java

@Bean
public EntityManagerFactory entityManagerFactory() {

    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setGenerateDdl(true);//from www. j  a va2  s . c om

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("br.com.gumga.academia.entidades");
    factory.setDataSource(dataSource());
    factory.afterPropertiesSet();

    return factory.getObject();
}

From source file:br.com.gumga.academia.Aplicacao.java

@Bean
public EntityManagerFactory entityManagerFactory() {

    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setGenerateDdl(true);/* w w w.ja va2s  .  com*/

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("br.com.gumga.academia.entidade");
    factory.setDataSource(dataSource());
    factory.afterPropertiesSet();

    return factory.getObject();
}

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 ava 2  s  .co  m*/
    em.setPackagesToScan(new String[] { "br.com.projetotcc.model" });

    JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();

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

    return em;
}

From source file:com.example.spring.boot.app.RepositoryConfig.java

@Bean
public EntityManagerFactory entityManagerFactory() {
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setGenerateDdl(true);/*from w ww . jav  a  2  s.  c  om*/

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan(User.class.getPackage().getName());
    factory.setDataSource(dataSource());
    factory.afterPropertiesSet();

    return factory.getObject();
}

From source file:com.tamnd.app.config.HibernateConfig.java

@Bean
@Autowired/*  w w w . j  ava  2  s . c  om*/
public LocalContainerEntityManagerFactoryBean sessionFactory(DataSource h2DataSource) {
    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setDataSource(h2DataSource);
    factory.setPackagesToScan(new String[] { "com.tamnd.app.core.entities" });
    factory.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    factory.setJpaProperties(hibernateProperties());

    return factory;
}

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

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource());//from ww w  .j a v  a2s .  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: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;/*www  .ja v a2s. com*/
}

From source file:com.mycompany.swing2explore.config.PersistenceJPAConfig.java

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

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

    return em;
}