Reverse engineering fails on table with composite primary key

I am trying to reverse engineer (generate entity classes) for a complex Oracle database using Hibernate Tools 6.5.2-Final maven plugin.

The hibernate.reveng.xml file is setup to generate entity classes only for all tables (700+) in a specific schema. The maven plugin fails with the following error message:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.hibernate.tool:hibernate-tools-maven:6.5.2.Final:hbm2java (entity-generation) on project <mavenProjectName>: Execution entity-generation of goal org.hibernate.tool:hibernate-tools-maven:6.5.2.Final:hbm2java failed: component class not found: <packageFromHibernateRevengXml>.MdEintragId

However, if I configure hibernate.reveng.xml to only reverse engineer that one table (MD_EINTRAG) the entity class for the table as well as the class for the composite primary key are created without any issue.

The stacktrace for the failure situation (only last element):

    Suppressed: java.lang.ClassNotFoundException: <packageFromHibernateRevengXml>.MdEintragId
        at jdk.internal.loader.BuiltinClassLoader.loadClass (BuiltinClassLoader.java:641)
        at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass (ClassLoaders.java:188)
        at java.lang.ClassLoader.loadClass (ClassLoader.java:521)
        at org.hibernate.boot.registry.classloading.internal.AggregatedClassLoader.findClass (AggregatedClassLoader.java:206)
        at java.lang.ClassLoader.loadClass (ClassLoader.java:588)
        at java.lang.ClassLoader.loadClass (ClassLoader.java:521)
        at java.lang.Class.forName0 (Native Method)
        at java.lang.Class.forName (Class.java:496)
        at java.lang.Class.forName (Class.java:475)
        at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName (ClassLoaderServiceImpl.java:123)
        at org.hibernate.mapping.Component.getComponentClass (Component.java:300)
        at org.hibernate.type.ComponentType.<init> (ComponentType.java:78)
        at org.hibernate.mapping.Component.getType (Component.java:370)
        at org.hibernate.mapping.Component.getType (Component.java:66)
        at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.getIdentifierType (InFlightMetadataCollectorImpl.java:993)
        at org.hibernate.type.EntityType.getIdentifierType (EntityType.java:598)
        at org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType (EntityType.java:638)
        at org.hibernate.mapping.Column.getTypeForEntityValue (Column.java:505)
        at org.hibernate.mapping.Column.calculateColumnSize (Column.java:442)
        at org.hibernate.mapping.BasicValue.resolve (BasicValue.java:361)
        at org.hibernate.mapping.BasicValue.resolve (BasicValue.java:340)
        at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.lambda$processValueResolvers$4 (InFlightMetadataCollectorImpl.java:1796)
        at java.util.ArrayList.removeIf (ArrayList.java:1682)
        at java.util.ArrayList.removeIf (ArrayList.java:1660)
        at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processValueResolvers (InFlightMetadataCollectorImpl.java:1795)
        at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses (InFlightMetadataCollectorImpl.java:1781)
        at org.hibernate.tool.internal.reveng.RevengMetadataBuilder.createPersistentClasses (RevengMetadataBuilder.java:127)
        at org.hibernate.tool.internal.reveng.RevengMetadataBuilder.build (RevengMetadataBuilder.java:86)
        at org.hibernate.tool.internal.metadata.RevengMetadataDescriptor.createMetadata (RevengMetadataDescriptor.java:44)
        at org.hibernate.tool.internal.export.common.AbstractExporter.buildMetadata (AbstractExporter.java:194)
        at org.hibernate.tool.internal.export.common.AbstractExporter.getMetadata (AbstractExporter.java:56)
        at org.hibernate.tool.internal.export.common.AbstractExporter.setupContext (AbstractExporter.java:164)
        at org.hibernate.tool.internal.export.java.JavaExporter.setupContext (JavaExporter.java:37)
        at org.hibernate.tool.internal.export.common.AbstractExporter.start (AbstractExporter.java:88)
        at org.hibernate.tool.maven.GenerateJavaMojo.executeExporter (GenerateJavaMojo.java:70)
        at org.hibernate.tool.maven.AbstractGenerationMojo.execute (AbstractGenerationMojo.java:90)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
        at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
        at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
        at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
        at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
        at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
        at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
        at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
        at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
        at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
        at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
        at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
        at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:104)
        at java.lang.reflect.Method.invoke (Method.java:578)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)

Someone any idea?

Please create a Jira issue for the HBX project: Hibernate Tools - Issues - Hibernate JIRA

Done: https://hibernate.atlassian.net/browse/HBX-2840

1 Like