Java Reference
In-Depth Information
The <table-filter> element allows you to include and exclude groups of tables from
the mapping process on the basis of pattern matches on their names. Where the <schema-
selection> element allows you to specify a set of tables matching a single pattern to be reverse
engineered, the <table-filter> element operates within this and allows multiple patterns to
be applied to include and exclude tables. Here's an example:
<table-filter match-name="NOTEPAD_ARCHIVE*" exclude="true"/>
Although the previous <schema-selection> element included all tables within the current
schema that matched the pattern NOTE* , this table filter excludes any tables that match the
pattern NOTEPAD_ARCHIVE* from reverse engineering. Table filters are applied in order, so using
this technique, you can build up a filter that only includes a specific set of tables.
The <table> task permits almost total control over the mapping details of the entity. You
can select a specific table by catalog, schema, and name. You can specify the class name that
it should take, how the primary key column(s) relate to that class's properties, the primary
key generator that it should use, the column types and properties that they are associated
with, and the details of the associations formed by foreign key relationships. Our simple
example places the generated entity into an appropriate class, with a nonstandard primary
key property name and a nonstandard type mapping for one of the columns ( note ). It also
excludes one of the columns ( audit ) from the entity model.
<table schema="PUBLIC"
name="NOTEPAD"
class="com.hibernatebook.tools.Notepad">
<primary-key>
<column name="id"
jdbc-type="INTEGER"
property="notepadPk"
type="int"/>
</primary-key>
<column name="note" jdbc-type="VARCHAR" type="char" property="note"/>
<column name="audit" exclude="true"/>
</table>
If it looks like you will have to manage the reverse engineering process to this level of
detail, it may in fact be more appropriate to create some or all of the mapping files manually,
which gives you total control over the specification of those entities. Complex specification of
mapping information in the reverse engineering file is really only appropriate if it is for excep-
tional classes when the general cases are common; or if you expect to need to regenerate the
model from the schema very frequently in response to changes in the schema details.
Templates
With the exception of <hbmtemplate> and <query> , all the Ant exporter tasks take the meta-
model information from the configuration, pass it to a set of FreeMarker templates, and write
the output to files. For more information on the FreeMarker template scripting language, see
the FreeMarker site at http://freemarker.sourceforge.net .
Search WWH ::




Custom Search