Discussion:
[Middlegen-user] Middlegen couldn't find any relations between any table
Zhao, John
2004-10-25 08:43:02 UTC
Permalink
Hi all,

Could anybody know what else do I need to set to have Middlegen works
with the table relationships (Swing GUI not show any relationship). I
just tested out with Oracle9i Scott/Tiger as:


<?xml version="1.0"?>

<!-- ===================================================================
-->
<!-- Fails if XDoclet 1.2.x is not on classpath
-->
<!-- ===================================================================
-->
<project name="test" default="init" basedir=".">

<property file="${user.home}/build.properties"/>
<property file="${basedir}/build.properties"/>
<property name="middlegen.home"
value="${basedir}/.."/>
<property name="xdoclet.version" value="1.2"/>

<property name="name" value="airline"/>

<!-- This was added because we were several people (in a course)
deploying to same app server>
<property environment="env"/>
<property name="unique.name"
value="${name}.${env.COMPUTERNAME}"/-->

<property name="unique.name" value="${name}"/>

<property name="appxml.src.file"
value="${basedir}/src/application.xml"/>
<property name="lib.dir"
value="${basedir}/lib"/>

<property name="src.dir"
value="${basedir}/src"/>
<property name="java.src.dir"
value="${src.dir}/java"/>
<property name="web.src.dir"
value="${src.dir}/web"/>

<property name="build.dir"
value="${basedir}/build"/>
<property name="build.java.dir"
value="${build.dir}/java"/>
<property name="build.gen-src.dir"
value="${build.dir}/gen-src"/>
<property name="build.gen-webui.dir"
value="${build.dir}/gen-webui"/>
<property name="build.classes.dir"
value="${build.dir}/classes"/>
<property name="build.ejb-meta.dir"
value="${build.dir}/ejb-meta"/>
<property name="build.web-meta.dir"
value="${build.dir}/web-meta"/>
<property name="build.gen-torque-schema.dir"
value="${build.dir}/torque"/>
<property name="build.gen-torque-conf.dir"
value="${build.dir}/torque-conf"/>

<property name="ear.dir"
value="${build.dir}/ear"/>
<property name="ear.file"
value="${ear.dir}/${unique.name}.ear"/>
<property name="ear.meta.dir"
value="${build.dir}/ear-meta"/>

<property name="ejb.dir"
value="${build.dir}/ejb"/>
<property name="ejb.jar.file"
value="${ejb.dir}/${unique.name}-ejb.jar"/>

<property name="build.sar-meta.dir"
value="${build.dir}/sar-meta"/>
<property name="build.sar.dir"
value="${build.dir}/sar"/>
<property name="sar.file"
value="${build.sar.dir}/${unique.name}-hibernate.sar"/>

<property name="war.dir"
value="${build.dir}/war"/>
<property name="war.file"
value="${war.dir}/${unique.name}-web.war"/>

<property name="build.html.dir"
value="${build.dir}/html"/>
<property name="build.jdo.dir"
value="${build.dir}/jdo"/>
<property name="build.xmi.dir"
value="${build.dir}/xmi"/>

<property name="actionlayer.plugin" value="struts"/>
<property name="persistencelayer.plugin" value="cmp20"/>

<!--
-->

<property file="${basedir}/build.properties"/>
<property name="lib.dir" value="${basedir}/lib"/>
<property name="build.gen-src.dir"
value="${build.dir}/gen-src"/>

<property name="database.driver.file"
value="${lib.dir}/classes12.jar"/>
<property name="database.driver.classpath"
value="${database.driver.file}"/>
<property name="database.driver"
value="oracle.jdbc.driver.OracleDriver" />
<property name="database.url"
value="jdbc:oracle:thin:@hxddba01:1521:mp9u" />
<property name="database.userid"
value="scott"/>
<property name="database.password"
value="tiger"/>
<property name="database.schema"
value="SCOTT"/>
<!-- ===================================================================
-->
<!-- Fails if XDoclet 1.2.x is not on classpath
-->
<!-- ===================================================================
-->
<path id="lib.class.path">
<pathelement path="${basedir}"/>
<pathelement path="${database.driver.classpath}"/>
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
<!-- The middlegen jars -->
<fileset dir="${middlegen.home}">
<include name="*.jar"/>
</fileset>
</path>


<target name="init">
<mkdir dir="${build}"/>
<mkdir dir="${build.classes.dir}"/>
</target>


<!--
=================================================================== -->
<!-- Run Middlegen
-->
<!--
=================================================================== -->
<target
name="middlegen"
description="Run Middlegen"
unless="middlegen.skip"
<!--

depends="init,fail-if-no-xdoclet-1.2,check-driver-present,panic-if-drive
r-not-present"
-->
<mkdir dir="${build.gen-src.dir}"/>

<taskdef
name="middlegen"
classname="middlegen.MiddlegenTask"
classpathref="lib.class.path"
/>

<middlegen
appname="${name}"
prefsdir="${src.dir}"
gui="${gui}"
databaseurl="${database.url}"
initialContextFactory="${java.naming.factory.initial}"
providerURL="${java.naming.provider.url}"
datasourceJNDIName="${datasource.jndi.name}"
driver="${database.driver}"
username="${database.userid}"
password="${database.password}"
schema="${database.schema}"
catalog="${database.catalog}"
<html destination="${build.html.dir}">
<!--
We can override the plugin's templates
by specifying the id of the original template
and providing a new one from the file system.

Uncomment the line below to see it in action.
(This technique can be used for all plugins).
-->
<!--fileproducer
id="single-table"
template="${basedir}/src/templates/single-table.vm"
/-->
</html>


<hibernate
destination="${build.gen-src.dir}"
package="${name}.hibernate"
genXDocletTags="true"
/>

</middlegen>

<mkdir dir="${build.classes.dir}"/>
</target>

<target name="hbm2java" description="Generate .java from .hbm
files.">
<taskdef
name="hbm2java"
classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
classpathref="lib.class.path"
/>

<hbm2java output="${build.gen-src.dir}">
<fileset dir="${build.gen-src.dir}">
<include name="**/*.hbm.xml"/>
</fileset>
</hbm2java>
</target>
</project>

My Ant output always complains:
: Middlegen couldn't find any relations between any tables. This may be
intentio
nal from the design of the database, but it may also be because you have
incorre
ctly defined the relationships. It could also be because the JDBC driver
you're
using doesn't correctly implement DatabaseMetaData. See the samples (for
an exam
ple on how to define relationships) and verify that your driver
correctly implem
ents DatabaseMetaData.

Anybody now why?
Thanks in advance!
John
***@amfam.com
Eivind Waaler
2004-10-25 09:59:05 UTC
Permalink
Middlegen reads the relationships from the DatabaseMetaData object gotten
from the getMetaData() method of the jdbc connection. When the
relationships are not found this is usually one of these two reasons:

- Your database does not have relationsships set up with foreign keys,
these are needed for the driver to be able to report the foreign keys
exported by a table (and show us the relationships).

- The jdbc driver doesn't support DatabaseMetaData in a proper way. Many
people are using Oracle, so I don't think this is very likely. You could
try with a different version of the driver, just to make sure.

.eivind
Post by Zhao, John
Hi all,
Could anybody know what else do I need to set to have Middlegen works
with the table relationships (Swing GUI not show any relationship). I
<?xml version="1.0"?>
<!-- ===================================================================
-->
<!-- Fails if XDoclet 1.2.x is not on classpath
-->
<!-- ===================================================================
-->
<project name="test" default="init" basedir=".">
<property file="${user.home}/build.properties"/>
<property file="${basedir}/build.properties"/>
<property name="middlegen.home"
value="${basedir}/.."/>
<property name="xdoclet.version" value="1.2"/>
<property name="name" value="airline"/>
<!-- This was added because we were several people (in a course)
deploying to same app server>
<property environment="env"/>
<property name="unique.name"
value="${name}.${env.COMPUTERNAME}"/-->
<property name="unique.name" value="${name}"/>
<property name="appxml.src.file"
value="${basedir}/src/application.xml"/>
<property name="lib.dir"
value="${basedir}/lib"/>
<property name="src.dir"
value="${basedir}/src"/>
<property name="java.src.dir"
value="${src.dir}/java"/>
<property name="web.src.dir"
value="${src.dir}/web"/>
<property name="build.dir"
value="${basedir}/build"/>
<property name="build.java.dir"
value="${build.dir}/java"/>
<property name="build.gen-src.dir"
value="${build.dir}/gen-src"/>
<property name="build.gen-webui.dir"
value="${build.dir}/gen-webui"/>
<property name="build.classes.dir"
value="${build.dir}/classes"/>
<property name="build.ejb-meta.dir"
value="${build.dir}/ejb-meta"/>
<property name="build.web-meta.dir"
value="${build.dir}/web-meta"/>
<property name="build.gen-torque-schema.dir"
value="${build.dir}/torque"/>
<property name="build.gen-torque-conf.dir"
value="${build.dir}/torque-conf"/>
<property name="ear.dir"
value="${build.dir}/ear"/>
<property name="ear.file"
value="${ear.dir}/${unique.name}.ear"/>
<property name="ear.meta.dir"
value="${build.dir}/ear-meta"/>
<property name="ejb.dir"
value="${build.dir}/ejb"/>
<property name="ejb.jar.file"
value="${ejb.dir}/${unique.name}-ejb.jar"/>
<property name="build.sar-meta.dir"
value="${build.dir}/sar-meta"/>
<property name="build.sar.dir"
value="${build.dir}/sar"/>
<property name="sar.file"
value="${build.sar.dir}/${unique.name}-hibernate.sar"/>
<property name="war.dir"
value="${build.dir}/war"/>
<property name="war.file"
value="${war.dir}/${unique.name}-web.war"/>
<property name="build.html.dir"
value="${build.dir}/html"/>
<property name="build.jdo.dir"
value="${build.dir}/jdo"/>
<property name="build.xmi.dir"
value="${build.dir}/xmi"/>
<property name="actionlayer.plugin" value="struts"/>
<property name="persistencelayer.plugin" value="cmp20"/>
<!--
-->
<property file="${basedir}/build.properties"/>
<property name="lib.dir" value="${basedir}/lib"/>
<property name="build.gen-src.dir"
value="${build.dir}/gen-src"/>
<property name="database.driver.file"
value="${lib.dir}/classes12.jar"/>
<property name="database.driver.classpath"
value="${database.driver.file}"/>
<property name="database.driver"
value="oracle.jdbc.driver.OracleDriver" />
<property name="database.url"
<property name="database.userid"
value="scott"/>
<property name="database.password"
value="tiger"/>
<property name="database.schema"
value="SCOTT"/>
<!-- ===================================================================
-->
<!-- Fails if XDoclet 1.2.x is not on classpath
-->
<!-- ===================================================================
-->
<path id="lib.class.path">
<pathelement path="${basedir}"/>
<pathelement path="${database.driver.classpath}"/>
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
<!-- The middlegen jars -->
<fileset dir="${middlegen.home}">
<include name="*.jar"/>
</fileset>
</path>
<target name="init">
<mkdir dir="${build}"/>
<mkdir dir="${build.classes.dir}"/>
</target>
<!--
=================================================================== -->
<!-- Run Middlegen
-->
<!--
=================================================================== -->
<target
name="middlegen"
description="Run Middlegen"
unless="middlegen.skip"
<!--
depends="init,fail-if-no-xdoclet-1.2,check-driver-present,panic-if-drive
r-not-present"
-->
<mkdir dir="${build.gen-src.dir}"/>
<taskdef
name="middlegen"
classname="middlegen.MiddlegenTask"
classpathref="lib.class.path"
/>
<middlegen
appname="${name}"
prefsdir="${src.dir}"
gui="${gui}"
databaseurl="${database.url}"
initialContextFactory="${java.naming.factory.initial}"
providerURL="${java.naming.provider.url}"
datasourceJNDIName="${datasource.jndi.name}"
driver="${database.driver}"
username="${database.userid}"
password="${database.password}"
schema="${database.schema}"
catalog="${database.catalog}"
<html destination="${build.html.dir}">
<!--
We can override the plugin's templates
by specifying the id of the original template
and providing a new one from the file system.
Uncomment the line below to see it in action.
(This technique can be used for all plugins).
-->
<!--fileproducer
id="single-table"
template="${basedir}/src/templates/single-table.vm"
/-->
</html>
<hibernate
destination="${build.gen-src.dir}"
package="${name}.hibernate"
genXDocletTags="true"
/>
</middlegen>
<mkdir dir="${build.classes.dir}"/>
</target>
<target name="hbm2java" description="Generate .java from .hbm
files.">
<taskdef
name="hbm2java"
classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
classpathref="lib.class.path"
/>
<hbm2java output="${build.gen-src.dir}">
<fileset dir="${build.gen-src.dir}">
<include name="**/*.hbm.xml"/>
</fileset>
</hbm2java>
</target>
</project>
: Middlegen couldn't find any relations between any tables. This may be
intentio
nal from the design of the database, but it may also be because you have
incorre
ctly defined the relationships. It could also be because the JDBC driver
you're
using doesn't correctly implement DatabaseMetaData. See the samples (for
an exam
ple on how to define relationships) and verify that your driver
correctly implem
ents DatabaseMetaData.
Anybody now why?
Thanks in advance!
John
Zhao, John
2004-10-25 21:58:01 UTC
Permalink
Thank you Eivind.

You are right, I found out that relationships for Scott/Tiger was not
setup by our DBA.

Thanks a lot!
John


-----Original Message-----
From: Eivind Waaler [mailto:***@tihlde.org]
Sent: Monday, October 25, 2004 6:58 AM
To: middlegen-***@lists.sourceforge.net
Cc: Zhao, John
Subject: Re: [Middlegen-user] Middlegen couldn't find any relations
between any table


Middlegen reads the relationships from the DatabaseMetaData object
gotten
from the getMetaData() method of the jdbc connection. When the
relationships are not found this is usually one of these two reasons:

- Your database does not have relationsships set up with foreign keys,
these are needed for the driver to be able to report the foreign keys
exported by a table (and show us the relationships).

- The jdbc driver doesn't support DatabaseMetaData in a proper way. Many
people are using Oracle, so I don't think this is very likely. You could
try with a different version of the driver, just to make sure.

.eivind
Post by Zhao, John
Hi all,
Could anybody know what else do I need to set to have Middlegen works
with the table relationships (Swing GUI not show any relationship). I
<?xml version="1.0"?>
<!--
===================================================================
Post by Zhao, John
-->
<!-- Fails if XDoclet 1.2.x is not on classpath
-->
<!--
===================================================================
Post by Zhao, John
-->
<project name="test" default="init" basedir=".">
<property file="${user.home}/build.properties"/>
<property file="${basedir}/build.properties"/>
<property name="middlegen.home"
value="${basedir}/.."/>
<property name="xdoclet.version" value="1.2"/>
<property name="name" value="airline"/>
<!-- This was added because we were several people (in a course)
deploying to same app server>
<property environment="env"/>
<property name="unique.name"
value="${name}.${env.COMPUTERNAME}"/-->
<property name="unique.name" value="${name}"/>
<property name="appxml.src.file"
value="${basedir}/src/application.xml"/>
<property name="lib.dir"
value="${basedir}/lib"/>
<property name="src.dir"
value="${basedir}/src"/>
<property name="java.src.dir"
value="${src.dir}/java"/>
<property name="web.src.dir"
value="${src.dir}/web"/>
<property name="build.dir"
value="${basedir}/build"/>
<property name="build.java.dir"
value="${build.dir}/java"/>
<property name="build.gen-src.dir"
value="${build.dir}/gen-src"/>
<property name="build.gen-webui.dir"
value="${build.dir}/gen-webui"/>
<property name="build.classes.dir"
value="${build.dir}/classes"/>
<property name="build.ejb-meta.dir"
value="${build.dir}/ejb-meta"/>
<property name="build.web-meta.dir"
value="${build.dir}/web-meta"/>
<property name="build.gen-torque-schema.dir"
value="${build.dir}/torque"/>
<property name="build.gen-torque-conf.dir"
value="${build.dir}/torque-conf"/>
<property name="ear.dir"
value="${build.dir}/ear"/>
<property name="ear.file"
value="${ear.dir}/${unique.name}.ear"/>
<property name="ear.meta.dir"
value="${build.dir}/ear-meta"/>
<property name="ejb.dir"
value="${build.dir}/ejb"/>
<property name="ejb.jar.file"
value="${ejb.dir}/${unique.name}-ejb.jar"/>
<property name="build.sar-meta.dir"
value="${build.dir}/sar-meta"/>
<property name="build.sar.dir"
value="${build.dir}/sar"/>
<property name="sar.file"
value="${build.sar.dir}/${unique.name}-hibernate.sar"/>
<property name="war.dir"
value="${build.dir}/war"/>
<property name="war.file"
value="${war.dir}/${unique.name}-web.war"/>
<property name="build.html.dir"
value="${build.dir}/html"/>
<property name="build.jdo.dir"
value="${build.dir}/jdo"/>
<property name="build.xmi.dir"
value="${build.dir}/xmi"/>
<property name="actionlayer.plugin" value="struts"/>
<property name="persistencelayer.plugin" value="cmp20"/>
<!--
-->
<property file="${basedir}/build.properties"/>
<property name="lib.dir" value="${basedir}/lib"/>
<property name="build.gen-src.dir"
value="${build.dir}/gen-src"/>
<property name="database.driver.file"
value="${lib.dir}/classes12.jar"/>
<property name="database.driver.classpath"
value="${database.driver.file}"/>
<property name="database.driver"
value="oracle.jdbc.driver.OracleDriver" />
<property name="database.url"
<property name="database.userid"
value="scott"/>
<property name="database.password"
value="tiger"/>
<property name="database.schema"
value="SCOTT"/>
<!--
===================================================================
Post by Zhao, John
-->
<!-- Fails if XDoclet 1.2.x is not on classpath
-->
<!--
===================================================================
Post by Zhao, John
-->
<path id="lib.class.path">
<pathelement path="${basedir}"/>
<pathelement path="${database.driver.classpath}"/>
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
<!-- The middlegen jars -->
<fileset dir="${middlegen.home}">
<include name="*.jar"/>
</fileset>
</path>
<target name="init">
<mkdir dir="${build}"/>
<mkdir dir="${build.classes.dir}"/>
</target>
<!--
===================================================================
-->
Post by Zhao, John
<!-- Run Middlegen
-->
<!--
===================================================================
-->
Post by Zhao, John
<target
name="middlegen"
description="Run Middlegen"
unless="middlegen.skip"
<!--
depends="init,fail-if-no-xdoclet-1.2,check-driver-present,panic-if-drive
Post by Zhao, John
r-not-present"
-->
<mkdir dir="${build.gen-src.dir}"/>
<taskdef
name="middlegen"
classname="middlegen.MiddlegenTask"
classpathref="lib.class.path"
/>
<middlegen
appname="${name}"
prefsdir="${src.dir}"
gui="${gui}"
databaseurl="${database.url}"
initialContextFactory="${java.naming.factory.initial}"
providerURL="${java.naming.provider.url}"
datasourceJNDIName="${datasource.jndi.name}"
driver="${database.driver}"
username="${database.userid}"
password="${database.password}"
schema="${database.schema}"
catalog="${database.catalog}"
<html destination="${build.html.dir}">
<!--
We can override the plugin's templates
by specifying the id of the original template
and providing a new one from the file system.
Uncomment the line below to see it in action.
(This technique can be used for all plugins).
-->
<!--fileproducer
id="single-table"
template="${basedir}/src/templates/single-table.vm"
/-->
</html>
<hibernate
destination="${build.gen-src.dir}"
package="${name}.hibernate"
genXDocletTags="true"
/>
</middlegen>
<mkdir dir="${build.classes.dir}"/>
</target>
<target name="hbm2java" description="Generate .java from .hbm
files.">
<taskdef
name="hbm2java"
classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
classpathref="lib.class.path"
/>
<hbm2java output="${build.gen-src.dir}">
<fileset dir="${build.gen-src.dir}">
<include name="**/*.hbm.xml"/>
</fileset>
</hbm2java>
</target>
</project>
: Middlegen couldn't find any relations between any tables. This may
be
Post by Zhao, John
intentio
nal from the design of the database, but it may also be because you
have
Post by Zhao, John
incorre
ctly defined the relationships. It could also be because the JDBC
driver
Post by Zhao, John
you're
using doesn't correctly implement DatabaseMetaData. See the samples
(for
Post by Zhao, John
an exam
ple on how to define relationships) and verify that your driver
correctly implem
ents DatabaseMetaData.
Anybody now why?
Thanks in advance!
John
Loading...