-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Adding one-to-many, many-to-one relationship in reveng
PostPosted: Wed May 30, 2007 11:28 pm 
Newbie

Joined: Wed May 30, 2007 10:34 pm
Posts: 3
Hibernate version: 3.2, Hibernate Tools 3.2.0.beta9a for Exclipse

Name and version of the database you are using: Oracle 9i

Hi,

I'm trying to reverse engineer from a database and add a one-to-many relationship where the foreign key is missing.

Code:
class RvsInstallation

  ... lots of mappings ...

  Set<RvsYearly> getRvsYearlies()

class RvsYearly

  ... lots of mappings ...

  RvsInstallation getRvsInstallation()

The primary key on RvsInstallation is RVS_INSTALLATION.INSTL_NO and I want it to join to RVS_YEARLY.INSTL_NO (which is part of the composite primary key, if that makes a difference.)

My best attempt:

Code:
<hibernate-reverse-engineering>
    <type-mapping>
        <sql-type jdbc-type="VARCHAR" hibernate-type="yes_no" length="1"></sql-type>
    </type-mapping>

    <table-filter match-name="RVS_.*" match-schema="ANDY"></table-filter>

    <table name="RVS_YEARLY">
        <foreign-key foreign-table="RVS_INSTALLATION">
            <set property="rvsInstallation"/>
        </foreign-key>
    </table>

</hibernate-reverse-engineering>

produces the correct mappings in Java and the hbm.xml files but is missing the key/columns in the xml as you'd expect.

I can't figure out how to configure the column-refs, as adding:

Code:
            <column-ref local-column="INSTL_NO" foreign-column="INSTL_NO"/>


Produces:

Code:
org.hibernate.tool.hbm2x.ExporterException: Error while processing template doc/tables/table.ftl
  freemarker.template.TemplateModelException: Method public java.lang.String org.hibernate.tool.hbm2x.doc.DocFileManager.getRef(org.hibernate.tool.hbm2x.doc.DocFile,org.hibernate.tool.hbm2x.doc.DocFile) threw an exception when invoked on org.hibernate.tool.hbm2x.doc.DocFileManager@aa034b
    freemarker.template.TemplateModelException: Method public java.lang.String org.hibernate.tool.hbm2x.doc.DocFileManager.getRef(org.hibernate.tool.hbm2x.doc.DocFile,org.hibernate.tool.hbm2x.doc.DocFile) threw an exception when invoked on org.hibernate.tool.hbm2x.doc.DocFileManager@aa034b
    java.lang.IllegalArgumentException: To cannot be null.


Can anyone help?

Much appreciated,
Andy.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 31, 2007 2:05 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
remove the hbm2doc generation and let me know if it still fails.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 31, 2007 3:02 am 
Newbie

Joined: Wed May 30, 2007 10:34 pm
Posts: 3
Nice one, it worked.

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 31, 2007 3:40 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
ok - could you then be so kind and create a testcase and report a bug against hbm2doc ? thanks ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.