Java Reference
In-Depth Information
Table B-2. Continued
Element
Description
<hbm2doc>
Generates HTML documentation for the database schema from the metamodel
<hbm2dao>
Generates standard DAOs from the metamodel
<hbmtemplate>
Generates arbitrary user-defined output from the metamodel
<query>
Runs arbitrary HQL queries against the database using the mapping information
in the metamodel
You may notice that the exporters available as Ant tasks correspond fairly closely to the
exporters available in the Hibernate Code Generation tool—largely because they rely upon
the same underlying implementations.
The two most commonly used tasks are <hbm2ddl> , which can generate a database
schema directly from the *.hbm.xml mapping files, and <hbm2hbmxml> , which, conversely, can
generate mapping files directly from the database.
The <hbm2ddl> element generates DDL scripts from the metamodel. These can be written
to a file—or, if the configuration object is provided with database connection details, they can
be run directly against the database. Table B-3 shows the attributes that can be supplied.
Table B-3. The Attributes Available to the <hbm2ddl> Element
Property
Default
Description
create
true
If set to true , causes the generated DDL to include commands to
create database objects. This allows to distinct tasks to be created:
one to drop all relevant database objects (using the drop attribute)
and the other to create them.
console
true
If set to true , causes the generated DDL to be displayed on the
console.
delimiter
;
Specifies the delimiter to be used to separate DDL statements.
destdir
If set, overrides, for this exporter only, the destination directory
specified on the tools task.
drop
false
If set to true , causes the generated DDL to include commands to drop
preexisting database objects before it tries to create them. This may
cause warning messages, depending upon the preexisting state of the
database; and it of course has the potential to destroy existing data.
export
true
If set to true , causes the DDL to be run directly against the data-
base (this has the potential to delete data—do not use carelessly).
format
false
If set to true , causes the generated DDL to be formatted using
whitespace in a more readable fashion. We recommend using this
option if you will be writing the DDL to a file.
haltonerror
false
If set to true , causes the script to halt if an error is encountered
while generating the DDL (typically, this is used while exporting
directly to the database to increase the visibility of any problems
encountered while setting up the schema).
outputfilename
Specifies the name of the file name that the generated DDL should
be stored in. If left unset, the generated DDL will not be stored.
update
false
Indicates that the tool should attempt to generate the appropriate
statements to bring the existing schema inline with the model. We
don't recommend using this option.
Search WWH ::




Custom Search