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

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

Introduction

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

Prototype

LocalContainerEntityManagerFactoryBean

Source Link

Usage

From source file:br.com.alura.casadocodigo.conf.JPAConfiguration.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {

    LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();

    JpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
    factoryBean.setJpaVendorAdapter(adapter);

    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setUsername("root");
    dataSource.setPassword("");
    dataSource.setUrl("jdbc:mysql://localhost:3306/casadocodigo");
    dataSource.setDriverClassName("com.mysql.jdbc.Driver");
    factoryBean.setDataSource(dataSource);

    Properties properties = new Properties();
    properties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
    properties.setProperty("hibernate.show_sql", "true");
    properties.setProperty("hibernate.hbm2ddl.auto", "update");
    factoryBean.setJpaProperties(properties);

    factoryBean.setPackagesToScan("br.com.alura.casadocodigo.models");

    return factoryBean;
}

From source file:ua.biglib.salivon.BookConfig.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
    emf.setDataSource(dataSource());// w  ww. j av a 2s  .  co  m
    emf.setJpaVendorAdapter(jpaVendorAdapter());
    return emf;
}

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

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {

    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource());//from   www . j  a  v  a2 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.iopr.PersistenceJPAConfig.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource());// w w w .j  a v  a  2  s  . c  om
    em.setPackagesToScan(new String[] { "com.iopr.model" });
    JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    em.setJpaVendorAdapter(vendorAdapter);
    em.setJpaProperties(additionalProperties());
    return em;
}

From source file:org.hellospring4.config.PersistenceConfig.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();

    em.setDataSource(dataSource());/*  w  w  w.  j a  v a 2  s .  c om*/
    em.setPackagesToScan(new String[] { "org.hellospring4.entities" });

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

    return em;
}

From source file:com.sapito.db.config.PersistenceConfig.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();

    em.setDataSource(dataSource());//from w w  w. j  a  v  a  2s . c om
    em.setPackagesToScan(new String[] { "com.sapito.db.entities" });

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

    return em;
}

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

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource());/*from   w  w  w.j av a  2  s. co m*/
    em.setPackagesToScan(new String[] { "com.mycompany.spring2explore.entities" });

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

    return em;
}

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

@Bean
@Autowired//www  .j a  va 2s  . c o  m
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:ru.langboost.config.DBConfig.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    EclipseLinkJpaVendorAdapter vendorAdapter = new EclipseLinkJpaVendorAdapter();
    vendorAdapter.setGenerateDdl(true);/*from  w w  w .  j  ava 2s .c  o  m*/
    vendorAdapter.setShowSql(true);

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan(Environment.BASE_PACKAGE);
    factory.setDataSource(dataSource());
    factory.setJpaProperties(jpaProperties());
    return factory;
}

From source file:org.surfnet.oaaas.repository.AbstractTestRepository.java

@SuppressWarnings({ "rawtypes", "unchecked" })
private static EntityManager entityManager(DataSource dataSource) {
    LocalContainerEntityManagerFactoryBean emfBean = new LocalContainerEntityManagerFactoryBean();
    emfBean.setDataSource(dataSource);//from ww w . j a  v  a2 s  .  c  o m
    emfBean.setPersistenceUnitName(PERSISTENCE_UNIT_NAME);
    emfBean.setPersistenceProviderClass(PERSISTENCE_PROVIDER_CLASS);
    emfBean.afterPropertiesSet();
    Map map = new HashMap<String, String>();
    map.put("openjpa.ConnectionFactoryProperties", "PrintParameters=true");
    return emfBean.getObject().createEntityManager(map);
}