Hello,
I have a problem using Hibernate Tools for reverse engineering. The one-side of a one-to-many-relation should not have a "Set<ManySideType>" inside.
Every entityA class that is generated has a Set of entitiyB that reference entityA. Have a look at these example tables:
Code:
---------------------------
Person
id name fk_car_id
---------------------------
---------------------------
Car
id name
---------------------------
My Person entity hast an attribute "Car car;" that is exactly what I want. But on the other side the Car entity has a "Set<Person> person" in that case I don't want the Set inside.
How do I tell Hibernate Tools to leave out the Sets of the one-side in a one-to-many-relation?Overwriting (one of) the following methods in the ReverseEngineeringStrategy doesn't help. This has side effects:
Code:
@Override
// removes ALL Sets
public boolean excludeForeignKeyAsCollection(String arg0, TableIdentifier arg1, List arg2, TableIdentifier arg3, List arg4) {
return super.excludeForeignKeyAsCollection(arg0, arg1, arg2, arg3, arg4);
}
@Override
// doesn't work either
public boolean excludeForeignKeyAsManytoOne(String arg0, TableIdentifier arg1, List arg2, TableIdentifier arg3, List arg4) {
return super.excludeForeignKeyAsManytoOne(arg0, arg1, arg2, arg3, arg4);
}
The most improtant part of my ant-build (I am using a template as well):
Code:
<jdbcconfiguration configurationfile="${src}/hibernate.cfg.xml"
reversestrategy="org.revengstrategy.MyReverseEngineeringStrategy"
revengfile="${buildconfig}/hibernate.reveng.xml"
packagename= "org.entity"/>
<!-- Generate entities -->
<hbmtemplate
templateprefix=""
filepattern="../entity/{class-name}.java"
templatepath="${templatepath}/entity"
template="Pojo.ftl" >
<property key="jdk5" value="true" />
<property key="ejb3" value="false" />
</hbmtemplate>