我尝试使用以下任务启动来生成dbSchema(Eclipse和Maven项目)

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.buildship.core.launch.runconfiguration">
<listAttribute key="arguments"/>
<stringAttribute key="gradle_distribution" value="GRADLE_DISTRIBUTION(WRAPPER)"/>
<listAttribute key="jvm_arguments"/>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
</listAttribute>
<booleanAttribute key="show_console_view" value="true"/>
<booleanAttribute key="show_execution_view" value="false"/>
<listAttribute key="tasks">
<listEntry value="dbSchema"/>
</listAttribute>
<booleanAttribute key="use_gradle_distribution_from_import" value="false"/>
<stringAttribute key="working_dir" value="${workspace_loc:/MyProject}"/>
</launchConfiguration>


这是控制台日志中的错误:

[ant:hibernatetool] An exception occurred while running exporter #2:hbm2ddl (Generates database schema)
[ant:hibernatetool] To get the full stack trace run ant with -verbose
[ant:hibernatetool] javax.persistence.PersistenceException: [PersistenceUnit: yadaPersistenceUnit] Unable to build Hibernate SessionFactory
[ant:hibernatetool] java.util.UnknownFormatConversionException: Conversion = '%'


此错误是由什么产生的?
[ant:hibernatetool] java.util.UnknownFormatConversionException: Conversion = '%'

如何解决这个问题呢?实体产生问题了吗?

到目前为止,该任务始终可以正常运行,并且我没有进行任何更改。它可以依靠什么?

最佳答案

这是由Settings类中的这一行引起的:

LOG.debugf("Using BatchFetchStyle : %", sessionFactoryOptions.getBatchFetchStyle().name());

它应该是“%s”,而不是“%”:
LOG.debugf("Using BatchFetchStyle : %s", sessionFactoryOptions.getBatchFetchStyle().name());

好像this commit添加了问题。由于日志级别未设置为调试,因此很可能未检测到该问题。

尝试将其设置为调试:
log4j.logger.org.hibernate.cfg=debug

关于hibernate - 运行导出器#2:hbm2ddl时发生异常(生成数据库架构),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58025091/

10-11 23:00