Package org.springframework.orm.jpa

Examples of org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean


      }
    }
  }

  private EntityManagerFactory getEntityManagerFactory(DataSource dataSource) throws Exception {
    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setDataSource(dataSource);
    factory.setPersistenceXmlLocation("classpath:org/springframework/webflow/persistence/persistence.xml");
    OpenJpaVendorAdapter openJpa = new OpenJpaVendorAdapter();
    factory.setJpaVendorAdapter(openJpa);
    factory.afterPropertiesSet();
    return factory.getObject();
  }
View Full Code Here


   */
  public LocalContainerEntityManagerFactoryBean entityManagerFactoryFactory()
      throws Exception {

        logger.debug("Creating entity manager factory factory ");
        LocalContainerEntityManagerFactoryBean entityManagerFactoryFactory = new LocalContainerEntityManagerFactoryBean();
    entityManagerFactoryFactory
        .setPersistenceUnitName(persistenceUnitName());
    logger.debug(String.format("Creating entity manager factory factory with PERSISTENT UNIT NAME %s", persistenceUnitName()));
       
        entityManagerFactoryFactory.setJpaVendorAdapter(jpaVendorAdapter());

        if (jpaProperties != null) {
            logger.debug("Setting JPA properties into entity manager factory factory");
            entityManagerFactoryFactory.setJpaProperties(jpaProperties);
    } else {
      entityManagerFactoryFactory.setJpaProperties(new Properties());
    }
    if (dataSource != null) {
      entityManagerFactoryFactory.setDataSource(dataSource);
    }

    entityManagerFactoryFactory.afterPropertiesSet();
    return entityManagerFactoryFactory;
  }
View Full Code Here

          if (exec || mode == Mode.UPDATE)
          {
              ClassPathXmlApplicationContext newContext = new SmartClassPathXmlApplicationContext(emfContextLocation);
              try {
                // get a reference to the factory bean, don't have it create a new EntityManager
                  LocalContainerEntityManagerFactoryBean factoryBean = newContext.getBean("&" + emfContextBeanName, LocalContainerEntityManagerFactoryBean.class);
                  SettingsFactory settingsFactory = new InjectedDataSourceSettingsFactory(factoryBean.getDataSource());
                  settings = settingsFactory.buildSettings(new Properties());
              }
              finally {
                newContext.close();
              }
View Full Code Here

  }

  /* private helper methods */

  private EntityManagerFactory getEntityManagerFactory(DataSource dataSource) throws Exception {
    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setDataSource(dataSource);
    factory.setPersistenceXmlLocation("classpath:org/springframework/webflow/persistence/persistence.xml");
    factory.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    factory.afterPropertiesSet();
    return factory.getObject();
  }
View Full Code Here

    initializer.setDatabasePopulator(databasePopulator);
    initializer.afterPropertiesSet();
  }

  private EntityManagerFactory getEntityManagerFactory(DataSource dataSource) throws Exception {
    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setDataSource(dataSource);
    factory.setPersistenceXmlLocation("classpath:org/springframework/webflow/persistence/persistence.xml");
    factory.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    factory.afterPropertiesSet();
    return factory.getObject();
  }
View Full Code Here

          getJdbcTemplate().queryForInt("select count(*) from T_BEAN"));
    }
  }

  private EntityManagerFactory getEntityManagerFactory(DataSource dataSource) throws Exception {
    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setDataSource(dataSource);
    factory.setPersistenceXmlLocation("classpath:org/springframework/webflow/persistence/persistence.xml");
    factory.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    factory.afterPropertiesSet();
    return factory.getObject();
  }
View Full Code Here

  @Bean
  public EntityManagerFactory entityManagerFactory() {
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setGenerateDdl(true);

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("app");
    factory.setDataSource(dataSource());
    factory.afterPropertiesSet();

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

    @Bean
    public EntityManagerFactory entityManagerFactory() {
  HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
  vendorAdapter.setGenerateDdl(true);

  LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
  factory.setJpaVendorAdapter(vendorAdapter);
  factory.setPackagesToScan("server.model");
  factory.setDataSource(dataSource());
  factory.afterPropertiesSet();

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

  }

  @Bean
  public LocalContainerEntityManagerFactoryBean entityManagerFactory()
  {
    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();

    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setGenerateDdl(Boolean.TRUE);
    vendorAdapter.setShowSql(Boolean.TRUE);

    factory.setDataSource(dataSource());
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("com.sivalabs.ssdemo.entities");

    Properties jpaProperties = new Properties();
    jpaProperties.put("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto"));
    factory.setJpaProperties(jpaProperties);

    factory.afterPropertiesSet();
    factory.setLoadTimeWeaver(new InstrumentationLoadTimeWeaver());
    return factory;
  }
View Full Code Here

  }

  @Bean
  public LocalContainerEntityManagerFactoryBean entityManagerFactory()
  {
    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();

    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setGenerateDdl(Boolean.TRUE);
    vendorAdapter.setShowSql(Boolean.TRUE);

    factory.setDataSource(dataSource());
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("com.sivalabs.phonebook.entities");

    Properties jpaProperties = new Properties();
    jpaProperties.put("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto"));
    factory.setJpaProperties(jpaProperties);

    factory.afterPropertiesSet();
    factory.setLoadTimeWeaver(new InstrumentationLoadTimeWeaver());
    return factory;
  }
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.