Package org.springframework.orm.jpa

Examples of org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean


public class JpaConfig {

  @Bean
  public EntityManagerFactory entityManagerFactory() {

    LocalContainerEntityManagerFactoryBean entityManagerFactory = new LocalContainerEntityManagerFactoryBean();
    entityManagerFactory.setDataSource(datasource());
    entityManagerFactory.setPackagesToScan(new String[] { "jpa.config.java" });
    entityManagerFactory.setPersistenceProvider(new HibernatePersistence());
    entityManagerFactory.afterPropertiesSet();
    return entityManagerFactory.getObject();
  }
View Full Code Here


    expect(DataSources.build(env)).andReturn(dataSource);

    PowerMock.replay(DataSources.class);
    replay(context, env);

    LocalContainerEntityManagerFactoryBean factory = new JpaModule()
        .jpaEntityManagerFactory(context);

    assertEquals(H2Dialect.class.getName(),
        factory.getJpaPropertyMap().get("hibernate.dialect"));

    verify(context, env);
    PowerMock.verify(DataSources.class);
  }
View Full Code Here

    expect(DataSources.build(env)).andReturn(dataSource);

    PowerMock.replay(DataSources.class);
    replay(context, env);

    LocalContainerEntityManagerFactoryBean factory = new JpaModule()
        .jpaEntityManagerFactory(context);

    assertEquals(MySQL5InnoDBDialect.class.getName(),
        factory.getJpaPropertyMap().get("hibernate.dialect"));

    verify(context, env);
    PowerMock.verify(DataSources.class);
  }
View Full Code Here

    }

    @Bean
    public EntityManagerFactory entityManagerFactory()
    {
        final LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean();
        bean.setDataSource( theDataSource );
        bean.setPersistenceUnitName( "jpaTest" );
        bean.setPackagesToScan( "org.kurron.foundation.spring.example.model" );
        bean.setJpaVendorAdapter( jpaVendorAdapter() );
        final Properties hibernateProperties = new Properties();
        hibernateProperties.setProperty( "hibernate.hbm2ddl.auto", "create-drop" );
        hibernateProperties.setProperty( "hibernate.show_sql", "true" );
        hibernateProperties.setProperty( "hibernate.format_sql", "true" );
        bean.setJpaProperties( hibernateProperties );
        return bean.getObject();
    }
View Full Code Here

        super();
    }

    @Bean
    public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
        final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
        em.setDataSource(dataSource());
        em.setPackagesToScan(new String[] { "org.baeldung.persistence.model" });
        final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
        em.setJpaVendorAdapter(vendorAdapter);
        em.setJpaProperties(additionalProperties());
        return em;
    }
View Full Code Here

    // beans

    @Bean
    public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
        final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
        em.setDataSource(dataSource());
        em.setPackagesToScan(new String[] { "org.baeldung.persistence.model" });

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

        return em;
    }
View Full Code Here

        super();
    }

    @Bean
    public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
        final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
        em.setDataSource(dataSource());
        em.setPackagesToScan(new String[] { "org.baeldung.persistence.model" });

        final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
        // vendorAdapter.set
        em.setJpaVendorAdapter(vendorAdapter);
        em.setJpaProperties(additionalProperties());

        return em;
    }
View Full Code Here

        return new JpaTransactionManager(entityManagerFactory());
    }

    @Bean
    public EntityManagerFactory entityManagerFactory() {
        LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean();
        bean.setDataSource(dataSource());
        bean.setPersistenceXmlLocation("classpath:META-INF/persistence.xml");
        bean.afterPropertiesSet();
        return bean.getObject();
    }
View Full Code Here

        return new JpaTransactionManager(entityManagerFactory());
    }

    @Bean
    public EntityManagerFactory entityManagerFactory() {
        LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean();
        bean.setDataSource(dataSource);
        bean.setPersistenceProvider(new HibernatePersistence());
        bean.setPersistenceXmlLocation("classpath:META-INF/persistence.xml");
        bean.afterPropertiesSet();
        return bean.getObject();
    }
View Full Code Here

        public EntityManagerFactory entityManagerFactory() {
            HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
            vendorAdapter.setDatabase(Database.HSQL);
            vendorAdapter.setGenerateDdl(true);

            LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
            factory.setJpaVendorAdapter(vendorAdapter);
            factory.setPackagesToScan(MODEL_BASE_PACKAGE);
            factory.setDataSource(dataSource());

            factory.afterPropertiesSet();

            return factory.getObject();
        }
View Full Code Here

TOP

Related Classes of org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.