Java Reference
In-Depth Information
Table B-1. The Daughter Elements of the Hibernate Tools Task
Attribute
Description
classpath
The path to use when locating libraries and configuration files.
destDir
The base directory (relative to the build script's own base directory) into which
any generated output will be written.
templatePath
The path containing user-created template files (see the further discussion of
templates in the “Templates” section later in the chapter.)
Within the declared Hibernate task, a number of additional standard elements can be
created, consisting of a classpath declaration (an alternative to using the classpath attri-
bute), a set of configuration elements, and a set of exporter elements.
The classpath element and attribute are standard Ant features that allow you to bring
in any necessary resources used by the Hibernate tasks.
The clever bit of the Hibernate Ant task lies in the configuration elements. Declaring a
configuration task causes an appropriate configuration object to be built in memory. These
in-memory configuration objects all extend the standard org.hibernate.cfg.Configuration
class. The Configuration class represents the mapping relationships between entities (com-
bined with information from any configuration, properties, or reverse engineering files), and
it is this information, the metamodel, that is then used to generate the various output files.
The provided configuration elements can conjure up a Configuration object from the stan-
dard mapping files, from the metadata information gathered over a JDBC connection, and
from the annotations discussed in Chapter 6.
<target name="exportDDL" depends="compile">
<htools destdir="${sql}">
<annotationconfiguration
configurationfile="${src}/hibernate.cfg.xml"/>
</htools>
</target>
Within any given Hibernate Tools task, you can only have one configuration element con-
figured—normally, you would not want to generate output from two distinct representations
of the mapping information, so the single declaration is shared between the generation tasks
enclosed within the toolset task elements. The following list describes the configuration tasks
and the attributes of each:
<configuration> : Mapping relationships are generated from conventional XML-based
mapping files and information in a *.cfg.xml or *.properties file.
configurationfile : The name of the XML configuration file being used.
propertyfile : The name of the properties file being used.
entityresolver : The name of the SAX EntityResolver to use when resolving “exter-
nal” XML entities (rarely used).
namingstrategy : A naming strategy to use (see Chapter 3) to establish table names
from entity names.
Search WWH ::




Custom Search