From 992786fc91b0a9fee86f8544787962e4341ec845 Mon Sep 17 00:00:00 2001 From: qibaoguang Date: Thu, 12 Feb 2015 10:31:51 +0800 Subject: [PATCH] Update 28.3.3. Creating and dropping JPA databases.md --- .../28.3.3. Creating and dropping JPA databases.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/IV. Spring Boot features/28.3.3. Creating and dropping JPA databases.md b/IV. Spring Boot features/28.3.3. Creating and dropping JPA databases.md index e69de29..19eaf4f 100644 --- a/IV. Spring Boot features/28.3.3. Creating and dropping JPA databases.md +++ b/IV. Spring Boot features/28.3.3. Creating and dropping JPA databases.md @@ -0,0 +1,9 @@ +### 28.3.3. 创建和删除JPA数据库 + +默认情况下,只有在你使用内嵌数据库(H2, HSQL或Derby)时,JPA数据库才会被自动创建。你可以使用spring.jpa.*属性显示的设置JPA。比如,为了创建和删除表你可以将下面的配置添加到application.properties中: +```java +spring.jpa.hibernate.ddl-auto=create-drop +``` +**注**:Hibernate自己内部对创建,删除表支持(如果你恰好记得这回事更好)的属性是hibernate.hbm2ddl.auto。使用spring.jpa.properties.*(前缀在被添加到实体管理器之前会被剥离掉),你可以设置Hibernate本身的属性,比如hibernate.hbm2ddl.auto。示例:`spring.jpa.properties.hibernate.globally_quoted_identifiers=true`将传递hibernate.globally_quoted_identifiers到Hibernate实体管理器。 + +默认情况下,DDL执行(或验证)被延迟到ApplicationContext启动。这也有一个spring.jpa.generate-ddl标识,如果Hibernate自动配置被激活,那该标识就不会被使用,因为ddl-auto设置粒度更细。