-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate Tools reverse engineering misses relational tables
PostPosted: Tue Jun 01, 2010 9:01 am 
Newbie

Joined: Fri May 28, 2010 4:02 pm
Posts: 3
I'm running the latest hibernatetools with ant to automatically create presistent classes from an existing postgres 8.4 database schema. I'm trying to get 'tools' to do the whole job itself using just <jdbcconfiguration> and the exporters, i.e. I don't want to list all the tables by name in any files. (In fact I also use the ant build to create the hibernate.cfg.xml file.) From the doc this seems to be possible to do, but i'm beginning to wonder. My schema consists of about 50% relational tables, i.e. tables with only two columns of foreign keys referring to other (primary) tables in the schema. These relational tables have a compound primary key consisting of the two foreign keys. HbntTools correctly generates classes for all the primary tables, but I am unable, by any means, to force it to do so for the relational tables. :-(

I first tried this using Middlegen to do the first step of creating the *hbm.xml files, and using the hbm2java exporter to finish the task. This method *did* include all the relational tables as well as the primary ones and generated decent persistent classes for all. However, for a couple reasons I'd like to skip the extra Middlegen step and do the whole thing with 'tools' if that's actually possible.

I also run hbm2doc as part of the same ant task when I'm running the pure HbntTools method. It generates correct html doc for all the tables, *including the relational ones*, while the hbm2hbmxml exporter skips the same relational tables. Huh?????

Here are the relavant build.xml section and hibernate.properties file:
...
<target name="hibernatetool" description="run hibernate tool">
<taskdef
name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="toolslib"
/>

<hibernatetool destdir="${build.classes.dir}">

<!-- use one or the other of the following Hb configurations, not both -->

<!-- to make hibernatetool reverse engineered files, just run "ant hibernatetool" -->
<jdbcconfiguration
propertyfile="./hibernate.properties"
packagename="com.hp.procurve.mobilitymanager.metadata.persistence"
detectmanytomany="true"
/>
<hbm2hbmxml destdir="./pre-src" />
<hbm2doc />



<!-- to make middlegen reverse engineered files run "ant middlegen" first, then "ant hibernatetool"
with this configuration enabled and the others disabled.
This one is working with the rest of the xml for middlegen below
<configuration propertyfile="./hibernate.properties" >
<fileset dir="${build.gen-src.dir}/metadata/hibernate">
<include name="**/*.hbm.xml"/>
<exclude name="**/*Test.hbm.xml"/>
</fileset>
</configuration>
-->



<hbm2java jdk5="true" ejb3="true" />
<hbm2cfgxml ejb3="true" />

</hibernatetool>
</target>
....
_______________________________________________________________________

hibernate.default_schema=rev100525
hibernate.connection.driver_class=org.postgresql.Driver
hibernate.connection.password=XXXXXXXX
hibernate.connection.url=jdbc:postgresql://localhost:5432/metadata
hibernate.connection.username=metadata
hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
hibernate.show_sql=false

_______________________________________________________________________

I've fooled with <table-filter> in a reveng.xml file with no change in results (except to produce some runtime errors in HbntTool with certain attribute values. It's a bit buggy. )

What do I need to do to make hbm2hbmxml recognize and record the relational tables as well as the others? Is this something that HibernateTools actually can't do yet? Do I have to stick with the Middlegen two-step method?

TIA,

Jim


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

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.