JBoss Community

Re: Getting "association error" when reverse-engineering an existing schema with Hibernate tools

created by John Citizen in JBoss Tools - View the full discussion

Thanks for the response.

 

I am using maven-hibernate3-plugin 2.2, which has a dependency on hibernate-tools  3.2.3.GA and hibernate-core 3.3.1.GA

 

Here is some output from running the following command:

 

$ mvn -X hibernate3:hbm2java

 

Apache Maven 3.0.4 (r1232337; 2012-01-17 18:44:56+1000)

Maven home: C:\dev\apache-maven-3.0.4\bin\..

Java version: 1.6.0_38, vendor: Sun Microsystems Inc.

OS name: "windows xp", version: "5.1", arch: "x86", family: "windows"

 

[INFO] --- hibernate3-maven-plugin:2.2:hbm2java (default-cli) @ foo ---

[DEBUG] org.codehaus.mojo:hibernate3-maven-plugin:jar:2.2:

[DEBUG]    cglib:cglib-nodep:jar:2.2.2:runtime

[DEBUG]    com.oracle:ojdbc:jar:11.1.0.6.0:runtime

[DEBUG]    log4j:log4j:jar:1.2.14:runtime

[DEBUG]    org.hibernate:hibernate-tools:jar:3.2.3.GA:compile

[DEBUG]       org.beanshell:bsh:jar:2.0b4:compile

[DEBUG]       freemarker:freemarker:jar:2.3.8:compile

[DEBUG]       org.hibernate:jtidy:jar:r8-20060801:compile

[DEBUG]    org.hibernate:hibernate-core:jar:3.3.1.GA:compile

[DEBUG]       antlr:antlr:jar:2.7.6:compile

[DEBUG]       commons-collections:commons-collections:jar:3.1:compile

[DEBUG]       dom4j:dom4j:jar:1.6.1:compile

[DEBUG]       org.slf4j:slf4j-api:jar:1.5.6:runtime (scope managed from compile) (version managed from 1.5.2)

[DEBUG]    org.codehaus.mojo.hibernate3:maven-hibernate3-api:jar:2.2:compile

[DEBUG]       xml-apis:xml-apis:jar:1.0.b2:compile

[DEBUG]       org.apache.geronimo.specs:geronimo-jta_1.0.1B_spec:jar:1.1.1:runtime

[DEBUG]       org.slf4j:slf4j-log4j12:jar:1.5.6:runtime

[DEBUG]       org.slf4j:jcl-over-slf4j:jar:1.5.6:runtime

[DEBUG]       org.codehaus.plexus:plexus-utils:jar:1.5.6:compile

[DEBUG]    org.apache.maven:maven-model:jar:2.0.6:compile

[DEBUG]    org.apache.maven:maven-project:jar:2.0.6:compile

[DEBUG]       org.apache.maven:maven-settings:jar:2.0.6:compile

[DEBUG]       org.apache.maven:maven-profile:jar:2.0.6:compile

[DEBUG]       org.apache.maven:maven-artifact-manager:jar:2.0.6:compile

[DEBUG]          org.apache.maven:maven-repository-metadata:jar:2.0.6:compile

[DEBUG]       org.apache.maven:maven-plugin-registry:jar:2.0.6:compile

[DEBUG]       org.apache.maven:maven-artifact:jar:2.0.6:compile

[DEBUG]       org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile

[DEBUG]          junit:junit:jar:3.8.2:test (scope managed from compile) (version managed from 3.8.1)

[DEBUG]          classworlds:classworlds:jar:1.1-alpha-2:compile

[DEBUG]    org.apache.maven:maven-plugin-api:jar:2.0.6:compile

[DEBUG]    org.codehaus.mojo.hibernate3:maven-hibernate3-jdk14:jar:2.2:compile

[DEBUG]    org.codehaus.mojo.hibernate3:maven-hibernate3-jdk15:jar:2.2:compile

[DEBUG]       org.hibernate:hibernate-entitymanager:jar:3.4.0.GA:compile

[DEBUG]          org.hibernate:hibernate-commons-annotations:jar:3.1.0.GA:compile

[DEBUG]          javax.transaction:jta:jar:1.1:compile

[DEBUG]       org.hibernate:ejb3-persistence:jar:1.0.2.GA:compile

[DEBUG]       org.hibernate:hibernate-annotations:jar:3.4.0.GA:compile

[DEBUG]       jboss:jboss-common:jar:4.0.2:compile

[DEBUG]          slide:webdavlib:jar:2.0:compile

[DEBUG]          xerces:xercesImpl:jar:2.6.2:compile

[DEBUG]       javassist:javassist:jar:3.4.GA:compile

 

[DEBUG] Goal:          org.codehaus.mojo:hibernate3-maven-plugin:2.2:hbm2java (default-cli)

[DEBUG] Style:         Regular

[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?>

<configuration>

  <componentProperties>

    <revengfile>/src/main/resources/reveng.xml</revengfile>

    <propertyfile>src/main/resources/hibernate.properties</propertyfile>

    <packagename>com.whatever.domain</packagename>

    <jdk5>true</jdk5>

    <ejb3>true</ejb3>

  </componentProperties>

  <components>

    <component>

      <name>hbm2java</name>

      <implementation>jdbcconfiguration</implementation>

      <outputDirectory>target/generated-sources/hibernate3</outputDirectory>

    </component>

  </components>

</configuration>

[DEBUG] =======================================================================

[INFO]

[INFO] >>> hibernate3-maven-plugin:2.2:hbm2java (default-cli) @ foo >>>

 

09:06:58,296        DEBUG DriverManagerConnectionProvider:138 - created connection to: jdbc:oracle:thin:@***, Isolation Level: 2

09:06:58,296         INFO SettingsFactory:116 - RDBMS: Oracle, version: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production

With the Partitioning, OLAP and Data Mining options

09:06:58,296         INFO SettingsFactory:117 - JDBC driver: Oracle JDBC driver, version: 11.1.0.6.0-Production

09:06:58,312         INFO Dialect:175 - Using dialect: org.hibernate.dialect.Oracle10gDialect

09:06:58,328         INFO TransactionFactoryFactory:59 - Using default transaction strategy (direct JDBC transactions)

09:06:58,343         INFO SettingsFactory:170 - Automatic flush during beforeCompletion(): disabled

09:06:58,343         INFO SettingsFactory:174 - Automatic session close at end of transaction: disabled

09:06:58,343         INFO SettingsFactory:181 - JDBC batch size: 15

09:06:58,343         INFO SettingsFactory:184 - JDBC batch updates for versioned data: disabled

09:06:58,343         INFO SettingsFactory:189 - Scrollable result sets: enabled

09:06:58,343        DEBUG SettingsFactory:193 - Wrap result sets: disabled

09:06:58,343         INFO SettingsFactory:197 - JDBC3 getGeneratedKeys(): disabled

09:06:58,343         INFO SettingsFactory:205 - Connection release mode: auto

09:06:58,343         INFO SettingsFactory:223 - Default schema: RAPS

09:06:58,343         INFO SettingsFactory:232 - Default batch fetch size: 1

 

[ERROR] Failed to execute goal org.codehaus.mojo:hibernate3-maven-plugin:2.2:hbm2java (default-cli) on project foo: Execution default-cli of goal org.codehaus.mojo:hibernate3-maven-plugin:2.2:hbm2java failed: An association from the table FOO refers to an unmapped class: com.whatever.domain.Bar -> [Help 1]

 

Caused by: 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.codehaus.mojo.hibernate3.configuration.AbstractComponentConfiguration.getConfiguration(AbstractComponentConfiguration.java:57)

          at org.codehaus.mojo.hibernate3.HibernateExporterMojo.configureExporter(HibernateExporterMojo.java:200)

          at org.codehaus.mojo.hibernate3.exporter.Hbm2JavaGeneratorMojo.configureExporter(Hbm2JavaGeneratorMojo.java:64)

          at org.codehaus.mojo.hibernate3.HibernateExporterMojo.doExecute(HibernateExporterMojo.java:273)

          at org.codehaus.mojo.hibernate3.HibernateExporterMojo.execute(HibernateExporterMojo.java:152)

          at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)

          ... 20 more

 

I am using the following hibernate configuration:

 

hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver

hibernate.connection.url=jdbc:oracle:thin:@****

hibernate.connection.username=****

hibernate.connection.password=****

hibernate.dialect=org.hibernate.dialect.Oracle10gDialect

hibernate.default_schema=MY_SCHEMA

 

and the following reverse enginerring file:

 

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-reverse-engineering PUBLIC

  "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN"

  "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >

 

<hibernate-reverse-engineering>

      <schema-selection match-schema="MY_SCHEMA" />

</hibernate-reverse-engineering>

 

 

Hope that helps.

Reply to this message by going to Community

Start a new discussion in JBoss Tools at Community