Java 类org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder 实例源码

项目:chimera    文件:JPosDatabaseAutoConfiguration.java   
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
    EntityManagerFactoryBuilder factoryBuilder)
{
    Map<String, Object> vendorProperties = getVendorProperties();
    customizeVendorProperties(vendorProperties);
    LocalContainerEntityManagerFactoryBean emfb = factoryBuilder.dataSource(getDataSource())
        .packages(getPackagesToScan())
        .persistenceUnit("default")
        .properties(vendorProperties)
        .jta(isJta())
        .build();

    emfb.setPersistenceUnitPostProcessors(new JPosPersistentUnitPostProcessor());
    return emfb;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:JpaBaseConfiguration.java   
@Bean
@ConditionalOnMissingBean
public EntityManagerFactoryBuilder entityManagerFactoryBuilder(
        JpaVendorAdapter jpaVendorAdapter,
        ObjectProvider<PersistenceUnitManager> persistenceUnitManagerProvider) {
    EntityManagerFactoryBuilder builder = new EntityManagerFactoryBuilder(
            jpaVendorAdapter, this.properties.getProperties(),
            persistenceUnitManagerProvider.getIfAvailable());
    builder.setCallback(getVendorCallback());
    return builder;
}
项目:orchestrator    文件:JpaConfig.java   
/**
 * Create a {@Link LocalContainerEntityManagerFactoryBean} for the workflow datasource.
 */
@Bean
@WorkflowPersistenceUnit
public LocalContainerEntityManagerFactoryBean workflowEntityManagerFactory(
    EntityManagerFactoryBuilder builder,
    @WorkflowPersistenceUnit DataSource workflowDatasource) {

  LocalContainerEntityManagerFactoryBean factoryBean = builder
      .dataSource(workflowDatasource)
      .packages((String[]) null)
      .persistenceUnit(Constants.PERSISTENCE_UNIT_NAME)
      .jta(true)
      .build();

  // JBPM needs them
  factoryBean.getJpaPropertyMap().put("hibernate.max_fetch_depth", "3");
  factoryBean.getJpaPropertyMap().put("hibernate.id.new_generator_mappings", "false");

  return factoryBean;
}
项目:easynetcn-cloud    文件:OneJpaConfig.java   
@Primary
@Bean(name = "oneEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder) {
    DataSource dataSource = dataSource();

    return builder.dataSource(dataSource).packages("com.easynetcn.cloud.one.web.data.entity")
            .persistenceUnit("onePersistenceUnit").build();
}
项目:springboot_op    文件:UserDataSourceConfiguration.java   
@Bean(name = "entityManagerFactoryUser")
public LocalContainerEntityManagerFactoryBean entityManagerFactoryUser (EntityManagerFactoryBuilder builder) {
    return builder
            .dataSource(userDataSource)
            .properties(getVendorProperties(userDataSource))
            .packages(new String[]{ "com.myspringboot.repository.user", "com.myspringboot.entity" }) //设置应用userDataSource的基础包名
            .persistenceUnit("userPersistenceUnit")
            .build();
}
项目:springboot_op    文件:BookDataSourceConfiguration.java   
@Primary
@Bean(name = "entityManagerFactoryBook")
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBook (EntityManagerFactoryBuilder builder) {
    return builder
            .dataSource(bookDataSource)
            .properties(getVendorProperties(bookDataSource))
            .packages(new String[]{"com.myspringboot.repository.book", "com.myspringboot.entity"}) //设置应用bookDataSource的基础包名
            .persistenceUnit("bookPersistenceUnit")
            .build();
}
项目:nixmash-blog    文件:MySqlConfig.java   
@Bean(name = "entityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
        EntityManagerFactoryBuilder factory) {
    return factory.dataSource(dataSource())
            .packages("com.nixmash.blog.jpa")
            .properties(getVendorProperties(dataSource()))
            .build();
}
项目:nixmash-blog    文件:H2Config.java   
@Bean(name = "entityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
        EntityManagerFactoryBuilder factory) {
    return factory.dataSource(dataSource())
            .packages("com.nixmash.blog.jpa")
            .properties(getVendorProperties(dataSource()))
            .build();
}
项目:springboot-security-wechat    文件:AuditDsConfig.java   
/**
 * 实体管理对象
 * @param builder 由spring注入这个对象,首先根据type注入(多个就取声明@Primary的对象),否则根据name注入
 * @return
 */
@Bean
@Primary
public LocalContainerEntityManagerFactoryBean firstEntityManagerFactory(
        EntityManagerFactoryBuilder builder) {
    return builder
            .dataSource(firstDataSource())
            .packages("com.jwcq.entity")
            .persistenceUnit("firstDs")
            .build();
}
项目:springboot-security-wechat    文件:UserDsConfig.java   
/**
 * 实体管理对象
 * @param builder 由spring注入这个对象,首先根据type注入(多个就取声明@Primary的对象),否则根据name注入
 * @return
 */
@Bean(name = "secondEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean secondEntityManagerFactory(
        EntityManagerFactoryBuilder builder) {
    return builder
            .dataSource(secondDataSource())
            .packages("com.jwcq.user.entity")
            .persistenceUnit("secondDs")
            .build();
}
项目:SpringBoot-Study    文件:ReadDataSourceConfig1.java   
/**
 * EntityManagerFactory类似于Hibernate的SessionFactory,mybatis的SqlSessionFactory
 * 总之,在执行操作之前,我们总要获取一个EntityManager,这就类似于Hibernate的Session,
 * mybatis的sqlSession.
 * @return
 */
@Bean(name = "readEntityManagerFactoryBean")
public LocalContainerEntityManagerFactoryBean readEntityManagerFactoryBean(EntityManagerFactoryBuilder builder) {
    return builder
            .dataSource(readDruidDataSource)
            .properties(jpaProperties.getProperties())
            .packages("com.lc.springBoot.jpa.entity") //设置实体类所在位置
            .persistenceUnit("readPersistenceUnit")//持久化单元名称
            .build();
    //.getObject();
}
项目:SpringBoot-Study    文件:WriteDataSourceConfig1.java   
/**
 * 我们通过LocalContainerEntityManagerFactoryBean来获取EntityManagerFactory实例
 * @return
 */
@Bean(name = "writeEntityManagerFactoryBean")
@Primary
public LocalContainerEntityManagerFactoryBean writeEntityManagerFactoryBean(EntityManagerFactoryBuilder builder) {
    return builder
            .dataSource(writeDruidDataSource)
            .properties(jpaProperties.getProperties())
            .packages("com.lc.springBoot.jpa.entity") //设置实体类所在位置
            .persistenceUnit("writePersistenceUnit")
            .build();
    //.getObject();//不要在这里直接获取EntityManagerFactory
}
项目:springboot-start    文件:SecondaryConfig.java   
@Bean(name = "secondaryEntityManager")
public LocalContainerEntityManagerFactoryBean secondaryEntityManagerFactoryBean(EntityManagerFactoryBuilder builder) {
    return builder
            .dataSource(secondaryDataSource())
            .properties(hibernateProperties())
            .packages("com.xiaofeng.domain") //设置实体类所在位置
            .persistenceUnit("secondaryPersistenceUnit")
            .build();
}
项目:springboot-start    文件:PrimaryConfig.java   
@Primary
@Bean(name = "primaryEntityManager")
public LocalContainerEntityManagerFactoryBean primaryEntityManagerFactoryBean(EntityManagerFactoryBuilder builder) {
    return builder
            .dataSource(primaryDataSource())
            .properties((hibernateProperties()))
            .packages("com.xiaofeng.domain") //设置实体类所在位置
            .persistenceUnit("primaryPersistenceUnit")
            .build();
}
项目:sample-boot-micro    文件:OrmRepository.java   
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean(String name, final DataSource dataSource) {
    EntityManagerFactoryBuilder emfBuilder = new EntityManagerFactoryBuilder(
            vendorAdapter(), getProperties(), null);
    Builder builder = emfBuilder
            .dataSource(dataSource)
            .persistenceUnit(name)
            .properties(getHibernateProperties(dataSource))
            .jta(false);
    if (ArrayUtils.isNotEmpty(annotatedClasses)) {
        builder.packages(annotatedClasses);
    } else {
        builder.packages(packageToScan);
    }
    return builder.build();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:JpaBaseConfiguration.java   
@Bean
@Primary
@ConditionalOnMissingBean({ LocalContainerEntityManagerFactoryBean.class,
        EntityManagerFactory.class })
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
        EntityManagerFactoryBuilder factoryBuilder) {
    Map<String, Object> vendorProperties = getVendorProperties();
    customizeVendorProperties(vendorProperties);
    return factoryBuilder.dataSource(this.dataSource).packages(getPackagesToScan())
            .properties(vendorProperties).jta(isJta()).build();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:FlywayAutoConfigurationTests.java   
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put("configured", "manually");
    properties.put("hibernate.transaction.jta.platform", NoJtaPlatform.INSTANCE);
    return new EntityManagerFactoryBuilder(new HibernateJpaVendorAdapter(),
            properties, null).dataSource(this.dataSource).build();
}
项目:spring-boot-concourse    文件:JpaBaseConfiguration.java   
@Bean
@ConditionalOnMissingBean
public EntityManagerFactoryBuilder entityManagerFactoryBuilder(
        JpaVendorAdapter jpaVendorAdapter,
        ObjectProvider<PersistenceUnitManager> persistenceUnitManagerProvider) {
    EntityManagerFactoryBuilder builder = new EntityManagerFactoryBuilder(
            jpaVendorAdapter, this.properties.getProperties(),
            persistenceUnitManagerProvider.getIfAvailable());
    builder.setCallback(getVendorCallback());
    return builder;
}
项目:spring-boot-concourse    文件:JpaBaseConfiguration.java   
@Bean
@Primary
@ConditionalOnMissingBean({ LocalContainerEntityManagerFactoryBean.class,
        EntityManagerFactory.class })
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
        EntityManagerFactoryBuilder factoryBuilder) {
    Map<String, Object> vendorProperties = getVendorProperties();
    customizeVendorProperties(vendorProperties);
    return factoryBuilder.dataSource(this.dataSource).packages(getPackagesToScan())
            .properties(vendorProperties).jta(isJta()).build();
}
项目:spring-boot-concourse    文件:FlywayAutoConfigurationTests.java   
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put("configured", "manually");
    properties.put("hibernate.transaction.jta.platform", NoJtaPlatform.INSTANCE);
    return new EntityManagerFactoryBuilder(new HibernateJpaVendorAdapter(),
            properties, null).dataSource(this.dataSource).build();
}
项目:sample-boot-hibernate    文件:OrmRepository.java   
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean(String name, final DataSource dataSource) {
    EntityManagerFactoryBuilder emfBuilder = new EntityManagerFactoryBuilder(
            vendorAdapter(), getProperties(), null);
    Builder builder = emfBuilder
            .dataSource(dataSource)
            .persistenceUnit(name)
            .properties(getHibernateProperties(dataSource))
            .jta(false);
    if (ArrayUtils.isNotEmpty(annotatedClasses)) {
        builder.packages(annotatedClasses);
    } else {
        builder.packages(packageToScan);
    }
    return builder.build();
}
项目:SpringBootTwoDataSources    文件:SecondaryDataSourceConfig.java   
@Bean(name = SECONDARY_ENTITY_MANAGER_FACTORY)
public LocalContainerEntityManagerFactoryBean secondaryEntityManagerFactory(EntityManagerFactoryBuilder builder) {
    return builder
            .dataSource(secondaryDataSource())
            .packages("demo.model.secondary")
            .persistenceUnit(SECONDARY_PERSISTENCE_UNIT)
            .properties(secondaryJpaProperties().getHibernateProperties(secondaryDataSource()))
            .build();
}
项目:SpringBootTwoDataSources    文件:PrimaryDataSourceConfig.java   
@Bean(name = PRIMARY_ENTITY_MANAGER_FACTORY)
@Primary
public LocalContainerEntityManagerFactoryBean primaryEntityManagerFactory(EntityManagerFactoryBuilder builder) {
    return builder
            .dataSource(primaryDataSource())
            .packages("demo.model.primary")
            .persistenceUnit(PRIMARY_PERSISTENCE_UNIT)
            .properties(primaryJpaProperties().getHibernateProperties(primaryDataSource()))
            .build();
}
项目:contestparser    文件:JpaBaseConfiguration.java   
@Bean
@ConditionalOnMissingBean
public EntityManagerFactoryBuilder entityManagerFactoryBuilder(
        JpaVendorAdapter jpaVendorAdapter) {
    EntityManagerFactoryBuilder builder = new EntityManagerFactoryBuilder(
            jpaVendorAdapter, this.jpaProperties.getProperties(),
            this.persistenceUnitManager);
    builder.setCallback(getVendorCallback());
    return builder;
}
项目:contestparser    文件:JpaBaseConfiguration.java   
@Bean
@Primary
@ConditionalOnMissingBean({ LocalContainerEntityManagerFactoryBean.class,
        EntityManagerFactory.class })
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
        EntityManagerFactoryBuilder factoryBuilder) {
    Map<String, Object> vendorProperties = getVendorProperties();
    customizeVendorProperties(vendorProperties);
    return factoryBuilder.dataSource(this.dataSource).packages(getPackagesToScan())
            .properties(vendorProperties).jta(isJta()).build();
}
项目:contestparser    文件:FlywayAutoConfigurationTests.java   
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put("configured", "manually");
    properties.put("hibernate.transaction.jta.platform", NoJtaPlatform.INSTANCE);
    return new EntityManagerFactoryBuilder(new HibernateJpaVendorAdapter(),
            properties, null).dataSource(this.dataSource).build();
}
项目:pungwecms    文件:JPAConfiguration.java   
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
        EntityManagerFactoryBuilder factoryBuilder, DataSource dataSource) {
    Map<String, String> hibernateProperties = mapPropertyNames("hibernate", hibernateConfiguration());
    return factoryBuilder.dataSource(dataSource).packages(
            "com.pungwe.cms.jpa.entity",
            "com.pungwe.cms.jpa.module",
            "com.pungwe.cms.jpa.theme",
            "com.pungwe.cms.jpa.block",
            "com.pungwe.cms.jpa.menu",
            "com.pungwe.cms.jpa.security"
    ).properties(hibernateProperties).build();
}
项目:orchestrator    文件:JpaConfig.java   
/**
 * Create a {@Link LocalContainerEntityManagerFactoryBean} for the orchestrator datasource.
 */
@Bean
@Primary
@OrchestratorPersistenceUnit
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
    EntityManagerFactoryBuilder builder,
    @OrchestratorPersistenceUnit DataSource datasource) {

  return builder
      .dataSource(datasource)
      .persistenceUnit("orchestrator")
      .packages("it.reply.orchestrator.dal.entity")
      .jta(true)
      .build();
}
项目:easynetcn-cloud    文件:OneJpaConfig.java   
@Primary
@Bean
public EntityManager entityManager(EntityManagerFactoryBuilder builder) {
    return entityManagerFactory(builder).getObject().createEntityManager();
}
项目:easynetcn-cloud    文件:OneJpaConfig.java   
@Primary
@Bean(name = "oneTransactionManager")
public PlatformTransactionManager transactionManagerPrimary(EntityManagerFactoryBuilder builder) {
    return new JpaTransactionManager(entityManagerFactory(builder).getObject());
}
项目:springboot_op    文件:UserDataSourceConfiguration.java   
@Bean(name = "entityManagerUser")
public EntityManager entityManager(EntityManagerFactoryBuilder builder) {
    return entityManagerFactoryUser(builder).getObject().createEntityManager();
}
项目:springboot_op    文件:UserDataSourceConfiguration.java   
@Bean(name = "transactionManagerUser")
public PlatformTransactionManager transactionManagerUser(EntityManagerFactoryBuilder builder) {
    return new JpaTransactionManager(entityManagerFactoryUser(builder).getObject());
}
项目:springboot_op    文件:BookDataSourceConfiguration.java   
@Primary
@Bean(name = "entityManagerBook")
public EntityManager entityManager(EntityManagerFactoryBuilder builder) {
    return entityManagerFactoryBook(builder).getObject().createEntityManager();
}
项目:springboot_op    文件:BookDataSourceConfiguration.java   
@Primary
@Bean(name = "transactionManagerBook")
public PlatformTransactionManager transactionManagerBook(EntityManagerFactoryBuilder builder) {
    return new JpaTransactionManager(entityManagerFactoryBook(builder).getObject());
}
项目:SpringBoot-Study    文件:ReadDataSourceConfig1.java   
/**
 * 配置事物管理器
 * @return
 */
@Bean(name = "readTransactionManager")
public PlatformTransactionManager readTransactionManager(EntityManagerFactoryBuilder builder) {
    return new JpaTransactionManager(readEntityManagerFactory(builder));
}
项目:SpringBoot-Study    文件:WriteDataSourceConfig1.java   
/**
 * 配置事物管理器
 * @return
 */
@Bean(name = "writeTransactionManager")
@Primary
public PlatformTransactionManager writeTransactionManager(EntityManagerFactoryBuilder builder) {
    return new JpaTransactionManager(writeEntityManagerFactory(builder));
}
项目:spring-cloud-samples    文件:JpaCommonConfig.java   
@Bean(name = "commonEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder) {
    return builder.dataSource(dataSource).properties(jpaProperties.getHibernateProperties(dataSource)).packages("com.zhaoql.customer.domain.entity").build();
}
项目:spring-cloud-samples    文件:JpaCommonConfig.java   
@Bean(name = "commonEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder) {
    return builder.dataSource(dataSource).properties(jpaProperties.getHibernateProperties(dataSource)).packages("com.zhaoql.product.domain.entity").build();
}
项目:spring-cloud-samples    文件:JpaCommonConfig.java   
@Bean(name = "commonEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder) {
    return builder.dataSource(dataSource).properties(jpaProperties.getHibernateProperties(dataSource)).packages("com.zhaoql.order.domain.entity").build();
}
项目:data-migration    文件:EntityManageConfiguration.java   
@Bean(name = "entityManagerFactoryPrimary")
public LocalContainerEntityManagerFactoryBean entityManagerFactoryCreate(EntityManagerFactoryBuilder builder) {
    return builder.dataSource(primaryDataSource).properties(getVendorProperties(primaryDataSource))
            .packages("org.gra4j.dataMigration.crud.entity") // 设置实体类所在位置
            .persistenceUnit("primaryPersistenceUnit").build();
}