當前位置: 首頁>>代碼示例>>Java>>正文


Java HibernateJpaVendorAdapter.setGenerateDdl方法代碼示例

本文整理匯總了Java中org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter.setGenerateDdl方法的典型用法代碼示例。如果您正苦於以下問題:Java HibernateJpaVendorAdapter.setGenerateDdl方法的具體用法?Java HibernateJpaVendorAdapter.setGenerateDdl怎麽用?Java HibernateJpaVendorAdapter.setGenerateDdl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter的用法示例。


在下文中一共展示了HibernateJpaVendorAdapter.setGenerateDdl方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: newEntityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //導入方法依賴的package包/類
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();
}
 
開發者ID:profullstack,項目名稱:spring-seed,代碼行數:23,代碼來源:JpaBuilderUtil.java

示例2: entityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //導入方法依賴的package包/類
@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();
}
 
開發者ID:bricket,項目名稱:b4,代碼行數:26,代碼來源:B4CoreRootConfig.java

示例3: entityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //導入方法依賴的package包/類
@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;
}
 
開發者ID:rumatoest,項目名稱:jdblender,代碼行數:26,代碼來源:Config.java

示例4: entityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //導入方法依賴的package包/類
@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;
}
 
開發者ID:aranga-nana,項目名稱:angular-spring-boot-micro-services-docker,代碼行數:20,代碼來源:JPAConfig.java

示例5: entityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //導入方法依賴的package包/類
@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;
}
 
開發者ID:Nanofus,項目名稱:Photocan,代碼行數:17,代碼來源:ProdProfile.java

示例6: entityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //導入方法依賴的package包/類
@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;
}
 
開發者ID:paulcwarren,項目名稱:spring-content,代碼行數:17,代碼來源:JpaInfrastructureConfig.java

示例7: entityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //導入方法依賴的package包/類
@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();
}
 
開發者ID:siteadmin,項目名稱:CCDA-Score-CARD,代碼行數:18,代碼來源:PersistanceConfigurationPostGres.java

示例8: getHibernateJpaVendorAdapter

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:FINRAOS,項目名稱:herd,代碼行數:22,代碼來源:DaoSpringModuleConfig.java

示例9: entityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //導入方法依賴的package包/類
@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();
}
 
開發者ID:aol,項目名稱:micro-server,代碼行數:22,代碼來源:SpringDataConfig.java

示例10: entityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //導入方法依賴的package包/類
@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;
}
 
開發者ID:sheelsh,項目名稱:SpringRESTDemo,代碼行數:18,代碼來源:ApplicationConfig.java

示例11: taskEntityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //導入方法依賴的package包/類
@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;
}
 
開發者ID:sofn,項目名稱:app-engine,代碼行數:17,代碼來源:TaskDbConfig.java

示例12: entityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //導入方法依賴的package包/類
@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();
	}
 
開發者ID:shaolinwu,項目名稱:uimaster,代碼行數:17,代碼來源:PersistentConfig.java

示例13: entityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:MUNDO-platform,項目名稱:srccode,代碼行數:21,代碼來源:JpaConfig.java

示例14: entityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //導入方法依賴的package包/類
@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();
}
 
開發者ID:OHDSI,項目名稱:WebAPI,代碼行數:19,代碼來源:DataAccessConfig.java

示例15: entityManagerFactory

import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; //導入方法依賴的package包/類
@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();
}
 
開發者ID:guocw998,項目名稱:SHD201407-app,代碼行數:17,代碼來源:TestDatabaseConfig.java


注:本文中的org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter.setGenerateDdl方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。