Java Code Examples for org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter#setGenerateDdl()

The following examples show how to use org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter#setGenerateDdl() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JPAConfiguration.java    From ariADDna with Apache License 2.0 7 votes vote down vote up
@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();
}
 
Example 2
Source File: RepositorySpringConfiguration.java    From personal_book_library_web_project with MIT License 7 votes vote down vote up
@Bean
public EntityManagerFactory entityManagerFactory() throws SQLException {

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

	LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
	factory.setJpaVendorAdapter(vendorAdapter);
	factory.setPackagesToScan("com.personal.book.library.datalayer.entity", 
							 "com.personal.book.library.datalayer.repository.jpa");
	factory.setDataSource(dataSource());
	factory.afterPropertiesSet();
	factory.setJpaProperties(jpaProperties());
	
	return factory.getObject();
}
 
Example 3
Source File: TaskDbConfig.java    From app-engine with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 4
Source File: InfrastructureConfig.java    From Learning-Path-Spring-5-End-to-End-Programming with MIT License 5 votes vote down vote up
@Bean
public JpaVendorAdapter jpaVendorAdapter() {
	HibernateJpaVendorAdapter bean = new HibernateJpaVendorAdapter();
	bean.setDatabase(org.springframework.orm.jpa.vendor.Database.H2);
	bean.setGenerateDdl(true);
	return bean;
}
 
Example 5
Source File: EnableJpaStoresTest.java    From spring-content with Apache License 2.0 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
	HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
	vendorAdapter.setDatabase(Database.HSQL);
	vendorAdapter.setGenerateDdl(true);

	LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
	factory.setJpaVendorAdapter(vendorAdapter);
	factory.setPackagesToScan(getClass().getPackage().getName());
	factory.setDataSource(dataSource());

	return factory;
}
 
Example 6
Source File: PartitionTemplateWithEmfTest.java    From score with Apache License 2.0 5 votes vote down vote up
@Bean
JpaVendorAdapter jpaVendorAdapter() {
    HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
    adapter.setShowSql(SHOW_SQL);
    adapter.setGenerateDdl(true);
    return adapter;
}
 
Example 7
Source File: JpaConfig.java    From spring-content with Apache License 2.0 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
	HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
	vendorAdapter.setDatabase(Database.H2);
	vendorAdapter.setGenerateDdl(true);

	LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
	factory.setJpaVendorAdapter(vendorAdapter);
	factory.setPackagesToScan("org.springframework.content.cmis.support");
	factory.setDataSource(dataSource());

	return factory;
}
 
Example 8
Source File: EnableCmisTest.java    From spring-content with Apache License 2.0 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
	HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
	vendorAdapter.setDatabase(Database.H2);
	vendorAdapter.setGenerateDdl(true);

	LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
	factory.setJpaVendorAdapter(vendorAdapter);
	factory.setPackagesToScan("org.springframework.content.cmis.integration");
	factory.setDataSource(dataSource());

	return factory;
}
 
Example 9
Source File: AppConfig.java    From Spring-Framework-Essentials with MIT License 5 votes vote down vote up
@Bean
public JpaVendorAdapter jpaVendorAdapter() {
    HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
    adapter.setShowSql(true);
    adapter.setGenerateDdl(true);
    adapter.setDatabase(Database.MYSQL);
    return adapter;
}
 
Example 10
Source File: OrmRepository.java    From sample-boot-micro with MIT License 5 votes vote down vote up
private JpaVendorAdapter vendorAdapter() {
    HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
    adapter.setShowSql(isShowSql());
    if (getDatabase() != null) {
        adapter.setDatabase(getDatabase());
    }
    adapter.setDatabasePlatform(getDatabasePlatform());
    adapter.setGenerateDdl(isGenerateDdl());
    return adapter;
}
 
Example 11
Source File: InfrastructureConfiguration.java    From spring-domain-events with Apache License 2.0 5 votes vote down vote up
@Bean
LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) {

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

	LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
	factoryBean.setDataSource(dataSource);
	factoryBean.setJpaVendorAdapter(adapter);
	factoryBean.setPackagesToScan("org.springframework.events.jpa");

	return factoryBean;
}
 
Example 12
Source File: WorkerNodeServiceTest.java    From score with Apache License 2.0 5 votes vote down vote up
@Bean
JpaVendorAdapter jpaVendorAdapter() {
    HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
    adapter.setShowSql(SHOW_SQL);
    adapter.setGenerateDdl(true);
    return adapter;
}
 
Example 13
Source File: BaseApplication.java    From rqueue with Apache License 2.0 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
  HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
  vendorAdapter.setGenerateDdl(true);
  LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
  factory.setJpaVendorAdapter(vendorAdapter);
  factory.setPackagesToScan("com.github.sonus21.rqueue.test.entity");
  factory.setDataSource(dataSource());
  return factory;
}
 
Example 14
Source File: SpringDataITest.java    From java-specialagent with Apache License 2.0 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
  final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
  vendorAdapter.setDatabase(Database.H2);
  vendorAdapter.setGenerateDdl(true);

  final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
  em.setDataSource(dataSource());
  em.setPackagesToScan("io.opentracing.contrib.specialagent.test.spring.data");
  em.setJpaVendorAdapter(vendorAdapter);
  return em;
}
 
Example 15
Source File: EngineTest.java    From score with Apache License 2.0 5 votes vote down vote up
@Bean
JpaVendorAdapter jpaVendorAdapter() {
    HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
    adapter.setShowSql(false);
    adapter.setGenerateDdl(true);
    return adapter;
}
 
Example 16
Source File: RepositoryConfiguration.java    From java-platform with Apache License 2.0 5 votes vote down vote up
@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.whenling");
		factory.setJpaDialect(new HibernateJpaDialect());

		Properties jpaProperties = new Properties();
		jpaProperties.put("hibernate.id.new_generator_mappings", false);
		jpaProperties.put("hibernate.hbm2ddl.auto", hibernateHbm2ddlAuto);
		jpaProperties.put("hibernate.dialect", hibernateDialect);
		jpaProperties.put("hibernate.show_sql", hibernateShowSql);
		jpaProperties.put("hibernate.format_sql", hibernateFormatSql);
		jpaProperties.put("hibernate.current_session_context_class", hibernateCurrentSessionContextClass);

		jpaProperties.put("javax.persistence.validation.mode", javaxPersistenceValidationMode);
		jpaProperties.put("hibernate.query.substitutions", hibernateQuerySubstitutions);
		jpaProperties.put("hibernate.default_batch_fetch_size", hibernateDefaultBatchFetchSize);
		jpaProperties.put("hibernate.max_fetch_depth", hibernateMaxFetchDepth);
		jpaProperties.put("hibernate.enable_lazy_load_no_trans", hibernateEnableLazyLoadNoTrans);
		jpaProperties.put("hibernate.bytecode.use_reflection_optimizer", hibernateBytecodeUseReflectionOptimizer);

		jpaProperties.put("hibernate.cache.use_second_level_cache", hibernateCacheUseSecondLevelCache);
		jpaProperties.put("hibernate.cache.region.factory_class", hibernateCacheInfinispanRegionFactoryClass);
//		jpaProperties.put("hibernate.cache.infinispan.cfg", hibernateCacheInfinispanCfg);
		jpaProperties.put("javax.persistence.sharedCache.mode", javaxPersistenceSharedCacheMode);
		jpaProperties.put("hibernate.generate_statistics", hibernateGenerateStatistics);

		jpaProperties.put("hibernate.cache.use_query_cache", hibernateCacheUseQueryCache);
		factory.setJpaProperties(jpaProperties);

		return factory;
	}
 
Example 17
Source File: EmbeddedDataSourceConfig.java    From spring-sync with Apache License 2.0 5 votes vote down vote up
@Bean
public JpaVendorAdapter jpaVendorAdapter() {
		HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter();
		hibernateJpaVendorAdapter.setShowSql(false);
		hibernateJpaVendorAdapter.setGenerateDdl(true);
		hibernateJpaVendorAdapter.setDatabase(Database.H2);
		return hibernateJpaVendorAdapter;
}
 
Example 18
Source File: SpringDataJpaConfig.java    From Project with Apache License 2.0 5 votes vote down vote up
@Bean
public HibernateJpaVendorAdapter jpaVendorAdapter() {
  HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
  adapter.setDatabase(Database.H2);
  adapter.setShowSql(false);
  adapter.setGenerateDdl(true);
  return adapter;
}
 
Example 19
Source File: MultiRedisSprigBaseApplication.java    From rqueue with Apache License 2.0 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
  HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
  vendorAdapter.setGenerateDdl(true);
  LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
  factory.setJpaVendorAdapter(vendorAdapter);
  factory.setPackagesToScan("com.github.sonus21.rqueue.test.entity");
  factory.setDataSource(dataSource());
  return factory;
}
 
Example 20
Source File: Config.java    From spring-data-jpa-datatables with Apache License 2.0 5 votes vote down vote up
@Bean
public AbstractEntityManagerFactoryBean entityManager(DataSource dataSource)
        throws SQLException {

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

    LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean();
    bean.setJpaVendorAdapter(jpaVendorAdapter);
    bean.setPackagesToScan(Config.class.getPackage().getName());
    bean.setDataSource(dataSource);

    return bean;
}