コード例 #1
0
 @Bean()
 public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
   LocalContainerEntityManagerFactoryBean retVal = new LocalContainerEntityManagerFactoryBean();
   retVal.setPersistenceUnitName("HAPI_PU");
   retVal.setDataSource(dataSource());
   retVal.setPackagesToScan("ca.uhn.fhir.jpa.entity");
   retVal.setPersistenceProvider(new HibernatePersistenceProvider());
   retVal.setJpaProperties(jpaProperties());
   retVal.afterPropertiesSet();
   return retVal;
 }
コード例 #2
0
ファイル: DbConfig.java プロジェクト: cakiremre/webseed
  @Bean(name = "entityManagerFactory")
  public LocalContainerEntityManagerFactoryBean emf() throws IOException {

    Properties jpaProps = new Properties();
    jpaProps.load(AppConfig.class.getClassLoader().getResourceAsStream("jpa.properties"));

    LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
    emf.setDataSource(dataSource());
    emf.setJpaVendorAdapter(jpaVendorAdapter());
    emf.setPackagesToScan("com.beam.sample.model.jpa");
    emf.setJpaProperties(jpaProps);
    emf.setPersistenceProvider(persistenceProvider());

    return emf;
  }
コード例 #3
0
  @Bean
  @ConfigurationProperties(prefix = "spring.jpa")
  public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) {

    LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
    emf.setPackagesToScan("app.models");
    emf.setPersistenceProvider(new HibernatePersistenceProvider());
    Properties jpaProperties = new Properties();

    // todo:����ǰȡ������
    // jpaProperties.setProperty("hibernate.hbm2ddl.auto", "create");
    jpaProperties.setProperty("hibernate.hbm2ddl.auto", "update");
    jpaProperties.setProperty("hibernate.show_sql", "false");
    jpaProperties.setProperty("hibernate.format_sql", "false");
    jpaProperties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5InnoDBDialect");

    emf.setJpaProperties(jpaProperties);
    emf.setDataSource(dataSource);
    return emf;
  }