Hi-
I'm having an issue with reverse engineering when I specify table filters. If I run without table filters the generated hbm files and pojos are absolutely perfect- all object associations (via foreign-key references) are generated. As soon as I use a table filter no object associations are generated. We have a fairly large schema at this point so requiring a full reverse engineer (which takes up to 17 minutes for some of our developers on a VPN) when only one or two tables have changed is a real issue.
Additionally we don't want to have to specify the foreign key refs by hand in the reveng file as that defeats the purpose of reverse engineering.
Note that we're using the hbmtemplate task for generating the hbm and pojos as well as a custom strategy that extends DelegatingReverseEngineeringStrategy. I'm not sure that would be the issue here since we are seeing the object associations generated when no table filters are used.
Is there a way to filter by table and still get the object associations generated in the hbm and pojo files? Are we missing something in our table filter?
-- just to make sure the custom reveng strategy and templates weren't to blame, I went back and did everything with a vanilla hibernate-tools reveng setup- default strategy and the templates right out of the jar and the standard ant tasks. I see the exact same behavior --
Thanks in advance for your help.
Here's the reveng file I'm using:
Code:
<?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="dev"/>
<type-mapping>
<sql-type jdbc-type="BIGINT" hibernate-type="java.lang.Long">
</sql-type>
<sql-type jdbc-type="BIT" hibernate-type="java.lang.Byte">
</sql-type>
<sql-type jdbc-type="INTEGER" hibernate-type="java.lang.Integer">
</sql-type>
<sql-type jdbc-type="TINYINT" hibernate-type="java.lang.Short">
</sql-type>
<sql-type jdbc-type="CHAR" hibernate-type="java.lang.String">
</sql-type>
<sql-type jdbc-type="CHAR" hibernate-type="java.lang.String"
length="1">
</sql-type>
</type-mapping>
<table-filter match-name="product_category"/>
</hibernate-reverse-engineering>
Here's the ant tasks:
Code:
<target name="reveng" depends="compile-hibernate">
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask">
<classpath refid="ant.class.path"/>
</taskdef>
<hibernatetool destdir="${root.dir}/generated">
<classpath refid="ant.class.path"/>
<!-- first, obtain the schema information using the datasource configured by
configuration file and then filter by schema/catalog/table using the
reveng.xml file. Also set up special handling of JDBC types in
reveng.xml -->
<jdbcconfiguration configurationfile="${root.dir}/build/hibernate/hibernate.cfg.xml"
packagename="com.web.dao"
revengfile="${root.dir}/build/hibernate/hibernate.reveng.xml"
reversestrategy="com.web.ant.ReverseEngineeringStrategy"
detectmanytomany="true">
</jdbcconfiguration>
<!-- invoke custom templates for generating hbm.xml files for
all tables reverse engineered in first step -->
<hbmtemplate
destdir="${root.dir}/generated"
filepattern="com/web/dao/{class-name}.hbm.xml"
templatepath="${root.dir}/build/hibernate/template"
templateprefix="hbm/"
template="hbm/hibernate-mapping.hbm.ftl">
<property key="jdk5" value="true"/>
<property key="ejb3" value="false"/>
</hbmtemplate>
<!-- based on generated hbm.xml files, generate
abstract pojo instances using custom templates -->
<hbmtemplate
destdir="${root.dir}/generated"
filepattern="com/web/dao/Abstract{class-name}.java"
templatepath="${root.dir}/build/hibernate/template/abstract"
templateprefix="pojo/"
template="pojo/Pojo.ftl">
<property key="jdk5" value="true"/>
<property key="ejb3" value="false"/>
<property key="parentClass" value="com.web.dao.DaoObject"/>
</hbmtemplate>
<!-- based on generated hbm.xml files, generate
concrete pojo instances using custom templates -->
<hbmtemplate
destdir="${root.dir}/generated"
filepattern="com/web/dao/{class-name}.java"
templatepath="${root.dir}/build/hibernate/template/concrete"
templateprefix="pojo/"
template="pojo/Pojo.ftl">
<property key="jdk5" value="true"/>
<property key="ejb3" value="false"/>
</hbmtemplate>
</hibernatetool>
Hibernate version:hibernate-tools-3.2.0.beta9 Name and version of the database you are using:mySQL 4.1.18-standard w/ InnoDBCode: