如何使 hbm2ddl schemaExport 将模式记录到标准输出?
引用persistence.xml
:
<persistence-unit name="test" transaction-type="RESOURCE_LOCAL">
<properties>
<property name="hibernate.archive.autodetection" value="class" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.hbm2ddl.auto" value="create" />
...
</properties>
</persistence-unit>
这是我在日志输出中看到的:
Sep 30, 2010 12:03:43 PM org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: Running hbm2ddl schema export
Sep 30, 2010 12:03:43 PM org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: exporting generated schema to database
Sep 30, 2010 12:03:43 PM org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: schema export complete
但我没有看到模式(SQL)导出本身。如何从 Hibernate (3.5.6-Final) 中获取此信息?
A quote from persistence.xml
:
<persistence-unit name="test" transaction-type="RESOURCE_LOCAL">
<properties>
<property name="hibernate.archive.autodetection" value="class" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.hbm2ddl.auto" value="create" />
...
</properties>
</persistence-unit>
This is what I see in log output:
Sep 30, 2010 12:03:43 PM org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: Running hbm2ddl schema export
Sep 30, 2010 12:03:43 PM org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: exporting generated schema to database
Sep 30, 2010 12:03:43 PM org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: schema export complete
But I don't see the schema (SQL) exported itself. How to get this information out of Hibernate (3.5.6-Final)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将
org.hibernate.tool.hbm2ddl
类别的日志记录激活为DEBUG
。更新:这是一个简化的
logback.xml
(我使用logback作为日志记录后端):如果您使用log4j,请调整它(您可以在此处找到工作配置)所以)。
Activate the logging of the
org.hibernate.tool.hbm2ddl
category toDEBUG
.Update: Here is a simplified
logback.xml
(I'm using logback as logging backend):Adapt it if you are using log4j (you'll find working configuration here on SO).
以防万一您使用 Spring Boot 偶然发现这一点。您可以在
application.yml
中配置以下内容:Just in case you stumble upon this using Spring Boot. You can configure the following in your
application.yml
:这是一个简化的
log4j.xml
配置。Here is a simplified
log4j.xml
configuration.