Java Reference
In-Depth Information
<hibernate-reverse-engineering>
<table-filter match-schema="PUBLIC" match-name="NOTE"/>
<table-filter match-schema="PUBLIC" match-name="NOTEPAD"/>
<table-filter match-schema="PUBLIC" match-name="NOTEPAD_NOTE"/>
</hibernate-reverse-engineering>
The reverse engineering file in the preceding code limits the tables to be used when gen-
erating the mapping information from the schema to the three explicitly named tables ( NOTE ,
NOTEPAD , and NOTEPAD_NOTE ) in the database's public schema.
A reverse engineering file always consists of a single top-level <hibernate-reverse-
engineering> element containing various additional elements. These daughter elements are
given in order in Table B-10:
Table B-10. The Elements Used in Configuring the Reverse Engineering File
Element
Cardinality
Description
<schema-selection>
Zero or more
Allows the reverse engineering process to be limited
by catalog, schema, and table name
<type-mapping>
Zero or one
Allows you to override the default mapping between
database types and Java types
<table-filter>
Zero or more
Allows you to include or exclude tables by catalog
name, schema name, and table name, and allows
them to be grouped into a particular package
<table>
Zero or more
Allows you to override the default mappings of tables
into entities
Rather than trying to exhaustively specify the syntax of a reverse engineering file, which is
anyway available through the DTD at http://hibernate.sourceforge.net/hibernate-reverse-
engineering-3.0.dtd , we think it is easier to follow the basic requirements of the file format
with some examples of valid <schema-selection> , <type-mapping> , <table-filter> , and <table>
elements.
Our first example specifies the following rule: tables should only be used for reverse engi-
neering if they are in the public schema and their names begin with NOTE :
<schema-selection match-schema="PUBLIC" match-table="NOTE*"/>
Our next example enforces a rule that database INTEGER types for which the column is
specified as NOT NULL must be represented using Hibernate's int type. It also enforces a rule
that database VARCHAR types that have a specified length of 250 should be treated as Hibernate
string types.
<type-mapping>
<sql-type jdbc-type="INTEGER" hibernate-type="int" not-null="true"/>
<sql-type jdbc-type="VARCHAR" hibernate-type="string" length="250"/>
</type-mapping>
These type mappings apply throughout the reverse engineering process—you cannot
specify them on a per-table basis using the <type-mapping> element, but you can using the
<table> element.
Search WWH ::




Custom Search