Package org.springframework.orm.jpa

Examples of org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean


     */
    @Bean
    public EntityManagerFactory entityManagerFactory() throws IOException {
        AbstractJpaConfiguration.log.info("EntityManagerFactory Bean을 생성합니다...");

        LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();

        String[] packagenames = getMappedPackageNames();
        if (packagenames != null && packagenames.length > 0) {
            log.debug("JPA용 entity를 scan합니다. packages=[{}]", arrayToCommaDelimitedString(packagenames));
            factoryBean.setPackagesToScan(packagenames);
        }

        factoryBean.setJpaProperties(jpaProperties());
        factoryBean.setDataSource(dataSource());

        HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
        adapter.setGenerateDdl(true);
        factoryBean.setJpaVendorAdapter(adapter);

        setupEntityManagerFactory(factoryBean);

        factoryBean.afterPropertiesSet();
        AbstractJpaConfiguration.log.info("EntityManagerFactory Bean을 생성했습니다!!!");

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


     */
    @Bean
    public EntityManagerFactory entityManagerFactory() throws IOException {
        log.info("EntityManagerFactory Bean을 생성합니다...");

        LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();

        String[] packagenames = getMappedPackageNames();
        if (packagenames != null && packagenames.length > 0) {
            log.debug("JPA용 entity를 scan합니다. packages=[{}]", arrayToCommaDelimitedString(packagenames));
            factoryBean.setPackagesToScan(packagenames);
        }

        factoryBean.setJpaProperties(jpaProperties());
        factoryBean.setDataSource(dataSource());

        HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
        adapter.setGenerateDdl(true);
        factoryBean.setJpaVendorAdapter(adapter);

        setupEntityManagerFactory(factoryBean);

        factoryBean.afterPropertiesSet();
        JpaRedisConfiguration.log.info("EntityManagerFactory Bean을 생성했습니다!!!");

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

     */
    @Bean
    public EntityManagerFactory entityManagerFactory() throws IOException {
        log.info("EntityManagerFactory Bean을 생성합니다...");

        LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();

        String[] packagenames = getMappedPackageNames();
        if (packagenames != null && packagenames.length > 0) {
            factoryBean.setPackagesToScan(packagenames);
        }

        factoryBean.setJpaProperties(jpaProperties());
        factoryBean.setDataSource(dataSource());

        HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
        adapter.setGenerateDdl(true);
        factoryBean.setJpaVendorAdapter(adapter);

        setupEntityManagerFactory(factoryBean);

        factoryBean.afterPropertiesSet();
        log.info("EntityManagerFactory Bean을 생성했습니다!!!");

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

    // beans

    @Bean
    public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
        final LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
        factoryBean.setDataSource(restDataSource());
        factoryBean.setPackagesToScan(new String[] { "org.rest" });

        final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter() {
            {
                // setDatabase( Database.H2 ); // TODO: is this necessary
                setDatabasePlatform(hibernateDialect);
                setShowSql(hibernateShowSql);
                setGenerateDdl(jpaGenerateDdl);
            }
        };
        factoryBean.setJpaVendorAdapter(vendorAdapter);

        factoryBean.setJpaProperties(additionlProperties());

        return factoryBean;
    }
View Full Code Here

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName)
        throws BeansException {
      if (bean instanceof LocalContainerEntityManagerFactoryBean) {
        LocalContainerEntityManagerFactoryBean factoryBean = (LocalContainerEntityManagerFactoryBean) bean;
        factoryBean.setPackagesToScan(this.packagesToScan);
        this.processed = true;
      }
      return bean;
    }
View Full Code Here

    EnvironmentTestUtils.addEnvironment(this.context,
        "spring.jpa.hibernate.namingStrategy:"
            + "org.hibernate.cfg.EJB3NamingStrategy");
    setupTestConfiguration();
    this.context.refresh();
    LocalContainerEntityManagerFactoryBean bean = this.context
        .getBean(LocalContainerEntityManagerFactoryBean.class);
    String actual = (String) bean.getJpaPropertyMap().get(
        "hibernate.ejb.naming_strategy");
    assertThat(actual, equalTo("org.hibernate.cfg.EJB3NamingStrategy"));
  }
View Full Code Here

        "spring.jpa.hibernate.namingstrategy:"
            + "org.hibernate.cfg.EJB3NamingStrategy");
    setupTestConfiguration();

    this.context.refresh();
    LocalContainerEntityManagerFactoryBean bean = this.context
        .getBean(LocalContainerEntityManagerFactoryBean.class);
    String actual = (String) bean.getJpaPropertyMap().get(
        "hibernate.ejb.naming_strategy");
    assertThat(actual, equalTo("org.hibernate.cfg.EJB3NamingStrategy"));
  }
View Full Code Here

    EnvironmentTestUtils.addEnvironment(this.context,
        "spring.jpa.properties.hibernate.ejb.naming_strategy:"
            + "org.hibernate.cfg.EJB3NamingStrategy");
    setupTestConfiguration();
    this.context.refresh();
    LocalContainerEntityManagerFactoryBean bean = this.context
        .getBean(LocalContainerEntityManagerFactoryBean.class);
    String actual = (String) bean.getJpaPropertyMap().get(
        "hibernate.ejb.naming_strategy");
    // You can't override this one from spring.jpa.properties because it has an
    // opinionated default
    assertThat(actual, not(equalTo("org.hibernate.cfg.EJB3NamingStrategy")));
  }
View Full Code Here

  public void customJpaProperties() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.context, "spring.jpa.properties.a:b",
        "spring.jpa.properties.a.b:c", "spring.jpa.properties.c:d");
    setupTestConfiguration();
    this.context.refresh();
    LocalContainerEntityManagerFactoryBean bean = this.context
        .getBean(LocalContainerEntityManagerFactoryBean.class);
    Map<String, Object> map = bean.getJpaPropertyMap();
    assertThat(map.get("a"), equalTo((Object) "b"));
    assertThat(map.get("c"), equalTo((Object) "d"));
    assertThat(map.get("a.b"), equalTo((Object) "c"));
  }
View Full Code Here

  public void usesManuallyDefinedEntityManagerFactoryBeanIfAvailable() {
    EnvironmentTestUtils.addEnvironment(this.context,
        "spring.datasource.initialize:false");
    setupTestConfiguration(TestConfigurationWithEntityManagerFactory.class);
    this.context.refresh();
    LocalContainerEntityManagerFactoryBean factoryBean = this.context
        .getBean(LocalContainerEntityManagerFactoryBean.class);
    Map<String, Object> map = factoryBean.getJpaPropertyMap();
    assertThat(map.get("configured"), equalTo((Object) "manually"));
  }
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.