コード例 #1
0
    public LocalContainerEntityManagerFactoryBean build() {
      LocalContainerEntityManagerFactoryBean entityManagerFactoryBean =
          new LocalContainerEntityManagerFactoryBean();
      if (EntityManagerFactoryBuilder.this.persistenceUnitManager != null) {
        entityManagerFactoryBean.setPersistenceUnitManager(
            EntityManagerFactoryBuilder.this.persistenceUnitManager);
      }
      if (this.persistenceUnit != null) {
        entityManagerFactoryBean.setPersistenceUnitName(this.persistenceUnit);
      }
      entityManagerFactoryBean.setJpaVendorAdapter(
          EntityManagerFactoryBuilder.this.jpaVendorAdapter);

      if (this.jta) {
        entityManagerFactoryBean.setJtaDataSource(this.dataSource);
      } else {
        entityManagerFactoryBean.setDataSource(this.dataSource);
      }

      entityManagerFactoryBean.setPackagesToScan(this.packagesToScan);
      entityManagerFactoryBean
          .getJpaPropertyMap()
          .putAll(EntityManagerFactoryBuilder.this.jpaProperties);
      entityManagerFactoryBean.getJpaPropertyMap().putAll(this.properties);
      if (EntityManagerFactoryBuilder.this.callback != null) {
        EntityManagerFactoryBuilder.this.callback.execute(entityManagerFactoryBean);
      }
      return entityManagerFactoryBean;
    }
コード例 #2
0
  protected LocalContainerEntityManagerFactoryBean entityManagerFactory(
      Map<String, Object> jpaProperties) {
    String[] packagesToScan = new String[] {ENTITY_BASE};
    AbstractJpaVendorAdapter jpaVendor = new HibernateJpaVendorAdapter();

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    if (persistenceUnitManager != null) {
      factory.setPersistenceUnitManager(persistenceUnitManager);
    }
    factory.setJpaPropertyMap(jpaProperties);
    factory.setJpaVendorAdapter(jpaVendor);
    factory.setPackagesToScan(packagesToScan);
    factory.setDataSource(dataSource());
    return factory;
  }