Search code examples
hibernategradleantschemahibernate-tools

An exception occurred while running exporter #2:hbm2ddl (Generates database schema)


I'm try to generate dbSchema with the following task launch (eclipse whith maven project)

<?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>

And this is the error from the console log:

[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 = '%'

What is this error generated from?

[ant:hibernatetool] java.util.UnknownFormatConversionException: Conversion = '%'

How to solve this problem? Is a problem generated by the entity?

The task has always worked correctly so far, and I have not made any changes. What can it depend on?


Solution

  • This is caused by this line in the Settings class:

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

    It should be "%s", not "%":

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

    Looks like this commit has added the issue. Most likely, the issue was not detected because the log level is not set to debug.

    Try setting it to debug:

    log4j.logger.org.hibernate.cfg=debug