Java 类org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter 实例源码

项目:b4    文件:B4CoreRootConfig.java   
@Bean
public EntityManagerFactory entityManagerFactory() {
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setDatabase(Database.H2);
    vendorAdapter.setGenerateDdl(jpaGenerateDdl);
    vendorAdapter.setShowSql(jpaShowSql);

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("org.bricket.b4.*.entity");
    factory.setDataSource(dataSource());
    factory.setJpaDialect(jpaDialect());

    Map<String, String> jpaProperties = new HashMap<String, String>();
    jpaProperties.put("hibernate.dialect", H2Dialect.class.getName());
    jpaProperties.put("hibernate.cache.region.factory_class", EhCacheRegionFactory.class.getName());
    jpaProperties.put("hibernate.cache.use_second_level_cache", "true");
    jpaProperties.put("hibernate.cache.use_query_cache", "true");
    jpaProperties.put("hibernate.cache.use_minimal_puts", "true");
    factory.setJpaPropertyMap(jpaProperties);

    factory.afterPropertiesSet();

    return factory.getObject();
}
项目:spring-seed    文件:JpaBuilderUtil.java   
public static EntityManagerFactory newEntityManagerFactory(DataSource dataSource, Class<?> ... entityPackages){
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setGenerateDdl(true);

    BasicDataSource basicDataSource = (BasicDataSource)dataSource;
    Database jpaDatabase = DatabaseType.findTypeByJdbcUrl(basicDataSource.getUrl()).getJpaDatabase();
    vendorAdapter.setDatabase(jpaDatabase);

    HashMap<String, Object> properties = new HashMap<String, Object>();
    //properties.put("hibernate.dialect", "org.hibernate.dialect.MySQL5InnoDBDialect");

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    //import @Entity classes
    factory.setPackagesToScan(Arrays.stream(entityPackages).map(thing -> thing.getPackage().getName()).toArray(String[]::new));
    //factory.setPersistenceUnitName("jproject");
    factory.setDataSource(dataSource);
    factory.setJpaPropertyMap(properties);
    factory.afterPropertiesSet();

    return factory.getObject();
}
项目:spring-security-angularjs    文件:JPAConfig.java   
@Bean(name = "entityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
    LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
    factoryBean.setDataSource(dataSource());
    factoryBean.setPackagesToScan("com.chinedu.truststack.persist");

    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setShowSql(true);
    vendorAdapter.setDatabasePlatform(hibernateDialect);
    factoryBean.setJpaVendorAdapter(vendorAdapter);

    Properties jpaProperties = new Properties();
    jpaProperties.put("hibernate.show_sql",hibernateShowSql);
    jpaProperties.put("hibernate.hbm2ddl.auto",hibernateUpate);
    factoryBean.setJpaProperties(jpaProperties);
    return factoryBean;
}
项目:amv-access-api-poc    文件:JpaConfig.java   
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    // JPA settings
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    // vendorAdapter.setGenerateDdl(true);
    // vendorAdapter.setShowSql(true);
    vendorAdapter.setDatabase(Database.MYSQL);

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("org.amv.access.model");
    factory.setDataSource(dataSource);
    factory.setJpaProperties(jpaProperties());
    factory.afterPropertiesSet();
    return factory;
}
项目:gamesboard    文件:PersistenceContext.java   
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();

    entityManagerFactoryBean.setDataSource(dataSource());
    entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    entityManagerFactoryBean.setPackagesToScan(PROPERTY_PACKAGES_TO_SCAN);

    Properties jpaProperties = new Properties();
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_DIALECT, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_DIALECT));
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_FORMAT_SQL, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_FORMAT_SQL));
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_HBM2DDL_AUTO, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_HBM2DDL_AUTO));
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY));
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_SHOW_SQL, true);//env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_SHOW_SQL));

    entityManagerFactoryBean.setJpaProperties(jpaProperties);

    return entityManagerFactoryBean;
}
项目:holon-datastore-jpa    文件:TestBase.java   
@Bean
public FactoryBean<EntityManagerFactory> entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
    emf.setDataSource(dataSource());
    emf.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    emf.setPackagesToScan(TestJpaDomain.class.getPackage().getName());
    emf.setPersistenceUnitName("test");
    return emf;
}
项目:d2g-api    文件:RepositoryConfiguration.java   
/**
 * Big Note: For spring based applications, the difference between different types of the entity manager factory bean is not so much. Spring will
 * always play the role, as container if you configure {@link LocalContainerEntityManagerFactoryBean}  and as application if you configure
 * {@link org.springframework.orm.jpa.LocalEntityManagerFactoryBean}
 *
 * @param dataSource  Factory for connections to the physical data source
 * @param environment Interface representing the environment in which the current application is running.
 * @return suitable entity manager factor bean bean for
 */
@Bean
LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource, Environment environment) {
    Properties jpaProperties = new Properties();
    jpaProperties.put("hibernate.dialect", environment.getRequiredProperty("hibernate.dialect"));
    jpaProperties.put("hibernate.hbm2ddl.auto", environment.getRequiredProperty("hibernate.hbm2ddl.auto"));
    jpaProperties.put("hibernate.ejb.naming_strategy", environment.getRequiredProperty("hibernate.ejb.naming_strategy"));
    jpaProperties.put("hibernate.show_sql", environment.getRequiredProperty("hibernate.show_sql"));
    jpaProperties.put("hibernate.format_sql", environment.getRequiredProperty("hibernate.format_sql"));
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
    entityManagerFactoryBean.setDataSource(dataSource);
    entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    entityManagerFactoryBean.setPackagesToScan("com.logicify.d2g.models");
    entityManagerFactoryBean.setJpaProperties(jpaProperties);
    return entityManagerFactoryBean;
}
项目:yadaframework    文件:YadaJpaConfig.java   
@Bean
public EntityManagerFactory entityManagerFactory() throws SQLException {
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    // vendorAdapter.setGenerateDdl(true); // Crea la tabella e le colonne quando non esistono
    vendorAdapter.setShowSql(config.getShowSql());
    vendorAdapter.setDatabasePlatform("org.hibernate.dialect.MySQL5InnoDBDialect");
    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    List<String> packages = config.getDbEntityPackages();
    packages.add("net.yadaframework.persistence.entity");
    packages.add("net.yadaframework.security.persistence.entity");
    packages.add("net.yadaframework.cms.persistence.entity");
    packages.add("net.yadaframework.commerce.persistence.entity");
    log.info("Scanning packages for entities: {}", StringUtils.join(packages, ","));
    factory.setPackagesToScan(packages.toArray(new String[]{}));
    factory.setDataSource(dataSource());
    factory.afterPropertiesSet();
    return factory.getObject();
}
项目:TicketServer    文件:SpringBusinessConfig.java   
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource());
    em.setPackagesToScan("com.tickets.business.entities");

    final Properties hibernateProperties = new Properties();
    hibernateProperties.setProperty("hibernate.hbm2ddl.auto", "update");
    hibernateProperties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
    em.setJpaProperties(hibernateProperties);

    final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    em.setJpaVendorAdapter(vendorAdapter);

    return em;
}
项目:jdblender    文件:Config.java   
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {

    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setGenerateDdl(false);
    vendorAdapter.setDatabase(Database.H2);
    vendorAdapter.setShowSql(false);

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("jdblender.sdata.model");
    factory.setDataSource(dataSourceH2());
    Map<String, Object> props = factory.getJpaPropertyMap();
    props.put("hibernate.cache.use_query_cache", "false");
    props.put("hibernate.cache.use_second_level_cache", "false");
    props.put("hibernate.hbm2ddl.auto", "validate");
    //props.put("hibernate.jdbc.batch_size", "100");
    //props.put("hibernate.cache.use_second_level_cache", "false");
    //props.put("hibernate.order_inserts", "1");
    //props.put("hibernate.order_updates", "1");

    factory.setJpaPropertyMap(props);

    return factory;
}
项目:angular-spring-boot-micro-services-docker    文件:JPAConfig.java   
@Bean(name = "coreEntityManager")
public LocalContainerEntityManagerFactoryBean entityManagerFactory()
{
    if (driver == null){
        throw new IllegalStateException("cannot find db.type property with valid value ( mysql,ms-sql)");
    }
    driver.create();
    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(driver.create());
    em.setPackagesToScan(new String[]{"com"});
    JpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setShowSql(false);
    vendorAdapter.setGenerateDdl(false);

    em.setJpaVendorAdapter(vendorAdapter);
    em.setJpaProperties(additionalProperties());
    return em;
}
项目:bookManager    文件:RootApplicationContextConfig.java   
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
    Map<String, Object> properties = new Hashtable<>();
    properties.put("javax.persistence.schema-generation.database.action", "none");
    properties.put("hibernate.connection.characterEncoding", "utf8");
    properties.put("hibernate.connection.useUnicode", "true");
    properties.put("hibernate.connection.charSet", "utf8");
    properties.put("hibernate.search.default.directory_provider", "filesystem");
    properties.put("hibernate.search.default.indexBase", context.getInitParameter("indexDir"));

    HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
    adapter.setDatabasePlatform("org.hibernate.dialect.MySQL5InnoDBDialect");

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(adapter);
    factory.setDataSource(this.bookManagerDataSource());
    factory.setPackagesToScan("net.viperfish.bookManager");
    factory.setSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
    factory.setValidationMode(ValidationMode.NONE);
    factory.setJpaPropertyMap(properties);
    return factory;
}
项目:bag-database    文件:JpaConfig.java   
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    myLogger.info("entityManagerFactory");
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
    entityManagerFactoryBean.setDataSource(dataSource());
    entityManagerFactoryBean.setPackagesToScan("com.github.swrirobotics");
    entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());

    Properties jpaProperties = new Properties();
    // Disable HBM2DDL; we use Liquibase to create our database
    jpaProperties.put(Environment.HBM2DDL_AUTO, "");
    // Set a large batch size for better performance over slow network links
    jpaProperties.put(Environment.STATEMENT_BATCH_SIZE, "100");
    jpaProperties.put(Environment.ORDER_INSERTS, "true");
    jpaProperties.put(Environment.ORDER_UPDATES, "true");
    jpaProperties.put(Environment.USE_NEW_ID_GENERATOR_MAPPINGS, "true");
    entityManagerFactoryBean.setJpaProperties(jpaProperties);

    return entityManagerFactoryBean;
}
项目:spring-content    文件:JpaInfrastructureConfig.java   
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {

    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setDatabase(Database.HSQL);
    vendorAdapter.setGenerateDdl(true);

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan(packagesToScan());
    factory.setPersistenceUnitName("spring-data-rest-webmvc");
    factory.setDataSource(dataSource());
    factory.afterPropertiesSet();

    return factory;
}
项目:ibankapp-base    文件:TestContextConfig.java   
@Bean
LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) {
  LocalContainerEntityManagerFactoryBean entityManagerFactoryBean =
      new LocalContainerEntityManagerFactoryBean();

  entityManagerFactoryBean.setDataSource(dataSource);
  entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
  entityManagerFactoryBean.setPackagesToScan("org.ibankapp");

  Properties properties = new Properties();
  properties.put("hibernate.dialect", "org.hibernate.dialect.DerbyDialect");
  properties.put("hibernate.ejb.naming_strategy", "org.hibernate.cfg.ImprovedNamingStrategy");
  properties.put("hibernate.hbm2ddl.auto", "update");
  properties.put("hibernate.show_sql", true);

  entityManagerFactoryBean.setJpaProperties(properties);
  return entityManagerFactoryBean;

}
项目:ariADDna    文件:JPAConfiguration.java   
@Bean
public EntityManagerFactory entityManagerFactory() throws SQLException {

    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setGenerateDdl(true);

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("com.stnetix.ariaddna.persistence.entities");
    factory.setDataSource(dataSource());
    Properties properties = new Properties();
    properties.put("hibernate.default_schema", "public");
    properties.put("hibernate.hbm2ddl.auto", "create-drop");
    properties.put("hibernate.show_sql", "true");
    properties.put("hibernate.format_sql", "true");
    properties.put("hibernate.use_sql_comments", "true");
    properties.put("hibernate.temp.use_jdbc_metadata_defaults", "false");
    properties.put("hibernate.dialect", dialect);

    factory.setJpaProperties(properties);
    factory.afterPropertiesSet();

    return factory.getObject();
}
项目:CCDA-Score-CARD    文件:PersistanceConfigurationPostGres.java   
@Bean(name = "postgresEntityManagerFactory")
public EntityManagerFactory entityManagerFactory() {
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setGenerateDdl(false);
    vendorAdapter.setShowSql(true);
    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("org.sitenv.service.ccda.smartscorecard.entities.postgres");
    Properties jpaProperties = new Properties();
    jpaProperties.put("hibernate.hbm2ddl.auto", "none");
    jpaProperties.put("hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect");
    factory.setJpaProperties(jpaProperties);
    factory.setDataSource(dataSource());
    factory.afterPropertiesSet();

    return factory.getObject();
}
项目:CCDA-Score-CARD    文件:PersistanceConfiguration.java   
@Bean(name="inmemoryEntityManagerFactory")
@Primary
public EntityManagerFactory entityManagerFactory() {
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setGenerateDdl(false);
    vendorAdapter.setShowSql(true);
    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("org.sitenv.service.ccda.smartscorecard.entities.inmemory");
    Properties jpaProperties = new Properties();
    jpaProperties.put("hibernate.hbm2ddl.auto", "none");
    jpaProperties.put("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
    jpaProperties.put("hibernate.format_sql", "true");
    jpaProperties.put("hibernate.show_sql", "false");
    factory.setDataSource(dataSource());
    factory.setJpaProperties(jpaProperties);
    factory.afterPropertiesSet();
    return factory.getObject();
}
项目:erudio-api-oauth2    文件:DatabaseConfig.java   
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();

    entityManagerFactoryBean.setDataSource(dataSource);

    entityManagerFactoryBean.setPackagesToScan(entitymanagerPackagesToScan);
    entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    entityManagerFactoryBean.setMappingResources(
            "namedQueries/Address.xml",
            "namedQueries/City.xml",
            "namedQueries/Country.xml",
            "namedQueries/Greeting.xml",
            "namedQueries/Person.xml",
            "namedQueries/PublicAreaType.xml"
            );

    Properties jpaProperties = new Properties();
    jpaProperties.put(org.hibernate.cfg.Environment.DIALECT, dialect);
    jpaProperties.put(org.hibernate.cfg.Environment.SHOW_SQL, show_sql);
    jpaProperties.put(org.hibernate.cfg.Environment.HBM2DDL_AUTO, hbm2ddlAuto);
    jpaProperties.put(org.hibernate.cfg.Environment.FORMAT_SQL, format_sql);
    entityManagerFactoryBean.setJpaProperties(jpaProperties);

    return entityManagerFactoryBean;
}
项目:Photocan    文件:ProdProfile.java   
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws URISyntaxException {
    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaDialect(new HibernateJpaDialect());

    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setGenerateDdl(true);

    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPersistenceUnitName("production");
    factory.setPackagesToScan("app.domain");
    factory.setDataSource(dataSource());

    factory.afterPropertiesSet();
    return factory;
}
项目:owsi-core-parent    文件:JpaConfigUtils.java   
/**
 * Construit un {@link LocalContainerEntityManagerFactoryBean} à partir d'un ensemble d'options usuelles.
 */
public static LocalContainerEntityManagerFactoryBean entityManagerFactory(IJpaConfigurationProvider provider) {
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();

    entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    entityManagerFactoryBean.setJpaProperties(getJpaProperties(provider));
    entityManagerFactoryBean.setDataSource(provider.getDataSource());
    entityManagerFactoryBean.setPackagesToScan(getPackagesToScan(provider.getJpaPackageScanProviders()));

    PersistenceProvider persistenceProvider = provider.getPersistenceProvider();
    if (persistenceProvider != null) {
        entityManagerFactoryBean.setPersistenceProvider(persistenceProvider);
    }

    return entityManagerFactoryBean;
}
项目:herd    文件:DaoSpringModuleConfig.java   
/**
 * Gets the Hibernate JPA vendor adapter needed by the entity manager.
 *
 * @return the Hibernate JPA vendor adapter.
 */
private JpaVendorAdapter getHibernateJpaVendorAdapter()
{
    HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter();
    // Set the database type.
    String databaseType = configurationHelper.getProperty(ConfigurationValue.DATABASE_TYPE);
    if (StringUtils.isBlank(databaseType))
    {
        throw new IllegalStateException(
            String.format("No database type found. Ensure the \"%s\" configuration entry is configured.", ConfigurationValue.DATABASE_TYPE.getKey()));
    }
    Database database = Database.valueOf(databaseType);
    LOGGER.info("jpaTargetDatabase={}", database);
    hibernateJpaVendorAdapter.setDatabase(database);
    hibernateJpaVendorAdapter.setGenerateDdl(false);
    return hibernateJpaVendorAdapter;
}
项目:micro-server    文件:SpringDataConfig.java   
@Bean
public EntityManagerFactory entityManagerFactory() {

    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    if (env.getGenerateDdl().equals("true")) {
        vendorAdapter.setGenerateDdl(true);
    } else {
        vendorAdapter.setGenerateDdl(false);
    }

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);

    factory.setPackagesToScan(new ConfigAccessor().get().getDataSources()
               .getOrElse(new ConfigAccessor().get().getDefaultDataSourceName(), Arrays.asList())
            .toArray(new String[0]));
    factory.setDataSource(dataSource);
    factory.afterPropertiesSet();

    return factory.getObject();
}
项目:multitenancy    文件:MultitenancyConfig.java   
@Bean
    public LocalContainerEntityManagerFactoryBean metaEntityManager(EntityManagerFactoryBuilder builder,
                                                                    @Qualifier("metaDataSource") DataSource dataSource) {
        Map<String, Object> props = new HashMap<>();
        props.putAll(jpaProps.getSubProperties("properties."));
//        props.put("hibernate.hbm2ddl.auto", "create");

        LocalContainerEntityManagerFactoryBean factory = builder.dataSource(dataSource)
            .jta(true)
            .persistenceUnit("metaPU")
            .packages("de.weichert.multitenancy")
            .properties(props)
            .build();
        factory.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
        factory.setJpaDialect(new HibernateJpaDialect());
        return factory;
    }
项目:SpringRESTDemo    文件:ApplicationConfig.java   
@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.mastersheel007.springrestdemo");

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

    return factory;
}
项目:app-engine    文件:TaskDbConfig.java   
@Bean
LocalContainerEntityManagerFactoryBean taskEntityManagerFactory() {

    HibernateJpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();
    jpaVendorAdapter.setGenerateDdl(true);

    LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();

    factoryBean.setDataSource(dataSource);
    factoryBean.setJpaVendorAdapter(jpaVendorAdapter);
    //此处应包含当前模块的domain类
    String packageName = TaskDbConfig.class.getPackage().getName();
    factoryBean.setPackagesToScan(StringUtils.substring(packageName, 0, StringUtils.lastIndexOf(packageName, '.')));

    return factoryBean;
}
项目:bookshop-api    文件:PersistenceConfig.java   
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource());
    em.setPackagesToScan(new String[] { "io.lucci.bookshop.persistence.model", "io.lucci.bookshop.persistence.converter" });

    final Properties hibernateProperties = new Properties();
    hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto"));
    hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect"));

    final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    // vendorAdapter.set
    em.setJpaVendorAdapter(vendorAdapter);
    em.setJpaProperties(hibernateProperties);

    return em;
}
项目:members_cuacfm    文件:JpaConfig.java   
/**
 * Configure entity manager factory.
 *
 * @return the local container entity manager factory bean
 */
@Bean
public LocalContainerEntityManagerFactoryBean configureEntityManagerFactory() {
   LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
   entityManagerFactoryBean.setDataSource(configureDataSource());
   entityManagerFactoryBean.setPackagesToScan("org.cuacfm.members");
   entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());

   Properties jpaProperties = new Properties();
   jpaProperties.put(org.hibernate.cfg.Environment.DIALECT, dialect);

   // This property resolve org.hibernate.lazyinitializationexception 
   // Another solution is change @PersistenceContext to @PersistenceContext(type = PersistenceContextType.EXTENDED) in class repository  
   jpaProperties.put("hibernate.enable_lazy_load_no_trans", true);

   // Comentado por que no se utiliza
   // jpaProperties.put(org.hibernate.cfg.Environment.HBM2DDL_AUTO, hbm2ddlAuto)
   entityManagerFactoryBean.setJpaProperties(jpaProperties);

   return entityManagerFactoryBean;
}
项目:opentipbot    文件:PersistenceContext.java   
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();

    entityManagerFactoryBean.setDataSource(dataSource());
    entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    entityManagerFactoryBean.setPackagesToScan(PROPERTY_PACKAGES_TO_SCAN);

    Properties jpaProperties = new Properties();
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_DIALECT, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_DIALECT));
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_FORMAT_SQL, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_FORMAT_SQL));
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_HBM2DDL_AUTO, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_HBM2DDL_AUTO));
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY));
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_SHOW_SQL, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_SHOW_SQL));
    jpaProperties.put("hibernate.jdbc.use_streams_for_binary", "false");

    entityManagerFactoryBean.setJpaProperties(jpaProperties);

    return entityManagerFactoryBean;
}
项目:uimaster    文件:PersistentConfig.java   
@Bean
    @ConditionalOnBean(name = "dataSource")
    public EntityManagerFactory entityManagerFactory() {
        HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
        vendorAdapter.setGenerateDdl(true);

        LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
        factory.setJpaVendorAdapter(vendorAdapter);
        factory.setPackagesToScan("org.shaolin");
        factory.setDataSource(dataSource());
//      factory.setPersistenceUnitManager(persistenceUnitManager);
//      factory.setMappingResources(mappingResources);
        factory.afterPropertiesSet();

        return factory.getObject();
    }
项目:reddcrawl    文件:PersistenceConfiguration.java   
@Bean
@Nonnull
public EntityManagerFactory entityManagerFactory() throws SQLException {

    final Properties properties = new Properties();
    properties.setProperty("hibernate.dialect", env.getProperty("db.hibernate.dialect"));
    properties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("db.hibernate.hbm2ddl.auto"));
    properties.setProperty("hibernate.temp.use_jdbc_metadata_defaults", "false");

    final LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    factory.setJpaDialect(new HibernateJpaDialect());
    factory.setDataSource(pgDataSource());
    factory.setPackagesToScan(this.getClass().getPackage().getName());
    factory.setJpaProperties(properties);
    factory.afterPropertiesSet();

    return factory.getObject();
}
项目:EDU_SYZT    文件:PersistenceContext.java   
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();

    entityManagerFactoryBean.setDataSource(dataSource());
    entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    entityManagerFactoryBean.setPackagesToScan(PROPERTY_PACKAGES_TO_SCAN);

    Properties jpaProperties = new Properties();
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_DIALECT, environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_DIALECT));
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_FORMAT_SQL, environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_FORMAT_SQL));
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_HBM2DDL_AUTO, environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_HBM2DDL_AUTO));
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY, environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY));
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_SHOW_SQL, environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_SHOW_SQL));

    entityManagerFactoryBean.setJpaProperties(jpaProperties);

    return entityManagerFactoryBean;
}
项目:srccode    文件:JpaConfig.java   
/**
 * Creates EntityManagerFactory.
 * @return LocalContainerEntityManagerFactoryBean
 */
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {

    HibernateJpaVendorAdapter hibernateJpa = new HibernateJpaVendorAdapter();
    hibernateJpa.setDatabasePlatform("org.hibernate.dialect.PostgreSQLDialect");
    hibernateJpa.setShowSql(false);
    hibernateJpa.setGenerateDdl(true);

    LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
    emf.setDataSource(dataSource);
    emf.setPackagesToScan("pl.orange.labs");
    emf.setJpaVendorAdapter(hibernateJpa);
    emf.setJpaPropertyMap(Collections.singletonMap("javax.persistence.validation.mode", "none"));
    emf.setPersistenceUnitName("Mundo");
    return emf;
}
项目:cwEnsaiosWeb    文件:JPAConfiguration.java   
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();

    JpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();

    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setUsername("root");
    dataSource.setPassword("");
    dataSource.setUrl("jdbc:mysql://localhost:3306/ensaiospring");
    dataSource.setDriverClassName("com.mysql.jdbc.Driver");

    Properties props = new Properties();
    props.setProperty("hibernate.dialect",
            "org.hibernate.dialect.MySQL5Dialect");
    props.setProperty("hibernate.show_sql", "true");
    props.setProperty("hibernate.hbm2ddl.auto", "update");

    factory.setJpaVendorAdapter(jpaVendorAdapter);
    factory.setDataSource(dataSource);
    factory.setJpaProperties(props);
    factory.setPackagesToScan("br.com.ciaware.springmvc.ensaio.models");

    return factory;
}
项目:Photocan    文件:ProdProfile.java   
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws URISyntaxException {
    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaDialect(new HibernateJpaDialect());

    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setGenerateDdl(true);

    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPersistenceUnitName("production");
    factory.setPackagesToScan("app.domain");
    factory.setDataSource(dataSource());

    factory.afterPropertiesSet();
    return factory;
}
项目:WebAPI    文件:DataAccessConfig.java   
@Bean
public EntityManagerFactory entityManagerFactory() {

    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setGenerateDdl(false);
    vendorAdapter.setShowSql(Boolean.valueOf(this.env.getRequiredProperty("spring.jpa.show-sql")));
    //hibernate.dialect is resolved based on driver
    //vendorAdapter.setDatabasePlatform(hibernateDialect);

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setJpaProperties(getJPAProperties());
    factory.setPackagesToScan("org.ohdsi.webapi");
    factory.setDataSource(primaryDataSource());
    factory.afterPropertiesSet();

    return factory.getObject();
}
项目:SHD201407-app    文件:TestDatabaseConfig.java   
@Bean
public EntityManagerFactory entityManagerFactory() throws SQLException {

    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setGenerateDdl(true);

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("com.urely.test");
    factory.setDataSource(dataSource());
    logger.info("Before LocalContainerEntityManagerFactoryBean.afterPropertiesSet():::"+factory.getJpaPropertyMap());
    factory.afterPropertiesSet();
    logger.info("After LocalContainerEntityManagerFactoryBean.afterPropertiesSet():::"+factory.getJpaPropertyMap());

    return factory.getObject();
}
项目:spring-agora-web    文件:ApplicationConfig.java   
@Bean
@Autowired
public EntityManagerFactory entityManagerFactory(DataSource dataSource)  
{
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setGenerateDdl(generateDDL.booleanValue());
    vendorAdapter.setShowSql(showSQL.booleanValue());
    vendorAdapter.setDatabasePlatform("org.hibernate.dialect.MySQL5InnoDBDialect");
    vendorAdapter.setDatabase(Database.MYSQL);

    Properties properties = new Properties();
    properties.setProperty("hibernate.cache.use_second_level_cache", "true");
    properties.setProperty("hibernate.cache.region.factory_class", "org.hibernate.cache.ehcache.EhCacheRegionFactory");
    properties.setProperty("hibernate.cache.use_query_cache", "true");
    properties.setProperty("hibernate.generate_statistics", showStatistics.toString());

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("io.springagora.core.domain");
    factory.setDataSource(dataSource);
    factory.setJpaProperties(properties);
    factory.afterPropertiesSet();

    return factory.getObject();
}
项目:spring-time    文件:DatabaseConfig.java   
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(Environment env) throws Exception {

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

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setPersistenceUnitName("sample");
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("ch.thp.proto.spring.time");
    factory.setDataSource(dataSource(env));

    factory.setJpaProperties(jpaProperties());

    return factory;
}
项目:TeeFun    文件:DataBaseConfig.java   
/**
 * @return the JPA entity manager
 */
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
    final LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();

    factoryBean.setDataSource(this.defaultDataSource());
    factoryBean.setPackagesToScan(new String[] { "com.teefun.db" });

    final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setShowSql(true);
    vendorAdapter.setGenerateDdl(true);

    factoryBean.setJpaVendorAdapter(vendorAdapter);

    factoryBean.setJpaProperties(this.hibernateProperties());

    return factoryBean;
}