John Citizen [
https://community.jboss.org/people/johnqcitizen] created the discussion
"Re: Getting "association error" when reverse-engineering an existing
schema with Hibernate tools"
To view the discussion, visit:
https://community.jboss.org/message/801796#801796
--------------------------------------------------------------
So I decided to remove maven from the problem and wrote an ant build script that uses
hibernate tools directly.
But I still get the same error:
[hibernatetool] An exception occurred while running exporter #2:hbm2java (Generates a set
of .java files)
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] org.hibernate.MappingException: *An association from the table FOO refers
to an unmapped class: com.whatever.domain.Bar*
BUILD FAILED
build.xml:23: org.hibernate.MappingException: An association from the table FOO refers to
an unmapped class: com.whatever.domain.Bar
at
org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1285)
at
org.hibernate.cfg.JDBCMetaDataConfiguration.secondPassCompileForeignKeys(JDBCMetaDataConfiguration.java:33)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1203)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1148)
at
org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:56)
at
org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:302)
at
org.hibernate.tool.ant.HibernateToolTask.getProperties(HibernateToolTask.java:318)
at org.hibernate.tool.ant.ExporterTask.configureExporter(ExporterTask.java:94)
at
org.hibernate.tool.ant.Hbm2JavaExporterTask.configureExporter(Hbm2JavaExporterTask.java:34)
at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:39)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:186)
Here's my ant *build.xml* file:
<project basedir="." default="reveng">
<path id="toolslib">
<path
location="/r/org/hibernate/hibernate-tools/3.2.3.GA/*hibernate-tools-3.2.3.GA.jar*"
/>
<path
location="/r/org/hibernate/hibernate-core/3.3.1.GA/*hibernate-core-3.3.1.GA.jar*"
/>
<path
location="/r/org/hibernate/hibernate-annotations/3.4.0.GA/hibernate-annotations-3.4.0.GA.jar"
/>
<path location="/r/freemarker/freemarker/2.3.8/freemarker-2.3.8.jar"
/>
<path location="/r/com/oracle/ojdbc/11.1.0.6.0/*ojdbc-11.1.0.6.0.jar*"
/>
<path
location="/r/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar"
/>
<path location="/r/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar" />
<path location="/r/org/slf4j/slf4j-api/1.5.6/slf4j-api-1.5.6.jar" />
<path location="/r/org/slf4j/slf4j-log4j12/1.5.6/slf4j-log4j12-1.5.6.jar"
/>
<path location="/r/log4j/log4j/1.2.16/log4j-1.2.16.jar" />
<path location="/r/cglib/cglib/2.2.2/cglib-2.2.2.jar" />
<path location="/r/asm/asm/3.3.1/asm-3.3.1.jar" />
<path
location="/r/commons-collections/commons-collections/3.1/commons-collections-3.1.jar"
/>
</path>
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="toolslib" />
<target name="reveng" description="Reverse-engineer a DB
schema">
<hibernatetool destdir="${build.dir}/generated">
<jdbcconfiguration propertyfile="*hibernate.properties*"
packagename="com.whatever.domain" revengfile="*reveng.xml*" />
<hbm2java jdk5="true" ejb3="true" />
</hibernatetool>
</target>
</project>
It is accessing the same *hibernate.properties* file and *reveng.xml* file specified in
the comment above.
Hope this helps.
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/801796#801796]
Start a new discussion in JBoss Tools at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]