it is a good approach and along the lines that I'm considering.
Points to consider:
It is not just entities that should/could be filtered; its also tables for e.g. hbm2ddl or both for hbm2doc.
The filter should be possible to define globally, but also locally per exporter since each exporter can have their own foreach attribute set.
Try and mimick ant resource collection/electors/filesets mechanism to make it more "natural"
...and finally, what is the filter on ? Is the filter on the input or the output ?
e.g. hbm2java process entities in the hbm model, and outputs the pojo for this entity - but it could be generating other things. I think the filter should be on the input; e.g. filtering the entities, components, tables etc.
One possible way of handling theses could be:
Code:
<hibernatetool destdir="${source.generated}">
<classpath>
<pathelement location="${libraries}"/>
<pathelement location="${compile.target.dir}"/>
<pathelement location="${install.interal.mapping.dir}"/>
</classpath>
<configuration configurationfile="${etc.dir}/hibernate.cfg.xml"/>
<filter> <!-- filter is not a good name since it means a different thing under ant, maybe restrict? -->
<table name="CUST.*"/>
<entity name="org.model.*"/>
</filter>
<hbm2java>
<filter>
<entity name=".*.customer.*"/> <!-- only the customer part of the model -->
</filter>
</hbm2java>
</hibernatetool>
The filters would be chained and be available inside the templates to be able to do filtering from more customized templates.
Thoughts?