mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-05 00:56:58 +08:00
Fix data sample (needed an enum for spring.jpa.ddl_auto)
This commit is contained in:
parent
369b0834a0
commit
a1dd6e3293
@ -0,0 +1 @@
|
||||
spring.jpa.ddl_auto: create_drop
|
@ -45,6 +45,14 @@ import org.springframework.util.StringUtils;
|
||||
@Import(JpaComponentScanDetector.class)
|
||||
public class HibernateJpaAutoConfiguration extends JpaAutoConfiguration {
|
||||
|
||||
public static enum DDLAUTO {
|
||||
none, validate, update, create, create_drop;
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name().toLowerCase().replace("_", "-");
|
||||
}
|
||||
}
|
||||
|
||||
private static final Map<EmbeddedDatabaseType, String> EMBEDDED_DATABASE_DIALECTS;
|
||||
static {
|
||||
EMBEDDED_DATABASE_DIALECTS = new LinkedHashMap<EmbeddedDatabaseType, String>();
|
||||
@ -61,15 +69,14 @@ public class HibernateJpaAutoConfiguration extends JpaAutoConfiguration {
|
||||
@Value("${spring.jpa.showSql:${spring.jpa.show_sql:false}}")
|
||||
private boolean showSql;
|
||||
|
||||
@Value("${spring.jpa.generateDdl:${spring.jpa.generate_ddl:false}}")
|
||||
private boolean generateDdl;
|
||||
@Value("${spring.jpa.ddlAuto:${spring.jpa.ddl_auto:none}}")
|
||||
private DDLAUTO ddlAuto;
|
||||
|
||||
@Bean
|
||||
@Override
|
||||
public JpaVendorAdapter jpaVendorAdapter() {
|
||||
HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
|
||||
adapter.setShowSql(this.showSql);
|
||||
adapter.setGenerateDdl(this.generateDdl);
|
||||
if (StringUtils.hasText(this.databasePlatform)) {
|
||||
adapter.setDatabasePlatform(this.databasePlatform);
|
||||
}
|
||||
@ -84,6 +91,10 @@ public class HibernateJpaAutoConfiguration extends JpaAutoConfiguration {
|
||||
// FIXME: detect EhCache
|
||||
properties.put("hibernate.cache.provider_class",
|
||||
"org.hibernate.cache.HashtableCacheProvider");
|
||||
if (this.ddlAuto != DDLAUTO.none) {
|
||||
properties.put("hibernate.hbm2ddl.auto", this.ddlAuto.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user