【发布时间】:2016-10-05 12:40:22
【问题描述】:
如何查看 Hibernate 为从 JPA 映射构建模式而生成的 DDL SQL?我正在使用嵌入式 HSQL 数据库。
我尝试了以下方法,但它们都没有在 Spring-Boot 1.3.5.RELEASE 中工作。
- 将以下内容添加到 application.properties 文件
- debug=true
- spring.jpa.properties.hibernate.show_sql=true
- 在 logback.xml 中设置 org.hibernate.SQL 级别调试
- http://docs.spring.io/spring-boot/docs/current/reference/html/howto-database-initialization.html 列出的步骤
那些只显示 Hibernate 为查询发出的 sql。由于以下属性,我正在寻找 Hibernate 发布的 DDL 模式 sql:
spring.jpa.hibernate.ddl-auto=create-drop
【问题讨论】:
-
你见过this SO question吗?
-
@TimBiegeleisen 是的,但它们与上面相同。它们只显示查询,而不是应用启动时 Hibernate 发出的 DDL。
-
show-sql 只显示 DML,您需要添加
debug=truetoapplication.properties 才能看到 DDL -
@Shibashis 我试过
debug=true,正如我的帖子中提到的那样。那仍然没有显示 DDL。
标签: spring hibernate spring-boot