gpt4 book ai didi

java - 如何使 hbm2ddl schemaExport 将模式记录到标准输出?

转载 作者:太空狗 更新时间:2023-10-29 22:53:50 25 4
gpt4 key购买 nike

引自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) 中获取此信息?

最佳答案

激活 org.hibernate.tool.hbm2ddl 类别的日志记录到 DEBUG


更新:这是一个简化的 logback.xml(我使用 logback 作为日志后端):

<configuration scan="true">

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
</layout>
</appender>

<!-- ### log just the SQL ### -->
<logger name="org.hibernate.SQL" level="DEBUG"/>

<!-- ### log JDBC bind parameters ### -->
<logger name="org.hibernate.type" level="TRACE"/>

<logger name="org.hibernate.tool.hbm2ddl" level="DEBUG"/>

<root level="ERROR">
<appender-ref ref="STDOUT"/>
</root>
</configuration>

如果您使用的是 log4j(您会在 SO 上找到有效的配置),请对其进行调整。

关于java - 如何使 hbm2ddl schemaExport 将模式记录到标准输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3829597/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com