Author: mcaspers
Date: 2011-03-02 18:34:47 -0500 (Wed, 02 Mar 2011)
New Revision: 29455
Removed:
trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins.xml
trunk/hibernatetools/docs/reference/en-US/master.xml
trunk/hibernatetools/docs/reference/en-US/master_output.xml
Modified:
trunk/hibernatetools/docs/reference/en-US/codegenarchitecture.xml
trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_0.png
trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_0_a.png
trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_0_b.png
trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_1.png
trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_2.png
trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_2_a.png
trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_3.png
trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_4_a.png
trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_4_b.png
trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_4_c.png
trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_4_d.png
trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_5.png
trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_6.png
trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_7.png
trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_8.png
trunk/hibernatetools/docs/reference/en-US/introduction.xml
trunk/hibernatetools/docs/reference/en-US/plugins.xml
Log:
updated images and general editing
Modified: trunk/hibernatetools/docs/reference/en-US/codegenarchitecture.xml
===================================================================
--- trunk/hibernatetools/docs/reference/en-US/codegenarchitecture.xml 2011-03-02 22:58:02
UTC (rev 29454)
+++ trunk/hibernatetools/docs/reference/en-US/codegenarchitecture.xml 2011-03-02 23:34:47
UTC (rev 29455)
@@ -3,36 +3,36 @@
<title>Code generation architecture</title>
<para>
- The code generation mechanism in <productname>Hibernate Tools</productname>
consists of a few core concepts. This section explains their overall structure, which are
the same for the <productname>Ant</productname> and
<productname>Eclipse</productname> tools.
+ The code generation mechanism in <productname>Hibernate Tools</productname>
consists of a few core concepts. This section explains their overall structure, which is
the same for the <productname>Ant</productname> and
<productname>Eclipse</productname> tools.
</para>
<section>
<title>Hibernate Meta Model</title>
<para>
- The meta model is the model used by <productname>Hibernate
Core</productname> to perform its object relational mapping. The model includes
information about tables, columns, classes, properties, components, values, collections
etc. The API is in the <code>org.hibernate.mapping</code> package and its main
entry point is the <code>Configuration</code> class, the same class that is
used to build a session factory.
+ The meta model is the model used by <productname>Hibernate
Core</productname> to perform its object relational mapping. The model includes
information about tables, columns, classes, properties, components, values, collections
etc. The API is in the <code>org.hibernate.mapping</code> package and its main
entry point is the <code>Configuration</code> class: the same class that is
used to build a session factory.
</para>
<para>
- The model represented by the <code>Configuration</code> class can be built
in many ways, which are listed below.
+ The model represented by the <code>Configuration</code> class can be built
in many ways:
</para>
<para>
<itemizedlist>
<listitem>
<para>
- A Core configuration uses <productname>Hibernate Core</productname> and
supports reading <filename>hbm.xml</filename> files, and requires a
<filename>hibernate.cfg.xml</filename> file. This is referred to as
<productname>core</productname> in Eclipse and
<code><configuration></code> in Ant.
+ A Core configuration uses <productname>Hibernate Core</productname> and
supports reading <filename>hbm.xml</filename> files, and requires a
<filename>hibernate.cfg.xml</filename> file. This is referred to as
<emphasis>Core</emphasis> in Eclipse and
<code><configuration></code> in Ant.
</para>
</listitem>
<listitem>
<para>
- An Annotation configuration uses <productname>Hibernate
Annotations</productname> and supports <filename>hbm.xml</filename>
files and annotated classes, and requires a
<filename>hibernate.cfg.xml</filename> file. This is referred to as
<productname>annotations</productname> in Eclipse and
<code><annotationconfiguration></code> in Ant.</para>
+ An Annotation configuration uses <productname>Hibernate
Annotations</productname>, supports <filename>hbm.xml</filename> files
and annotated classes, and requires a <filename>hibernate.cfg.xml</filename>
file. This is referred to as <emphasis>Annotations</emphasis> in Eclipse and
<code><annotationconfiguration></code> in Ant.</para>
</listitem>
<listitem>
<para>
- A JPA configuration uses a <productname>Hibernate
EntityManager</productname> and supports <filename>hbm.xml</filename>
files and annotated classes, and requires that the project has a
<filename>META-INF/persistence.xml</filename> file in its classpath. This is
referred to as <productname>JPA</productname> in Eclipse and
<code><jpaconfiguration></code> in Ant.</para>
+ A JPA configuration uses a <productname>Hibernate
EntityManager</productname> and supports <filename>hbm.xml</filename>
files and annotated classes, and requires that the project has a
<filename>META-INF/persistence.xml</filename> file in its classpath. This is
referred to as <emphasis>JPA</emphasis> in Eclipse and
<code><jpaconfiguration></code> in Ant.</para>
</listitem>
<listitem>
@@ -43,12 +43,12 @@
</para>
<para>
- In most projects you will normally use only one of the Core, Annotation or JPA
configuration and possibly the JDBC configuration if you are using the reverse engineering
facilities of <productname>Hibernate Tools</productname>.
+ In most projects you will normally use only one of the
<emphasis>Core</emphasis>, <emphasis>Annotation</emphasis> or
<emphasis>JPA</emphasis> configuration and possibly the JDBC configuration if
you are using the reverse engineering facilities of <productname>Hibernate
Tools</productname>.
</para>
<note>
<title>Note:</title>
- <para>No matter which Hibernate Configuration type you are using
<productname>Hibernate Tools</productname> supports them.</para>
+ <para>Hibernate Tools has support for all kinds of Hibernate
Configurations.</para>
</note>
<para>The following drawing illustrates the core concepts:</para>
@@ -78,15 +78,15 @@
<title>Exporters</title>
<para>
- Code generation is done in so called Exporters. An <code>Exporter</code>
is handed a Hibernate Meta Model represented as a <code>Configuration</code>
instance and it is then the job of the exporter to generate a set of code artifacts.
+ Code generation is performed by an Exporters. An
<emphasis>Exporter</emphasis> is handed a Hibernate Meta Model represented as
a <code>Configuration</code> instance, and it is then the job of the exporter
to generate a set of code artifacts.
</para>
<para>
- The tools provides a default set of Exporter's which can be used in both Ant and
the Eclipse UI. Documentation for these Exporters is in <xref
linkend="ant"/> and <xref linkend="plugins"/>.
+ The tool provides a default set of Exporter's which can be used in both Ant and
the Eclipse UI. Documentation for these Exporters can be found in <xref
linkend="ant"/> and <xref linkend="plugins"/>.
</para>
<para>
- Users can provide their own custom Exporter's, either through custom classes
implementing the Exporter interface or simply be providing custom templates. This is
documented at in <xref linkend="hbmtemplate"/>.
+ Users can provide their own custom Exporter's, either through custom classes
implementing the <code>Exporter</code> interface or simply through custom
templates. This is documented at in <xref linkend="hbmtemplate"/>.
</para>
</section>
</chapter>
Deleted: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins.xml
===================================================================
--- trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins.xml 2011-03-02
22:58:02 UTC (rev 29454)
+++ trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins.xml 2011-03-02
23:34:47 UTC (rev 29455)
@@ -1,2564 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<chapter id="plugins" role="updated">
- <title>Eclipse Plugins</title>
- <para>This chapter will introduce you to the functionality that
<property>Hibernate
- Tools</property> provide within Eclipse. That is a set of wizards and editors
for simplifying
- the work with <property>Hibernate</property>.</para>
- <section>
- <title>Introduction</title>
- <para>Hibernate Eclipse Tools include wizards for creating Hibernate mapping
files,
- configuration files (.cfg.xml), revenge.xml as well as wizards for adjusting
Console
- Configuration and Code Generation. Special structured and XML editors, editors for
executing
- HQL and Criteria queries are also provided in Hibernate Console. Refer to <xref
- linkend="hibernate_key_features"/> section to find all benefits that
you
- can take advantage of while using the tools within Eclipse.</para>
- <note>
- <title>Note:</title>
- <para>Please note that these tools do not try to hide any functionality of
<property
- >Hibernate</property>. The tools make working with
<property>Hibernate</property> easier,
- but you are still encouraged/required to read the <ulink
-
url="http://www.hibernate.org/5.html">Hibernate
Documentation</ulink> to fully utilize
- <property>Hibernate Tools</property> and especially
<property>Hibernate</property> it
- self.</para>
- </note>
- </section>
- <section id="map_file_wizard">
- <title>Creating a Hibernate Mapping File</title>
- <para>Hibernate mapping files are used to specify how your objects are related
to database
- tables.</para>
- <para>To create basic mappings for properties and associations, i. e. generate
<emphasis>
- <property>.hbm.xml</property>
- </emphasis> files, Hibernate Tools provide a basic wizard which you can bring
up by navigating
- <emphasis>
- <property>New > Hibernate XML mapping
file</property>.</emphasis></para>
- <para>At first you'll be asked to select a package or multiple
individual classes to map.
- It's also possible to create an empty file, don't select any packages
or classes and an
- empty .hbm will be created in the specified location</para>
- <para id="depth_control">With <property>depth
control</property> option you can define dependences depth for
- choosing classes (it means to set level of references which is used to collect
linked classes
- to the selection). </para>
- <figure>
- <title>Hibernate XML Mapping File Wizard</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/plugins_0.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The next wizard page lists the mappings to be generated. As you see
<property>Customers</property>, <property>Orders</property>,
<property>Productlines</property> and
<property>Products</property> classes added under <property>depth
control</property> driving. </para>
- <figure>
- <title>Mappings to be generated</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/plugins_0_a.png"/>
- </imageobject>
- </mediaobject>
- </figure>
-
- <para>This wizard page outputs a generated .hbm files preview.</para>
- <figure>
- <title>Preview Generated Mapping Files</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/plugins_0_b.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>Pressing <property>Finish</property> creates the
files.</para>
- </section>
- <section id="hib_config_file">
- <title>Creating a Hibernate Configuration File</title>
- <para>To be able to reverse engineer, prototype queries, and of course to
simply use <property
- >Hibernate Core</property> a <emphasis>
- <property>hibernate.properties</property>
- </emphasis> or <emphasis>
- <property>hibernate.cfg.xml</property>
- </emphasis> file is needed. The <property>Hibernate
Tools</property> provide a wizard for
- generating the <emphasis>
- <property>hibernate.cfg.xml</property>
- </emphasis> file if you do not already have such one.</para>
- <para>Start the wizard by clicking <emphasis>
- <property>New > Other (Ctrl+N)</property>
- </emphasis>, then <emphasis>
- <property>Hibernate > Hibernate Configuration File
(cfg.xml)</property>
- </emphasis> and press <emphasis>
- <property>Next</property>
- </emphasis> or on a web Seam project in the <property>Web
Projects</property> view <emphasis>
- <property> WebContent -> New -> File -> Hibernate Configuration
3.0</property>
- </emphasis>. After selecting the wanted location for the <emphasis>
- <property>hibernate.cfg.xml</property>
- </emphasis> file, you will see the following page:</para>
- <figure>
- <title>Hibernate Configuration File Wizard</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center"
fileref="images/plugins/plugins_1.png" format="PNG"/>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_1.png" format="PNG"/>
- </imageobject>
- </mediaobject>
- </figure>
- <note>
- <title>Note:</title>
- <para>The contents in the combo boxes for the JDBC driver class and JDBC URL
change
- automatically, depending on the Dialect and actual driver you have
chosen.</para>
- </note>
- <para>Enter your configuration information in this dialog. Details about the
configuration
- options can be found in <ulink
-
url="http://docs.jboss.org/ejb3/app-server/Hibernate3/reference/en/h...
- Reference Documentation</ulink>.</para>
- <para>Press <emphasis>
- <property>Finish</property>
- </emphasis> to create the configuration file, after optionally creating a
Console
- configuration, the <emphasis>
- <property>hibernate.cfg.xml</property>
- </emphasis> will be automatically opened in an editor. The last option
<emphasis>
- <property>Create Console Configuration</property>
- </emphasis> is enabled by default and when enabled, it will automatically use
the <emphasis>
- <property>hibernate.cfg.xml</property>
- </emphasis> for the basis of a Console configuration.</para>
- </section>
- <section id="console_conf">
- <title>Hibernate Console Configuration</title>
- <para>A Console configuration describes how the <property>Hibernate
plugin</property> should
- configure <property>Hibernate</property> and what configuration files,
including which
- classpath are needed to load the POJO's, JDBC drivers etc. It is required to
make usage of
- query prototyping, reverse engineering and code generation. You can have multiple
named
- console configurations. Normally you would just need one per project, but more is
definitely
- possible if your project requires this.</para>
- <section id="creat_console_conf">
- <title>Creating a Hibernate Console Configuration</title>
- <para>You create a console configuration by running the
<property>Console Configuration
- Wizard</property>, shown in the following screenshot. The same wizard
will also be used if
- you are coming from the <emphasis>
- <property>hibernate.cfg.xml</property>
- </emphasis> wizard and had enabled <emphasis>
- <property>Create Console Configuration</property>
- </emphasis>.</para>
- <note>
- <title>Note:</title>
- <para>The wizard will look at the current selection in the IDE and try and
auto-detect the
- settings which you then can just approve or modify to suit your
needs.</para>
- </note>
- <para/>
- <para>The dialog consists of five tabs: </para>
- <itemizedlist>
- <listitem>
- <para><emphasis>
- <property>Main</property>
- </emphasis> for the basic/required settings</para>
- </listitem>
- </itemizedlist>
- <figure>
- <title> Creating Hibernate Console Configuration</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center"
fileref="images/plugins/plugins_2.png" format="PNG"/>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_2.png" format="PNG"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The following table describes the available settings on the
<emphasis>
- <property>Main</property>
- </emphasis> tab. The wizard can automatically detect default values for
most of these if you
- started the wizard with the relevant java project or resource
selected.</para>
- <table>
- <title>Hibernate Console Configuration Parameters</title>
- <tgroup cols="3">
- <colspec colnum="1" align="left"
colwidth="1*"/>
- <colspec colnum="2" colwidth="3*"/>
- <colspec colnum="3" align="left"
colwidth="1*"/>
- <thead>
- <row>
- <entry align="center">
- <para>Parameter</para>
- </entry>
- <entry align="center">
- <para>Description</para>
- </entry>
- <entry align="center">
- <para>Auto detected value</para>
- </entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <para>Name</para>
- </entry>
- <entry>
- <para>The unique name of the console configuration</para>
- </entry>
- <entry>
- <para>Name of the selected project</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Type</para>
- </entry>
- <entry>
- <para>Choose between "Core",
"Annotations" and "JPA".
- Note that the two latter requires running Eclipse IDE with a JDK 5
runtime,
- otherwise you will get classloading and/or version
errors.</para>
- </entry>
- <entry>
- <para>No default value</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Project</para>
- </entry>
- <entry>
- <para>The name of a java project which classpath should be used in
the console
- configuration</para>
- </entry>
- <entry>
- <para>Name of the selected project</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Database connection</para>
- </entry>
- <entry>
- <para>DTP provided connection that you can use instead of what is
in cfg.xml and jpa
- persistence.xml. It's possible to use either already
configured hibernate or
- JPA connection or specify a new one here.</para>
- </entry>
- <entry>
- <para>[Hibernate Configured connection]</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Property file</para>
- </entry>
- <entry>
- <para>Path to a hibernate.properties file</para>
- </entry>
- <entry>
- <para>First hibernate.properties file found in the selected
project</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Configuration file</para>
- </entry>
- <entry>
- <para>Path to a hibernate.cfg.xml file</para>
- </entry>
- <entry>
- <para>First hibernate.cfg.xml file found in the selected
project</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Persistence unit</para>
- </entry>
- <entry>
- <para>Name of the persistence unit to use</para>
- </entry>
- <entry>
- <para>No default value (lets Hibernate Entity Manager find the
persistence unit or
- it can be defined manually using Browse button)</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <tip>
- <title>Tip:</title>
- <para>The two latter settings are normally not required if you specify a
project and it has
- <emphasis>
- <property>
- <literal> /hibernate.cfg.xml </literal>
- </property>
- </emphasis> or <emphasis>
- <property>
- <literal>/META-INF/persistence.xml</literal>
- </property>
- </emphasis> in its project classpath.</para>
- </tip>
- <itemizedlist>
- <listitem>
- <para>
- <emphasis>
- <property>Options</property>
- </emphasis> for the additional/optional settings</para>
- </listitem>
- </itemizedlist>
- <figure>
- <title>Options Tab of the Console Configuration Wizard</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/plugins_2_a.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The next table describes Hibernate Console Configuration options
available on the
- <emphasis>
- <property>Options</property>
- </emphasis> tab.</para>
- <table>
- <title>Hibernate Console Configuration Options</title>
- <tgroup cols="3">
- <colspec colnum="1" align="left"
colwidth="1*"/>
- <colspec colnum="2" colwidth="3*"/>
- <colspec colnum="3" align="left"
colwidth="1*"/>
- <thead>
- <row>
- <entry align="center">
- <para>Parameter</para>
- </entry>
- <entry align="center">
- <para>Description</para>
- </entry>
- <entry align="center">
- <para>Auto detected value</para>
- </entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <para>Database dialect</para>
- </entry>
- <entry>
- <para>Define a database dialect. It's possible either to
write your value or choose
- from list. </para>
- </entry>
- <entry>
- <para>No default value</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Naming strategy</para>
- </entry>
- <entry>
- <para>Fully qualified classname of a custom NamingStrategy. Only
required if you use
- a special naming strategy.</para>
- </entry>
- <entry>
- <para>No default value</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Entity resolver</para>
- </entry>
- <entry>
- <para>Fully qualified classname of a custom EntityResolver. Only
required if you
- have special xml entity includes in your mapping files.</para>
- </entry>
- <entry>
- <para>No default value</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <itemizedlist>
- <listitem>
- <para><emphasis>
- <property>Classpath</property>
- </emphasis> for classpath</para>
- </listitem>
- </itemizedlist>
- <figure>
- <title>Specifying Classpath in Hibernate Console
Configuration</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center"
fileref="images/plugins/plugins_3.png" format="PNG"/>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_3.png" format="PNG"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The following table specifies the parameters of the Classpath tab of
the wizard.</para>
- <table>
- <title>Hibernate Console Configuration Classpath</title>
- <tgroup cols="3">
- <colspec colnum="1" align="left"
colwidth="1*"/>
- <colspec colnum="2" colwidth="3*"/>
- <colspec colnum="3" colwidth="1*"/>
- <thead>
- <row>
- <entry align="center">
- <para>Parameter</para>
- </entry>
- <entry align="center">
- <para>Description</para>
- </entry>
- <entry align="center">
- <para>Auto detected value</para>
- </entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <para>Classpath</para>
- </entry>
- <entry>
- <para>The classpath for loading POJO and JDBC drivers; only needed
if the default
- classpath of the Project does not contain the required classes. Do not
add
- Hibernate core libraries or dependencies, they are already included. If
you get
- ClassNotFound errors then check this list for possible missing or
redundant
- directories/jars.</para>
- </entry>
- <entry>
- <para>Empty</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Include default classpath from project</para>
- </entry>
- <entry>
- <para>When enabled the project classpath will be appended to the
classpath specified
- above</para>
- </entry>
- <entry>
- <para>Enabled</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <itemizedlist>
- <listitem>
- <para><emphasis>
- <property>Mappings</property>
- </emphasis> for additional mappings</para>
- </listitem>
- </itemizedlist>
- <figure>
- <title>Specifying additional Mappings in Hibernate Console
Configuration</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center"
fileref="images/plugins/plugins_4.png" format="PNG"/>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_4.png" format="PNG"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>Parameters of the Mappings tab of the <property>Hibernate Console
Configuration
- wizard</property> are explained below:</para>
- <table>
- <title>Hibernate Console Configuration Mappings</title>
- <tgroup cols="3">
- <colspec colnum="1" align="left"
colwidth="1*"/>
- <colspec colnum="2" colwidth="3*"/>
- <colspec colnum="3" colwidth="1*"/>
- <thead>
- <row>
- <entry align="center">
- <para>Parameter</para>
- </entry>
- <entry align="center">
- <para>Description</para>
- </entry>
- <entry align="center">
- <para>Auto detected value</para>
- </entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <para>Mapping files </para>
- </entry>
- <entry>
- <para>List of additional mapping files that should be loaded. Note:
A
- hibernate.cfg.xml or persistence.xml can also contain mappings. Thus if
these are
- duplicated here, you will get "Duplicate mapping" errors when
using the console
- configuration.</para>
- </entry>
- <entry>
- <para>empty</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <itemizedlist>
- <listitem>
- <para>and the last tab <emphasis>
- <property>Common</property>
- </emphasis></para>
- </listitem>
- </itemizedlist>
- <figure>
- <title>Common Tab of the Console Configuration Wizard</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/plugins_4_a.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>It allows to define general aspects of the launch configuration
including storage
- location, console encoding and some others.</para>
- <para>Clicking <emphasis>
- <property>Finish</property>
- </emphasis> creates the configuration and shows it in the
<property>Hibernate Configurations
- view</property>.</para>
- <figure>
- <title>Console Overview</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center"
fileref="images/plugins/plugins_5.png" format="PNG"/>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_5.png" format="PNG"/>
- </imageobject>
- </mediaobject>
- </figure>
- </section>
- <section id="modif_console_conf">
- <title>Modifying a Hibernate Console Configuration </title>
- <para>When you created a hibernate console configuration you can modify it in
2 ways: </para>
- <itemizedlist>
- <listitem>
- <para>right click on the configuration in <emphasis>
- <property>Hibernate Configurations View->Edit Configuration
</property>
- </emphasis> or just double click on <property>Console
Configuration</property> item.</para>
- <figure>
- <title>Opening Edit Configuration Wizard</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/plugins_4_c.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para> After clicking you will see the Edit Configuration Wizard that is
similar to
- <emphasis>
- <property>Create Console Configuration</property>
- </emphasis>,described in <xref
linkend="creat_console_conf"/>. </para>
- </listitem>
- <listitem>
- <para>use Properties view for modifying some of Console Configuration
properties.</para>
- <figure>
- <title>Properties View</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/plugins_4_b.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The following table describes the available settings in the
Properties view. Most
- properties are changeable by left click but some are not. <table>
- <title>Properties</title>
- <tgroup cols="3">
- <colspec colnum="1" align="left"
colwidth="1*"/>
- <colspec colnum="2" colwidth="3*"/>
- <colspec colnum="3" align="left"
colwidth="1*"/>
- <thead>
- <row>
- <entry align="center">
- <para>Property</para>
- </entry>
- <entry align="center">
- <para>Description</para>
- </entry>
- <entry align="center">
- <para>Is Changeable</para>
- </entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <para>Additional mapping files </para>
- </entry>
- <entry>
- <para>List of additional mapping files that should be loaded.
</para>
- </entry>
- <entry>
- <para>False</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Configuration file</para>
- </entry>
- <entry>
- <para>Path to a hibernate.cfg.xml file</para>
- </entry>
- <entry>
- <para>False</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Connection</para>
- </entry>
- <entry>
- <para>DTP provided connection that you can use instead of
what is in cfg.xml
- and jpa persistence.xml. It's possible to use either
already configured
- hibernate or JPA connection or specify a new one
here.</para>
- </entry>
- <entry>
- <para>True</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Name</para>
- </entry>
- <entry>
- <para>The unique name of the console
configuration</para>
- </entry>
- <entry>
- <para>True</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Project</para>
- </entry>
- <entry>
- <para>The name of a java project which classpath should be
used in the console
- configuration</para>
- </entry>
- <entry>
- <para>True</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Properties file</para>
- </entry>
- <entry>
- <para>Path to a hibernate.properties file</para>
- </entry>
- <entry>
- <para>False</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Type</para>
- </entry>
- <entry>
- <para>Choose between "CORE",
"ANNOTATIONS" and
- "JPA" according to the method of relational
mapping you want to
- use. Note that the two latter requires running Eclipse IDE with a
JDK 5
- runtime, otherwise you will get classloading and/or version
errors.</para>
- </entry>
- <entry>
- <para>True</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table></para>
- </listitem>
- </itemizedlist>
- </section>
- <section id='closing_conf_config'>
- <title>Closing Hibernate Console Configuration</title>
- <para>To close <property>Hibernate Console
Configuration</property> you need do right click your configuration
- and choose <property>Close Configuration</property> option
</para>
- <figure>
- <title>Close Hibernate Console Configuration</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/plugins_4_d.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>While closing configuration the connection with database will be
closed, jar libs will
- be unlock (for Windows) and other resources will set as free. </para>
- </section>
- </section>
- <section id="refeng_codegen" role="updated">
- <title>Reverse Engineering and Code Generation</title>
- <para>A "click-and-generate" reverse engineering and code
generation facility is
- available. This facility allows you to generate a range of artifacts based on
database or an
- already existing Hibernate configuration, be that mapping files or annotated
classes. Some of
- these are POJO Java source file, Hibernate <emphasis>
- <property>.hbm.xml</property>
- </emphasis>, <emphasis>
- <property>hibernate.cfg.xml</property>
- </emphasis> generation and schema documentation.</para>
- <para>To start working with this process, start the <property>Hibernate
Code
- Generation</property> which is available in the toolbar via the
<property
- >Hibernate</property> icon or via the <emphasis>
- <property>Run > Hibernate Code Generation</property>
- </emphasis> menu item.</para>
- <section id="code_gen">
- <title>Code Generation Launcher</title>
- <para>When you click on <emphasis>
- <property>Open Hibernate Code Generation Dialog...</property>
- </emphasis> the standard Eclipse launcher dialog will appear. In this
dialog you can create,
- edit and delete named Hibernate code generation
"launchers".</para>
- <figure id="hib_code_gen">
- <title>Getting Hibernate Code Generation Wizard</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata fileref="images/plugins/plugins_6.png"
format="PNG"/>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_6.png" format="PNG"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para/>
- <figure>
- <title>Hibernate Code Generation Wizard</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center" scale="80"
fileref="images/plugins/plugins_7.png" format="PNG"
- />
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_7.png" format="PNG"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The first time you create a code generation launcher you should give it
a meaningful
- name, otherwise the default prefix <emphasis>
- <property>New_Generation</property>
- </emphasis> will be used.</para>
- <tip>
- <title>Tip:</title>
- <para>The "At least one exporter option must be selected"
is just a warning
- stating that for this launch to work you need to select an exporter on the
Exporter tab.
- When an exporter has been selected the warning will disappear.</para>
- </tip>
- <para>The dialog also have the standard tabs <emphasis>
- <property>Refresh</property>
- </emphasis> and <emphasis>
- <property>Common</property>
- </emphasis> that can be used to configure which directories should be
automatically
- refreshed and various general settings launchers, such as saving them in a
project for
- sharing the launcher within a team.</para>
- <para>On the <emphasis>
- <property>Main</property>
- </emphasis> tab you see the following fields:</para>
- <table>
- <title>Code generation "Main" tab fields</title>
- <tgroup cols="2">
- <colspec colnum="1" align="left"
colwidth="1*"/>
- <colspec colnum="2" colwidth="3*"/>
- <colspec colnum="3" colwidth="0.5*"/>
- <thead>
- <row>
- <entry align="center">
- <para>Field</para>
- </entry>
- <entry align="center">
- <para>Description</para>
- </entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <para>Console Configuration</para>
- </entry>
- <entry>
- <para>The name of the console configuration which should be used
when code
- generating</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Output directory</para>
- </entry>
- <entry>
- <para>Path to a directory where all output will be written by
default. It's possible
- to enter absolute directory path, for example - "d:/temp". Be
aware that existing
- files will be overwritten, so be sure to specify the correct
directory.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Reverse engineer from JDBC Connection</para>
- </entry>
- <entry>
- <para>If enabled, the tools will reverse engineer the database
available via the
- connection information in the selected Hibernate Console Configuration
and
- generate code based on the database schema. If not enabled, the code
generation
- will just be based on the mappings already specified in the Hibernate
Console
- configuration.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Package</para>
- </entry>
- <entry>
- <para>The package name here is used as the default package name for
any entities
- found when reverse engineering</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>reveng.xml</para>
- </entry>
- <entry>
- <para>Path to a reveng.xml file. A reveng.xml file allows you to
control certain
- aspects of the reverse engineering. e.g. how jdbc types are mapped to
hibernate
- types and especially important which tables are included/excluded from
the
- process. Clicking "setup" allows you to select an existing
reveng.xml file or
- create a new one. See more details about the reveng.xml file in
<xref
- linkend="reverseengineering"/>.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>reveng. strategy</para>
- </entry>
- <entry>
- <para>If reveng.xml does not provide enough customization you can
provide your own
- implementation of an ReverseEngineeringStrategy. The class needs to be
in the
- classpath of the Console Configuration, otherwise you will get class
not found
- exceptions. See <xref
linkend="custom-reveng-strategy"/> for details and an
- example of a custom strategy.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Generate basic typed composite ids</para>
- </entry>
- <entry>
- <para>A table that has a multi-column primary key a
<composite-id> mapping
- will always be created. If this option is enabled and there are
matching
- foreign-keys each key column is still considered a 'basic'
scalar (string, long,
- etc.) instead of a reference to an entity. If you disable this option
a
- <code><key-many-to-one></code> instead.
Note: a
- <code><many-to-one></code> property is
still created, but is simply marked
- as non-updatable and non-insertable.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Detect optimistic lock columns</para>
- </entry>
- <entry>
- <para>Automatically detect optimistic lock columns. Controllable
via reveng.
- strategy; the current default is to use columns named VERSION or
TIMESTAMP.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Detect many-to-many tables</para>
- </entry>
- <entry>
- <para>Automatically detect many-to-many tables. Controllable via
reveng.
- strategy.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Detect one-to-one associations</para>
- </entry>
- <entry>
- <para> Reverse engineering detects one-to-one associations via
primary key and both
- hbm.xml and annotation generation generates the proper code for it.
</para>
- <para> The detection is enabled by default (except for Seam 1.2 and
Seam 2.0)
- reverse engineering. For Hibernate Tools generation there is a checkbox
to disable
- if not wanted. </para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Use custom templates</para>
- </entry>
- <entry>
- <para>If enabled, the Template directory will be searched first
when looking up the
- templates, allowing you to redefine how the individual templates
process the
- hibernate mapping model.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Template directory</para>
- </entry>
- <entry>
- <para>A path to a directory with custom templates</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </section>
- <section id="exportes">
- <title>Exporters</title>
- <para>The <emphasis>
- <property>Exporters</property>
- </emphasis> tab is used to specify which type of code that should be
generated. Each
- selection represents an Exporter that is responsible for generating the code,
hence the
- name.</para>
- <figure>
- <title>Selecting Exporters</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center" scale="80"
fileref="images/plugins/plugins_8.png" format="PNG"
- />
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_8.png" format="PNG"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The following table describes in short the various exporters. Remember
you can
- add/remove any Exporters depending on your needs.</para>
- <table>
- <title>Code generation "Exporter" tab fields</title>
- <tgroup cols="2">
- <colspec colnum="1" align="left"
colwidth="1*"/>
- <colspec colnum="2" colwidth="3*"/>
- <thead>
- <row>
- <entry align="center">
- <para>Field</para>
- </entry>
- <entry align="center">
- <para>Description</para>
- </entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <para>Domain code</para>
- </entry>
- <entry>
- <para>Generates POJO's for all the persistent classes and
components found in the
- given Hibernate configuration.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>DAO code</para>
- </entry>
- <entry>
- <para>Generates a set of DAO's for each entity
found.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Hibernate XML Mappings</para>
- </entry>
- <entry>
- <para>Generate mapping (hbm.xml) files for each
entity.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Hibernate XML Configuration</para>
- </entry>
- <entry>
- <para>Generate a hibernate.cfg.xml file. Used to keep the
hibernate.cfg.xml update
- with any new found mapping files.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Schema Documentation (.html)</para>
- </entry>
- <entry>
- <para>Generates a set of html pages that documents the database
schema and some of
- the mappings.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Generic Exporter (hbmtemplate)</para>
- </entry>
- <entry>
- <para>Fully customizable exporter which can be used to perform
custom
- generation.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Schema Export (.ddl)</para>
- </entry>
- <entry>
- <para>Generates the appropriate SQL DDL and allows you to store the
result in a file
- or export it directly to the database.</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <para>Each Exporter listens to certain properties and these can be setup in
the <emphasis>
- <property>Properties</property>
- </emphasis> section where you can add/remove predefined or customer
properties for each of
- the exporters. The following table lists the time of writing predefined
properties:</para>
- <para>
- <table>
- <title>Exporter Properties</title>
- <tgroup cols="2">
- <colspec colnum="1" align="left"
colwidth="1*"/>
- <colspec colnum="2" colwidth="3*"/>
- <thead>
- <row>
- <entry align="center">
- <para>Name</para>
- </entry>
- <entry align="center">
- <para>Description</para>
- </entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <para>jdk5</para>
- </entry>
- <entry>
- <para>Generate Java 5 syntax</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>ejb3</para>
- </entry>
- <entry>
- <para>Generate EJB 3 annotations</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>for_each</para>
- </entry>
- <entry>
- <para>Specifies for which type of model elements the exporter
should create a file
- and run through the templates. Possible values are: entity,
component,
- configuration</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>template_path</para>
- </entry>
- <entry>
- <para>Custom template directory for this specific exporter. You
can use Eclipse
- variables.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>template_name</para>
- </entry>
- <entry>
- <para>Name for template relative to the template
path</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>outputdir</para>
- </entry>
- <entry>
- <para>Custom output directory for this specific exporter. You can
use Eclipse
- variables.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>file_pattern</para>
- </entry>
- <entry>
- <para>Pattern to use for the generated files, relatively for the
output dir.
- Example: {package-name}/{class-name}.java .</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>dot.executable</para>
- </entry>
- <entry>
- <para>Executable to run GraphViz (only relevant, but optional for
Schema
- documentation)</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>drop</para>
- </entry>
- <entry>
- <para>Output will contain drop statements for the tables, indices
and
- constraints</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>delimiter</para>
- </entry>
- <entry>
- <para>If specified the statements will be dumped to this
file</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>create</para>
- </entry>
- <entry>
- <para>Output will contain create statements for the tables,
indices and
- constraints</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>scriptToConsole</para>
- </entry>
- <entry>
- <para>The script will be output to Console</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>exportToDatabase</para>
- </entry>
- <entry>
- <para>Executes the generated statements against the
database</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>outputFileName</para>
- </entry>
- <entry>
- <para>If specified the statements will be dumped to this
file</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>haltOnError</para>
- </entry>
- <entry>
- <para>Halts the build process if an error occurs</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>format</para>
- </entry>
- <entry>
- <para>Applies basic formatting to the statements</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>schemaUpdate</para>
- </entry>
- <entry>
- <para>Updates a schema</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </para>
- <para>To add a property to the chosen Exporter click the <emphasis>
- <property>Add</property>
- </emphasis> button in the <property>Properties</property>
section. In the appeared dialog
- you should select the property from the proposed list and the value for
it.</para>
- <figure>
- <title>Adding the Property for Schema Export (.ddl)</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/plugins_8a.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <tip>
- <title>Tip:</title>
- <para>If the property is a directory, it is possible to browse directories
in the Value
- field.</para>
- </tip>
- <figure>
- <title>Specifying the Property Value</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/plugins_8b.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- </section>
- </section>
- <section id="map_config_editor">
- <title>Hibernate Mapping and Configuration File Editor</title>
- <para>The <property>Hibernate Mapping File editor</property>
provides XML editing functionality
- for the <emphasis>
- <property>hbm.xml </property>
- </emphasis> and <emphasis>
- <property>cfg.xml</property>
- </emphasis> files. The editor is based on the Eclipse WTP tools and extends
its functionality
- to provide Hibernate specific code completion.</para>
- <figure>
- <title>XML Editing Functionality</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center" scale="80"
fileref="images/plugins/plugins_9.png" format="PNG"/>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_9.png" format="PNG"/>
- </imageobject>
- </mediaobject>
- </figure>
- <section>
- <title>Java property/class completion</title>
- <para>Package, class, and field completion is enabled for relevant XML
attributes. The
- auto-completion detects its context and limits the completion for e.g.
- <code><property></code> and only shows the
properties/fields available in the
- enclosing <code><class></code> ,
<code><subclass></code> etc. It is also
- possible to navigate from the <emphasis>
- <property>hbm.xml</property>
- </emphasis> files to the relevant class/field in java code.</para>
- <figure>
- <title>Navigation Functionality</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center"
fileref="images/plugins/plugins_10.png" format="PNG"
- scale="80"/>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_10.png" format="PNG"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>This is done via the standard hyperlink navigation functionality in
Eclipse; per default
- it is done by pressing F3 while the cursor is on a class/field or by pressing
<emphasis>
- <property>Ctrl</property>
- </emphasis> and the mouse button to perform the same
navigation.</para>
- <para>For java completion and navigation to work the file needs to reside
inside an Eclipse
- Java project, otherwise no completion will occur.</para>
- <note>
- <title>Note:</title>
- <para>Java completion does not require a Hibernate console configuration to
be used.</para>
- </note>
- </section>
- <section>
- <title>Table/Column completion</title>
- <para>Table and column completion is also available for all table and column
attributes. </para>
- <figure>
- <title>Table and Column Completion</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center" scale="80"
fileref="images/plugins/plugins_11.png"
- format="PNG"/>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_11.png" format="PNG"/>
- </imageobject>
- </mediaobject>
- </figure>
- <important>
- <title>Important:</title>
- <para>Table/Column completion requires a proper configured hibernate
console configuration
- and this configuration should be the default for the project where the
<emphasis>
- <property>hbm.xml</property>
- </emphasis> resides.</para>
- </important>
- <para>You can check which console configuration is selected under the
Properties of a project
- and look under the <emphasis>
- <property>Hibernate Settings</property>
- </emphasis> page. When a proper configuration is selected it will be used
to fetch the
- table/column names in the background.</para>
- <note>
- <title>Note:</title>
- <para>Currently it is not recommended to use this feature on large
databases since it does
- not fetch the information iteratively. It will be improved in future
versions.</para>
- </note>
- </section>
- <section>
- <title>Configuration property completion</title>
- <para>In <emphasis>
- <property>cfg.xml</property>
- </emphasis> code completion for the value of
<code><property> name</code> attributes
- is available.</para>
- <figure>
- <title>Property Completion</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center" scale="80"
fileref="images/plugins/plugins_12.png"
- format="PNG"/>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_12.png" format="PNG"/>
- </imageobject>
- </mediaobject>
- </figure>
- </section>
- </section>
- <section id="map_config_struct_editor">
- <title>Structured Hibernate Mapping and Configuration File
Editor</title>
- <para>The structured editor represents the file in the tree form. It also
allows to modify the
- structure of the file and its elements with the help of tables provided on the
right-hand
- area.</para>
- <para>To open any mapping file in the editor, choose <emphasis>
- <property>Open With > Hibernate 3.0 XML Editor</property>
- </emphasis> option from the context menu of the file. The editor should look
as
- follows:</para>
- <figure>
- <title>Structured hbm.xml Editor</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/plugins_12_a.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>For the configuration file you should choose <emphasis>
- <property>Open With > Hibernate Configuration 3.0 XML
Editor</property>
- </emphasis>option.</para>
- <figure>
- <title>Structured cfg.xml Editor</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/plugins_12_b.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- </section>
- <section id="properties_editor">
- <title>JBoss Tools Properties Editor</title>
- <para>The editor is meant for editing
<literal>.properties</literal> files. It contains two
- tabs: the <property>Properties</property> (UI) tab and the
<property>Source</property> tab for
- manual editing.</para>
- <para>For <literal>hibernate.properties</literal> file
<property>JBoss Tools Properties
- Editor</property> provides content assist which is available both for
hibernate properties
- and property values. You can make use of the content assist while editing the file
in the
- Source view and in the Properties view of the editor.</para>
- <para>To add the property in the <property>Properties</property>
view, click the <emphasis>
- <property>Add</property>
- </emphasis> button.</para>
- <figure>
- <title>Adding the Property</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/add_property1.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>In the <emphasis>
- <property>Name</property>
- </emphasis> field press <emphasis>
- <property>Ctrl+Space</property>
- </emphasis> to invoke the content assist. It will suggest <emphasis>
- <property>'hibernate.'</property>
- </emphasis> which is the prefix for all hibernate properties. After selecting
<emphasis>
- <property>'hibernate.'</property>
- </emphasis> and invoking the content assist again, other prefixes and
properties are displayed
- as the proposals with a description of each one.</para>
- <figure>
- <title>Content Assist for Properties Names</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/add_property2.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>When invoking the content assist in the <emphasis>
- <property>Value</property>
- </emphasis> field, it also provides a list of proposals.</para>
- <figure>
- <title>Content Assist for Properties Values</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/add_property3.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>In the <property>Source</property> view of the editor,
content assist also could be
- invoked both for properties names and values:</para>
- <figure>
- <title>Content Assist in the Source view</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/add_property4.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <figure>
- <title>Content Assist in the Source view</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/add_property5.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- </section>
- <section id="rev_xml_editor">
- <title>Reveng.xml Editor</title>
- <para>A <emphasis>
- <property>reveng.xml </property>
- </emphasis> file is used to customize and control how reverse engineering is
performed by the
- tools. The plugins provide an editor to ease the editing of this file and hence
used to
- configure the reverse engineering process.</para>
- <para>The editor is intended to allow easy definition of type mappings, table
include/excludes
- and specific override settings for columns, e.g. define an explicit name for a
column when the
- default naming rules are not applicable.</para>
- <note>
- <title>Note:</title>
- <para> Not all the features of the <emphasis>
- <property>.reveng.xml </property>
- </emphasis> file are exposed or fully implemented in the editor, but the
main functionality
- is there. To understand the full flexibility of the <emphasis>
- <property>reveng.xml</property>
- </emphasis>, please see <xref
linkend="hibernaterevengxmlfile"/>
- </para>
- </note>
- <para>The editor is activated as soon as an <emphasis>
- <property>.reveng.xml </property>
- </emphasis> file is opened. To get an initial <emphasis>
- <property>reveng.xml </property>
- </emphasis> file the <property>Reverse Engineering File
Wizard</property> can be started via
- <emphasis>
- <property>Ctrl+N</property>
- </emphasis> and <emphasis>
- <property>Hibernate > Hibernate Reverse Engineering File
(reveng.xml)</property>
- </emphasis> then.</para>
- <figure>
- <title>ChooseReverse Engineering File Wizard </title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center" scale="80"
fileref="images/plugins/plugins_22.png" format="PNG"
- />
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_22.png" format="PNG"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>Or you can get it via the <property>Code Generation
Launcher</property> by checking the
- proper section in the <emphasis>
- <property>Main</property>
- </emphasis> tab of the <xref
linkend="hib_code_gen"/>.</para>
- <para>The following screenshot shows the <emphasis>
- <property>Overview</property>
- </emphasis> page where the wanted console configuration is selected
(auto-detected if
- Hibernate 3 support is enabled for the project)</para>
- <figure>
- <title>Overview Page</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center" scale="80"
fileref="images/plugins/plugins_13.png" format="PNG"
- />
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_13.png" format="PNG"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The <emphasis>
- <property>Table Filter</property>
- </emphasis> page allows you to specify which tables to include and exclude.
Pressing
- <emphasis>
- <property>Refresh</property>
- </emphasis> shows the tables from the database that have not yet been
excluded.</para>
- <figure>
- <title>Table Filters Page</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center" scale="80"
fileref="images/plugins/plugins_14.png" format="PNG"
- />
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_14.png" format="PNG"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The <emphasis>
- <property>Type Mappings</property>
- </emphasis> page is used for specifying type mappings from JBDC types to any
Hibernate type
- (including usertypes) if the default rules are not applicable. Here again to see
the database
- tables press <emphasis>
- <property>Refresh</property>
- </emphasis> button underneath. More about type mappings you can find further
in the <xref
- linkend="type_map"/> section.</para>
- <figure>
- <title>Type Mappings Page</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center" scale="80"
fileref="images/plugins/plugins_15.png" format="PNG"
- />
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_15.png" format="PNG"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The <emphasis>
- <property>Table and Columns</property>
- </emphasis> page allows you to explicit set e.g. which hibernatetype and
propertyname that
- should be used in the reverse engineered model. For more details on how to
configure the
- tables while reverse engineering read the <xref
linkend="tab_and_col"/> section.</para>
- <figure>
- <title>Table and Columns Page</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center" scale="80"
fileref="images/plugins/plugins_16.png" format="PNG"
- />
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_16.png" format="PNG"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>Now that you have configured all necessary parts, you can learn how to
work with <property
- >Hibernate Console Perspective</property>.</para>
- </section>
- <section id="hib_console">
- <title>Hibernate Console Perspective</title>
- <para>The <property>Hibernate Console Perspective</property>
combines a set of views which allow
- you to see the structure of your mapped entities/classes, edit HQL queries, execute
the
- queries, and see the results. To use this perspective you need to create a
<xref
- linkend="console_conf"/>.</para>
- <section>
- <title>Viewing the entity structure</title>
- <para>To view your new configuration and entity/class structure, switch to
<property>Hibernate
- Configurations View</property>. Expanding the tree allows you to browse
the class/entity
- structure and see the relationships.</para>
- <figure>
- <title>Hibernate Console Perspective</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center" scale="80"
fileref="images/plugins/plugins_17.png"/>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_17.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The <property>Console Configuration</property> does not
dynamically adjust to changes
- done in mappings and java code. To reload the configuration select the
configuration and
- click the <emphasis>
- <property>Reload</property>
- </emphasis> button in the view toolbar or in the context
menu.</para>
- <para>Besides, it's possible to open source and mapping files for
objects showed in
- <property>Hibernate Configurations View</property>. Just bring up
the context menu for a
- necessary object and select <emphasis>
- <property>Open Source File</property>
- </emphasis> to see appropriate Java class or <emphasis>
- <property>Open Mapping File</property>
- </emphasis> to open a proper <emphasis>
- <property>.hbm.xml</property>.</emphasis></para>
- <figure>
- <title>Opening Source for Objects</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/plugins_17_a.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <section id="map_diagram">
- <title>Mapping Diagram</title>
- <para>In order to get a visual feel on how entities are related as well as
view their
- structures, a <property>Mapping Diagram</property> is provided. It
is available by right
- clicking on the entity you want a mapping diagram for and then choosing
<emphasis>
- <property>Mapping
Diagram</property>.</emphasis></para>
- <figure>
- <title>Mapping Diagram</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center" scale="80"
fileref="images/plugins/plugins_18.png"/>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_18.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>To make <property>Mapping Diagram</property> usage easier
you can use <property
- >Rules</property>,
<property>Grid</property>,<property>Snap to Geometry</property>
- checkboxes in the <emphasis>
- <property>View</property>
- </emphasis> menu. </para>
- <figure>
- <title>View menu</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/map_diagram1.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>If you will select <emphasis>
- <property>Rules</property>
- </emphasis> checkbox, the view print page scale will be added to the
page. The numbers on
- the scale show its size in inches.If you click on the scale a <emphasis>
- <property>Ruler Guide</property>
- </emphasis> will appear on the diagram. You can connect any diagram item
to it.To connect
- the items you should move their tops to the Ruler Guide. And while moving the
ruler guide,
- the items will be moved together with it as a whole.</para>
- <figure>
- <title>Moving the Ruler guide</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/map_diagram2.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>If you'll select <emphasis>
- <property>Grid</property>
- </emphasis> checkbox, the grid will appear on the diagram.</para>
- <figure>
- <title>Grid on Mapping diagram</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/map_diagram3.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The checkbox <emphasis>
- <property>Snap to Geometry</property>
- </emphasis> helps to put the items of the diagram into allineation with
the grid.</para>
- <para>For better navigating through the diagram use <property>Outline
view</property> which
- is available in the structural and graphical modes.</para>
- <figure>
- <title>Navigating in the Structural Mode</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/plugins_18_a.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>To switch over between the modes use the buttons in the top-right
corner of the
- <property>Outline view</property>.</para>
- <figure>
- <title>Navigating in the Graphical Mode</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/plugins_18_b.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The options in the context menu of the mapping diagram are listed in
the next
- table.</para>
- <table>
- <title>Context Menu Options of the Mapping Diagram</title>
- <tgroup cols="3">
- <colspec colnum="1" align="left"
colwidth="1*"/>
- <colspec colnum="2" align="left"
colwidth="1*"/>
- <colspec colnum="3" align="left"
colwidth="3*"/>
- <thead>
- <row>
- <entry align="center">
- <para>Icon</para>
- </entry>
- <entry align="center">
- <para>Command</para>
- </entry>
- <entry align="center">
- <para>Description</para>
- </entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <para>
- <inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/toggleConnections.png"/>
- </imageobject>
- </inlinemediaobject>
- </para>
- </entry>
- <entry>
- <para>Show|Hide connections</para>
- </entry>
- <entry>Allows to select what types of connections should be shown
on the diagram: <itemizedlist>
- <listitem>
- <para>Property Mappings</para>
- </listitem>
- <listitem>
- <para>Class Mappings</para>
- </listitem>
- <listitem>
- <para>Associations</para>
- </listitem>
- <listitem>
- <para>Foreign key constraints</para>
- </listitem>
- </itemizedlist></entry>
- </row>
- <row>
- <entry>
- <para/>
- </entry>
- <entry>
- <para>Select All</para>
- </entry>
- <entry>
- <para>Makes all the diagram elements selected</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>
- <inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/autoLayout.png"/>
- </imageobject>
- </inlinemediaobject>
- </para>
- </entry>
- <entry>
- <para>Auto layout</para>
- </entry>
- <entry>
- <para>Used to dispose all the items of the diagram in a standard
manner</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>
- <inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/exportAsImage.png"/>
- </imageobject>
- </inlinemediaobject>
- </para>
- </entry>
- <entry>
- <para>Export as Image</para>
- </entry>
- <entry>
- <para>Allows to export a diagram as
<emphasis><property>.png
- </property>,</emphasis>
- <emphasis>
- <property>.jpeg</property>
- </emphasis> or <emphasis>
- <property>.bmp </property>
- </emphasis></para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <para>When you open the context menu while clicking an item on the diagram,
it quite differs
- from the one described before.</para>
- <figure>
- <title>Context Menu in Mapping Item</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/plugins_18_g.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The next table describes all the extra options in the menu of mapping
items:</para>
- <table>
- <title>Extra Options in the Context Menu of Mapping Item</title>
- <tgroup cols="3">
- <colspec colnum="1" align="left"
colwidth="1*"/>
- <colspec colnum="2" align="left"
colwidth="1*"/>
- <colspec colnum="3" align="left"
colwidth="3*"/>
- <thead>
- <row>
- <entry align="center">
- <para>Icon</para>
- </entry>
- <entry align="center">
- <para>Command</para>
- </entry>
- <entry align="center">
- <para>Description</para>
- </entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <para>
- <inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/openSourceFile_but.png"/>
- </imageobject>
- </inlinemediaobject>
- </para>
- </entry>
- <entry>
- <para>Open Source File</para>
- </entry>
- <entry>
- <para>Makes it possible to open a source file for a chosen
object/element. The
- selected element will be highlighted in the open file.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>
- <inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/openMappingFile_but.png"/>
- </imageobject>
- </inlinemediaobject>
- </para>
- </entry>
- <entry>
- <para>Open Mapping File</para>
- </entry>
- <entry>
- <para>Makes it possible to open a mapping file for a chosen
object/element. The
- selected element will be highlighted in the open file.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>
- <inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/visibleState.png"/>
- </imageobject>
- </inlinemediaobject>
- </para>
- </entry>
- <entry>
- <para>Show|Hide shape(s)</para>
- </entry>
- <entry>
- <para>Used to hide/show an item on the mapping
diagram</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>
- <inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/expandState.png"/>
- </imageobject>
- </inlinemediaobject>
- </para>
- </entry>
- <entry>
- <para>Expand|Collapse shape(s)</para>
- </entry>
- <entry>
- <para>Used for expanding/collapsing fields of the
item</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <tip>
- <title>Tip:</title>
- <para>All the described types of the context menu are also available in
the <property
- >Outline</property> view.</para>
- </tip>
- <para>The below table lists the actions that could be performed using the
keyboard keys (or
- keys combinations).</para>
- <table>
- <title>Hibernate Mapping Diagram Shortcut Keys</title>
- <tgroup cols="2">
- <colspec colnum="1" align="left"
colwidth="3*"/>
- <colspec colnum="2" align="left"
colwidth="1*"/>
- <thead>
- <row>
- <entry align="center">
- <para>Command</para>
- </entry>
- <entry align="center">
- <para>Binding</para>
- </entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <para>Scroll the diagram content</para>
- </entry>
- <entry>
- <para>Ctrl + Shift + arrows</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Collapse/Expand selected item(s)</para>
- </entry>
- <entry>
- <para> Enter </para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Show/Hide selected item(s)</para>
- </entry>
- <entry>
- <para> + </para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Sort items in alphabetical order or return the initial
state</para>
- </entry>
- <entry>
- <para>Space</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Navigate between the items</para>
- </entry>
- <entry>
- <para>Arrows</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <para>It's possible to save the diagram in the eclipse workspace.
Click the usual
- <emphasis>
- <property>File > Save As</property>
- </emphasis> option, the wizard will ask you to set the location within
you project where
- to save the file and give the name for the diagram. The item's names
concatenated
- with the ampersand symbols are set as the default name for a diagram. The file
is saved
- with the <literal>.hibernate</literal> extension.</para>
- <figure>
- <title>The Diagram saved in the Workspace</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/saveDiagram.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <tip>
- <title>Note:</title>
- <para>If you restart the Eclipse with the mapping diagram opened, the
mapping diagram will
- be restored with the message like on the figure below. To view the diagram
content, you
- should perform the refreshing.</para>
- </tip>
- <figure>
- <title>The Diagram after Restarting the Eclipse</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/diagram1.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <figure>
- <title>The Diagram after Refreshing</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/diagram2.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>There are some useful commands in the toolbar.</para>
- <figure>
- <title>The Diagram View Toolbar</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/diagramToolbar.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>They are described in the table below.</para>
- <table>
- <title>Command in Diagram View Toolbar </title>
- <tgroup cols="3">
- <colspec colnum="1" align="left"
colwidth="1*"/>
- <colspec colnum="2" align="left"
colwidth="1*"/>
- <colspec colnum="3" align="left"
colwidth="3*"/>
- <thead>
- <row>
- <entry align="center">
- <para>Icon</para>
- </entry>
- <entry align="center">
- <para>Command</para>
- </entry>
- <entry align="center">
- <para>Description</para>
- </entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <para>
- <inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/toolbarRefresh.png"/>
- </imageobject>
- </inlinemediaobject>
- </para>
- </entry>
- <entry>
- <para>Refresh Visual Mapping</para>
- </entry>
- <entry>
- <para>It update <property>Mapping Diagram</property>
if <property>Console
- Configuration</property> was changed. </para>
- </entry>
- </row>
- <row>
- <entry>
- <para>
- <inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/toolbarZoom.png"/>
- </imageobject>
- </inlinemediaobject>
- </para>
- </entry>
- <entry>
- <para>Zoom Box</para>
- </entry>
- <entry>
- <para>Used to define scale of the diagram. Also it's used for
<property>Mapping
- Diagram</property> printing. If you want to put the whole
<property
- >diagram</property> to one print page, you need select
<property
- >Page</property> option in the <property>Zoom
Box</property>.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>
- <inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/toolbarAutolayout.png"/>
- </imageobject>
- </inlinemediaobject>
- </para>
- </entry>
- <entry>
- <para>Auto layout</para>
- </entry>
- <entry>
- <para>Used to arrange all diagram items in a standard
manner.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>
- <inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/toolbarShowHideConnections.png"/>
- </imageobject>
- </inlinemediaobject>
- </para>
- </entry>
- <entry>
- <para>Show|Hide connections</para>
- </entry>
- <entry>
- <para>Used to show or hide connection on the diagram. Moreover
you can choose what
- type of connections must be present on the diagram
(<property>Property
- Mappings</property>, <property>Class
Mappings</property>, <property
- >Associations</property> or <property>Foreign key
constraints</property>)
- .</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>
- <inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/toolbarExpandCollapse.png"/>
- </imageobject>
- </inlinemediaobject>
- </para>
- </entry>
- <entry>
- <para>Expand|Collapse</para>
- </entry>
- <entry>
- <para>Used for expanding/collapsing fields of the
item.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>
- <inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/toolbarShowHideShapes.png"/>
- </imageobject>
- </inlinemediaobject>
- </para>
- </entry>
- <entry>
- <para> Show|Hide shape(s)</para>
- </entry>
- <entry>
- <para>Used to hide/show an item on the mapping
diagram.</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </section>
- </section>
- <section>
- <title>Prototyping Queries</title>
- <para>Queries can be prototyped by entering them into the
<property>HQL</property> or
- <property>Criteria Editor</property>. To execute a query you should
click the green run
- button in the editor toolbar or press <emphasis>
- <property>Ctrl+Enter</property>
- </emphasis>.</para>
- <section id="hql_and_criteria_editors">
- <title>HQL Editor and Hibernate Criteria Editor</title>
- <para>To open the query editors right-click your project
<property>Console
- Configuration</property> and select <property>HQL
Editor</property> (or <property
- >Hibernate Criteria Editor</property>).</para>
- <figure>
- <title>Opening HQL Editor</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/prototypingQueries.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <tip>
- <title>Tip:</title>
- <para>If the context menu items are disabled then you need at first to
create a <property
- >Session Factory</property>. That is done by simply expanding the
<property>Session
- Factory</property> node.</para>
- </tip>
- <para>When open the editors they should automatically detect the chosen
Console
- Configuration.</para>
- <para>To get a prefill query for any entity (or any entity child node)
listed in the
- <emphasis>
- <property>Session Factory</property>
- </emphasis> you should double-click it. This will open the
<property>HQL Editor</property>
- with the associated query.</para>
- <para>Choosing <emphasis>
- <property>HQL Editor</property>
- </emphasis> in the context menu for any entity (or any entity child node)
will also open
- the HQL editor with the associated query. If you choose <emphasis>
- <property>Hibernate Criteria Editor</property>
- </emphasis> in the context menu, it will open <property>Hibernate
Criteria
- Editor</property> with the associated criteria.</para>
- <figure>
- <title>Generating Simple Queries</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center" scale="80"
fileref="images/plugins/plugins_19.png"
- format="PNG"/>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_19.png" format="PNG"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>It's also possible to copy a portion of code from
<emphasis>
- <property>.java</property>
- </emphasis> file into the <property>HQL</property> or
<property>Criteria
- editor</property>. To do this make use of the Quick Fix option
(<emphasis>
- <property>Ctrl + 1</property>)</emphasis>.</para>
- <figure>
- <title>Quick Fix Option Demonstration</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/plugins_19_b.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>You can also update the original java code according to changes in
the HQL or Criteria
- editor. For that you should save your HQL/Criteria query and submit the
replacing in
- appeared confirmation dialog.</para>
- <figure>
- <title>Updating Java Code</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/plugins_19_c.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>Also you can pin <property>HQL editor</property> and
<property>Criteria
- editor</property> for one tab in <property>Hibernate Query
Result</property> view. For
- that you need click on <property>Stick result to one
tab</property>
- button(<inlinemediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/sticky_but.png"/>
- </imageobject>
- </inlinemediaobject> ). In the issue query executions results will be
shown in one tab (no
- more will be opened). </para>
- <para> Moreover you are able to rename tab in <property>Hibernate
Query Result</property>.
- Click the tab, and type a new name in <property>Property View->Tab
name field</property>. </para>
- <figure>
- <title>Tab Renaming</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/plugins_19_d.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- </section>
- <section>
- <title>Error Handling</title>
- <para>Errors during creation of the <property>Session
Factory</property> or running the
- queries (e.g. if your configuration or query is incorrect) will be shown in a
message
- dialog or inclined in the view that detected the error, you may get more
information about
- the error in the <property>Error Log View</property> on the right
pane.</para>
- <para>Results of a query will be shown in the <property>Hibernate
Query Result
- View</property> and details of possible errors (syntax errors, database
errors, etc.)
- can be seen in the <property>Error Log
View</property>.</para>
- <note>
- <title>Note:</title>
- <para>HQL queries are executed by default using
<literal>list()</literal> thus without any
- limit of the size of the output the query could return a large result set.
You might run
- out of memory. To avoid this you can put a value in the Max results field to
reduce the
- number of elements returned.</para>
- </note>
- </section>
- <section>
- <title>Dynamic Query Translator</title>
- <para>If the <property>Hibernate Dynamic Query Translator
View</property> is visible while
- writing in the <property>HQL Editor</property> it will show the
generated SQL for a HQL
- query.</para>
- <figure>
- <title>Hibernate Dynamic Query Translator View</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center" scale="80"
fileref="images/plugins/plugins_20.png"
- format="PNG"/>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_20.png" format="PNG"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The translation is done each time you stop typing into the editor, if
there are errors
- in the HQL the parse exception will be shown embedded in the
view.</para>
- </section>
- </section>
- <section>
- <title>Properties View</title>
- <para>As you can see on the figure,when clicking on class/entity
<property>Properties
- view</property> shows the number of query results as well as the time of
executing.</para>
- <figure>
- <title>Properties View</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center" scale="80"
fileref="images/plugins/plugins_21_a.png"
- format="PNG"/>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_21_a.png" format="PNG"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>It also displays the structure of any persistent object selected in the
<property
- >Hibernate Query Results View</property>. Editing is not yet
supported.</para>
- <figure>
- <title>Properties View for Selected Object</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center" scale="80"
fileref="images/plugins/plugins_21_b.png"
- format="PNG"/>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_21_b.png" format="PNG"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>You can also use <property>Properties view</property> when
clicking on the configuration
- itself in Hibernate Configuration View( <xref
linkend="modif_console_conf"/>). </para>
- </section>
- </section>
- <section id="jpa_annotations">
- <title>Hibernate:add JPA annotations refactoring </title>
- <para>Using this wizard you can add the next Hibernate annotations to the
class: <emphasis>
- <property>@Column</property>
- </emphasis>,<emphasis>
- <property>@Entity</property>
- </emphasis>,<emphasis>
- <property>@ManyToOne</property>
- </emphasis>,<emphasis>
- <property>@OneToMany</property>
- </emphasis>,<emphasis>
- <property>@OneToOne</property>
- </emphasis>,<emphasis>
- <property>@ManyToMany</property>
- </emphasis>,<emphasis>
- <property>@MappedSuperclass</property>
- </emphasis>,<emphasis>
- <property>@Id</property>
- </emphasis>,<emphasis>
- <property>@GeneratedValue</property>
- </emphasis> ,<emphasis>
- <property>@Version </property>
- </emphasis>
- </para>
- <itemizedlist>
- <listitem>
- <para><emphasis>
- <property>@Column</property>
- </emphasis> is added to all String properties.</para>
- </listitem>
- <listitem>
- <para><emphasis>
- <property>@Entity</property>
- </emphasis> is always declared before any class where it doesn't
present.</para>
- </listitem>
- <listitem>
- <para><emphasis>
- <property>@ManyToOne</property>
- </emphasis>,<emphasis>
- <property>@OneToMany</property>
- </emphasis>,<emphasis>
- <property>@OneToOne</property>
- </emphasis>,<emphasis>
- <property>@ManyToMany</property>
- </emphasis> - this annotations are declared according to the classes
hierarchy.</para>
- </listitem>
- <listitem>
- <para><emphasis>
- <property>@MappedSuperclass</property>
- </emphasis> is added to abstract superclasses.</para>
- </listitem>
- <listitem>
- <para><emphasis>
- <property>@Id</property>
- </emphasis>,<emphasis>
- <property>@GeneratedValue</property>
- </emphasis> are added automatically only to the properties under the name
"Id",where they
- don't present.</para>
- </listitem>
- <listitem>
- <para><emphasis>
- <property>@Version</property>
- </emphasis> is declared in case you select <xref
linkend="optim_lock"/>.</para>
- </listitem>
- </itemizedlist>
- <note>
- <title>Note:</title>
- <para>This section doesn't cover the meaning of the
<property>Hibernate annotations</property>
- , for more information read <ulink
-
url="http://docs.jboss.org/hibernate/stable/annotations/reference/en...
- Annotations Documentation</ulink> .</para>
- </note>
- <para>To open this wizard you should right click the class you want to enrich
with annotations
- <emphasis>
- <property>>Source>Generate Hibernate/JPA
annotations</property>
- </emphasis>. You will see the Hibernate:add JPA annotations dialog.
</para>
- <figure>
- <title>Starting Hibernate:add JPA annotations dialog</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/annotations1.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para> In the top of it you can see the list of all classes that will be passed
through
- refactoring. Besides the class you have selected in this list you can also find
its
- superclasses and the classes that objects present in the current class as
properties. If you
- want to add new classes or package to the list of classes, you should click the
<property
- >Back</property> button. In result you will see <property>Add
classes and
- packages</property> page.</para>
- <figure>
- <title>Add classes and packages page </title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/annotations1_a.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>Here you can add one more classes or whole package, moreover you can
limit dependencies
- depth by selecting <property>depth control</property> option (more
about this option you will
- find in <xref linkend="depth_control"/>). When finished
- just press the <property>Next</property> button and you will be
returned to <property>The
- following classes will be changed</property> page and will be able to
continue work with
- it.</para>
- <para>By default the tags are added to the fields of selected classes. But you
can change this
- option to <emphasis>
- <property>Getters</property>
- </emphasis>in <emphasis>
- <property> Preferred location of Annotations</property>
- </emphasis> dropdownlist and then all the annotations will be added to the
getter methods. If
- you choose <emphasis>
- <property>Auto select from class preference</property>
- </emphasis> then the annotations are added according to the majority of the
already existed
- ones positions. </para>
- <para> If it's nessecary to map your String properties to the columns that
length differ from
- the default value(255) ,change <emphasis>
- <property>Default string length field</property>
- </emphasis> and <code>@Column(length = your length)</code> will
be created before every String
- property. </para>
- <para id="optim_lock">You can add optimistic locking capability to an
entity bean by selecting
- <emphasis>
- <property>Enable optimistic locking</property>
- </emphasis> checkbox. This operation will add version property to all the
selected classes.
- The property will be also annotated with @Version ,getter and setter will be
created. If the
- property is already exists,it won't be created ,but the getters,setters will be
generated. If
- there is already @MappedSuperclass with version in the base class of the current
class -
- <emphasis>
- <property>"version"</property>
- </emphasis> is not inserted into the current class. </para>
- <para>After defining all necessary settings in the current step press
<emphasis>
- <property>Next</property>
- </emphasis> and follow the next wizard steps. </para>
- <figure>
- <title>Hibernate:add JPA annotations view</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/annotations2.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The view represents two windows: one with the source code and and the
second with
- refactored one. With the help of <inlinemediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/butt1.png"/>
- </imageobject>
- </inlinemediaobject> ,<inlinemediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/butt2.png"/>
- </imageobject>
- </inlinemediaobject> ,<inlinemediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/butt3.png"/>
- </imageobject>
- </inlinemediaobject> ,<inlinemediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/butt4.png"/>
- </imageobject>
- </inlinemediaobject> buttons you can quickly navigate between the differences
in the code. If
- you don't agree with some changes you can't undo them but you can remove
the class from the
- list of classes that need refactoring. </para>
- <figure>
- <title>List of classes that need refactoring</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/annotations3.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>To apply the changes click <emphasis>
- <property>Finish</property>
- </emphasis>.</para>
- </section>
- <section id="debug_log">
- <title>Enable debug logging in the plugins</title>
- <para>It is possible to configure the eclipse plugin to route all logging made
by the plugins
- and hibernate code it self to the <property>Error Log View</property>
in Eclipse.</para>
- <para><property>Error Log View</property> is very useful tool to
solve any problem which appears in Hibernate Tools Plugins.
- You can use if there are troubles with setting up <property>Hibernate Console
Configuration</property>.</para>
- <para>This is done by editing the <emphasis>
- <property>hibernate-log4j.properties</property>
- </emphasis> in <emphasis>
- <property>org.hibernate.eclipse/ directory/jar</property>
- </emphasis>. This file includes a default configuration that only logs WARN
and above to a set
- of custom appenders (PluginFileAppender and PluginLogAppender). You can change
these settings
- to be as verbose or silent as you please - see <ulink
url="http://www.hibernate.org/5.html"
- >Hibernate Documentation</ulink> for interesting categories and Log4j
documentation.</para>
- <section>
- <title>Relevant Resources Links</title>
- <para>Find more on how to configure logging via a log4j property file in
<ulink
-
url="http://supportweb.cs.bham.ac.uk/docs/tutorials/docsystem/build/tutorials/log4j/log4j.html"
- >Log4j documentation</ulink>.</para>
- </section>
- </section>
- <section id="dali_integration">
- <title>Hibernate support for Dali plugins in Eclipse WTP</title>
- <para>Starting from 3.0.0 Alpha1 version of <property>JBoss
Tools</property> Hibernate plugins
- support Eclipse Dali integration what now makes it possible to use a Hibernate as a
complete
- JPA development platform.</para>
- <para>When starting a new JPA project from <emphasis>
- <property>New > Other > JPA > JPA
Project</property>
- </emphasis> (or simply <emphasis>
- <property>New > JPA Project</property>
- </emphasis> in <property>JPA Perspective</property>), the first
wizard page looks as
- follows.</para>
- <figure>
- <title>Starting JPA Project</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/dali_integration1.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>It's possible here to select a target runtime and change the
project configuration,
- or you can leave everything as it is.</para>
- <para>On the JPA Facet page you should choose Hibernate as a target platform.
Also select the
- proper database connection, if it is defined, or add a new one by clicking the
<emphasis>
- <property>Add connection</property>
- </emphasis> link.</para>
- <para>Hitting <emphasis>
- <property>Finish</property>
- </emphasis> will generate the project.</para>
- <figure>
- <title>Targeting at Hibernate Platform</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/dali_integration2.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <note>
- <title>Note:</title>
- <para>Please note, if you choose Hibernate as a platform while creating a
JPA/Dali project, a
- Hibernate Console Configuration for the project is created automatically when the
wizard
- finishes its work. It allows a full usage of <property>Hibernate
Tools</property> features
- without additional setup.</para>
- </note>
- <para>By enabling Hibernate platform specific features you can now generate DDL
and Entities.
- For that find <emphasis>
- <property>JPA Tools > Generate Tables from Entities/Generate Entities
from Tables</property>
- </emphasis> options in the context menu of your JPA project.</para>
- <figure>
- <title>Generate DDL/Entities</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/dali_integration3.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <note>
- <title>Note:</title>
- <para>Please, remember to put the proper database driver to the classpath of
your
- project.</para>
- </note>
- <para>The <property>Generate Entities wizard</property> first will
ask you to choose the
- directory where all output will be written.</para>
- <figure>
- <title>Generate Entities Wizard</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/dali_integration4.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>To generate entities you can use:</para>
- <itemizedlist>
- <listitem>
- <para>a Hibernate Console Configuration (proposed by default)</para>
- <para>Just make sure that the <emphasis>
- <property>Use Console Configuration</property>
- </emphasis> checkbox is selected and choose a needed configuration from
the <emphasis>
- <property>Console configurations</property>
- </emphasis> list box.</para>
- <figure>
- <title>Generate Entities Wizard</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/dali_integration5.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- </listitem>
- </itemizedlist>
- <itemizedlist>
- <listitem>
- <para>or a DTP connection directly</para>
- <para>Just uncheck <emphasis>
- <property>Use Console Configuration</property>
- </emphasis> and adjust database settings.</para>
- </listitem>
- </itemizedlist>
- <para>All the same you do with Generate Entities Wizard you can do with
Generate DDL wizard.
- Special feature for Generate DDL wizard is possible automatic execution of
Generation DDL in
- the database. </para>
- <figure>
- <title>Generate DDL Wizard</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/plugins/dali_integration6.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>Thus, you can now have the Hibernate runtime support in Eclipse JPA
projects.</para>
- </section>
-</chapter>
Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_0.png
===================================================================
(Binary files differ)
Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_0_a.png
===================================================================
(Binary files differ)
Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_0_b.png
===================================================================
(Binary files differ)
Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_1.png
===================================================================
(Binary files differ)
Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_2.png
===================================================================
(Binary files differ)
Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_2_a.png
===================================================================
(Binary files differ)
Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_3.png
===================================================================
(Binary files differ)
Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_4_a.png
===================================================================
(Binary files differ)
Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_4_b.png
===================================================================
(Binary files differ)
Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_4_c.png
===================================================================
(Binary files differ)
Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_4_d.png
===================================================================
(Binary files differ)
Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_5.png
===================================================================
(Binary files differ)
Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_6.png
===================================================================
(Binary files differ)
Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_7.png
===================================================================
(Binary files differ)
Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_8.png
===================================================================
(Binary files differ)
Modified: trunk/hibernatetools/docs/reference/en-US/introduction.xml
===================================================================
--- trunk/hibernatetools/docs/reference/en-US/introduction.xml 2011-03-02 22:58:02 UTC
(rev 29454)
+++ trunk/hibernatetools/docs/reference/en-US/introduction.xml 2011-03-02 23:34:47 UTC
(rev 29455)
@@ -151,15 +151,15 @@
<section>
<title>Other relevant resources on the topic</title>
- <para><productname>Hibernate Tools</productname> page on <ulink
url="http://www.hibernate.org/">hibernate.org</ulink>....
+ <para>The <productname>Hibernate Tools</productname> page on
<ulink
url="http://www.hibernate.org/subprojects/tools.html">hibern...
<para>
- All <productname>JBoss Tools</productname> release documentation can be
found at <ulink
url="http://docs.jboss.org/tools/">http://docs.jboss.org/too...
in the corresponding release directory.
+ All <productname>JBDS</productname> release documentation can be found on
the <ulink
url="http://docs.redhat.com/docs/en-US/JBoss_Developer_Studio/index....
Documentation</ulink> website.
</para>
<para>
- There is some extra information about <productname>Hibernate</productname>
on the <ulink
url="http://www.jboss.org/community/wiki/JBossHibernate3">JBoss Wiki page.
</ulink>
+ There is some additional information on
<productname>Hibernate</productname> on the <ulink
url="http://www.jboss.org/community/wiki/JBossHibernate3">JBoss
Wiki</ulink> page.
</para>
<para>
- The latest <productname>JBoss Tools</productname> documentation builds are
available at <ulink
url="http://download.jboss.org/jbosstools/nightly-docs/">htt...;.
+ Nighly documentation builds are available <ulink
url="http://download.jboss.org/jbosstools/nightly-docs/">her...;.
</para>
</section>
Deleted: trunk/hibernatetools/docs/reference/en-US/master.xml
===================================================================
--- trunk/hibernatetools/docs/reference/en-US/master.xml 2011-03-02 22:58:02 UTC (rev
29454)
+++ trunk/hibernatetools/docs/reference/en-US/master.xml 2011-03-02 23:34:47 UTC (rev
29455)
@@ -1,82 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
-"http://www.docbook.org/xml/4.3/docbookx.dtd"
-
-[
-<!ENTITY introduction SYSTEM "introduction.xml">
-<!ENTITY setup SYSTEM "setup.xml">
-<!ENTITY codegenarchitecture SYSTEM "codegenarchitecture.xml">
-<!ENTITY plugins SYSTEM "plugins.xml">
-<!ENTITY ant SYSTEM "ant.xml">
-<!ENTITY reveng SYSTEM "reverseengineering.xml">
-<!ENTITY codegen SYSTEM "codegen.xml">
-
-<!ENTITY seamlink "../../seam/html_single/index.html">
-<!ENTITY aslink "../../as/html_single/index.html">
-<!ENTITY esblink "../../esb_ref_guide/html_single/index.html">
-<!ENTITY gsglink "../../GettingStartedGuide/html_single/index.html">
-<!ENTITY hibernatelink "../../hibernatetools/html_single/index.html">
-<!ENTITY jbpmlink "../../jbpm/html_single/index.html">
-<!ENTITY jsflink "../../jsf/html_single/index.html">
-<!ENTITY jsfreflink "../../jsf_tools_ref_guide/html_single/index.html">
-<!ENTITY jsftutoriallink
"../../jsf_tools_tutorial/html_single/index.html">
-<!ENTITY strutsreflink
"../../struts_tools_ref_guide/html_single/index.html">
-<!ENTITY strutstutoriallink
"../../struts_tools_tutorial/html_single/index.html">
-
-]>
-<book>
- <bookinfo>
- <title>Hibernate Tools Reference Guide</title>
- <corpauthor>
- <inlinemediaobject>
- <imageobject role="fo">
- <imagedata format="PNG"
fileref="images/jbosstools_logo.png" />
- </imageobject>
- <imageobject role="html">
- <imagedata/>
- </imageobject>
- </inlinemediaobject>
- </corpauthor>
-
<author><firstname>Max</firstname><surname>Andersen</surname><email>max.andersen(a)jboss.com</email></author>
-
<author><firstname>Olga</firstname><surname>Chikvina</surname></author>
-
<author><firstname>Svetlana</firstname><surname>Mukhina</surname><email>smukhina(a)exadel.com</email></author>
-
- <copyright>
- <year>2007</year>
- <year>2008</year>
- <year>2009</year>
- <year>2010</year>
- <holder>JBoss by Red Hat</holder>
- </copyright>
-
- <releaseinfo>
- Version: 3.3.1.GA
- </releaseinfo>
-
-
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/hibernate_logo_a.png"
format="PNG"/>
- </imageobject>
- </mediaobject>
-
-<abstract>
- <title/>
- <para>
- <ulink
url="http://download.jboss.org/jbosstools/nightly-docs/en/hibernatet...
version</ulink>
- </para>
-</abstract>
-
- </bookinfo>
- <toc/>
-
- &introduction;
- &setup;
- &codegenarchitecture;
- &plugins;
- &ant;
- &reveng;
- &codegen;
-
-
- </book>
Deleted: trunk/hibernatetools/docs/reference/en-US/master_output.xml
===================================================================
--- trunk/hibernatetools/docs/reference/en-US/master_output.xml 2011-03-02 22:58:02 UTC
(rev 29454)
+++ trunk/hibernatetools/docs/reference/en-US/master_output.xml 2011-03-02 23:34:47 UTC
(rev 29455)
@@ -1,5822 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
-"http://www.docbook.org/xml/4.3/docbookx.dtd"
-
-[
-<!ENTITY introduction SYSTEM "introduction.xml">
-<!ENTITY setup SYSTEM "setup.xml">
-<!ENTITY codegenarchitecture SYSTEM "codegenarchitecture.xml">
-<!ENTITY plugins SYSTEM "plugins.xml">
-<!ENTITY ant SYSTEM "ant.xml">
-<!ENTITY reveng SYSTEM "reverseengineering.xml">
-<!ENTITY codegen SYSTEM "codegen.xml">
-
-<!ENTITY seamlink "../../seam/html_single/index.html">
-<!ENTITY aslink "../../as/html_single/index.html">
-<!ENTITY esblink "../../esb_ref_guide/html_single/index.html">
-<!ENTITY gsglink "../../GettingStartedGuide/html_single/index.html">
-<!ENTITY hibernatelink "../../hibernatetools/html_single/index.html">
-<!ENTITY jbpmlink "../../jbpm/html_single/index.html">
-<!ENTITY jsflink "../../jsf/html_single/index.html">
-<!ENTITY jsfreflink "../../jsf_tools_ref_guide/html_single/index.html">
-<!ENTITY jsftutoriallink
"../../jsf_tools_tutorial/html_single/index.html">
-<!ENTITY strutsreflink
"../../struts_tools_ref_guide/html_single/index.html">
-<!ENTITY strutstutoriallink
"../../struts_tools_tutorial/html_single/index.html">
-
-]><book
xmlns:diffmk="http://diffmk.sf.net/ns/diff">
- <bookinfo>
- <title>Hibernate Tools Reference Guide</title>
- <corpauthor>
- <inlinemediaobject>
- <imageobject role="fo">
- <imagedata fileref="images/jbosstools_logo.png"
format="PNG"></imagedata>
- </imageobject>
- <imageobject role="html">
- <imagedata></imagedata>
- </imageobject>
- </inlinemediaobject>
- </corpauthor>
-
<author><firstname>Max</firstname><surname>Andersen</surname><email>max.andersen(a)jboss.com</email></author>
-
<author><firstname>Olga</firstname><surname>Chikvina</surname></author>
-
<author><firstname>Svetlana</firstname><surname>Mukhina</surname><email>smukhina(a)exadel.com</email></author>
-
- <copyright>
- <year>2007</year>
- <year>2008</year>
- <year>2009</year>
- <year>2010</year>
- <holder>JBoss by Red Hat</holder>
- </copyright>
-
- <releaseinfo><diffmk:wrapper diffmk:change="changed">
- Version: 3.3.1.GA
- </diffmk:wrapper></releaseinfo>
-
-
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/hibernate_logo_a.png"
format="PNG"></imagedata>
- </imageobject>
- </mediaobject>
-
-<abstract>
- <title></title>
- <para>
- <ulink
url="http://download.jboss.org/jbosstools/nightly-docs/en/hibernatet...
version</ulink>
- </para>
-</abstract>
-
- </bookinfo>
- <toc></toc>
-
-
-<chapter id="introduction"
xml:base="file:///home/vchukhutsina/repos/ochik_jboss/hibernatetools/docs/reference/en-US/introduction.xml">
-
- <title>Introduction</title>
-
- <para><property moreinfo="none">Hibernate
Tools</property> is a toolset for <ulink
url="http://www.hibernate.org/6.html">Hibernate 3</ulink> and <ulink
url="http://www.hibernate.org/27.html">related projects</ulink>. The
tools provide Ant
- tasks and Eclipse plugins for performing reverse engineering, code generation,
visualization
- and interaction with Hibernate.</para>
-
- <section id="hibernate_key_features">
- <title>Key Features</title>
-
- <para>First, we propose to look through the list of key features that you
can benefit from
- if you start using <property moreinfo="none">Hibernate
Tools</property>.</para>
-
- <table>
- <title>Key Functionality for Hibernate Tools</title>
- <tgroup cols="3">
-
- <colspec align="left" colnum="1"
colwidth="1*"></colspec>
- <colspec colnum="2"
colwidth="5*"></colspec>
- <colspec align="left" colnum="3"
colwidth="1*"></colspec>
-
- <thead>
- <row>
- <entry>Feature</entry>
- <entry>Benefit</entry>
- <entry>Chapter</entry>
- </row>
- </thead>
-
- <tbody>
-
- <row>
- <entry>
- <para>Code Generation through Ant Task</para>
- </entry>
- <entry>
- <para>Allows to execute mapping or Java code generation
from reverse
- engineering, schema generation and generation of other
artifacts
- during the build process.</para>
- </entry>
- <entry><link linkend="ant">ant
task</link></entry>
- </row>
-
- <row>
- <entry>
- <para>Wizards for creation
- purposes and code
- generation</para>
- </entry>
- <entry>
- <para> A set of wizards are provided with the Hibernate
Eclipse tools to
- quickly create common Hibernate files such as
configuration
- (cfg.xml) files, mapping files and revenge.xml as well.
Code
- Generation wizard helps to generate a series of various
artifacts,
- there is even support for completely reverse engineer an
existing
- database schema.</para>
- </entry>
- <entry> <link
linkend="map_file_wizard">hibernate mapping file</link>
- <link
linkend="hib_config_file">hibernate configuration file</link>
- <link linkend="code_gen">code
generation</link>
- </entry>
- </row>
-
-
- <row>
- <entry>
- <para>
- Mapping and Configuration files
- Editors
- </para>
- </entry>
- <entry>
- <para>Support auto-completion and syntax highlighting.
Editors also
- support semantic auto-completion for class names and
property/field
- names, making it much more versatile than a normal XML
- editor.</para>
- </entry>
- <entry> <link
linkend="map_config_editor">mapping and configuration files
editors</link></entry>
- </row>
-
- <row>
- <entry>
- <para>Tools for organizing and controlling Reverse
Engineering</para>
- </entry>
- <entry>
- <para>Code Generation wizard provides powerful
functionality for
- generating a series of various artifacts like domain
model classes,
- mapping files, annotated EJB3 entity beans, etc. and
reveng.xml file
- editor allows to control this processes.</para>
- </entry>
- <entry><link linkend="code_gen">code
generation</link>
- <link linkend="rev_xml_editor">reveng.xml
editor</link></entry>
- </row>
-
- <row>
- <entry>
- <para>Hibernate Console</para>
- </entry>
- <entry>
- <para>It is a new perspective in Eclipse which provides
an overview of
- your Hibernate Console configurations, were you also can
get an
- interactive view of your persistent classes and their
relationships.
- The console allows you to execute HQL queries against
your database
- and browse the result directly in Eclipse.</para>
- </entry>
- <entry><link
linkend="hib_console">hibernate console</link></entry>
- </row>
-
- <row>
- <entry>
- <para>HQL Editor and Hibernate Criteria Editor</para>
- </entry>
- <entry>
- <para>The editors are intended for writing, editing and
executing HQL queries and criterias. They also support the functionality for generating
- simple queries.</para>
- </entry>
- <entry><link
linkend="hql_and_criteria_editors">hql and hibernate criteria
editors</link></entry>
- </row>
-
- <row>
- <entry>
- <para>Functional Mapping Diagram</para>
- </entry>
- <entry>
- <para>Makes possible to visualize structure of entities
and
- relationships between them.</para>
- </entry>
- <entry><link linkend="map_diagram">mapping
diagram</link></entry>
- </row>
-
-
- <row>
- <entry>
- <para>Eclipse JDT integration</para>
- </entry>
- <entry>
- <para>Hibernate Tools integrates into the Java code
completion and build
- support of Java in Eclipse. This gives you code
completion of HQL
- inside Java code. Additionally, Hibernate Tools will add
problem
- markers if your queries are not valid against the
console
- configuration associated with the project.</para>
- </entry>
- </row>
-
- </tbody>
- </tgroup>
- </table>
- </section>
-
- <section>
- <title>Other relevant resources on the topic</title>
-
- <!--para>Hibernate Tools page on the <ulink
url="http://www.hibernate.org/255.html">hibernate.org</ul...
- <para>All JBoss Developer Studio/JBoss Tools release documentation you can
find at<ulink
url="http://docs.jboss.org/tools/">http://docs.jboss.org/too...
in the corresponding release directory.</para>
- <para>There is some extra information about Hidernate on <ulink
url="http://www.jboss.org/community/wiki/JBossHibernate3">JBoss Wiki page.
</ulink></para>
- <para>The latest documentation builds are available at <ulink
url="http://download.jboss.org/jbosstools/nightly-docs/">htt...
- </section>
-
-</chapter>
-
-
-<chapter id="setup"
xml:base="file:///home/vchukhutsina/repos/ochik_jboss/hibernatetools/docs/reference/en-US/setup.xml">
- <title>Download and install Hibernate Tools</title>
- <para><property moreinfo="none">Hibernate Tools</property>
can be used "standalone" via Ant 1.6.x or
- fully integrated into an Eclipse + WTP based IDE, such as <property
moreinfo="none">JBDS/JBoss Tools</property>,
- or a default Eclipse + WTP installation. The following sections describe the install
steps in
- these environments.</para>
- <note>
- <title>Note:</title>
- <para>The <property moreinfo="none">Hibernate Tools
3.3.0</property> (the current release version) requires
- Eclipse Galileo 3.5.</para>
- </note>
- <section>
- <title>JBoss Tools</title>
- <para><property moreinfo="none">JBoss Tools
3.1.0</property> (the latest release) includes <property
moreinfo="none">Hibernate
- Tools 3.3.0</property> and thus nothing is required besides <property
moreinfo="none">downloading</property>
- and <property moreinfo="none">installing JBoss
Tools</property>. If you need to update to a newer version of
- the <property moreinfo="none">Hibernate Tools</property> just
follow the instructions in the Eclipse IDE
- section.</para>
- </section>
- <section>
- <title>Eclipse IDE</title>
- <para>To install the <property moreinfo="none">Hibernate
Tools</property> into any <property moreinfo="none">Eclipse
- 3.5</property> based IDE you can either use <ulink
url="http://download.jboss.org/jbosstools/updates/stable/">J... Tools Update
Site</ulink>
- or install it manually.</para>
- <para>If you want to install the <property
moreinfo="none">Hibernate Tools</property> distribution manually you
- need to:</para>
- <itemizedlist>
- <listitem>
- <para>Download from
www.eclipse.org:</para>
- <itemizedlist>
- <listitem>
- <para>birt-report-framework-2_5_0.zip</para>
- </listitem>
- <listitem>
- <para>birt-wtp-integration-sdk-2_3_2.zip</para>
- </listitem>
- <listitem>
- <para>dtp-sdk_1.7.0.zip</para>
- </listitem>
- <listitem>
- <para>eclipse-SDK-3.5-win32.zip</para>
- </listitem>
- <listitem>
- <para>emf-runtime-2.5.0.zip</para>
- </listitem>
- <listitem>
- <para>GEF-SDK-3.5.0.zip</para>
- </listitem>
- <listitem>
-
<para>org.eclipse.swtbot.eclipse.test-2.0.0.371-dev-e35.zip</para>
- </listitem>
- <listitem>
- <para>org.eclipse.swtbot.eclipse-2.0.0.340-dev.zip</para>
- </listitem>
- <listitem>
- <para>site-1.6.2.zip</para>
- </listitem>
- <listitem>
- <para>tptp.sdk-TPTP-4.6.0.zip</para>
- </listitem>
- <listitem>
- <para>wtp-sdk-R-3.1-20090616035105.zip</para>
- </listitem>
- <listitem>
- <para>xsd-runtime-2.5.0.zip</para>
- </listitem>
- </itemizedlist>
- </listitem>
- <listitem>
- <para>Then you should unpack these files into Eclipse install
folder.</para>
- </listitem>
- <listitem>
- <para>From <ulink
url="https://www.hibernate.org/6.html">hibernate.org-Download
Overview</ulink> download <ulink
url="http://downloads.sourceforge.net/project/jboss/JBossTools/JBoss...
Tools</ulink>
- .</para>
-
- </listitem>
- <listitem>
- <para>Unpack <property moreinfo="none">Hibernate
Tools</property> in eclipse/dropins folder</para>
- </listitem>
- </itemizedlist>
- <note>
- <title>Note:</title>
- <para>If you need more detailed instructions on plugins installation and
general usage of eclipse
- then check out <ulink
url="https://eclipse-tutorial.dev.java.net/">https://eclipse...
and especially <ulink
url="https://eclipse-tutorial.dev.java.net/visual-tutorials/updatema...
which
- covers using the update manager.</para>
- </note>
- <section>
- <title>Usage of Eclipse WTP</title>
- <para>The <property moreinfo="none">Hibernate
Tools</property> plugins currently use <property
moreinfo="none">WTP
- 3.x</property> which at this time is the latest stable release from the
Eclipse Webtools
- project.</para>
- <para>Because the WTP project not always have had proper versioning of their
plugins there
- might exist WTP plugins in your existing eclipse directory from other Eclipse
based projects
- that are from an earlier WTP release but has either the same version number or
higher. It is
- thus recommended that if you have issues with WTP provided features to try and
install the
- plugins on a clean install of eclipse to ensure there are no version
collisions.</para>
- </section>
- </section>
- <section>
- <title>Ant</title>
- <para>To use the tools via Ant you need the <emphasis>
- <property moreinfo="none">hibernate-tools.jar</property>
- </emphasis> and associated libraries. The libraries are included in the
distribution from the
- Hibernate website and the Eclipse updatesite. The libraries are located in the
eclipse plugins
- directory at <emphasis>
- <property
moreinfo="none">/plugins/org.hibernate.eclipse.x.x.x/lib/tools/</property>
- </emphasis>. These libraries are 100% independent from the eclipse platform.
How to use these
- via ant tasks are described in the <link linkend="ant">Ant
Tools</link> chapter.</para>
- </section>
-</chapter>
-
-
-<chapter id="codegenarchitecture"
xml:base="file:///home/vchukhutsina/repos/ochik_jboss/hibernatetools/docs/reference/en-US/codegenarchitecture.xml">
- <title>Code generation architecture</title>
-
- <para>The code generation mechanism in the <property
moreinfo="none">Hibernate Tools</property> consists of a few
- core concepts. This section explains their overall structure which are the same for
the Ant and
- Eclipse tools.</para>
-
- <section>
- <title>Hibernate Meta Model</title>
-
- <para>The meta model is the model used by Hibernate Core to perform its object
relational
- mapping. The model includes information about tables, columns, classes,
properties,
- components, values, collections etc. The API is in <literal
moreinfo="none">org.hibernate.mapping</literal>
- and its main entry point is the <property
moreinfo="none">Configuration</property> class, the same class that is
- used to build a session factory.</para>
-
- <para>The model represented by the <property
moreinfo="none">Configuration</property> class can be build in many
- ways. The following list the currently supported ones in <property
moreinfo="none">Hibernate Tools</property>. </para>
-
- <para>
- <itemizedlist>
- <listitem>
- <para>A Core configuration uses Hibernate Core and supports reading
<emphasis>
- <property moreinfo="none">hbm.xml</property>
- </emphasis> files, requires a <emphasis>
- <property
moreinfo="none">hibernate.cfg.xml</property>
- </emphasis>. Named core in Eclipse and
- <code><configuration></code>
- in ant.</para>
- </listitem>
-
- <listitem>
- <para>An Annotation configuration uses Hibernate Annotations and supports
<emphasis>
- <property moreinfo="none">hbm.xml</property>
- </emphasis> and annotated classes, requires a <emphasis>
- <property
moreinfo="none">hibernate.cfg.xml</property>
- </emphasis>. Named annotations in Eclipse and
- <code><annotationconfiguration></code>
- in ant.</para>
- </listitem>
-
- <listitem>
- <para>A JPA configuration uses a Hibernate EntityManager and supports
<emphasis>
- <property moreinfo="none">hbm.xml</property>
- </emphasis> and annotated classes requires that the project has a
<emphasis>
- <property
moreinfo="none">META-INF/persistence.xml</property>
- </emphasis> in its classpath. Named JPA in Eclipse and
- <code><jpaconfiguration></code>
- in ant.</para>
- </listitem>
-
- <listitem>
- <para>A JDBC configuration uses <property
moreinfo="none">Hibernate Tools</property> reverse engineering
- and reads its mappings via JDBC metadata + additional reverse engineering
files
- (reveng.xml). Automatically used in Eclipse when doing reverse engineering
from JDBC and
- named
- <code><jdbcconfiguration></code>
- in ant.</para>
- </listitem>
- </itemizedlist>
- </para>
-
- <para>In most projects you will normally use only one of the Core, Annotation
or JPA
- configuration and possibly the JDBC configuration if you are using the reverse
engineering
- facilities of <property moreinfo="none">Hibernate
Tools</property>. </para>
-
- <note>
- <title>Note:</title>
- <para>No matter which Hibernate Configuration type you are using <property
moreinfo="none">Hibernate
- Tools</property> supports them.</para>
- </note>
-
- <para>The following drawing illustrates the core concepts:</para>
-
- <para>
- <figure float="0">
- <title>Hibernate Core Concepts</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata
fileref="images/code_generation/code_generation_1.png"
format="PNG"></imagedata>
- </imageobject>
-
- <imageobject role="html">
-
- <imagedata align="center"
fileref="images/code_generation/code_generation_1.png"
format="PNG"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- </para>
-
- <para>The code generation is done based on the Configuration model no matter
which type of
- configuration have been used to create the meta model, and thus the code generation
is
- independent on the source of the meta model and represented via
Exporters.</para>
- </section>
-
- <section>
- <title>Exporters</title>
-
- <para>Code generation is done in so called Exporters. An
<code>Exporter</code> is handed a
- Hibernate Meta Model represented as a <code>Configuration</code>
instance and it is then
- the job of the exporter to generate a set of code artifacts.</para>
-
- <para>The tools provides a default set of Exporter's which can be used in
both Ant and the
- Eclipse UI. Documentation for these Exporters is in the <link
linkend="ant">Ant Tools</link>
- and <link linkend="plugins">Eclipse Plugins</link>
chapters.</para>
-
- <para>Users can provide their own customer Exporter's, either by custom
classes implementing the
- Exporter interface or simply be providing custom templates. This is documented at
<xref linkend="hbmtemplate"></xref></para>
- </section>
-</chapter>
-
-
-<chapter id="plugins" role="updated"
xml:base="file:///home/vchukhutsina/repos/ochik_jboss/hibernatetools/docs/reference/en-US/plugins.xml">
- <title>Eclipse Plugins</title>
- <para>This chapter will introduce you to the functionality that <property
moreinfo="none">Hibernate
- Tools</property> provide within Eclipse. That is a set of wizards and editors
for simplifying
- the work with <property
moreinfo="none">Hibernate</property>.</para>
- <section>
- <title>Introduction</title>
- <para>Hibernate Eclipse Tools include wizards for creating Hibernate mapping
files,
- configuration files (.cfg.xml), revenge.xml as well as wizards for adjusting
Console
- Configuration and Code Generation. Special structured and XML editors, editors for
executing
- HQL and Criteria queries are also provided in Hibernate Console. Refer to <link
linkend="hibernate_key_features">Key Features</link> section to find
all benefits that you
- can take advantage of while using the tools within Eclipse.</para>
- <note>
- <title>Note:</title>
- <para>Please note that these tools do not try to hide any functionality of
<property moreinfo="none">Hibernate</property>. The tools make
working with <property moreinfo="none">Hibernate</property> easier,
- but you are still encouraged/required to read the <ulink
url="http://www.hibernate.org/5.html">Hibernate Documentation</ulink>
to fully utilize
- <property moreinfo="none">Hibernate Tools</property> and
especially <property moreinfo="none">Hibernate</property> it
- self.</para>
- </note>
- <section id="download_base_project">
- <title>Download base project</title>
- <para><diffmk:wrapper diffmk:change="changed">You can
download example projects which are used for this
chapter.</diffmk:wrapper></para>
- <para><property moreinfo="none">JPA base
project</property><diffmk:wrapper diffmk:change="added"> is
available on </diffmk:wrapper><ulink diffmk:change="added"
url="http://docs.jboss.org/tools/resources/"><diffmk:wrapper
diffmk:change="added">documentation resources page
</diffmk:wrapper></ulink><diffmk:wrapper
diffmk:change="added">
- together with </diffmk:wrapper><ulink diffmk:change="added"
url="http://docs.jboss.org/tools/resources/TestHibernateproject_for_...
diffmk:change="added">base Java
project</diffmk:wrapper></ulink>.</para>
- <para>Also you need start <ulink
url="http://docs.jboss.org/tools/resources/GSG_database.zip">...
- <note>
- <title>Note:</title>
- <para>How to run database you can know in <ulink
url="http://docs.jboss.org/tools/3.0.1.GA/en/GettingStartedGuide/htm...
Started Guide</ulink>.</para>
- </note>
- </section>
- </section>
- <section id="map_file_wizard">
- <title>Creating a Hibernate Mapping File</title>
- <para>Hibernate mapping files are used to specify how your objects are related
to database
- tables.</para>
- <para>To create basic mappings for properties and associations, i. e. generate
<emphasis>
- <property moreinfo="none">.hbm.xml</property>
- </emphasis> files, Hibernate Tools provide a basic wizard which you can bring
up by navigating
- <emphasis>
- <property moreinfo="none">New > Hibernate XML mapping
file</property>.</emphasis></para>
- <para>At first you'll be asked to select a package or multiple individual
classes to map.
- It's also possible to create an empty file, don't select any packages or
classes and an
- empty .hbm will be created in the specified location</para>
- <para id="depth_control">With <property
moreinfo="none">depth control</property><diffmk:wrapper
diffmk:change="changed"> option you can define
- dependences depth for choosing classes (it means to set level of references which
is used to
- collect linked classes to the selection). </diffmk:wrapper></para>
- <figure float="0">
- <title>Hibernate XML Mapping File Wizard</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/plugins_0.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The next wizard page lists the mappings to be generated. As you see
<property moreinfo="none">Customers</property>, <property
moreinfo="none">Orders</property>, <property
moreinfo="none">Productlines</property><diffmk:wrapper
diffmk:change="changed"> and
- </diffmk:wrapper><property
moreinfo="none">Products</property> classes added under <property
moreinfo="none">depth control</property><diffmk:wrapper
diffmk:change="changed">
- driving. </diffmk:wrapper></para>
- <figure float="0">
- <title>Mappings to be generated</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/plugins_0_a.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>This wizard page outputs a generated .hbm files preview.</para>
- <figure float="0">
- <title>Preview Generated Mapping Files</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/plugins_0_b.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>Pressing <property
moreinfo="none">Finish</property> creates the files.</para>
- </section>
- <section id="hib_config_file">
- <title>Creating a Hibernate Configuration File</title>
- <para>To be able to reverse engineer, prototype queries, and of course to
simply use <property moreinfo="none">Hibernate Core</property> a
<emphasis>
- <property moreinfo="none">hibernate.properties</property>
- </emphasis> or <emphasis>
- <property moreinfo="none">hibernate.cfg.xml</property>
- </emphasis> file is needed. The <property
moreinfo="none">Hibernate Tools</property> provide a wizard for
- generating the <emphasis>
- <property moreinfo="none">hibernate.cfg.xml</property>
- </emphasis> file if you do not already have such one.</para>
- <para>Start the wizard by clicking <emphasis>
- <property moreinfo="none">New > Other
(Ctrl+N)</property>
- </emphasis>, then <emphasis>
- <property moreinfo="none">Hibernate > Hibernate
Configuration File (cfg.xml)</property>
- </emphasis> and press <emphasis>
- <property moreinfo="none">Next</property>
- </emphasis> or on a web Seam project in the <property
moreinfo="none">Web Projects</property> view <emphasis>
- <property moreinfo="none"> WebContent -> New ->
File -> Hibernate Configuration 3.0</property>
- </emphasis>. After selecting the wanted location for the <emphasis>
- <property moreinfo="none">hibernate.cfg.xml</property>
- </emphasis> file, you will see the following page:</para>
- <figure float="0">
- <title>Hibernate Configuration File Wizard</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center"
fileref="images/plugins/plugins_1.png"
format="PNG"></imagedata>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_1.png"
format="PNG"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <note>
- <title>Note:</title>
- <para>The contents in the combo boxes for the JDBC driver class and JDBC URL
change
- automatically, depending on the Dialect and actual driver you have
chosen.</para>
- </note>
- <para>Enter your configuration information in this dialog. Details about the
configuration
- options can be found in <ulink
url="http://docs.jboss.org/ejb3/app-server/Hibernate3/reference/en/h...
- Reference Documentation</ulink>.</para>
- <para>Press <emphasis>
- <property moreinfo="none">Finish</property>
- </emphasis> to create the configuration file, after optionally creating a
Console
- configuration, the <emphasis>
- <property moreinfo="none">hibernate.cfg.xml</property>
- </emphasis> will be automatically opened in an editor. The last option
<emphasis>
- <property moreinfo="none">Create Console
Configuration</property>
- </emphasis> is enabled by default and when enabled, it will automatically use
the <emphasis>
- <property moreinfo="none">hibernate.cfg.xml</property>
- </emphasis> for the basis of a Console configuration.</para>
- </section>
- <section id="console_conf">
- <title>Hibernate Console Configuration</title>
- <para>A Console configuration describes how the <property
moreinfo="none">Hibernate plugin</property> should
- configure <property moreinfo="none">Hibernate</property> and
what configuration files, including which
- classpath are needed to load the POJO's, JDBC drivers etc. It is required to
make usage of
- query prototyping, reverse engineering and code generation. You can have multiple
named
- console configurations. Normally you would just need one per project, but more is
definitely
- possible if your project requires this.</para>
- <section id="creat_console_conf">
- <title>Creating a Hibernate Console Configuration</title>
- <para>You can create a console configuration by running the <property
moreinfo="none">Console Configuration
- Wizard</property>, shown in the following screenshot. The same wizard
will also be used if
- you are coming from the <emphasis>
- <property moreinfo="none">hibernate.cfg.xml</property>
- </emphasis> wizard and had enabled <emphasis>
- <property moreinfo="none">Create Console
Configuration</property>
- </emphasis>.</para>
- <note>
- <title>Note:</title>
- <para>The wizard will look at the current selection in the IDE and try and
auto-detect the
- settings which you then can just approve or modify to suit your
needs.</para>
- </note>
- <para></para>
- <para>The dialog consists of five tabs: </para>
- <itemizedlist>
- <listitem>
- <para><emphasis>
- <property moreinfo="none">Main</property>
- </emphasis> for the basic/required settings</para>
- </listitem>
- </itemizedlist>
- <figure float="0">
- <title> Creating Hibernate Console Configuration</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center"
fileref="images/plugins/plugins_2.png"
format="PNG"></imagedata>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_2.png"
format="PNG"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The following table describes the available settings on the
<emphasis>
- <property moreinfo="none">Main</property>
- </emphasis><diffmk:wrapper diffmk:change="changed"> tab.
The wizard can automatically detect the default values for most of them if
- you started the wizard with the relevant java project or resource
selected.</diffmk:wrapper></para>
- <table>
- <title>Hibernate Console Configuration Parameters</title>
- <tgroup cols="3">
- <colspec align="left" colnum="1"
colwidth="1*"></colspec>
- <colspec colnum="2" colwidth="3*"></colspec>
- <colspec align="left" colnum="3"
colwidth="1*"></colspec>
- <thead>
- <row>
- <entry align="center">
- <para>Parameter</para>
- </entry>
- <entry align="center">
- <para>Description</para>
- </entry>
- <entry align="center">
- <para>Auto detected value</para>
- </entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <para>Name</para>
- </entry>
- <entry>
- <para>The unique name of the console configuration</para>
- </entry>
- <entry>
- <para>Name of the selected project</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Type</para>
- </entry>
- <entry>
- <para>Choose between "Core", "Annotations" and
"JPA".
- Note that the two latter requires running Eclipse IDE with a JDK 5
runtime,
- otherwise you will get classloading and/or version
errors.</para>
- </entry>
- <entry>
- <para>No default value</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Project</para>
- </entry>
- <entry>
- <para>The name of a java project which classpath should be used in
the console
- configuration</para>
- </entry>
- <entry>
- <para>Name of the selected project</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Database connection</para>
- </entry>
- <entry>
- <para>DTP provided connection that you can use instead of what is
in cfg.xml and jpa
- persistence.xml. It's possible to use either already configured
hibernate or
- JPA connection or specify a new one here.</para>
- </entry>
- <entry>
- <para>[Hibernate Configured connection]</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Property file</para>
- </entry>
- <entry>
- <para>Path to a hibernate.properties file</para>
- </entry>
- <entry>
- <para>First hibernate.properties file found in the selected
project</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Configuration file</para>
- </entry>
- <entry>
- <para>Path to a hibernate.cfg.xml file</para>
- </entry>
- <entry>
- <para>First hibernate.cfg.xml file found in the selected
project</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Persistence unit</para>
- </entry>
- <entry>
- <para>Name of the persistence unit to use</para>
- </entry>
- <entry>
- <para><diffmk:wrapper diffmk:change="changed">No
default value (let Hibernate Entity Manager find the persistence unit or it
- can be defined manually using Browse
button)</diffmk:wrapper></para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <tip>
- <title>Tip:</title>
- <para><diffmk:wrapper diffmk:change="changed">The two
latter settings are usually not required if you specify a project and it has
- </diffmk:wrapper><emphasis>
- <property moreinfo="none">
- <literal moreinfo="none"> /hibernate.cfg.xml
</literal>
- </property>
- </emphasis> or <emphasis>
- <property moreinfo="none">
- <literal
moreinfo="none">/META-INF/persistence.xml</literal>
- </property>
- </emphasis> in its project classpath.</para>
- </tip>
- <itemizedlist>
- <listitem>
- <para>
- <emphasis>
- <property moreinfo="none">Options</property>
- </emphasis> for the additional/optional settings</para>
- </listitem>
- </itemizedlist>
- <figure float="0">
- <title>Options Tab of the Console Configuration Wizard</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/plugins_2_a.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The next table describes Hibernate Console Configuration options
available on the
- <emphasis>
- <property moreinfo="none">Options</property>
- </emphasis> tab.</para>
- <table>
- <title>Hibernate Console Configuration Options</title>
- <tgroup cols="3">
- <colspec align="left" colnum="1"
colwidth="1*"></colspec>
- <colspec colnum="2" colwidth="3*"></colspec>
- <colspec align="left" colnum="3"
colwidth="1*"></colspec>
- <thead>
- <row>
- <entry align="center">
- <para>Parameter</para>
- </entry>
- <entry align="center">
- <para>Description</para>
- </entry>
- <entry align="center">
- <para>Auto detected value</para>
- </entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <para>Database dialect</para>
- </entry>
- <entry>
- <para><diffmk:wrapper
diffmk:change="changed">Define a database dialect. It's possible either
to write your value or
- choose from list. </diffmk:wrapper></para>
- </entry>
- <entry>
- <para>No default value</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Naming strategy</para>
- </entry>
- <entry>
- <para>Fully qualified classname of a custom NamingStrategy. Only
required if you use
- a special naming strategy.</para>
- </entry>
- <entry>
- <para>No default value</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Entity resolver</para>
- </entry>
- <entry>
- <para>Fully qualified classname of a custom EntityResolver. Only
required if you
- have special xml entity includes in your mapping files.</para>
- </entry>
- <entry>
- <para>No default value</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <itemizedlist>
- <listitem>
- <para><emphasis>
- <property moreinfo="none">Classpath</property>
- </emphasis> for classpath</para>
- </listitem>
- </itemizedlist>
- <figure float="0">
- <title>Specifying Classpath in Hibernate Console
Configuration</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center"
fileref="images/plugins/plugins_3.png"
format="PNG"></imagedata>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_3.png"
format="PNG"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The following table specifies the parameters of the Classpath tab of
the wizard.</para>
- <table>
- <title>Hibernate Console Configuration Classpath</title>
- <tgroup cols="3">
- <colspec align="left" colnum="1"
colwidth="1*"></colspec>
- <colspec colnum="2" colwidth="3*"></colspec>
- <colspec colnum="3" colwidth="1*"></colspec>
- <thead>
- <row>
- <entry align="center">
- <para>Parameter</para>
- </entry>
- <entry align="center">
- <para>Description</para>
- </entry>
- <entry align="center">
- <para>Auto detected value</para>
- </entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <para>Classpath</para>
- </entry>
- <entry>
- <para>The classpath for loading POJO and JDBC drivers; only needed
if the default
- classpath of the Project does not contain the required classes. Do not
add
- Hibernate core libraries or dependencies, they are already included. If
you get
- ClassNotFound errors then check this list for possible missing or
redundant
- directories/jars.</para>
- </entry>
- <entry>
- <para>Empty</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Include default classpath from project</para>
- </entry>
- <entry>
- <para>When enabled the project classpath will be appended to the
classpath specified
- above</para>
- </entry>
- <entry>
- <para>Enabled</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <itemizedlist>
- <listitem>
- <para><emphasis>
- <property moreinfo="none">Mappings</property>
- </emphasis> for additional mappings</para>
- </listitem>
- </itemizedlist>
- <figure float="0">
- <title>Specifying additional Mappings in Hibernate Console
Configuration</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center"
fileref="images/plugins/plugins_4.png"
format="PNG"></imagedata>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_4.png"
format="PNG"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>Parameters of the Mappings tab of the <property
moreinfo="none">Hibernate Console Configuration
- wizard</property> are explained below:</para>
- <table>
- <title>Hibernate Console Configuration Mappings</title>
- <tgroup cols="3">
- <colspec align="left" colnum="1"
colwidth="1*"></colspec>
- <colspec colnum="2" colwidth="3*"></colspec>
- <colspec colnum="3" colwidth="1*"></colspec>
- <thead>
- <row>
- <entry align="center">
- <para>Parameter</para>
- </entry>
- <entry align="center">
- <para>Description</para>
- </entry>
- <entry align="center">
- <para>Auto detected value</para>
- </entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <para>Mapping files </para>
- </entry>
- <entry>
- <para>List of additional mapping files that should be loaded. Note:
A
- hibernate.cfg.xml or persistence.xml can also contain mappings. Thus if
these are
- duplications here, you will get "Duplicate mapping" errors
when using the console
- configuration.</para>
- </entry>
- <entry>
- <para>empty</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <itemizedlist>
- <listitem>
- <para>and the last tab <emphasis>
- <property moreinfo="none">Common</property>
- </emphasis></para>
- </listitem>
- </itemizedlist>
- <figure float="0">
- <title>Common Tab of the Console Configuration Wizard</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/plugins_4_a.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>It allows to define general aspects of the launch configuration
including storage
- location, console encoding and some others.</para>
- <para>Clicking <emphasis>
- <property moreinfo="none">Finish</property>
- </emphasis> creates the configuration and shows it in the <property
moreinfo="none">Hibernate Configurations
- view</property>.</para>
- <figure float="0">
- <title>Console Overview</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center"
fileref="images/plugins/plugins_5.png"
format="PNG"></imagedata>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_5.png"
format="PNG"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- </section>
- <section id="modif_console_conf">
- <title>Modifying a Hibernate Console Configuration </title>
- <para>When you created a hibernate console configuration you can modify it in
2 ways: </para>
- <itemizedlist>
- <listitem>
- <para>right-click on the configuration in <emphasis>
- <property moreinfo="none">Hibernate Configurations
View->Edit Configuration </property>
- </emphasis> or just double-click on <property
moreinfo="none">Console Configuration</property><diffmk:wrapper
diffmk:change="changed">
- item.</diffmk:wrapper></para>
- <figure float="0">
- <title>Opening Edit Configuration Wizard</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/plugins_4_c.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para> After clicking you will see the Edit Configuration Wizard that is
similar to
- <emphasis>
- <property moreinfo="none">Create Console
Configuration</property>
- </emphasis>,described in <link
linkend="creat_console_conf">Creating a Hibernate Console
- Configuration section</link>. </para>
- </listitem>
- <listitem>
- <para>use Properties view for modifying some of Console Configuration
properties.</para>
- <figure float="0">
- <title>Properties View</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/plugins_4_b.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The following table describes the available settings in the
Properties view. Most
- properties are changeable by left click but some are not. <table>
- <title>Properties</title>
- <tgroup cols="3">
- <colspec align="left" colnum="1"
colwidth="1*"></colspec>
- <colspec colnum="2"
colwidth="3*"></colspec>
- <colspec align="left" colnum="3"
colwidth="1*"></colspec>
- <thead>
- <row>
- <entry align="center">
- <para>Property</para>
- </entry>
- <entry align="center">
- <para>Description</para>
- </entry>
- <entry align="center">
- <para>Is Changeable</para>
- </entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <para>Additional mapping files </para>
- </entry>
- <entry>
- <para>List of additional mapping files that should be loaded.
</para>
- </entry>
- <entry>
- <para>False</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Configuration file</para>
- </entry>
- <entry>
- <para>Path to a hibernate.cfg.xml file</para>
- </entry>
- <entry>
- <para>False</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Connection</para>
- </entry>
- <entry>
- <para>DTP provided connection that you can use instead of
what is in cfg.xml
- and jpa persistence.xml. It's possible to use either already
configured
- hibernate or JPA connection or specify a new one
here.</para>
- </entry>
- <entry>
- <para>True</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Name</para>
- </entry>
- <entry>
- <para>The unique name of the console
configuration</para>
- </entry>
- <entry>
- <para>True</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Project</para>
- </entry>
- <entry>
- <para>The name of a java project which classpath should be
used in the console
- configuration</para>
- </entry>
- <entry>
- <para>True</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Properties file</para>
- </entry>
- <entry>
- <para>Path to a hibernate.properties file</para>
- </entry>
- <entry>
- <para>False</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Type</para>
- </entry>
- <entry>
- <para><diffmk:wrapper
diffmk:change="changed">Choose between "CORE",
"ANNOTATIONS" and
- "JPA" according to the method of relational mapping you
want to
- use. Note, the two latter requires running Eclipse IDE with a JDK
5 runtime,
- otherwise you will get classloading and/or version
errors.</diffmk:wrapper></para>
- </entry>
- <entry>
- <para>True</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table></para>
- </listitem>
- </itemizedlist>
- </section>
- <section id="closing_conf_config">
- <title>Closing Hibernate Console Configuration</title>
- <para>To close <property moreinfo="none">Hibernate Console
Configuration</property><diffmk:wrapper diffmk:change="changed"> you
need do right-click
- your configuration and choose </diffmk:wrapper><property
moreinfo="none">Close Configuration</property> option </para>
- <figure float="0">
- <title>Close Hibernate Console Configuration</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/plugins_4_d.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>While closing configuration the connection with database will be
closed, jar libs will
- be unlock (for Windows) and other resources will set as free. </para>
- </section>
- </section>
- <section id="refeng_codegen" role="updated">
- <title>Reverse Engineering and Code Generation</title>
- <para>A "click-and-generate" reverse engineering and code generation
facility is
- available. This facility allows you to generate a range of artifacts based on
database or an
- already existing Hibernate configuration, be that mapping files or annotated
classes. Some of
- these are POJO Java source file, Hibernate <emphasis>
- <property moreinfo="none">.hbm.xml</property>
- </emphasis>, <emphasis>
- <property moreinfo="none">hibernate.cfg.xml</property>
- </emphasis> generation and schema documentation.</para>
- <para>To start working with this process, start the <property
moreinfo="none">Hibernate Code
- Generation</property> which is available in the toolbar via the
<property moreinfo="none">Hibernate</property> icon or via the
<emphasis>
- <property moreinfo="none">Run > Hibernate Code
Generation</property>
- </emphasis> menu item.</para>
- <section id="code_gen">
- <title>Code Generation Launcher</title>
- <para>When you click on <emphasis>
- <property moreinfo="none">Open Hibernate Code Generation
Dialog...</property>
- </emphasis> the standard Eclipse launcher dialog will appear. In this
dialog you can create,
- edit and delete named Hibernate code generation
"launchers".</para>
- <figure float="0" id="hib_code_gen">
- <title>Getting Hibernate Code Generation Wizard</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata fileref="images/plugins/plugins_6.png"
format="PNG"></imagedata>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_6.png"
format="PNG"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para></para>
- <figure float="0">
- <title>Hibernate Code Generation Wizard</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center"
fileref="images/plugins/plugins_7.png" format="PNG"
scale="80"></imagedata>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_7.png"
format="PNG"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The first time you create a code generation launcher you should give it
a meaningful
- name, otherwise the default prefix <emphasis>
- <property moreinfo="none">New_Generation</property>
- </emphasis> will be used.</para>
- <tip>
- <title>Tip:</title>
- <para>The "At least one exporter option must be selected" is just
a warning
- stating that for this launch to work you need to select an exporter on the
Exporter tab.
- When an exporter has been selected the warning will disappear.</para>
- </tip>
- <para>The dialog also have the standard tabs <emphasis>
- <property moreinfo="none">Refresh</property>
- </emphasis> and <emphasis>
- <property moreinfo="none">Common</property>
- </emphasis> that can be used to configure which directories should be
automatically
- refreshed and various general settings launchers, such as saving them in a
project for
- sharing the launcher within a team.</para>
- <para>On the <emphasis>
- <property moreinfo="none">Main</property>
- </emphasis> tab you see the following fields:</para>
- <table>
- <title>Code generation "Main" tab fields</title>
- <tgroup cols="2">
- <colspec align="left" colnum="1"
colwidth="1*"></colspec>
- <colspec colnum="2" colwidth="3*"></colspec>
- <colspec colnum="3" colwidth="0.5*"></colspec>
- <thead>
- <row>
- <entry align="center">
- <para>Field</para>
- </entry>
- <entry align="center">
- <para>Description</para>
- </entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <para>Console Configuration</para>
- </entry>
- <entry>
- <para>The name of the console configuration which should be used
when code
- generating</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Output directory</para>
- </entry>
- <entry>
- <para>Path to a directory where all output will be written by
default. It's possible
- to enter absolute directory path, for example - "d:/temp". Be
aware that existing
- files will be overwritten, so be sure to specify the correct
directory.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Reverse engineer from JDBC Connection</para>
- </entry>
- <entry>
- <para>If enabled, the tools will reverse engineer the database
available via the
- connection information in the selected Hibernate Console Configuration
and
- generate code based on the database schema. If not enabled, the code
generation
- will just be based on the mappings already specified in the Hibernate
Console
- configuration.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Package</para>
- </entry>
- <entry>
- <para>The package name here is used as the default package name for
any entities
- found when reverse engineering</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>reveng.xml</para>
- </entry>
- <entry>
- <para>Path to a reveng.xml file. A reveng.xml file allows you to
control certain
- aspects of the reverse engineering. e.g. how jdbc types are mapped to
hibernate
- types and especially important which tables are included/excluded from
the
- process. Clicking "setup" allows you to select an existing
reveng.xml file or
- create a new one. See more details about the reveng.xml file in
<xref linkend="reverseengineering"></xref>.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>reveng. strategy</para>
- </entry>
- <entry>
- <para>If reveng.xml does not provide enough customization you can
provide your own
- implementation of an ReverseEngineeringStrategy. The class needs to be
in the
- classpath of the Console Configuration, otherwise you will get class
not found
- exceptions. See <xref
linkend="custom-reveng-strategy"></xref> for details and an
- example of a custom strategy.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Generate basic typed composite ids</para>
- </entry>
- <entry>
- <para>A table that has a multi-column primary key a
<composite-id> mapping
- will always be created. If this option is enabled and there are
matching
- foreign-keys each key column is still considered a 'basic'
scalar (string, long,
- etc.) instead of a reference to an entity. If you disable this option
a
- <code><key-many-to-one></code> instead.
Note: a
- <code><many-to-one></code> property is
still created, but is simply marked
- as non-updatable and non-insertable.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Detect optimistic lock columns</para>
- </entry>
- <entry>
- <para>Automatically detect optimistic lock columns. Controllable
via reveng.
- strategy; the current default is to use columns named VERSION or
TIMESTAMP.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Detect many-to-many tables</para>
- </entry>
- <entry>
- <para>Automatically detect many-to-many tables. Controllable via
reveng.
- strategy.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Detect one-to-one associations</para>
- </entry>
- <entry>
- <para> Reverse engineering detects one-to-one associations via
primary key and both
- hbm.xml and annotation generation generates the proper code for it.
</para>
- <para> The detection is enabled by default (except for Seam 1.2 and
Seam 2.0)
- reverse engineering. For Hibernate Tools generation there is a checkbox
to disable
- if not wanted. </para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Use custom templates</para>
- </entry>
- <entry>
- <para>If enabled, the Template directory will be searched first
when looking up the
- templates, allowing you to redefine how the individual templates
process the
- hibernate mapping model.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Template directory</para>
- </entry>
- <entry>
- <para>A path to a directory with custom templates</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </section>
- <section id="exportes">
- <title>Exporters</title>
- <para>The <emphasis>
- <property moreinfo="none">Exporters</property>
- </emphasis> tab is used to specify which type of code that should be
generated. Each
- selection represents an Exporter that is responsible for generating the code,
hence the
- name.</para>
- <figure float="0">
- <title>Selecting Exporters</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center"
fileref="images/plugins/plugins_8.png" format="PNG"
scale="80"></imagedata>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_8.png"
format="PNG"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The following table describes in short the various exporters. Remember
you can
- add/remove any Exporters depending on your needs.</para>
- <table>
- <title>Code generation "Exporter" tab fields</title>
- <tgroup cols="2">
- <colspec align="left" colnum="1"
colwidth="1*"></colspec>
- <colspec colnum="2" colwidth="3*"></colspec>
- <thead>
- <row>
- <entry align="center">
- <para>Field</para>
- </entry>
- <entry align="center">
- <para>Description</para>
- </entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <para>Domain code</para>
- </entry>
- <entry>
- <para>Generates POJO's for all the persistent classes and
components found in the
- given Hibernate configuration.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>DAO code</para>
- </entry>
- <entry>
- <para>Generates a set of DAO's for each entity
found.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Hibernate XML Mappings</para>
- </entry>
- <entry>
- <para>Generate mapping (hbm.xml) files for each
entity.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Hibernate XML Configuration</para>
- </entry>
- <entry>
- <para>Generate a hibernate.cfg.xml file. Used to keep the
hibernate.cfg.xml update
- with any new found mapping files.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Schema Documentation (.html)</para>
- </entry>
- <entry>
- <para>Generates a set of html pages that documents the database
schema and some of
- the mappings.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Generic Exporter (hbmtemplate)</para>
- </entry>
- <entry>
- <para>Fully customizable exporter which can be used to perform
custom
- generation.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Schema Export (.ddl)</para>
- </entry>
- <entry>
- <para>Generates the appropriate SQL DDL and allows you to store the
result in a file
- or export it directly to the database.</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <para>Each Exporter listens to certain properties and these can be setup in
the <emphasis>
- <property moreinfo="none">Properties</property>
- </emphasis> section where you can add/remove predefined or customer
properties for each of
- the exporters. The following table lists the time of writing predefined
properties:</para>
- <para>
- <table>
- <title>Exporter Properties</title>
- <tgroup cols="2">
- <colspec align="left" colnum="1"
colwidth="1*"></colspec>
- <colspec colnum="2" colwidth="3*"></colspec>
- <thead>
- <row>
- <entry align="center">
- <para>Name</para>
- </entry>
- <entry align="center">
- <para>Description</para>
- </entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <para>jdk5</para>
- </entry>
- <entry>
- <para>Generate Java 5 syntax</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>ejb3</para>
- </entry>
- <entry>
- <para>Generate EJB 3 annotations</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>for_each</para>
- </entry>
- <entry>
- <para>Specifies for which type of model elements the exporter
should create a file
- and run through the templates. Possible values are: entity,
component,
- configuration</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>template_path</para>
- </entry>
- <entry>
- <para>Custom template directory for this specific exporter. You
can use Eclipse
- variables.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>template_name</para>
- </entry>
- <entry>
- <para>Name for template relative to the template
path</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>outputdir</para>
- </entry>
- <entry>
- <para>Custom output directory for this specific exporter. You can
use Eclipse
- variables.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>file_pattern</para>
- </entry>
- <entry>
- <para>Pattern to use for the generated files, relatively for the
output dir.
- Example: {package-name}/{class-name}.java .</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>dot.executable</para>
- </entry>
- <entry>
- <para>Executable to run GraphViz (only relevant, but optional for
Schema
- documentation)</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>drop</para>
- </entry>
- <entry>
- <para>Output will contain drop statements for the tables, indices
and
- constraints</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>delimiter</para>
- </entry>
- <entry>
- <para>If specified the statements will be dumped to this
file</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>create</para>
- </entry>
- <entry>
- <para>Output will contain create statements for the tables,
indices and
- constraints</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>scriptToConsole</para>
- </entry>
- <entry>
- <para>The script will be output to Console</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>exportToDatabase</para>
- </entry>
- <entry>
- <para>Executes the generated statements against the
database</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>outputFileName</para>
- </entry>
- <entry>
- <para>If specified the statements will be dumped to this
file</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>haltOnError</para>
- </entry>
- <entry>
- <para>Halts the build process if an error occurs</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>format</para>
- </entry>
- <entry>
- <para>Applies basic formatting to the statements</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>schemaUpdate</para>
- </entry>
- <entry>
- <para>Updates a schema</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </para>
- <para>To add a property to the chosen Exporter click the <emphasis>
- <property moreinfo="none">Add</property>
- </emphasis> button in the <property
moreinfo="none">Properties</property> section. In the appeared dialog
- you should select the property from the proposed list and the value for
it.</para>
- <figure float="0">
- <title>Adding the Property for Schema Export (.ddl)</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/plugins_8a.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <tip>
- <title>Tip:</title>
- <para>If the property is a directory, it is possible to browse directories
in the Value
- field.</para>
- </tip>
- <figure float="0">
- <title>Specifying the Property Value</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/plugins_8b.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- </section>
- </section>
- <section id="map_config_editor">
- <title>Hibernate Mapping and Configuration File Editor</title>
- <para>The <property moreinfo="none">Hibernate Mapping File
editor</property> provides XML editing functionality
- for the <emphasis>
- <property moreinfo="none">hbm.xml </property>
- </emphasis> and <emphasis>
- <property moreinfo="none">cfg.xml</property>
- </emphasis> files. The editor is based on the Eclipse WTP tools and extends
its functionality
- to provide Hibernate specific code completion.</para>
- <figure float="0">
- <title>XML Editing Functionality</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center"
fileref="images/plugins/plugins_9.png" format="PNG"
scale="80"></imagedata>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_9.png"
format="PNG"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <section>
- <title>Java property/class completion</title>
- <para>Package, class, and field completion is enabled for relevant XML
attributes. The
- auto-completion detects its context and limits the completion for e.g.
- <code><property></code> and only shows the
properties/fields available in the
- enclosing <code><class></code> ,
<code><subclass></code> etc. It is also
- possible to navigate from the <emphasis>
- <property moreinfo="none">hbm.xml</property>
- </emphasis> files to the relevant class/field in java code.</para>
- <figure float="0">
- <title>Navigation Functionality</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center"
fileref="images/plugins/plugins_10.png" format="PNG"
scale="80"></imagedata>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_10.png"
format="PNG"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>This is done via the standard hyperlink navigation functionality in
Eclipse; per default
- it is done by pressing F3 while the cursor is on a class/field or by pressing
<emphasis>
- <property moreinfo="none">Ctrl</property>
- </emphasis> and the mouse button to perform the same
navigation.</para>
- <para>For java completion and navigation to work the file needs to reside
inside an Eclipse
- Java project, otherwise no completion will occur.</para>
- <note>
- <title>Note:</title>
- <para>Java completion does not require a Hibernate console configuration to
be used.</para>
- </note>
- </section>
- <section>
- <title>Table/Column completion</title>
- <para>Table and column completion is also available for all table and column
attributes. </para>
- <figure float="0">
- <title>Table and Column Completion</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center"
fileref="images/plugins/plugins_11.png" format="PNG"
scale="80"></imagedata>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_11.png"
format="PNG"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <important>
- <title>Important:</title>
- <para>Table/Column completion requires a proper configured hibernate
console configuration
- and this configuration should be the default for the project where the
<emphasis>
- <property moreinfo="none">hbm.xml</property>
- </emphasis> resides.</para>
- </important>
- <para>You can check which console configuration is selected under the
Properties of a project
- and look under the <emphasis>
- <property moreinfo="none">Hibernate Settings</property>
- </emphasis> page. When a proper configuration is selected it will be used
to fetch the
- table/column names in the background.</para>
- <note>
- <title>Note:</title>
- <para>Currently it is not recommended to use this feature on large
databases since it does
- not fetch the information iteratively. It will be improved in future
versions.</para>
- </note>
- </section>
- <section>
- <title>Configuration property completion</title>
- <para>In <emphasis>
- <property moreinfo="none">cfg.xml</property>
- </emphasis> code completion for the value of
<code><property> name</code> attributes
- is available.</para>
- <figure float="0">
- <title>Property Completion</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center"
fileref="images/plugins/plugins_12.png" format="PNG"
scale="80"></imagedata>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_12.png"
format="PNG"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- </section>
- </section>
- <section id="map_config_struct_editor">
- <title>Structured Hibernate Mapping and Configuration File
Editor</title>
- <para>The structured editor represents the file in the tree form. It also
allows to modify the
- structure of the file and its elements with the help of tables provided on the
right-hand
- area.</para>
- <para>To open any mapping file in the editor, choose <emphasis>
- <property moreinfo="none">Open With > Hibernate 3.0 XML
Editor</property>
- </emphasis> option from the context menu of the file. The editor should look
as
- follows:</para>
- <figure float="0">
- <title>Structured hbm.xml Editor</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/plugins_12_a.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>For the configuration file you should choose <emphasis>
- <property moreinfo="none">Open With > Hibernate
Configuration 3.0 XML Editor</property>
- </emphasis>option.</para>
- <figure float="0">
- <title>Structured cfg.xml Editor</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/plugins_12_b.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- </section>
- <section id="properties_editor">
- <title>JBoss Tools Properties Editor</title>
- <para>The editor is meant for editing <literal
moreinfo="none">.properties</literal> files. It contains two
- tabs: the <property moreinfo="none">Properties</property>
(UI) tab and the <property moreinfo="none">Source</property> tab
for
- manual editing.</para>
- <para>For <literal
moreinfo="none">hibernate.properties</literal> file <property
moreinfo="none">JBoss Tools Properties
- Editor</property> provides content assist which is available both for
hibernate properties
- and property values. You can make use of the content assist while editing the file
in the
- Source view and in the Properties view of the editor.</para>
- <para>To add the property in the <property
moreinfo="none">Properties</property> view, click the <emphasis>
- <property moreinfo="none">Add</property>
- </emphasis> button.</para>
- <figure float="0">
- <title>Adding the Property</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/add_property1.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>In the <emphasis>
- <property moreinfo="none">Name</property>
- </emphasis> field press <emphasis>
- <property moreinfo="none">Ctrl+Space</property>
- </emphasis> to invoke the content assist. It will suggest <emphasis>
- <property moreinfo="none">'hibernate.'</property>
- </emphasis> which is the prefix for all hibernate properties. After selecting
<emphasis>
- <property moreinfo="none">'hibernate.'</property>
- </emphasis> and invoking the content assist again, other prefixes and
properties are displayed
- as the proposals with a description of each one.</para>
- <figure float="0">
- <title>Content Assist for Properties Names</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/add_property2.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>When invoking the content assist in the <emphasis>
- <property moreinfo="none">Value</property>
- </emphasis> field, it also provides a list of proposals.</para>
- <figure float="0">
- <title>Content Assist for Properties Values</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/add_property3.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>In the <property moreinfo="none">Source</property>
view of the editor, content assist also could be
- invoked both for properties names and values:</para>
- <figure float="0">
- <title>Content Assist in the Source view</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/add_property4.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <figure float="0">
- <title>Content Assist in the Source view</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/add_property5.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- </section>
- <section id="rev_xml_editor">
- <title>Reveng.xml Editor</title>
- <para>A <emphasis>
- <property moreinfo="none">reveng.xml </property>
- </emphasis> file is used to customize and control how reverse engineering is
performed by the
- tools. The plugins provide an editor to ease the editing of this file and hence
used to
- configure the reverse engineering process.</para>
- <para>The editor is intended to allow easy definition of type mappings, table
include/excludes
- and specific override settings for columns, e.g. define an explicit name for a
column when the
- default naming rules are not applicable.</para>
- <note>
- <title>Note:</title>
- <para> Not all the features of the <emphasis>
- <property moreinfo="none">.reveng.xml </property>
- </emphasis> file are exposed or fully implemented in the editor, but the
main functionality
- is there. To understand the full flexibility of the <emphasis>
- <property moreinfo="none">reveng.xml</property>
- </emphasis>, please see <xref
linkend="hibernaterevengxmlfile"></xref>
- </para>
- </note>
- <para>The editor is activated as soon as an <emphasis>
- <property moreinfo="none">.reveng.xml </property>
- </emphasis> file is opened. To get an initial <emphasis>
- <property moreinfo="none">reveng.xml </property>
- </emphasis> file the <property moreinfo="none">Reverse
Engineering File Wizard</property> can be started via
- <emphasis>
- <property moreinfo="none">Ctrl+N</property>
- </emphasis> and <emphasis>
- <property moreinfo="none">Hibernate > Hibernate Reverse
Engineering File (reveng.xml)</property>
- </emphasis> then.</para>
- <figure float="0">
- <title>ChooseReverse Engineering File Wizard </title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center"
fileref="images/plugins/plugins_22.png" format="PNG"
scale="80"></imagedata>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_22.png"
format="PNG"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>Or you can get it via the <property moreinfo="none">Code
Generation Launcher</property> by checking the
- proper section in the <emphasis>
- <property moreinfo="none">Main</property>
- </emphasis> tab of the <link linkend="hib_code_gen">Hibernate
Code Generation
- Wizard</link>.</para>
- <para>The following screenshot shows the <emphasis>
- <property moreinfo="none">Overview</property>
- </emphasis> page where the wanted console configuration is selected
(auto-detected if
- Hibernate 3 support is enabled for the project)</para>
- <figure float="0">
- <title>Overview Page</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center"
fileref="images/plugins/plugins_13.png" format="PNG"
scale="80"></imagedata>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_13.png"
format="PNG"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The <emphasis>
- <property moreinfo="none">Table Filter</property>
- </emphasis> page allows you to specify which tables to include and exclude.
Pressing
- <emphasis>
- <property moreinfo="none">Refresh</property>
- </emphasis> shows the tables from the database that have not yet been
excluded.</para>
- <figure float="0">
- <title>Table Filters Page</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center"
fileref="images/plugins/plugins_14.png" format="PNG"
scale="80"></imagedata>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_14.png"
format="PNG"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The <emphasis>
- <property moreinfo="none">Type Mappings</property>
- </emphasis> page is used for specifying type mappings from JBDC types to any
Hibernate type
- (including usertypes) if the default rules are not applicable. Here again to see
the database
- tables press <emphasis>
- <property moreinfo="none">Refresh</property>
- </emphasis> button underneath. More about type mappings you can find further
in the <link linkend="type_map">Type Mappings</link>
section.</para>
- <figure float="0">
- <title>Type Mappings Page</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center"
fileref="images/plugins/plugins_15.png" format="PNG"
scale="80"></imagedata>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_15.png"
format="PNG"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The <emphasis>
- <property moreinfo="none">Table and Columns</property>
- </emphasis> page allows you to explicit set e.g. which hibernatetype and
propertyname that
- should be used in the reverse engineered model. For more details on how to
configure the
- tables while reverse engineering read the <link
linkend="tab_and_col">Specific table
- configuration</link> section.</para>
- <figure float="0">
- <title>Table and Columns Page</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center"
fileref="images/plugins/plugins_16.png" format="PNG"
scale="80"></imagedata>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_16.png"
format="PNG"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>Now that you have configured all necessary parts, you can learn how to
work with <property moreinfo="none">Hibernate Console
Perspective</property>.</para>
- </section>
- <section id="hib_console">
- <title>Hibernate Console Perspective</title>
- <para>The <property moreinfo="none">Hibernate Console
Perspective</property> combines a set of views which allow
- you to see the structure of your mapped entities/classes, edit HQL queries, execute
the
- queries, and see the results. To use this perspective you need to create a <link
linkend="console_conf">Console configuration</link>.</para>
- <section>
- <title>Viewing the entity structure</title>
- <para>To view your new configuration and entity/class structure, switch to
<property moreinfo="none">Hibernate
- Configurations View</property>. Expanding the tree allows you to browse
the class/entity
- structure and see the relationships.</para>
- <figure float="0">
- <title>Hibernate Console Perspective</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center"
fileref="images/plugins/plugins_17.png"
scale="80"></imagedata>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_17.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The <property moreinfo="none">Console
Configuration</property> does not dynamically adjust to changes
- done in mappings and java code. To reload the configuration select the
configuration and
- click the <emphasis>
- <property moreinfo="none">Reload</property>
- </emphasis> button in the view toolbar or in the context
menu.</para>
- <para>Besides, it's possible to open source and mapping files for objects
showed in
- <property moreinfo="none">Hibernate Configurations
View</property>. Just bring up the context menu for a
- necessary object and select <emphasis>
- <property moreinfo="none">Open Source File</property>
- </emphasis> to see appropriate Java class or <emphasis>
- <property moreinfo="none">Open Mapping File</property>
- </emphasis> to open a proper <emphasis>
- <property
moreinfo="none">.hbm.xml</property>.</emphasis></para>
- <figure float="0">
- <title>Opening Source for Objects</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/plugins_17_a.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <section id="map_diagram">
- <title>Mapping Diagram</title>
- <para>In order to get a visual feel on how entities are related as well as
view their
- structures, a <property moreinfo="none">Mapping
Diagram</property> is provided. It is available by right
- clicking on the entity you want a mapping diagram for and then choosing
<emphasis>
- <property moreinfo="none">Mapping
Diagram</property>.</emphasis></para>
- <figure float="0">
- <title>Mapping Diagram</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center"
fileref="images/plugins/plugins_18.png"
scale="80"></imagedata>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_18.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>To make <property moreinfo="none">Mapping
Diagram</property> usage easier you can use <property
moreinfo="none">Rules</property>, <property
moreinfo="none">Grid</property>,<property
moreinfo="none">Snap to Geometry</property>
- checkboxes in the <emphasis>
- <property moreinfo="none">View</property>
- </emphasis> menu. </para>
- <figure float="0">
- <title>View menu</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/map_diagram1.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>If you will select <emphasis>
- <property moreinfo="none">Rules</property>
- </emphasis> checkbox, the view print page scale will be added to the
page. The numbers on
- the scale show its size in inches.If you click on the scale a <emphasis>
- <property moreinfo="none">Ruler Guide</property>
- </emphasis> will appear on the diagram. You can connect any diagram item
to it.To connect
- the items you should move their tops to the Ruler Guide. And while moving the
ruler guide,
- the items will be moved together with it as a whole.</para>
- <figure float="0">
- <title>Moving the Ruler guide</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/map_diagram2.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>If you'll select <emphasis>
- <property moreinfo="none">Grid</property>
- </emphasis> checkbox, the grid will appear on the diagram.</para>
- <figure float="0">
- <title>Grid on Mapping diagram</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/map_diagram3.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The checkbox <emphasis>
- <property moreinfo="none">Snap to Geometry</property>
- </emphasis> helps to put the items of the diagram into allineation with
the grid.</para>
- <para>For better navigating through the diagram use <property
moreinfo="none">Outline view</property> which
- is available in the structural and graphical modes.</para>
- <figure float="0">
- <title>Navigating in the Structural Mode</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/plugins_18_a.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>To switch over between the modes use the buttons in the top-right
corner of the
- <property moreinfo="none">Outline
view</property>.</para>
- <figure float="0">
- <title>Navigating in the Graphical Mode</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/plugins_18_b.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The options in the context menu of the mapping diagram are listed in
the next
- table.</para>
- <table>
- <title>Context Menu Options of the Mapping Diagram</title>
- <tgroup cols="3">
- <colspec align="left" colnum="1"
colwidth="1*"></colspec>
- <colspec align="left" colnum="2"
colwidth="1*"></colspec>
- <colspec align="left" colnum="3"
colwidth="3*"></colspec>
- <thead>
- <row>
- <entry align="center">
- <para>Icon</para>
- </entry>
- <entry align="center">
- <para>Command</para>
- </entry>
- <entry align="center">
- <para>Description</para>
- </entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <para>
- <inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/toggleConnections.png"></imagedata>
- </imageobject>
- </inlinemediaobject>
- </para>
- </entry>
- <entry>
- <para>Show|Hide connections</para>
- </entry>
- <entry>Allows to select what types of connections should be shown
on the diagram: <itemizedlist>
- <listitem>
- <para>Property Mappings</para>
- </listitem>
- <listitem>
- <para>Class Mappings</para>
- </listitem>
- <listitem>
- <para>Associations</para>
- </listitem>
- <listitem>
- <para>Foreign key constraints</para>
- </listitem>
- </itemizedlist></entry>
- </row>
- <row>
- <entry>
- <para></para>
- </entry>
- <entry>
- <para>Select All</para>
- </entry>
- <entry>
- <para>Makes all the diagram elements selected</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>
- <inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/autoLayout.png"></imagedata>
- </imageobject>
- </inlinemediaobject>
- </para>
- </entry>
- <entry>
- <para>Auto layout</para>
- </entry>
- <entry>
- <para>Used to dispose all the items of the diagram in a standard
manner</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>
- <inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/exportAsImage.png"></imagedata>
- </imageobject>
- </inlinemediaobject>
- </para>
- </entry>
- <entry>
- <para>Export as Image</para>
- </entry>
- <entry>
- <para>Allows to export a diagram as <emphasis><property
moreinfo="none">.png
- </property>,</emphasis>
- <emphasis>
- <property moreinfo="none">.jpeg</property>
- </emphasis> or <emphasis>
- <property moreinfo="none">.bmp </property>
- </emphasis></para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <para>When you open the context menu while clicking an item on the diagram,
it quite differs
- from the one described before.</para>
- <figure float="0">
- <title>Context Menu in Mapping Item</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/plugins_18_g.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The next table describes all the extra options in the menu of mapping
items:</para>
- <table>
- <title>Extra Options in the Context Menu of Mapping Item</title>
- <tgroup cols="3">
- <colspec align="left" colnum="1"
colwidth="1*"></colspec>
- <colspec align="left" colnum="2"
colwidth="1*"></colspec>
- <colspec align="left" colnum="3"
colwidth="3*"></colspec>
- <thead>
- <row>
- <entry align="center">
- <para>Icon</para>
- </entry>
- <entry align="center">
- <para>Command</para>
- </entry>
- <entry align="center">
- <para>Description</para>
- </entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <para>
- <inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/openSourceFile_but.png"></imagedata>
- </imageobject>
- </inlinemediaobject>
- </para>
- </entry>
- <entry>
- <para>Open Source File</para>
- </entry>
- <entry>
- <para>Makes it possible to open a source file for a chosen
object/element. The
- selected element will be highlighted in the open file.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>
- <inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/openMappingFile_but.png"></imagedata>
- </imageobject>
- </inlinemediaobject>
- </para>
- </entry>
- <entry>
- <para>Open Mapping File</para>
- </entry>
- <entry>
- <para>Makes it possible to open a mapping file for a chosen
object/element. The
- selected element will be highlighted in the open file.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>
- <inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/visibleState.png"></imagedata>
- </imageobject>
- </inlinemediaobject>
- </para>
- </entry>
- <entry>
- <para>Show|Hide shape(s)</para>
- </entry>
- <entry>
- <para>Used to hide/show an item on the mapping
diagram</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>
- <inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/expandState.png"></imagedata>
- </imageobject>
- </inlinemediaobject>
- </para>
- </entry>
- <entry>
- <para>Expand|Collapse shape(s)</para>
- </entry>
- <entry>
- <para>Used for expanding/collapsing fields of the
item</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <tip>
- <title>Tip:</title>
- <para>All the described types of the context menu are also available in
the <property moreinfo="none">Outline</property> view.</para>
- </tip>
- <para>The below table lists the actions that could be performed using the
keyboard keys (or
- keys combinations).</para>
- <table>
- <title>Hibernate Mapping Diagram Shortcut Keys</title>
- <tgroup cols="2">
- <colspec align="left" colnum="1"
colwidth="3*"></colspec>
- <colspec align="left" colnum="2"
colwidth="1*"></colspec>
- <thead>
- <row>
- <entry align="center">
- <para>Command</para>
- </entry>
- <entry align="center">
- <para>Binding</para>
- </entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <para>Scroll the diagram content</para>
- </entry>
- <entry>
- <para>Ctrl + Shift + arrows</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Collapse/Expand selected item(s)</para>
- </entry>
- <entry>
- <para> Enter </para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Show/Hide selected item(s)</para>
- </entry>
- <entry>
- <para> + </para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Sort items in alphabetical order or return the initial
state</para>
- </entry>
- <entry>
- <para>Space</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Navigate between the items</para>
- </entry>
- <entry>
- <para>Arrows</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <para>It's possible to save the diagram in the eclipse workspace. Click
the usual
- <emphasis>
- <property moreinfo="none">File > Save
As</property>
- </emphasis> option, the wizard will ask you to set the location within
you project where
- to save the file and give the name for the diagram. The item's names
concatenated
- with the ampersand symbols are set as the default name for a diagram. The file
is saved
- with the <literal moreinfo="none">.hibernate</literal>
extension.</para>
- <figure float="0">
- <title>The Diagram saved in the Workspace</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/saveDiagram.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <tip>
- <title>Note:</title>
- <para>If you restart the Eclipse with the mapping diagram opened, the
mapping diagram will
- be restored with the message like on the figure below. To view the diagram
content, you
- should perform the refreshing.</para>
- </tip>
- <figure float="0">
- <title>The Diagram after Restarting the Eclipse</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/diagram1.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <figure float="0">
- <title>The Diagram after Refreshing</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/diagram2.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>There are some useful commands in the toolbar.</para>
- <figure float="0">
- <title>The Diagram View Toolbar</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/diagramToolbar.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>They are described in the table below.</para>
- <table>
- <title>Command in Diagram View Toolbar </title>
- <tgroup cols="3">
- <colspec align="left" colnum="1"
colwidth="1*"></colspec>
- <colspec align="left" colnum="2"
colwidth="1*"></colspec>
- <colspec align="left" colnum="3"
colwidth="3*"></colspec>
- <thead>
- <row>
- <entry align="center">
- <para>Icon</para>
- </entry>
- <entry align="center">
- <para>Command</para>
- </entry>
- <entry align="center">
- <para>Description</para>
- </entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <para>
- <inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/toolbarRefresh.png"></imagedata>
- </imageobject>
- </inlinemediaobject>
- </para>
- </entry>
- <entry>
- <para>Refresh Visual Mapping</para>
- </entry>
- <entry>
- <para>It update <property moreinfo="none">Mapping
Diagram</property> if <property moreinfo="none">Console
- Configuration</property> was changed. </para>
- </entry>
- </row>
- <row>
- <entry>
- <para>
- <inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/toolbarZoom.png"></imagedata>
- </imageobject>
- </inlinemediaobject>
- </para>
- </entry>
- <entry>
- <para>Zoom Box</para>
- </entry>
- <entry>
- <para>Used to define scale of the diagram. Also it's used for
<property moreinfo="none">Mapping
- Diagram</property> printing. If you want to put the whole
<property moreinfo="none">diagram</property> to one print page, you
need select <property moreinfo="none">Page</property> option in the
<property moreinfo="none">Zoom Box</property>.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>
- <inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/toolbarAutolayout.png"></imagedata>
- </imageobject>
- </inlinemediaobject>
- </para>
- </entry>
- <entry>
- <para>Auto layout</para>
- </entry>
- <entry>
- <para>Used to arrange all diagram items in a standard
manner.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>
- <inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/toolbarShowHideConnections.png"></imagedata>
- </imageobject>
- </inlinemediaobject>
- </para>
- </entry>
- <entry>
- <para>Show|Hide connections</para>
- </entry>
- <entry>
- <para>Used to show or hide connection on the diagram. Moreover
you can choose what
- type of connections must be present on the diagram (<property
moreinfo="none">Property
- Mappings</property>, <property
moreinfo="none">Class Mappings</property>, <property
moreinfo="none">Associations</property> or <property
moreinfo="none">Foreign key constraints</property>)
- .</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>
- <inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/toolbarExpandCollapse.png"></imagedata>
- </imageobject>
- </inlinemediaobject>
- </para>
- </entry>
- <entry>
- <para>Expand|Collapse</para>
- </entry>
- <entry>
- <para>Used for expanding/collapsing fields of the
item.</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>
- <inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/toolbarShowHideShapes.png"></imagedata>
- </imageobject>
- </inlinemediaobject>
- </para>
- </entry>
- <entry>
- <para> Show|Hide shape(s)</para>
- </entry>
- <entry>
- <para>Used to hide/show an item on the mapping
diagram.</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </section>
- </section>
- <section>
- <title>Prototyping Queries</title>
- <para>Queries can be prototyped by entering them into the <property
moreinfo="none">HQL</property> or
- <property moreinfo="none">Criteria Editor</property>. To
execute a query you should click the green run
- button in the editor toolbar or press <emphasis>
- <property moreinfo="none">Ctrl+Enter</property>
- </emphasis>.</para>
- <section id="hql_and_criteria_editors">
- <title>HQL Editor and Hibernate Criteria Editor</title>
- <para>To open the query editors right-click your project <property
moreinfo="none">Console
- Configuration</property> and select <property
moreinfo="none">HQL Editor</property> (or <property
moreinfo="none">Hibernate Criteria Editor</property>).</para>
- <figure float="0">
- <title>Opening HQL Editor</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/prototypingQueries.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <tip>
- <title>Tip:</title>
- <para>If the context menu items are disabled then you need at first to
create a <property moreinfo="none">Session Factory</property>. That
is done by simply expanding the <property moreinfo="none">Session
- Factory</property> node.</para>
- </tip>
- <para>When open the editors they should automatically detect the chosen
Console
- Configuration.</para>
- <para>To get a prefill query for any entity (or any entity child node)
listed in the
- <emphasis>
- <property moreinfo="none">Session Factory</property>
- </emphasis> you should double-click it. This will open the <property
moreinfo="none">HQL Editor</property>
- with the associated query.</para>
- <para>Choosing <emphasis>
- <property moreinfo="none">HQL Editor</property>
- </emphasis> in the context menu for any entity (or any entity child node)
will also open
- the HQL editor with the associated query. If you choose <emphasis>
- <property moreinfo="none">Hibernate Criteria
Editor</property>
- </emphasis> in the context menu, it will open <property
moreinfo="none">Hibernate Criteria
- Editor</property> with the associated criteria.</para>
- <figure float="0">
- <title>Generating Simple Queries</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center"
fileref="images/plugins/plugins_19.png" format="PNG"
scale="80"></imagedata>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_19.png"
format="PNG"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>It's also possible to copy a portion of code from
<emphasis>
- <property moreinfo="none">.java</property>
- </emphasis> file into the <property
moreinfo="none">HQL</property> or <property
moreinfo="none">Criteria
- editor</property>. To do this make use of the Quick Fix option
(<emphasis>
- <property moreinfo="none">Ctrl +
1</property>)</emphasis>.</para>
- <figure float="0">
- <title>Quick Fix Option Demonstration</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/plugins_19_b.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>You can also update the original java code according to changes in
the HQL or Criteria
- editor. For that you should save your HQL/Criteria query and submit the
replacing in
- appeared confirmation dialog.</para>
- <figure float="0">
- <title>Updating Java Code</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/plugins_19_c.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>Also you can pin <property moreinfo="none">HQL
editor</property> and <property moreinfo="none">Criteria
- editor</property> for one tab in <property
moreinfo="none">Hibernate Query Result</property> view. For
- that you need click on <property moreinfo="none">Stick result
to one tab</property>
- button(<inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/sticky_but.png"></imagedata>
- </imageobject>
- </inlinemediaobject> ). In the issue query executions results will be
shown in one tab (no
- more will be opened). </para>
- <para> Moreover you are able to rename tab in <property
moreinfo="none">Hibernate Query Result</property>.
- Click the tab, and type a new name in <property
moreinfo="none">Property View->Tab name field</property>.
</para>
- <figure float="0">
- <title>Tab Renaming</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/plugins_19_d.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- </section>
- <section>
- <title>Error Handling</title>
- <para>Errors during creation of the <property
moreinfo="none">Session Factory</property> or running the
- queries (e.g. if your configuration or query is incorrect) will be shown in a
message
- dialog or inclined in the view that detected the error, you may get more
information about
- the error in the <property moreinfo="none">Error Log
View</property> on the right pane.</para>
- <para>Results of a query will be shown in the <property
moreinfo="none">Hibernate Query Result
- View</property> and details of possible errors (syntax errors, database
errors, etc.)
- can be seen in the <property moreinfo="none">Error Log
View</property>.</para>
- <note>
- <title>Note:</title>
- <para>HQL queries are executed by default using <literal
moreinfo="none">list()</literal> thus without any
- limit of the size of the output the query could return a large result set.
You might run
- out of memory. To avoid this you can put a value in the Max results field to
reduce the
- number of elements returned.</para>
- </note>
- </section>
- <section>
- <title>Dynamic Query Translator</title>
- <para>If the <property moreinfo="none">Hibernate Dynamic
Query Translator View</property> is visible while
- writing in the <property moreinfo="none">HQL
Editor</property> it will show the generated SQL for a HQL
- query.</para>
- <figure float="0">
- <title>Hibernate Dynamic Query Translator View</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center"
fileref="images/plugins/plugins_20.png" format="PNG"
scale="80"></imagedata>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_20.png"
format="PNG"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The translation is done each time you stop typing into the editor, if
there are errors
- in the HQL the parse exception will be shown embedded in the
view.</para>
- </section>
- </section>
- <section>
- <title>Properties View</title>
- <para>As you can see on the figure,when clicking on class/entity <property
moreinfo="none">Properties
- view</property> shows the number of query results as well as the time of
executing.</para>
- <figure float="0">
- <title>Properties View</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center"
fileref="images/plugins/plugins_21_a.png" format="PNG"
scale="80"></imagedata>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_21_a.png"
format="PNG"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>It also displays the structure of any persistent object selected in the
<property moreinfo="none">Hibernate Query Results View</property>.
Editing is not yet supported.</para>
- <figure float="0">
- <title>Properties View for Selected Object</title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata align="center"
fileref="images/plugins/plugins_21_b.png" format="PNG"
scale="80"></imagedata>
- </imageobject>
- <imageobject role="html">
- <imagedata align="center"
fileref="images/plugins/plugins_21_b.png"
format="PNG"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>You can also use <property moreinfo="none">Properties
view</property> when clicking on the configuration
- itself in Hibernate Configuration View( <link
linkend="modif_console_conf">Modifying a
- Hibernate Console Configuration section</link>). </para>
- </section>
- </section>
- <section id="jpa_annotations">
- <title>Hibernate:add JPA annotations refactoring </title>
- <para>Using this wizard you can add the next Hibernate annotations to the
class: <emphasis>
- <property moreinfo="none">@Column</property>
- </emphasis>,<emphasis>
- <property moreinfo="none">@Entity</property>
- </emphasis>,<emphasis>
- <property moreinfo="none">@ManyToOne</property>
- </emphasis>,<emphasis>
- <property moreinfo="none">@OneToMany</property>
- </emphasis>,<emphasis>
- <property moreinfo="none">@OneToOne</property>
- </emphasis>,<emphasis>
- <property moreinfo="none">@ManyToMany</property>
- </emphasis>,<emphasis>
- <property moreinfo="none">@MappedSuperclass</property>
- </emphasis>,<emphasis>
- <property moreinfo="none">@Id</property>
- </emphasis>,<emphasis>
- <property moreinfo="none">@GeneratedValue</property>
- </emphasis> ,<emphasis>
- <property moreinfo="none">@Version </property>
- </emphasis>
- </para>
- <itemizedlist>
- <listitem>
- <para><emphasis>
- <property moreinfo="none">@Column</property>
- </emphasis> is added to all String properties.</para>
- </listitem>
- <listitem>
- <para><emphasis>
- <property moreinfo="none">@Entity</property>
- </emphasis> is always declared before any class where it doesn't
present.</para>
- </listitem>
- <listitem>
- <para><emphasis>
- <property moreinfo="none">@ManyToOne</property>
- </emphasis>,<emphasis>
- <property moreinfo="none">@OneToMany</property>
- </emphasis>,<emphasis>
- <property moreinfo="none">@OneToOne</property>
- </emphasis>,<emphasis>
- <property moreinfo="none">@ManyToMany</property>
- </emphasis> - this annotations are declared according to the classes
hierarchy.</para>
- </listitem>
- <listitem>
- <para><emphasis>
- <property moreinfo="none">@MappedSuperclass</property>
- </emphasis> is added to abstract superclasses.</para>
- </listitem>
- <listitem>
- <para><emphasis>
- <property moreinfo="none">@Id</property>
- </emphasis>,<emphasis>
- <property moreinfo="none">@GeneratedValue</property>
- </emphasis> are added automatically only to the properties under the name
"Id",where they
- don't present.</para>
- </listitem>
- <listitem>
- <para><emphasis>
- <property moreinfo="none">@Version</property>
- </emphasis> is declared in case you select <link
linkend="optim_lock">Enable optimistic
- locking</link>.</para>
- </listitem>
- </itemizedlist>
- <note>
- <title>Note:</title>
- <para>This section doesn't cover the meaning of the <property
moreinfo="none">Hibernate annotations</property>
- , for more information read <ulink
url="http://docs.jboss.org/hibernate/stable/annotations/reference/en...
- Annotations Documentation</ulink> .</para>
- </note>
- <para>To open this wizard you should right click the class you want to enrich
with annotations
- <emphasis>
- <property moreinfo="none">>Source>Generate
Hibernate/JPA annotations</property>
- </emphasis>. You will see the Hibernate:add JPA annotations dialog.
</para>
- <figure float="0">
- <title>Starting Hibernate:add JPA annotations dialog</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/annotations1.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para> In the top of it you can see the list of all classes that will be passed
through
- refactoring. Besides the class you have selected in this list you can also find
its
- superclasses and the classes that objects present in the current class as
properties. If you
- want to add new classes or package to the list of classes, you should click the
<property moreinfo="none">Back</property> button. In result you will
see <property moreinfo="none">Add classes and
- packages</property> page.</para>
- <figure float="0">
- <title>Add classes and packages page </title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/annotations1_a.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>Here you can add one more classes or whole package, moreover you can
limit dependencies
- depth by selecting <property moreinfo="none">depth
control</property> option (more about this option you will
- find in <link linkend="depth_control">Creating a Hibernate Mapping
File</link>). When finished
- just press the <property moreinfo="none">Next</property>
button and you will be returned to <property moreinfo="none">The
- following classes will be changed</property> page and will be able to
continue work with
- it.</para>
- <para>By default the tags are added to the fields of selected classes. But you
can change this
- option to <emphasis>
- <property moreinfo="none">Getters</property>
- </emphasis>in <emphasis>
- <property moreinfo="none"> Preferred location of
Annotations</property>
- </emphasis> dropdownlist and then all the annotations will be added to the
getter methods. If
- you choose <emphasis>
- <property moreinfo="none">Auto select from class
preference</property>
- </emphasis> then the annotations are added according to the majority of the
already existed
- ones positions. </para>
- <para> If it's nessecary to map your String properties to the columns that
length differ from
- the default value(255) ,change <emphasis>
- <property moreinfo="none">Default string length
field</property>
- </emphasis> and <code>@Column(length = your length)</code> will
be created before every String
- property. </para>
- <para id="optim_lock">You can add optimistic locking capability to an
entity bean by selecting
- <emphasis>
- <property moreinfo="none">Enable optimistic
locking</property>
- </emphasis> checkbox. This operation will add version property to all the
selected classes.
- The property will be also annotated with @Version ,getter and setter will be
created. If the
- property is already exists,it won't be created ,but the getters,setters will be
generated. If
- there is already @MappedSuperclass with version in the base class of the current
class -
- <emphasis>
- <property moreinfo="none">"version"</property>
- </emphasis> is not inserted into the current class. </para>
- <para>After defining all necessary settings in the current step press
<emphasis>
- <property moreinfo="none">Next</property>
- </emphasis> and follow the next wizard steps. </para>
- <figure float="0">
- <title>Hibernate:add JPA annotations view</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/annotations2.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>The view represents two windows: one with the source code and and the
second with
- refactored one. With the help of <inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/butt1.png"></imagedata>
- </imageobject>
- </inlinemediaobject> ,<inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/butt2.png"></imagedata>
- </imageobject>
- </inlinemediaobject> ,<inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/butt3.png"></imagedata>
- </imageobject>
- </inlinemediaobject> ,<inlinemediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/butt4.png"></imagedata>
- </imageobject>
- </inlinemediaobject> buttons you can quickly navigate between the differences
in the code. If
- you don't agree with some changes you can't undo them but you can remove
the class from the
- list of classes that need refactoring. </para>
- <figure float="0">
- <title>List of classes that need refactoring</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/annotations3.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>To apply the changes click <emphasis>
- <property moreinfo="none">Finish</property>
- </emphasis>.</para>
- </section>
- <section id="debug_log">
- <title>Enable debug logging in the plugins</title>
- <para>It is possible to configure the eclipse plugin to route all logging made
by the plugins
- and hibernate code it self to the <property moreinfo="none">Error
Log View</property> in Eclipse.</para>
- <para><property moreinfo="none">Error Log
View</property><diffmk:wrapper diffmk:change="changed"> is very
useful tool to solve any problem which appears
- in Hibernate Tools Plugins. You can use if there are troubles with setting up
</diffmk:wrapper><property moreinfo="none">Hibernate Console
Configuration</property>.</para>
- <para>This is done by editing the <emphasis>
- <property
moreinfo="none">hibernate-log4j.properties</property>
- </emphasis> in <emphasis>
- <property moreinfo="none">org.hibernate.eclipse/
directory/jar</property>
- </emphasis>. This file includes a default configuration that only logs WARN
and above to a set
- of custom appenders (PluginFileAppender and PluginLogAppender). You can change
these settings
- to be as verbose or silent as you please - see <ulink
url="http://www.hibernate.org/5.html">Hibernate Documentation</ulink>
for interesting categories and Log4j documentation.</para>
- <section>
- <title>Relevant Resources Links</title>
- <para>Find more on how to configure logging via a log4j property file in
<ulink
url="http://supportweb.cs.bham.ac.uk/docs/tutorials/docsystem/build/tutorials/log4j/log4j.html">Log4j
documentation</ulink>.</para>
- </section>
- </section>
- <section id="dali_integration">
- <title>Hibernate support for Dali plugins in Eclipse WTP</title>
- <para>Starting from 3.0.0 Alpha1 version of <property
moreinfo="none">JBoss Tools</property> Hibernate plugins
- support Eclipse Dali integration what now makes it possible to use a Hibernate as a
complete
- JPA development platform.</para>
- <section id="jpa_project_with_hibernate">
- <title>Creating JPA project with Hibernate support</title>
- <para>When starting a new JPA project from <emphasis>
- <property moreinfo="none">New > Other > JPA
> JPA Project</property>
- </emphasis> (or simply <emphasis>
- <property moreinfo="none">New > JPA
Project</property>
- </emphasis> in <property moreinfo="none">JPA
Perspective</property><diffmk:wrapper diffmk:change="changed">), the
first wizard page looks as
- follows.</diffmk:wrapper></para>
- <figure diffmk:change="added" float="0">
- <title>Starting JPA Project</title>
- <mediaobject diffmk:change="added">
- <imageobject diffmk:change="added">
- <imagedata
fileref="images/plugins/dali_integration1.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para><diffmk:wrapper diffmk:change="changed">It's
possible here to select a target runtime and change the project configuration,
- or you can leave everything as it is.</diffmk:wrapper></para>
- <para><diffmk:wrapper diffmk:change="changed">On the JPA
Facet page you should choose Hibernate as a target platform. Also select the
- proper database connection, if it is defined, or add a new one by clicking the
</diffmk:wrapper><emphasis>
- <property moreinfo="none">Add connection</property>
- </emphasis> link.</para>
- <para>Hitting <emphasis>
- <property moreinfo="none">Finish</property>
- </emphasis> will generate the project.</para>
- <figure diffmk:change="added" float="0">
- <title>Targeting at Hibernate Platform</title>
- <mediaobject diffmk:change="added">
- <imageobject diffmk:change="added">
- <imagedata
fileref="images/plugins/dali_integration2.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <note diffmk:change="added">
- <title>Note:</title>
- <para><diffmk:wrapper diffmk:change="changed">Please note,
if you choose Hibernate as a platform while creating a JPA/Dali project,
- a Hibernate Console Configuration for the project is created automatically when
the wizard
- finishes its work. It allows a full usage of
</diffmk:wrapper><property moreinfo="none">Hibernate
Tools</property><diffmk:wrapper diffmk:change="changed"> features
- without additional setup.</diffmk:wrapper></para>
- </note>
- </section>
- <section id="generate_ddl_entities_with_hibernate">
- <title>Generating DDL and Entities</title>
- <para><diffmk:wrapper diffmk:change="changed">By enabling
Hibernate platform specific features you can now generate DDL and Entities.
- For that find </diffmk:wrapper><emphasis>
- <property moreinfo="none"><diffmk:wrapper
diffmk:change="changed">JPA Tools > Generate Tables from
Entities/Generate Entities from
- Tables</diffmk:wrapper></property>
- </emphasis> options in the context menu of your JPA project.</para>
- <figure diffmk:change="added" float="0">
- <title>Generate DDL/Entities</title>
- <mediaobject diffmk:change="added">
- <imageobject diffmk:change="added">
- <imagedata
fileref="images/plugins/dali_integration3.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <note diffmk:change="added">
- <title>Note:</title>
- <para><diffmk:wrapper diffmk:change="changed">Please,
remember to put the proper database driver to the classpath of your
- project.</diffmk:wrapper></para>
- </note>
- <para>The <property moreinfo="none">Generate Entities
wizard</property><diffmk:wrapper diffmk:change="changed"> first will
ask you to choose the
- directory where all output will be written.</diffmk:wrapper></para>
- <figure diffmk:change="added" float="0">
- <title>Generate Entities Wizard</title>
- <mediaobject diffmk:change="added">
- <imageobject diffmk:change="added">
- <imagedata
fileref="images/plugins/dali_integration4.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>To generate entities you can use:</para>
- <itemizedlist diffmk:change="added">
- <listitem diffmk:change="added">
- <para>a Hibernate Console Configuration (proposed by
default)</para>
- <para>Just make sure that the <emphasis>
- <property moreinfo="none">Use Console
Configuration</property>
- </emphasis> checkbox is selected and choose a needed configuration from
the <emphasis>
- <property moreinfo="none">Console
configurations</property>
- </emphasis> list box.</para>
- <figure diffmk:change="added" float="0">
- <title>Generate Entities Wizard</title>
- <mediaobject diffmk:change="added">
- <imageobject diffmk:change="added">
- <imagedata
fileref="images/plugins/dali_integration5.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- </listitem>
- </itemizedlist>
- <itemizedlist diffmk:change="added">
- <listitem diffmk:change="added">
- <para>or a DTP connection directly</para>
- <para>Just uncheck <emphasis>
- <property moreinfo="none">Use Console
Configuration</property>
- </emphasis> and adjust database settings.</para>
- </listitem>
- </itemizedlist>
- <para><diffmk:wrapper diffmk:change="changed">All the same
you do with Generate Entities Wizard you can do with Generate DDL wizard.
- Special feature for Generate DDL wizard is possible automatic execution of
Generation DDL in
- the database. </diffmk:wrapper></para>
- <figure diffmk:change="added" float="0">
- <title>Generate DDL Wizard</title>
- <mediaobject diffmk:change="added">
- <imageobject diffmk:change="added">
- <imagedata
fileref="images/plugins/dali_integration6.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <para>Thus, you can now have the Hibernate runtime support in Eclipse JPA
projects.</para>
- </section>
- <section id="hibernate_annotations_support">
- <title>Hibernate Annotations Support</title>
- <para>Also Hibernate Annotations are supported in <property
moreinfo="none"><diffmk:wrapper diffmk:change="changed">Dali
Java Persistence
- Tools</diffmk:wrapper></property><diffmk:wrapper
diffmk:change="changed">. The next annotations are integrated with
</diffmk:wrapper><property moreinfo="none"><diffmk:wrapper
diffmk:change="changed">JPA
- Details</diffmk:wrapper></property> view:</para>
- <itemizedlist>
- <listitem>
- <para>Id Generator annotations - <property
moreinfo="none">@GenericGenerator</property> and <property
moreinfo="none">@GeneratedValue</property></para>
- <figure float="0">
- <title>@GenericGenerator support in Dali</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/dali_integration7.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <figure float="0">
- <title>@GeneratedValue support in Dali</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/dali_integration8.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- </listitem>
- <listitem>
- <para>Property annotations- <property
moreinfo="none">@DiscriminatorFormula</property>, <property
moreinfo="none">@Generated Annotation</property>, <property
moreinfo="none">@Index annotation</property></para>
- <figure float="0">
- <title>@Index support in Dali</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/dali_integration9.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- </listitem>
- <listitem>
- <para>Mapping Queries annotations - <property
moreinfo="none">@NamedQuery</property> and <property
moreinfo="none">@NamedNativeQuery</property></para>
- <figure float="0">
- <title>Add New Named Query Dialog with Hibernate Support</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/dali_integration10.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- <figure float="0">
- <title>@NamedQuery support in Dali</title>
- <mediaobject>
- <imageobject>
- <imagedata
fileref="images/plugins/dali_integration11.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- </listitem>
- <listitem diffmk:change="added">
- <para diffmk:change="added"><diffmk:wrapper
diffmk:change="added">Association annotations in an
</diffmk:wrapper><property diffmk:change="added"
moreinfo="none"><diffmk:wrapper
diffmk:change="added">embeddable</diffmk:wrapper></property><diffmk:wrapper
diffmk:change="added"> object (</diffmk:wrapper><property
diffmk:change="added" moreinfo="none"><diffmk:wrapper
diffmk:change="added">@OneToOne</diffmk:wrapper></property><diffmk:wrapper
diffmk:change="added">, </diffmk:wrapper><property
diffmk:change="added" moreinfo="none"><diffmk:wrapper
diffmk:change="added">@ManyToOne</diffmk:wrapper></property><diffmk:wrapper
diffmk:change="added">, </diffmk:wrapper><property
diffmk:change="added" moreinfo="none"><diffmk:wrapper
diffmk:change="added">@OneToMany</diffmk:wrapper></property><diffmk:wrapper
diffmk:change="added"> or </diffmk:wrapper><property
diffmk:change="added" moreinfo="none"><diffmk:wrapper
diffmk:change="added">@ManyToMany</diffmk:wrapper></property><diffmk:!
wrapper diffmk:change="added">)</diffmk:wrapper></para>
- <figure diffmk:change="added" float="0">
- <title diffmk:change="added"><diffmk:wrapper
diffmk:change="added">Hibernate Support for Embeddable
Object</diffmk:wrapper></title>
- <mediaobject diffmk:change="added">
- <imageobject diffmk:change="added">
- <imagedata diffmk:change="added"
fileref="images/plugins/dali_integration12.png"></imagedata>
- </imageobject>
- </mediaobject>
- </figure>
- </listitem>
- </itemizedlist>
- <para>More information about Hibernate Annotation you can find in <ulink
url="http://docs.jboss.org/hibernate/stable/annotations/reference/en...
diffmk:change="changed">Hibernate
- Annotations Reference Guide</diffmk:wrapper></ulink>.
</para>
- </section>
- <section>
- <title>Relevant Resources Links</title>
- <para>There is full information about native Dali plugin features on
<ulink
url="http://help.eclipse.org/galileo/index.jsp?nav=/8"><d...
diffmk:change="changed">Eclipse Documentation
- page</diffmk:wrapper></ulink>.</para>
- </section>
- </section>
-</chapter>
-
-
-<chapter id="ant"
xml:base="file:///home/vchukhutsina/repos/ochik_jboss/hibernatetools/docs/reference/en-US/ant.xml">
- <title>Ant Tools</title>
-
- <para>Maybe somebody will find it more preferable to use Ant for generation
purposes. Thus, this
- chapter is intended to get you ready to start using Hibernate Tools via Ant
tasks.</para>
-
- <section>
- <title>Introduction</title>
-
- <para>The <emphasis>
- <property moreinfo="none">hibernate-tools.jar</property>
- </emphasis> contains the core for the <property
moreinfo="none">Hibernate Tools</property>. It is used as the
- basis for both the Ant tasks described in this document and the eclipse plugins
both available
- from
tools.hibernate.org. The <emphasis>
- <property moreinfo="none">hibernate-tools.jar</property>
- </emphasis> is located in your eclipse plugins directory at <emphasis>
- <property
moreinfo="none">/plugins/org.hibernate.eclipse.x.x.x/lib/tools/hibernate-tools.jar</property>.</emphasis></para>
- <para>This jar is 100% independent from the eclipse platform and can thus be
used independently
- of eclipse.</para>
-
- <note>
- <title>Note:</title>
- <para>There might be incompatibilities with respect to the Hibernate3.jar
bundled with the
- tools and your own jar. Thus to avoid any confusion it is recommended to use the
- hibernate3.jar and hibernate-annotations.jar bundled with the tools when you want
to use the
- Ant tasks. Do not worry about using e.g. Hibernate 3.2 jar's with e.g. a
Hibernate 3.1
- project since the output generated will work with previous Hibernate 3 versions.
</para>
- </note>
- </section>
-
- <section>
- <title>The <hibernatetool> Ant Task</title>
-
- <para>To use the ant tasks you need to have the <emphasis>
- <property moreinfo="none">hibernatetool</property>
- </emphasis> task defined. That is done in your <emphasis>
- <property moreinfo="none">build.xml</property>
- </emphasis> by inserting the following xml (assuming the jars are in the
- <literal moreinfo="none">lib</literal> directory):
</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<path id="toolslib">
- <path location="lib/hibernate-tools.jar" />
- <path location="lib/hibernate3.jar" />
- <path location="lib/freemarker.jar" />
- <path location="${jdbc.driver.jar}" />
-</path>
-
-<taskdef name="hibernatetool"
- classname="org.hibernate.tool.ant.HibernateToolTask"
- classpathref="toolslib" />
-]]></programlisting>
-
- <para>This
- <code><taskdef></code>
- defines an Ant task called <emphasis>
- <property moreinfo="none"> hibernatetool </property>
- </emphasis> which now can be used anywhere in your ant <emphasis>
- <property moreinfo="none">build.xml</property>
- </emphasis> files. It is important to include all the <property
moreinfo="none">Hibernate Tools</property>
- dependencies as well as the jdbc driver.</para>
-
- <para>Notice that to use the annotation based Configuration you must <ulink
url="http://annotations.hibernate.org">get a release</ulink>.
</para>
-
- <para></para>
-
- <para>When using the <emphasis>
- <property moreinfo="none"> hibernatetool </property>
- </emphasis> task you have to specify one or more of the
following:</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<hibernatetool
- destdir="defaultDestinationDirectory"
- templatepath="defaultTemplatePath"
->
- <classpath ...>
- <property key="propertyName" value="value"/>
- <propertyset ...>
- (<configuration ...>|<annotationconfiguration ...>|
- <jpaconfiguration ...>|<jdbcconfiguration ...>)
- (<hbm2java>,<hbm2cfgxml>,<hbmtemplate>,...)
-</hibernatetool>]]></programlisting>
-
- <table frame="topbot">
- <title>Hibernatetool attributes</title>
-
- <tgroup cols="3">
-
- <colspec colwidth="0.3*"></colspec>
-
- <colspec colwidth="1.0*"></colspec>
-
- <colspec colwidth="0.3*"></colspec>
-
-
- <thead>
- <row>
- <entry>Attribute name</entry>
-
- <entry>Definition</entry>
-
- <entry>Attribute use</entry>
- </row>
- </thead>
-
- <tbody>
- <row>
- <entry>
- <para>destdir</para>
- </entry>
-
- <entry>
- <para>Destination directory for files generated with
exporters</para>
- </entry>
-
- <entry>
- <para>Required</para>
- </entry>
- </row>
-
- <row>
- <entry>
- <para>templatepath</para>
- </entry>
-
- <entry>
- <para>A path to be used to look up user-edited
templates</para>
- </entry>
-
- <entry>
- <para>Optional</para>
- </entry>
- </row>
-
- <row>
- <entry>
- <para>classpath</para>
- </entry>
-
- <entry>
- <para>A classpath to be used to resolve resources, such as mappings
and
- usertypes</para>
- </entry>
-
- <entry>
- <para>Optional, but very often required</para>
- </entry>
- </row>
-
-
- <row>
- <entry>
- <para>property (and propertyset)</para>
- </entry>
-
- <entry>
- <para>Used to set properties to control the exporters. Mostly
relevant for providing
- custom properties to user defined templates</para>
- </entry>
-
- <entry>
- <para>Optional</para>
- </entry>
- </row>
-
- <row>
- <entry>
- <para>configuration (annotationconfiguration, jpaconfiguration,
- jdbcconfiguration)</para>
- </entry>
-
- <entry>
- <para>One of four different ways of configuring the Hibernate Meta
Model must be
- specified</para>
- </entry>
-
- <entry>
- <para></para>
- </entry>
- </row>
-
- <row>
- <entry>
- <para>hbm2java (hbm2cfgxml, hbmtemplate, etc.)</para>
- </entry>
-
- <entry>
- <para>One or more of the exporters must be specified</para>
- </entry>
-
- <entry>
- <para></para>
- </entry>
- </row>
-
- </tbody>
-
- </tgroup>
- </table>
-
- <section>
- <title>Basic examples</title>
-
- <para>The following example shows the most basic setup for generating
pojo's via <code><hbm2java></code> from a normal
<emphasis>
- <property moreinfo="none">
- <literal moreinfo="none">hibernate.cfg.xml</literal>
- </property>. </emphasis> The output will be put in the
<emphasis>
- <property
moreinfo="none">${build.dir}/generated</property>
- </emphasis> directory.</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<hibernatetool
destdir="${build.dir}/generated">
- <classpath>
- <path location="${build.dir}/classes"/>
- </classpath>
-
- <configuration configurationfile="hibernate.cfg.xml"/>
- <hbm2java/>
-</hibernatetool>]]></programlisting>
-
-
- <para>The following example is similar, but now we are performing multiple
exports from the
- same configuration. We are exporting the schema via
<code><hbm2dll></code>, generates some DAO code via
<code><hbm2dao></code>
- and finally runs a custom code generation via
<code><hbmtemplate></code>. This is again from a normal
<emphasis>
- <property moreinfo="none">hibernate.cfg.xml</property>
- </emphasis> and the output is still put in the <emphasis>
- <property moreinfo="none">
- <literal
moreinfo="none">${build.dir}/generated</literal>
- </property>
- </emphasis> directory. Furthermore the example also shows where a classpath
is specified
- when you e.g. have custom usertypes or some mappings that is needed to be looked
up as a
- classpath resource.</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<hibernatetool
destdir="${build.dir}/generated">
- <classpath>
- <path location="${build.dir}/classes"/>
- </classpath>
-
- <configuration configurationfile="hibernate.cfg.xml"/>
- <hbm2ddl/>
- <hbm2dao/>
- <hbmtemplate
- filepattern="{package-name}/I{class-name}Constants.java"
- templatepath="${etc.dir}/customtemplates"
- template="myconstants.vm"
- />
-</hibernatetool>]]></programlisting>
-
- </section>
- </section>
-
- <section>
- <title>Hibernate Configurations</title>
-
- <para><emphasis>Hibernatetool</emphasis> supports four different
Hibernate configurations: A
- standard Hibernate configuration
- (<code><configuration></code>), Annotation based
- configuration (<code><annotationconfiguration></code>),
- JPA persistence based configuration
- (<code><jpaconfiguration></code>) and a JDBC based
- configuration (<code><jdbcconfiguration></code>)
- for use when reverse engineering.</para>
-
- <para>Each have in common that they are able to build up a Hibernate
Configuration object from
- which a set of exporters can be run to generate various output. </para>
-
- <note>
- <title>Note:</title>
- <para>Output can be anything, e.g. specific files, statements execution
against a database,
- error reporting or anything else that can be done in java code.</para>
- </note>
-
- <para>The following sections describe what the various configurations can do,
plus lists the
- individual settings they have.</para>
-
- <section>
- <title>Standard Hibernate Configuration
(<configuration>)</title>
-
- <para>A
- <code><configuration></code>
- is used to define a standard Hibernate configuration. A standard Hibernate
- configuration reads the mappings from a <emphasis>
- <property moreinfo="none">cfg.xml</property>
- </emphasis> and/or a fileset.</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<configuration
- configurationfile="hibernate.cfg.xml"
- propertyfile="hibernate.properties"
- entityresolver="EntityResolver classname"
- namingstrategy="NamingStrategy classname"
->
- <fileset...>
-
- </configuration>]]></programlisting>
-
- <table frame="topbot">
- <title>Configuration attributes</title>
-
- <tgroup cols="3">
-
- <colspec colwidth="0.3*"></colspec>
-
- <colspec colwidth="1.0*"></colspec>
-
- <colspec colwidth="0.3*"></colspec>
-
-
- <thead>
- <row>
- <entry>Attribute name</entry>
-
- <entry>Definition</entry>
-
- <entry>Attribute use</entry>
- </row>
- </thead>
-
- <tbody>
- <row>
- <entry>
- <para>configurationfile</para>
- </entry>
-
- <entry>
- <para>The name of a Hibernate configuration file, e.g.
"hibernate.cfg.xml"</para>
- </entry>
-
- <entry>
- <para>Optional</para>
- </entry>
- </row>
-
- <row>
- <entry>
- <para>propertyfile</para>
- </entry>
-
- <entry>
- <para>The name of a property file, e.g.
"hibernate.properties"</para>
- </entry>
-
- <entry>
- <para>Optional</para>
- </entry>
- </row>
-
- <row>
- <entry>
- <para>entity-resolver</para>
- </entry>
-
- <entry>
- <para>Name of a class that implements org.xml.sax.EntityResolver.
Used if the
- mapping files require custom entity resolver</para>
- </entry>
-
- <entry>
- <para>Optional</para>
- </entry>
- </row>
-
-
- <row>
- <entry>
- <para>namingstrategy</para>
- </entry>
-
- <entry>
- <para>Name of a class that implements
org.hibernate.cfg.NamingStrategy. Used for
- setting up the naming strategy in Hibernate which controls the
automatic naming of
- tables and columns.In JPA projects naming strategy is supported for
default Name/Columns mapping</para>
- </entry>
-
- <entry>
- <para>Optional</para>
- </entry>
- </row>
-
- <row>
- <entry>
- <para>fileset</para>
- </entry>
-
- <entry>
- <para>A standard Ant fileset. Used to include hibernate mapping
files. Remember that
- if mappings are already specified in the hibernate.cfg.xml then it
should not be
- included via the fileset as it will result in duplicate import
exceptions.</para>
- </entry>
-
- <entry>
- <para></para>
- </entry>
- </row>
-
- </tbody>
-
- </tgroup>
- </table>
-
- <section>
- <title>Example</title>
-
- <para>This example shows an example where no <emphasis>
- <property moreinfo="none">
- <literal moreinfo="none">hibernate.cfg.xml</literal>
- </property>
- </emphasis> exists, and a <emphasis>
- <property moreinfo="none"> hibernate.properties
</property>
- </emphasis> and fileset is used instead. </para>
-
- <note>
- <title>Note:</title>
- <para> Hibernate will still read any global <emphasis>
- <property
moreinfo="none">hibernate.properties</property>
- </emphasis> available in the classpath, but the specified properties
file here will
- override those values for any non-global property.</para>
- </note>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<hibernatetool
destdir="${build.dir}/generated">
- <configuration propertyfile="{etc.dir}/hibernate.properties">
- <fileset dir="${src.dir}">
- <include name="**/*.hbm.xml"/>
- <exclude name="**/*Test.hbm.xml"/>
- </fileset>
- </configuration>
-
- <!-- list exporters here -->
-
-</hibernatetool>]]></programlisting>
-
- </section>
- </section>
-
- <section>
- <title>Annotation based Configuration
(<annotationconfiguration>)</title>
-
- <para>An
- <code><annotationconfiguration></code>
- is used when you want to read the metamodel from EJB3/Hibernate Annotations
- based POJO's.</para>
-
- <important>
- <title>Important:</title>
- <para>To use it remember to put the jar files needed for using hibernate
annotations in the
- classpath of the
- <code><taskdef></code>, i. e.
- hibernate-annotations.jar and hibernate-commons-annotations.jar.</para>
- </important>
-
- <para>The
- <code><annotationconfiguration></code>
- supports the same attributes as a
- <code><configuration></code>
- except that the configurationfile attribute is now required as that is from
- where an <emphasis>AnnotationConfiguration</emphasis> gets the list
of classes/packages it
- should load.</para>
-
- <para>Thus the minimal usage is:</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<hibernatetool
destdir="${build.dir}/generated">
- <annotationconfiguration
- configurationfile="hibernate.cfg.xml"/>
-
- <!-- list exporters here -->
-
-</hibernatetool>
-]]></programlisting>
-
- </section>
-
- <section>
- <title>JPA based configuration
(<jpaconfiguration>)</title>
-
- <para>A <code><jpaconfiguration></code>
- is used when you want to read the metamodel from JPA/Hibernate Annotation where
- you want to use the auto-scan configuration as defined in the JPA spec (part of
EJB3). In
- other words, when you do not have a <emphasis>
- <property moreinfo="none">hibernate.cfg.xml</property>,
</emphasis> but instead have a setup where you use
- a <emphasis>
- <property moreinfo="none">persistence.xml</property>
- </emphasis> packaged in a JPA compliant manner.</para>
-
- <para>The <code><jpaconfiguration></code>
- will simply just try and auto-configure it self based on the available
- classpath, e.g. look for <emphasis>
- <property
moreinfo="none">META-INF/persistence.xml</property>.
</emphasis></para>
-
- <para>The <emphasis>
- <property moreinfo="none">persistenceunit</property>
- </emphasis> attribute can be used to select a specific persistence unit. If
no <emphasis>
- <property moreinfo="none">persistenceunit</property>
- </emphasis> is specified it will automatically search for one and if a
unique one is found,
- use it, but if multiple persistence units are available it will
error.</para>
-
- <para>To use a <code><jpaconfiguration></code>
- you will need to specify some additional jars from Hibernate EntityManager in
- the <code><taskdef></code> of the hibernatetool. The
following shows a full setup:</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<path id="ejb3toolslib">
- <path refid="jpatoolslib"/> <!-- ref to previously defined toolslib
-->
- <path location="lib/hibernate-annotations.jar" />
- <path location="lib/ejb3-persistence.jar" />
- <path location="lib/hibernate-entitymanager.jar" />
- <path location="lib/jboss-archive-browsing.jar" />
- <path location="lib/javaassist.jar" />
-</path>
-
-<taskdef name="hibernatetool"
- classname="org.hibernate.tool.ant.HibernateToolTask"
- classpathref="jpatoolslib" />
-
-<hibernatetool destdir="${build.dir}">
- <jpaconfiguration persistenceunit="caveatemptor"/>
- <classpath>
- <!-- it is in this classpath you put your classes dir,
- and/or jpa persistence compliant jar -->
- <path location="${build.dir}/jpa/classes" />
- </classpath>
-
- <!-- list exporters here -->
-
-</hibernatetool>
-]]></programlisting>
-
-
- <note>
- <title>Note:</title>
- <para>ejb3configuration was the name used in previous versions. It still
works but will emit
- a warning telling you to use <literal
moreinfo="none">jpaconfiguration</literal> instead.</para>
- </note>
-
- </section>
-
- <section>
- <title>JDBC Configuration for reverse engineering
(<jdbcconfiguration>)</title>
-
- <para>A <code><jdbcconfiguration></code> is used to
perform reverse engineering of the database from a JDBC connection.</para>
-
- <para>This configuration works by reading the connection properties either
from <emphasis>
- <property moreinfo="none">hibernate.cfg.xml</property>
- </emphasis> or <emphasis>
- <property
moreinfo="none">hibernate.properties</property>
- </emphasis> with a fileset.</para>
-
- <para>The <code><jdbcconfiguration></code> has the
same attributes as a
- <code><configuration></code>
- plus the following additional attributes:</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<jdbcconfiguration
- ...
- packagename="package.name"
- revengfile="hibernate.reveng.xml"
- reversestrategy="ReverseEngineeringStrategy classname"
- detectmanytomany="true|false"
- detectoptmisticlock="true|false"
->
- ...
- </jdbcconfiguration>]]></programlisting>
-
- <table frame="topbot">
- <title>Jdbcconfiguration attributes</title>
-
- <tgroup cols="3">
-
- <colspec colwidth="0.3*"></colspec>
-
- <colspec colwidth="1.0*"></colspec>
-
- <colspec colwidth="0.3*"></colspec>
-
-
- <thead>
- <row>
- <entry>Attribute name</entry>
-
- <entry>Definition</entry>
-
- <entry>Attribute use</entry>
- </row>
- </thead>
-
- <tbody>
- <row>
- <entry>
- <para>packagename</para>
- </entry>
-
- <entry>
- <para>The default package name to use when mappings for classes are
created</para>
- </entry>
-
- <entry>
- <para>Optional</para>
- </entry>
- </row>
-
- <row>
- <entry>
- <para>revengfile</para>
- </entry>
-
- <entry>
- <para>The name of a property file, e.g.
"hibernate.properties"</para>
- </entry>
-
- <entry>
- <para>Optional</para>
- </entry>
- </row>
-
- <row>
- <entry>
- <para>reversestrategy</para>
- </entry>
-
- <entry>
- <para>Name of a class that implements
org.hibernate.cfg.reveng.ReverseEngineeringStrategy.
- Used for setting up the strategy the tools will use to control the
reverse engineering, e.g. naming of
- properties, which tables to include/exclude etc. Using a class instead
of (or as
- addition to) a reveng.xml file gives you full programmatic control of
the reverse
- engineering.</para>
- </entry>
-
- <entry>
- <para>Optional</para>
- </entry>
- </row>
-
-
- <row>
- <entry>
- <para>detectManytoMany</para>
- </entry>
-
- <entry>
- <para>If true, tables which are pure many-to-many link tables will
be mapped as
- such. A pure many-to-many table is one which primary-key contains
exactly two
- foreign-keys pointing to other entity tables and has no other
columns.</para>
- </entry>
-
- <entry>
- <para>Default: true</para>
- </entry>
- </row>
-
- <row>
- <entry>
- <para>detectOptimisticLock</para>
- </entry>
-
- <entry>
- <para>If true, columns named VERSION or TIMESTAMP with appropriate
types will be
- mapped with the appropriate optimistic locking corresponding to
- <code><version></code> or
<code><timestamp></code>.</para>
- </entry>
-
- <entry>
- <para>Default: true</para>
- </entry>
- </row>
-
- </tbody>
-
- </tgroup>
- </table>
-
- <section>
- <title>Example</title>
-
- <para>Here is an example of using
<code><jdbcconfiguration></code> to generate Hibernate xml
mappings via
- <code><hbm2hbmxml></code>. The connection settings
here
- is read from a <emphasis>
- <property moreinfo="none"> hibernate.properties
</property>
- </emphasis> file but could just as well have been read from a
<emphasis>
- <property moreinfo="none">hibernate.cfg.xml</property>.
</emphasis></para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<hibernatetool>
- <jdbcconfiguration propertyfile="etc/hibernate.properties" />
- <hbm2hbmxml destdir="${build.dir}/src" />
-</hibernatetool>
-]]></programlisting>
- </section>
- </section>
- </section>
-
- <section>
- <title>Exporters</title>
-
- <para>Exporters are the parts that do the actual job of converting the
hibernate metamodel into
- various artifacts, mainly code. The following section describes the current
supported set of
- exporters in the <property moreinfo="none">Hibernate
Tool</property> distribution. It is also possible for
- userdefined exporters, that is done through the
- <code><hbmtemplate></code>
- exporter.</para>
-
- <section>
- <title>Database schema exporter (<hbm2ddl>)</title>
-
- <para><code><hbm2ddl></code> lets you run
schemaexport and schemaupdate which generates the appropriate SQL
- DDL and allow you to store the result in a file or export it directly to the
database.
- Remember that if a custom naming strategy is needed it is placed on the
configuration
- element.</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<hbm2ddl
- export="true|false"
- update="true|false"
- drop="true|false"
- create="true|false"
- outputfilename="filename.ddl"
- delimiter=";"
- format="true|false"
- haltonerror="true|false"
- >]]></programlisting>
-
- <table frame="topbot">
- <title>Hbm2ddl exporter attributes</title>
-
- <tgroup cols="3">
-
- <colspec colwidth="0.3*"></colspec>
-
- <colspec colwidth="1.0*"></colspec>
-
- <colspec colwidth="0.3*"></colspec>
-
-
- <thead>
- <row>
- <entry>Attribute name</entry>
-
- <entry>Definition</entry>
-
- <entry>Attribute use</entry>
- </row>
- </thead>
-
- <tbody>
- <row>
- <entry>
- <para>export</para>
- </entry>
-
- <entry>
- <para>Executes the generated statements against the
database</para>
- </entry>
-
- <entry>
- <para>Default: true</para>
- </entry>
- </row>
-
- <row>
- <entry>
- <para>update</para>
- </entry>
-
- <entry>
- <para>Try and create an update script representing the
"delta"
- between what is in the database and what the mappings specify. Ignores
- create/update attributes. (<emphasis>Do *not* use against
production databases, no
- guarantees at all that the proper delta can be generated nor that the
underlying
- database can actually execute the needed
operations</emphasis>).</para>
- </entry>
-
- <entry>
- <para>Default: false</para>
- </entry>
- </row>
-
- <row>
- <entry>
- <para>drop</para>
- </entry>
-
- <entry>
- <para>Output will contain drop statements for the tables, indices
and
- constraints</para>
- </entry>
-
- <entry>
- <para>Default: false</para>
- </entry>
- </row>
-
-
- <row>
- <entry>
- <para>create</para>
- </entry>
-
- <entry>
- <para>Output will contain create statements for the tables, indices
and
- constraints</para>
- </entry>
-
- <entry>
- <para>Default: true</para>
- </entry>
- </row>
-
- <row>
- <entry>
- <para>outputfilename</para>
- </entry>
-
- <entry>
- <para>If specified the statements will be dumped to this
file</para>
- </entry>
-
- <entry>
- <para>Optional</para>
- </entry>
- </row>
-
- <row>
- <entry>
- <para>delimiter</para>
- </entry>
-
- <entry>
- <para>If specified the statements will be dumped to this
file</para>
- </entry>
-
- <entry>
- <para>Default: ";"</para>
- </entry>
- </row>
-
- <row>
- <entry>
- <para>format</para>
- </entry>
-
- <entry>
- <para>Apply basic formatting to the statements</para>
- </entry>
-
- <entry>
- <para>Default: false</para>
- </entry>
- </row>
-
- <row>
- <entry>
- <para>haltonerror</para>
- </entry>
-
- <entry>
- <para>Halt build process if an error occurs</para>
- </entry>
-
- <entry>
- <para>Default: false</para>
- </entry>
- </row>
- </tbody>
-
- </tgroup>
- </table>
-
- <section>
- <title>Example</title>
-
- <para>Basic example of using
<code><hbm2ddl></code>, which does not export to the
- database but simply dumps the sql to a file named <emphasis>
- <property moreinfo="none">sql.ddl</property>.
</emphasis></para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<hibernatetool
destdir="${build.dir}/generated">
- <configuration configurationfile="hibernate.cfg.xml"/>
- <hbm2ddl export="false" outputfilename="sql.ddl"/>
-</hibernatetool>]]></programlisting>
- </section>
- </section>
-
- <section>
- <title>POJO java code exporter (<hbm2java>)</title>
-
- <para><code><hbm2java></code> is a java
codegenerator. Options for controlling whether JDK 5 syntax can be
- used and whether the POJO should be annotated with EJB3/Hibernate
Annotations.</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<hbm2java
- jdk5="true|false"
- ejb3="true|false"
->]]></programlisting>
-
- <table frame="topbot">
- <title>Hbm2java exporter attributes</title>
-
- <tgroup cols="3">
-
- <colspec colwidth="0.3*"></colspec>
-
- <colspec colwidth="1.0*"></colspec>
-
- <colspec colwidth="0.3*"></colspec>
-
-
- <thead>
- <row>
- <entry>Attribute name</entry>
-
- <entry>Definition</entry>
-
- <entry>Default value</entry>
- </row>
- </thead>
-
- <tbody>
- <row>
- <entry>
- <para>jdk</para>
- </entry>
-
- <entry>
- <para>Code will contain JDK 5 constructs such as generics and
static imports</para>
- </entry>
-
- <entry>
- <para>False</para>
- </entry>
- </row>
-
- <row>
- <entry>
- <para>ejb3</para>
- </entry>
-
- <entry>
- <para>Code will contain EJB 3 features, e.g. using annotations
from
- javax.persistence and org.hibernate.annotations</para>
- </entry>
-
- <entry>
- <para>False</para>
- </entry>
- </row>
-
- </tbody>
-
- </tgroup>
- </table>
-
- <section>
- <title>Example</title>
-
- <para>Basic example of using
<code><hbm2java></code> to generate POJO's that utilize jdk5
constructs.</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<hibernatetool
destdir="${build.dir}/generated">
- <configuration configurationfile="hibernate.cfg.xml"/>
- <hbm2java jdk5="true"/>
-</hibernatetool>]]></programlisting>
- </section>
- </section>
-
- <section>
- <title>Hibernate Mapping files exporter
(<hbm2hbmxml>)</title>
-
- <para><code><hbm2hbmxml></code> generates a set of
.hbm files. Intended to be used together with a
- <code><jdbcconfiguration></code>
- when performing reverse engineering, but can be used with any kind of
- configuration. e.g. to convert from annotation based pojo's to
<emphasis>
- <property moreinfo="none">hbm.xml</property>.
</emphasis></para>
-
- <note>
- <title>Note:</title>
- <para>Not every possible mapping transformation is possible/implemented
(contributions
- welcome) so some hand editing might be necessary.</para>
- </note>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<hbm2hbmxml/>]]></programlisting>
-
- <section>
- <title>Example</title>
-
- <para>Basic usage of <code><hbm2hbmxml></code>.
</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<hibernatetool
destdir="${build.dir}/generated">
- <configuration configurationfile="hibernate.cfg.xml"/>
- <hbm2hbmxml/>
-</hibernatetool>]]></programlisting>
-
- <para><code><hbm2hbmxml></code> is normally used
with a <code><jdbcconfiguration></code> like in the above
example, but any other configuration can also be used to
- convert between the different ways of performing mappings. Here is an example
of that,
- using an <code><annotationconfiguration></code>
- .</para>
-
- <note>
- <title>Note:</title>
- <para>Not all conversions are implemented (contributions welcome), so
some hand editing
- might be necessary.</para>
- </note>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<hibernatetool
destdir="${build.dir}/generated">
- <annotationconfiguration configurationfile="hibernate.cfg.xml"/>
- <hbm2hbmxml/>
-</hibernatetool>]]></programlisting>
- </section>
- </section>
-
- <section>
- <title>Hibernate Configuration file exporter
(<hbm2cfgxml>)</title>
-
- <para><code><hbm2cfgxml></code> generates a
<emphasis>
- <property moreinfo="none">hibernate.cfg.xml</property>.
</emphasis> Intended to be used together with a
<code><jdbcconfiguration></code>
- when performing reverse engineering, but it can be used with any kind of
- configuration. The <code><hbm2cfgxml></code> will
contain the properties used and adds mapping entries for each mapped class.</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<hbm2cfgxml
- ejb3="true|false"
-/>
-]]></programlisting>
-
- <table frame="topbot">
- <title>Hbm2cfgxml exporter attribute</title>
-
- <tgroup cols="3">
-
- <colspec colwidth="0.3*"></colspec>
-
- <colspec colwidth="1.0*"></colspec>
-
- <colspec colwidth="0.3*"></colspec>
-
-
- <thead>
- <row>
- <entry>Attribute name</entry>
-
- <entry>Definition</entry>
-
- <entry>Default value</entry>
- </row>
- </thead>
-
- <tbody>
-
- <row>
- <entry>
- <para>ejb3</para>
- </entry>
-
- <entry>
- <para>The generated cfg.xml will have <mapping
class=".."/>, opposed
- to <mapping resource="..."/> for each
mapping.</para>
- </entry>
-
- <entry>
- <para>False</para>
- </entry>
- </row>
-
- </tbody>
-
- </tgroup>
- </table>
-
- </section>
-
- <section>
- <title>Documentation exporter (<hbm2doc>)</title>
-
- <para><code><hbm2doc></code>
- generates html documentation a'la javadoc for the database schema
et.al.</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<hbm2doc/>]]></programlisting>
- </section>
-
- <section>
- <title>Query exporter (<query>)</title>
-
- <para><code><query></code> is used to execute a HQL
query statements and optionally sends the output to a
- file. It can be used for verifying the mappings and for basic data
extraction.</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<query
- destfile="filename">
- <hql>[a HQL query string]</hql>
-</query>
-]]></programlisting>
-
- <para>Currently one session is opened and used for all queries and the query
is executed via
- the list() method. In the future more options might become available, like
performing
- executeUpdate(), use named queries and etc.</para>
-
- <para></para>
-
- <section>
- <title>Examples</title>
-
- <para>The simplest usage of <code><query></code>
will just execute the query without dumping to a file. This can be used to
- verify that queries can actually be performed.</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<hibernatetool>
- <configuration configurationfile="hibernate.cfg.xml"/>
- <query>from java.lang.Object</query>
-</hibernatetool>]]></programlisting>
-
- <para>Multiple queries can be executed by nested
<code><hql></code> elements.
- In this example we also let the output be dumped to <emphasis>
- <property moreinfo="none">queryresult.txt</property>.
</emphasis></para>
-
- <note>
- <title>Note:</title>
- <para> Currently the dump is simply a call to toString on each
element.</para>
- </note>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<hibernatetool>
- <configuration configurationfile="hibernate.cfg.xml"/>
- <query destfile="queryresult.txt">
- <hql>select c.name from Customer c where c.age > 42</hql>
- <hql>from Cat</hql>
-</hibernatetool>]]></programlisting>
-
- </section>
- </section>
-
- <section id="hbmtemplate">
- <title>Generic Hibernate metamodel exporter
(<hbmtemplate>)</title>
-
- <para>Generic exporter that can be controlled by a user provides a template
or class.</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<hbmtemplate
- filepattern="{package-name}/{class-name}.ftl"
- template="somename.ftl"
- exporterclass="Exporter classname"
-/>]]></programlisting>
-
- <note>
- <title>Note:</title>
- <para>Previous versions of the tools used Velocity. We are now using
Freemarker which
- provides us much better exception and error handling.</para>
- </note>
-
- <section>
- <title>Exporter via <hbmtemplate></title>
-
- <para>The following is an example of reverse engineering via
- <code><jdbcconfiguration></code> and usage of a
custom Exporter via the
- <code><hbmtemplate></code>.</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[ <hibernatetool destdir="${destdir}">
- <jdbcconfiguration
- configurationfile="hibernate.cfg.xml"
- packagename="my.model"/>
-
- <!-- setup properties -->
- <property key="appname" value="Registration"/>
- <property key="shortname" value="crud"/>
-
- <hbmtemplate
- exporterclass="my.own.Exporter"
- filepattern="."/>
-
-</hibernatetool>
-]]></programlisting>
-
- </section>
- <section>
- <title>Relevant Resources Links</title>
-
- <para>Read more about <ulink
url="http://velocity.apache.org/">Velocity</ulink> and <ulink
url="http://freemarker.org/">Freemarker</ulink> to find out why using
the last is better
- or refer to Max Andersen discussion on the topic in <ulink
url="http://in.relation.to/2110.lace;jsessionid=3462F47B17556604C15DF1B96572E940">"A
story about FreeMarker and Velocity"</ulink>.</para>
- </section>
- </section>
- </section>
-
-
-
- <section>
- <title>Using properties to configure Exporters</title>
-
- <para>Exporters can be controlled by user properties. The user properties are
specified via
- <code><property></code>
- or
- <code><propertyset></code>
- and each exporter will have access to them directly in the templates and via
- <property
moreinfo="none">Exporter.setProperties()</property>.</para>
-
- <section>
- <title><property> and
- <propertyset></title>
-
- <para>The <code><property></code>
- allows you bind a string value to a key. The value will be available in the
- templates via <code>$<key></code>.
- The following example will assign the string value
- <code>"true"</code>
- to the variable
- <code>$descriptors</code>
- .</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<property key="descriptors"
value="true"/>]]></programlisting>
-
- <para>Most times using <code><property></code> is
enough for specifying the properties needed for the exporters. Still the ant
- tools supports the notion of <code><propertyset></code>
that is used for grouping a set of properties. More about the functionality of
<code><propertyset></code>
- is explained in detail in the <ulink
url="http://ant.apache.org/manual/">Ant
- manual</ulink>.</para>
- </section>
-
- <section>
- <title>Getting access to user specific classes</title>
-
- <para>If the templates need to access some user class it becomes possible by
specifying a <code>
- "toolclass"</code> in the properties.</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<property
key="hibernatetool.sometool.toolclass"
value="x.y.z.NameOfToolClass"/>
-]]></programlisting>
-
- <para>Placing the above <code><property></code> tag
in <code><hibernatetool></code>
- or inside any exporter will automatically create an instance of
- <literal moreinfo="none">x.y.z.NameOfToolClass</literal>
and it will be available in the templates as
- <literal moreinfo="none">$sometool</literal>. This is
useful to delegate logic and code generation to java
- code instead of placing such logic in the templates.</para>
-
- <section>
- <title>Example</title>
-
- <para>Here is an example that uses
<code><hbmtemplate></code>
- together with <code><property></code> which will be
available to the templates/exporter. </para>
- <note>
- <title>Note:</title>
- <para> This example actually simulates what
<code><hbm2java></code> actually does.</para>
- </note>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<hibernatetool
destdir="${build.dir}/generated">
-<configuration
- configurationfile="etc/hibernate.cfg.xml"/>
- <hbmtemplate
- templateprefix="pojo/"
- template="pojo/Pojo.ftl"
- filepattern="{package-name}/{class-name}.java">
- <property key="jdk5" value="true" />
- <property key="ejb3" value="true" />
- </hbmtemplate>
-</hibernatetool>
-]]></programlisting>
- </section>
- </section>
- </section>
-</chapter>
-
-
-<chapter id="reverseengineering"
xml:base="file:///home/vchukhutsina/repos/ochik_jboss/hibernatetools/docs/reference/en-US/reverseengineering.xml">
- <title>Controlling reverse engineering</title>
-
- <para>When using the <code><jdbcconfiguration></code>,
the ant task will read the
- database metadata and thus will perform a reverse engineering of the database schema
into a
- normal Hibernate Configuration. It is from this object e.g.
<code><hbm2java></code>can generate other artifacts such as
<emphasis>
- <property moreinfo="none">.java</property>
- </emphasis>, <emphasis>
- <property moreinfo="none">.hbm.xml</property>
- </emphasis> etc.</para>
-
- <para>To govern this process <property
moreinfo="none">Hibernate</property> uses a reverse engineering
strategy. A
- reverse engineering strategy is mainly called to provide more java like names for
tables, column
- and foreignkeys into classes, properties and associations. It also used to provide
mappings from
- SQL types to <property moreinfo="none">Hibernate</property>
types. The strategy can be customized by a user. The
- user can even provide its own custom reverse engineering strategy if the provided
strategy is
- not enough, or simply just provide a small part of the strategy and delegate the rest
to the
- default strategy.</para>
-
- <para>Thus, further in this chapter we will discuss how you can configure the
process of a reverse
- engineering, what default reverse engineering strategy includes as well as some custom
concepts.</para>
-
- <section>
- <title>Default reverse engineering strategy</title>
-
- <para>The default strategy uses some rules for mapping JDBC artifact names to
java artifact
- names. It also provide basic typemappings from JDBC types to <property
moreinfo="none">Hibernate</property>
- types. It is the default strategy that uses the packagename attribute to convert a
table name
- to a fully qualified classname.</para>
- </section>
-
- <section id="hibernaterevengxmlfile">
- <title>hibernate.reveng.xml file</title>
-
- <para>To have fine control over the process a <emphasis>
- <property moreinfo="none">hibernate.reveng.xml</property>
- </emphasis> file can be provided. In this file you can specify type mappings
and table
- filtering. This file can be created by hand (it's just basic XML) or you can
use the
- <ulink
url="http://www.hibernate.org/30.html">Hibernate
plugins</ulink> which have a
- specialized editor.</para>
-
- <note>
- <title>Note:</title>
- <para>Many databases are case-sensitive with their names and thus if you
cannot make some
- table match and you are sure it is not excluded by a
<code><table-filter></code> then check
- if the case matches; most databases stores table names in
uppercase.</para>
- </note>
-
- <para>Below you can see an example of a <emphasis>
- <property moreinfo="none">reveng.xml</property>.
</emphasis> Following the example gives you more details
- about the format.</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<?xml version="1.0"
encoding="UTF-8"?>
-<!DOCTYPE hibernate-reverse-engineering
- SYSTEM
"http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >
-
-<hibernate-reverse-engineering>
-
-<type-mapping>
- <!-- jdbc-type is name for java.sql.Types -->
- <sql-type jdbc-type="VARCHAR" length='20'
hibernate-type="SomeUserType" />
- <sql-type jdbc-type="VARCHAR" length='1'
hibernate-type="yes_no" />
- <!-- length, scale and precision can be used to specify the mapping precisely -->
- <sql-type jdbc-type="NUMERIC" precision='1'
hibernate-type="boolean" />
- <!-- the type-mappings are ordered. This mapping will be consulted last,
- thus overridden by the previous one if precision=1 for the column -->
- <sql-type jdbc-type="NUMERIC" hibernate-type="long" />
-</type-mapping>
-
-<!-- BIN$ is recycle bin tables in Oracle -->
-<table-filter match-name="BIN$.*" exclude="true" />
-
-<!-- Exclude DoNotWantIt from all catalogs/schemas -->
-<table-filter match-name="DoNotWantIt" exclude="true" />
-
-<!-- exclude all tables from the schema SCHEMA in catalog BAD. -->
-<table-filter match-catalog="BAD" match-schema="SCHEMA"
match-name=".*" exclude="true" />
-
-<!-- table allows you to override/define how reverse engineering
- is done for a specific table -->
-<table name="ORDERS">
- <primary-key>
- <!-- setting up a specific id generator for a table -->
- <generator class="sequence">
- <param name="table">seq_table</param>
- </generator>
- <key-column name="CUSTID"/>
- </primary-key>
- <column name="NAME" property="orderName" type="string"
/>
- <!-- control many-to-one and set names for a specific named foreign key constraint
-->
- <foreign-key constraint-name="ORDER_CUST">
- <many-to-one property="customer"/>
- <set property="orders"/>
- </foreign-key>
- <!-- can also control a pure (shared pk) one-to-one -->
- <foreign-key constraint-name="ADDRESS_PERSON">
- <one-to-one exclude="false"/>
- <inverse-one-to-one exclude="true"/>
- </foreign-key>
-</table>
-
-</hibernate-reverse-engineering>]]></programlisting>
-
-
- <section>
- <title>Schema Selection (<schema-selection>)</title>
-
- <para><code><schema-selection></code> is used to
drive which schemas the reverse engineering will try and
- process.</para>
-
- <para>By default the reverse engineering will read all schemas and then use
<code><table-filter></code>
- to decide which tables get reverse engineered and which do not; this makes it
- easy to get started but can be inefficient on databases with many
schemas.</para>
-
- <para>With <code><schema-selection></code> it is
thus possible to limit the actual processed schemas and thus significantly
- speed-up the reverse engineering.
<code><table-filter></code> is still used to then decide which
tables will be included/excluded.</para>
-
- <note>
- <title>Note:</title>
- <para>If no <code><schema-selection></code> is
specified, the reverse
- engineering works as if all schemas should be processed. This is equal to:
- <![CDATA[<schema-selection/>]]>. Which in turn is equal to:
- <![CDATA[<schema-selection match-catalog=".*"
match-schema=".*" match-table=".*"/>]]></para>
- </note>
-
- <section>
- <title>Examples</title>
-
- <para>The following will process all tables from <emphasis>
- <property
moreinfo="none">"MY_SCHEMA"</property>.
- </emphasis></para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<schema-selection
match-schema="MY_SCHEMA"/>]]></programlisting>
-
- <para>It is possible to have multiple <literal
moreinfo="none">schema-selection</literal>'s to support
- multi-schema reading or simply to limit the processing to very specific tables.
The
- following example processes all tables in <emphasis>
- <property
moreinfo="none">"MY_SCHEMA"</property>,
- </emphasis> a specific <emphasis>
- <property moreinfo="none">"CITY"</property>
- </emphasis> table plus all tables that starts with <emphasis>
- <property
moreinfo="none">"CODES_"</property>
- </emphasis> in <emphasis>
- <property
moreinfo="none">"COMMON_SCHEMA"</property>.
- </emphasis></para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<schema-selection
match-schema="MY_SCHEMA"/>
-<schema-selection match-schema="COMMON_SCHEMA"
match-table="CITY"/>
-<schema-selection match-schema="COMMON_SCHEMA"
match-table="CODES_.*"/>]]></programlisting>
- </section>
- </section>
-
- <section id="type_map">
- <title>Type mappings (<type-mapping>)</title>
-
- <para>The <code><type-mapping></code> section
specifies how the JDBC types found in the database should be mapped to
- Hibernate types. e.g. <emphasis>
- <property
moreinfo="none">java.sql.Types.VARCHAR</property></emphasis> with
a length of 1 should be mapped to the
- Hibernate type <emphasis>
- <property
moreinfo="none">yes_no</property></emphasis> or <emphasis>
- <property
moreinfo="none">java.sql.Types.NUMERIC</property></emphasis>
should generally just be
- converted to the Hibernate type <literal
moreinfo="none">long</literal>.</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<type-mapping>
- <sql-type
- jdbc-type="integer value or name from java.sql.Types"
- length="a numeric value"
- precision="a numeric value"
- scale="a numeric value"
- not-null="true|false"
- hibernate-type="hibernate type name"
- />
-</type-mapping>]]></programlisting>
-
- <para>The number of attributes specified and the sequence of the <literal
moreinfo="none">sql-type</literal>'s
- is important. Meaning that <property
moreinfo="none">Hibernate</property> will search for the most specific
- first, and if no specific match is found it will seek from top to bottom when
trying to
- resolve a type mapping.</para>
-
- <section>
- <title>Example</title>
-
- <para>The following is an example of a type-mapping which shows the
flexibility and the
- importance of ordering of the type mappings.</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<type-mapping>
- <sql-type jdbc-type="NUMERIC" precision="15"
hibernate-type="big_decimal"/>
- <sql-type jdbc-type="NUMERIC" not-null="true"
hibernate-type="long" />
- <sql-type jdbc-type="NUMERIC" not-null="false"
hibernate-type="java.lang.Long" />
- <sql-type jdbc-type="VARCHAR" length="1"
not-null="true"
- hibernate-type="java.lang.Character"/>
- <sql-type jdbc-type="VARCHAR"
hibernate-type="your.package.TrimStringUserType"/>
- <sql-type jdbc-type="VARCHAR" length="1"
hibernate-type="char"/>
- <sql-type jdbc-type="VARCHAR" hibernate-type="string"/>
-</type-mapping>]]></programlisting>
-
- <para>The following table shows how this affects an example table named
<emphasis>
- <property
moreinfo="none">CUSTOMER</property>:</emphasis></para>
-
- <table frame="topbot">
- <title>sql-type examples</title>
-
- <tgroup cols="7">
- <colspec colwidth="0.4*"></colspec>
-
- <colspec colwidth="0.4*"></colspec>
-
- <colspec colwidth="0.2*"></colspec>
-
- <colspec colwidth="0.3*"></colspec>
-
- <colspec colwidth="0.2*"></colspec>
-
- <colspec colwidth="1.0*"></colspec>
-
- <colspec colwidth="0.7*"></colspec>
-
- <thead>
- <row>
- <entry>Column</entry>
-
- <entry>jdbc-type</entry>
-
- <entry>length</entry>
-
- <entry>precision</entry>
-
- <entry>not-null</entry>
-
- <entry>Resulting hibernate-type</entry>
-
- <entry>Rationale</entry>
- </row>
- </thead>
-
- <tbody>
- <row>
- <entry>ID</entry>
-
- <entry>INTEGER</entry>
-
- <entry></entry>
-
- <entry>10</entry>
-
- <entry>true</entry>
-
- <entry>int</entry>
-
- <entry>Nothing is defined for INTEGER. Falling back to default
behavior.</entry>
- </row>
-
- <row>
- <entry>NAME</entry>
-
- <entry>VARCHAR</entry>
-
- <entry>30</entry>
-
- <entry></entry>
-
- <entry>false</entry>
-
- <entry>your.package.TrimStringUserType</entry>
-
- <entry>No type-mapping matches length=30 and not-null=false, but
type-mapping
- matches the 2 mappings which only specifies VARCHAR. The type-mapping
that comes
- first is chosen.</entry>
- </row>
-
- <row>
- <entry>INITIAL</entry>
-
- <entry>VARCHAR</entry>
-
- <entry>1</entry>
-
- <entry></entry>
-
- <entry>false</entry>
-
- <entry>char</entry>
-
- <entry>Even though there is a generic match for VARCHAR, the more
specific
- type-mapping for VARCHAR with not-null="false" is chosen. The
first VARCHAR
- sql-type matches in length but has no value for not-null and thus is
not
- considered.</entry>
- </row>
-
- <row>
- <entry>CODE</entry>
-
- <entry>VARCHAR</entry>
-
- <entry>1</entry>
-
- <entry></entry>
-
- <entry>true</entry>
-
- <entry>java.lang.Character</entry>
-
- <entry>The most specific VARCHAR with not-null="true" is
selected</entry>
- </row>
-
- <row>
- <entry>SALARY</entry>
-
- <entry>NUMERIC</entry>
-
- <entry></entry>
-
- <entry>15</entry>
-
- <entry>false</entry>
-
- <entry>big_decimal</entry>
-
- <entry>There is a precise match for NUMERIC with precision
15</entry>
- </row>
-
- <row>
- <entry>AGE</entry>
-
- <entry>NUMERIC</entry>
-
- <entry></entry>
-
- <entry>3</entry>
-
- <entry>false</entry>
-
- <entry>java.lang.Long</entry>
-
- <entry>type-mapping for NUMERIC with
not-null="false"</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- <para></para>
- </section>
- </section>
-
- <section>
- <title>Table filters (<table-filter>)</title>
-
- <para>The <code><table-filter></code>
- let you specify matching rules for performing general filtering/setup for
- tables, e.g. let you include or exclude specific tables based on the schema or
even a
- specific prefix.</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<table-filter
- match-catalog="catalog_matching_rule"
- match-schema="schema_matching_rule"
- match-name="table_matching_rule"
- exclude="true|false"
- package="package.name"
-/>]]></programlisting>
-
- <table frame="topbot">
- <title>Table-filter attributes</title>
-
- <tgroup cols="3">
-
- <colspec colwidth="0.3*"></colspec>
-
- <colspec colwidth="1.0*"></colspec>
-
- <colspec colwidth="0.3*"></colspec>
-
-
- <thead>
- <row>
- <entry>Attribute name</entry>
-
- <entry>Definition</entry>
-
- <entry>Default value</entry>
- </row>
- </thead>
-
- <tbody>
- <row>
- <entry><para>match-catalog</para></entry>
-
- <entry><para>Pattern for matching catalog part of the
table</para></entry>
-
- <entry><para>.*</para></entry>
- </row>
-
- <row>
- <entry><para>match-schema</para></entry>
-
- <entry><para>Pattern for matching schema part of the
table</para></entry>
-
- <entry><para>.*</para></entry>
- </row>
-
- <row>
- <entry><para>match-table</para></entry>
-
- <entry><para>Pattern for matching table part of the
table</para></entry>
-
- <entry><para>.*</para></entry>
- </row>
-
- <row>
- <entry><para>exclude </para></entry>
-
- <entry><para>If true the table will not be part of the
reverse
- engineering</para></entry>
-
- <entry><para>false</para></entry>
- </row>
-
- <row>
- <entry><para>package</para></entry>
-
- <entry><para>The default package name to use for classes
based on tables
- matched by this table-filter</para></entry>
-
- <entry><para>""</para></entry>
- </row>
- </tbody>
-
- </tgroup>
- </table>
-
- </section>
-
- <section id="tab_and_col">
- <title>Specific table configuration (<table>)</title>
-
- <para><code><table></code>
- allows you to provide explicit configuration on how a table should be reverse
- engineered. Amongst other things it allows controlling over the naming of a class
for the
- table, specifying which identifier generator should be used for the primary key
etc.</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<table
- catalog="catalog_name"
- schema="schema_name"
- name="table_name"
- class="ClassName"
->
- <primary-key.../>
- <column.../>
- <foreign-key.../>
- </table>]]></programlisting>
-
- <table frame="topbot">
- <title>Table attributes</title>
-
- <tgroup cols="3">
-
- <colspec colwidth="0.3*"></colspec>
-
- <colspec colwidth="1.0*"></colspec>
-
- <colspec colwidth="0.3*"></colspec>
-
-
- <thead>
- <row>
- <entry>Attribute name</entry>
-
- <entry>Definition</entry>
-
- <entry>Attribute use</entry>
- </row>
- </thead>
-
- <tbody>
- <row>
- <entry><para>catalog</para></entry>
-
- <entry><para>Catalog name for a table. It has to be specified
if you are
- reverse engineering multiple catalogs or if it is not equal to
- hiberante.default_catalog.</para></entry>
-
- <entry><para>Optional</para></entry>
- </row>
-
- <row>
- <entry><para>schema</para></entry>
-
- <entry><para>Schema name for a table. It has to be specified if
you are
- reverse engineering multiple schemas or if it is not equal to
- hiberante.default_schema.</para></entry>
-
- <entry><para>Optional</para></entry>
- </row>
-
- <row>
- <entry><para>name</para></entry>
-
- <entry><para>Name for a table.</para></entry>
-
- <entry><para>Required</para></entry>
- </row>
-
- <row>
- <entry><para>class</para></entry>
-
- <entry><para>The class name for a table. Default name is a
camelcase version
- of the table name.</para></entry>
-
- <entry><para>Optional</para></entry>
- </row>
-
- </tbody>
-
- </tgroup>
- </table>
-
- <section>
- <title><primary-key></title>
-
- <para>A <code><primary-key></code> allows you to
define a primary-key for tables that don't have it
- defined in the database, and probably more importantly it allows you to define
which
- identifier strategy should be used (even for already existing
primary-key's).</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<primary-key
- <generator class="generatorname">
- <param name="param_name">parameter value</param>
- </generator>
- <key-column...>
- </primary-key>]]></programlisting>
-
- <table frame="topbot">
- <title>Primary-key attributes</title>
-
- <tgroup cols="3">
-
- <colspec colwidth="0.3*"></colspec>
-
- <colspec colwidth="1.0*"></colspec>
-
- <colspec colwidth="0.3*"></colspec>
-
-
- <thead>
- <row>
- <entry>Attribute name</entry>
-
- <entry>Definition</entry>
-
- <entry>Attribute use</entry>
- </row>
- </thead>
-
- <tbody>
- <row>
- <entry><para>generator/class</para></entry>
-
- <entry><para>Defines which identifier generator should be
used.
- The class name is any hibernate short hand name or fully qualified
class name for an
- identifier strategy.</para></entry>
-
- <entry><para>Optional</para></entry>
- </row>
-
- <row>
- <entry><para>generator/param</para></entry>
-
- <entry><para>Allows to specify which parameter with a name
and
- value should be passed to the identifier
generator.</para></entry>
-
- <entry><para>Optional</para></entry>
- </row>
-
- <row>
- <entry><para>key-column</para></entry>
-
- <entry><para>Specifies which column(s ) the primary-key
consists of. A
- key-column is same as column, but does not have the exclude
property.</para></entry>
-
- <entry><para>Optional</para></entry>
- </row>
-
- </tbody>
-
- </tgroup>
- </table>
-
- </section>
-
- <section>
- <title><column></title>
-
- <para>With a <code><column></code> it is possible
to explicitly name the resulting property for a column. It is
- also possible to redefine what jdbc and/or Hibernate type a column should be
processed as
- and finally it is possible to completely exclude a column from
processing.</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<column
- name="column_name"
- jdbc-type="java.sql.Types type"
- type="hibernate_type"
- property="propertyName"
- exclude="true|false"
-/>]]></programlisting>
-
- <table frame="topbot">
- <title>Column attributes</title>
-
- <tgroup cols="3">
-
- <colspec colwidth="0.3*"></colspec>
-
- <colspec colwidth="1.0*"></colspec>
-
- <colspec colwidth="0.3*"></colspec>
-
-
- <thead>
- <row>
- <entry>Attribute name</entry>
-
- <entry>Definition</entry>
-
- <entry>Attribute use</entry>
- </row>
- </thead>
-
- <tbody>
- <row>
- <entry><para>name</para></entry>
-
- <entry><para>Column name</para></entry>
-
- <entry><para>Required</para></entry>
- </row>
-
- <row>
- <entry><para>jdbc-type</para></entry>
-
- <entry><para>Which jdbc-type this column should be processed
as. A
- value from java.sql.Types, either numerical (93) or the constant name
- (TIMESTAMP).</para></entry>
-
- <entry><para>Optional</para></entry>
- </row>
-
- <row>
- <entry><para>type</para></entry>
-
- <entry><para>Which hibernate-type to use for this specific
column</para></entry>
-
- <entry><para>Optional</para></entry>
- </row>
-
-
- <row>
- <entry><para>property</para></entry>
-
- <entry><para>What property name will be generated for this
- column</para></entry>
-
- <entry><para>Optional</para></entry>
- </row>
-
- <row>
- <entry><para>exclude</para></entry>
-
- <entry><para>Set to true if this column should be
ignored</para></entry>
-
- <entry><para>default: false</para></entry>
- </row>
-
- </tbody>
-
- </tgroup>
- </table>
-
- </section>
-
- <section>
- <title><foreign-key></title>
-
- <para>The <code><foreign-key></code>
- has two purposes. One for allowing to define foreign-keys in databases that
- does not support them or does not have them defined in their schema. Secondly,
to allow
- defining the name of the resulting properties (many-to-one, one-to-one and
one-to-many's).</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<foreign-key
- constraint-name="foreignKeyName"
- foreign-catalog="catalogName"
- foreign-schema="schemaName"
- foreign-table="tableName"
- >
- <column-ref local-column="columnName"
foreign-column="foreignColumnName"/>
- <many-to-one
- property="aPropertyName"
- exclude="true|false"/>
- <set
- property="aCollectionName"
- exclude="true|false"
-
- <one-to-one
- property="aPropertyName"
- exclude="true|false"/>
- <inverse-one-to-one
- property="aPropertyName"
- exclude="true|false"/>
- </foreign-key>]]></programlisting>
- <table frame="topbot">
- <title>Foreign-key attributes</title>
-
- <tgroup cols="3">
-
- <colspec colwidth="0.3*"></colspec>
-
- <colspec colwidth="1.0*"></colspec>
-
- <colspec colwidth="0.3*"></colspec>
-
-
- <thead>
- <row>
- <entry>Attribute name</entry>
-
- <entry>Definition</entry>
-
- <entry>Attribute use</entry>
- </row>
- </thead>
-
- <tbody>
- <row>
- <entry><para>constraint-name</para></entry>
-
- <entry><para>Name of the foreign key constraint. Important
when
- naming many-to-one, one-to-one and set. It is the constraint-name that
is used to link the
- processed foreign-keys with the resulting property
names.</para></entry>
-
- <entry><para>Required</para></entry>
- </row>
-
- <row>
- <entry><para>foreign-catalog</para></entry>
-
- <entry><para>Name of the foreign table's catalog. (Only
- relevant if you want to explicitly define a foreign
key).</para></entry>
-
- <entry><para>Optional</para></entry>
- </row>
-
- <row>
- <entry><para>foreign-schema</para></entry>
-
- <entry><para>Name of the foreign table's schema. (Only
relevant
- if you want to explicitly define a foreign
key).</para></entry>
-
- <entry><para>Optional</para></entry>
- </row>
-
-
- <row>
- <entry><para>foreign-table</para></entry>
-
- <entry><para>Name of the foreign table. (Only relevant if
you
- want to explicitly define a foreign key).</para></entry>
-
- <entry><para>Optional</para></entry>
- </row>
-
- <row>
- <entry><para>column-ref </para></entry>
-
- <entry><para>Defines that the foreign-key constraint between
a
- local-column and foreign-column name. (Only relevant if you want to
explicitly
- define a foreign key).</para></entry>
-
- <entry><para>Optional</para></entry>
- </row>
-
- <row>
- <entry><para>many-to-one</para></entry>
-
- <entry><para>Defines that a many-to-one should be created and
the
- property attribute specifies the name of the resulting property.
Exclude can be
- used to explicitly define that it should be created or
not.</para></entry>
-
- <entry><para>Optional</para></entry>
- </row>
-
- <row>
- <entry><para>set</para></entry>
-
- <entry><para>Defines that a set should be created based on
this foreign-key
- and the property attribute specifies the name of the resulting (set)
property.
- Exclude can be used to explicitly define that it should be created or
not.</para></entry>
-
- <entry><para>Optional</para></entry>
- </row>
-
- <row>
- <entry><para>one-to-one</para></entry>
-
- <entry><para>Defines that a one-to-one should be created and
the
- property attribute specifies the name of the resulting property.
Exclude can be
- used to explicitly define that it should be created or
not.</para></entry>
-
- <entry><para>Optional</para></entry>
- </row>
-
- <row>
- <entry><para>inverse-one-to-one</para></entry>
-
- <entry><para>Defines that an inverse one-to-one should be
created based on this foreign-key
- and the property attribute specifies the name of the resulting
property.
- Exclude can be used to explicitly define that it should be created or
not.</para></entry>
-
- <entry><para>Optional</para></entry>
- </row>
- </tbody>
-
- </tgroup>
- </table>
-
- </section>
- </section>
- </section>
-
- <section id="custom-reveng-strategy">
- <title>Custom strategy</title>
-
- <para>It is possible to implement a user strategy. Such strategy must implement
<emphasis>
- <property
moreinfo="none">org.hibernate.cfg.reveng.ReverseEngineeringStrategy</property>.
- </emphasis> It is recommended that one uses the
- <property
moreinfo="none">DelegatingReverseEngineeringStrategy</property> and
provide a public constructor
- which takes another <property
moreinfo="none">ReverseEngineeringStrategy </property> as an argument.
This will
- allow you to only implement the relevant methods and provide a fallback strategy.
Example of
- custom delegating strategy which converts all column names that ends with
<emphasis>
- <property moreinfo="none">"PK"</property>
- </emphasis> into a property named <emphasis>
- <property moreinfo="none">"id"</property>.
- </emphasis></para>
-
- <programlisting format="linespecific"
role="JAVA"><![CDATA[public class ExampleStrategy extends
DelegatingReverseEngineeringStrategy {
-
- public ExampleStrategy(ReverseEngineeringStrategy delegate) {
- super(delegate);
- }
-
- public String columnToPropertyName(TableIdentifier table, String column) {
- if(column.endsWith("PK")) {
- return "id";
- } else {
- return super.columnToPropertyName(table, column);
- }
- }
-}]]></programlisting>
- </section>
-
- <section>
- <title>Custom Database Metadata</title>
-
- <para>By default the reverse engineering is performed by reading using the JDBC
database
- metadata API. This is done via the class <emphasis>
- <property
moreinfo="none">org.hibernate.cfg.reveng.dialect.JDBCMetaDataDialect</property>
- </emphasis> which is an implementation of <emphasis>
- <property
moreinfo="none">org.hibernate.cfg.reveng.dialect.MetaDataDialect</property>.
- </emphasis></para>
-
- <para>The default implementation can be replaced with an alternative
implementation by setting
- the property <emphasis>
- <property
moreinfo="none">hibernatetool.metadatadialect</property>
- </emphasis> to a fully qualified classname for a class that implements
- <property
moreinfo="none">JDBCMetaDataDialect</property>.</para>
-
- <para>This can be used to provide database specific optimized metadata reading.
If you create an
- optimized/better metadata reading for your database it will be a very welcome
- contribution.</para>
- </section>
-</chapter>
-
-
-<chapter id="codegen"
xml:base="file:///home/vchukhutsina/repos/ochik_jboss/hibernatetools/docs/reference/en-US/codegen.xml">
- <title>Controlling POJO code generation</title>
-
- <para>When using <code><hbm2java></code> or the eclipse
plugin to generate POJO java code you have the possibility to control
- certain aspects of the code generation. This is primarily done with the
<code><meta></code>
- tag in the mapping files. The following section describes the possible <code>
- <meta>
- </code> tags and their use.</para>
-
- <section>
- <title>The <meta> attribute</title>
-
- <para>The <code><meta></code> tag is a simple way of
annotating the <emphasis>
- <property moreinfo="none">hbm.xml</property>
- </emphasis> with information, so tools have a natural place to store/read
information that is
- not directly related to the Hibernate core.</para>
-
- <para>You can use the <code><meta></code> tag to e.g.
tell <code><hbm2java></code>
- to only generate <emphasis>
- <property moreinfo="none">"protected"</property>
- </emphasis> setters, have classes always implement a certain set of
interfaces or even have
- them extend a certain base class and even more.</para>
-
- <para>The following example shows how to use various
<code><meta></code>
- attributes and the resulting java code.</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<class name="Person">
- <meta attribute="class-description">
- Javadoc for the Person class
- @author Frodo
- </meta>
- <meta attribute="implements">IAuditable</meta>
- <id name="id" type="long">
- <meta attribute="scope-set">protected</meta>
- <generator class="increment"/>
- </id>
- <property name="name" type="string">
- <meta attribute="field-description">The name of the
person</meta>
- </property>
-</class>]]></programlisting>
-
- <para>The above <emphasis>
- <property moreinfo="none">hbm.xml</property>
- </emphasis> will produce something like the following (code shortened for
better
- understanding). Notice the Javadoc comment and the protected set
methods:</para>
-
- <programlisting format="linespecific"
role="JAVA"><![CDATA[// default package
-
-import java.io.Serializable;
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.apache.commons.lang.builder.HashCodeBuilder;
-import org.apache.commons.lang.builder.ToStringBuilder;
-
-/**
- * Javadoc for the Person class
- * @author Frodo
- */
-public class Person implements Serializable, IAuditable {
-
- public Long id;
-
- public String name;
-
- public Person(java.lang.String name) {
- this.name = name;
- }
-
- public Person() {
- }
-
- public java.lang.Long getId() {
- return this.id;
- }
-
- protected void setId(java.lang.Long id) {
- this.id = id;
- }
-
- /**
- * The name of the person
- */
- public java.lang.String getName() {
- return this.name;
- }
-
- public void setName(java.lang.String name) {
- this.name = name;
- }
-
-}]]></programlisting>
-
- <table frame="topbot">
- <title>Supported meta tags</title>
-
- <tgroup cols="2">
- <colspec colwidth="1.0*"></colspec>
-
- <colspec colwidth="2*"></colspec>
-
- <thead>
- <row>
- <entry>Attribute</entry>
-
- <entry>Description</entry>
- </row>
- </thead>
-
- <tbody>
- <row>
- <entry>
- <literal moreinfo="none">class-description</literal>
- </entry>
-
- <entry>inserted into the javadoc for classes</entry>
- </row>
-
- <row>
- <entry>
- <literal moreinfo="none">field-description</literal>
- </entry>
-
- <entry>inserted into the javadoc for fields/properties</entry>
- </row>
-
- <row>
- <entry>
- <literal moreinfo="none">interface</literal>
- </entry>
-
- <entry>If true, an interface is generated instead of an
class.</entry>
- </row>
-
- <row>
- <entry>
- <literal moreinfo="none">implements</literal>
- </entry>
-
- <entry>interface the class should implement</entry>
- </row>
-
- <row>
- <entry>
- <literal moreinfo="none">extends</literal>
- </entry>
-
- <entry>class that the current class should extend (ignored for
subclasses)</entry>
- </row>
-
- <row>
- <entry>
- <literal moreinfo="none">generated-class</literal>
- </entry>
-
- <entry>overrule the name of the actual class generated</entry>
- </row>
-
- <row>
- <entry>
- <literal moreinfo="none">scope-class</literal>
- </entry>
-
- <entry>scope for class</entry>
- </row>
-
- <row>
- <entry>
- <literal moreinfo="none">scope-set</literal>
- </entry>
-
- <entry>scope for setter method</entry>
- </row>
-
- <row>
- <entry>
- <literal moreinfo="none">scope-get</literal>
- </entry>
-
- <entry>scope for getter method</entry>
- </row>
-
- <row>
- <entry>
- <literal moreinfo="none">scope-field</literal>
- </entry>
-
- <entry>scope for actual field</entry>
- </row>
-
- <row>
- <entry>
- <literal moreinfo="none">default-value</literal>
- </entry>
-
- <entry>default initialization value for a field</entry>
- </row>
-
- <row>
- <entry>
- <literal moreinfo="none">use-in-tostring</literal>
- </entry>
-
- <entry>include this property in the <literal
moreinfo="none">toString()</literal></entry>
- </row>
-
- <row>
- <entry>
- <literal moreinfo="none">use-in-equals</literal>
- </entry>
-
- <entry>include this property in the <literal
moreinfo="none">equals()</literal> and
- <literal moreinfo="none">hashCode()</literal>
method. If no use-in-equals is specified, no
- equals/hashcode will be generated.</entry>
- </row>
-
- <row>
- <entry>
- <literal moreinfo="none">gen-property</literal>
- </entry>
-
- <entry>property will not be generated if false (use with
care)</entry>
- </row>
-
- <row>
- <entry>
- <literal moreinfo="none">property-type</literal>
- </entry>
-
- <entry>Overrides the default type of property. Use this with any
tag's to specify the
- concrete type instead of just Object.</entry>
- </row>
-
- <row>
- <entry>
- <literal moreinfo="none">class-code</literal>
- </entry>
-
- <entry>Extra code that will inserted at the end of the
class</entry>
- </row>
-
- <row>
- <entry>
- <literal moreinfo="none">extra-import</literal>
- </entry>
-
- <entry>Extra import that will inserted at the end of all other
imports</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- <para>Attributes declared via the
<code><meta></code>
- tag are per default <emphasis>
- <property moreinfo="none">"inherited"</property>
- </emphasis> inside an <emphasis>
- <property moreinfo="none">hbm.xml</property>
- </emphasis> file.</para>
-
- <para>What does that mean? It means that if you e.g want to have all your
classes implement
- <property moreinfo="none">IAuditable</property> then you
just add an <code> <meta
-
attribute="implements">IAuditable</meta></code> in
the top of the <emphasis>
- <property moreinfo="none">hbm.xml</property>
- </emphasis> file, just after
<code><hibernate-mapping></code>. Now all classes defined
- in that <emphasis>
- <property moreinfo="none">hbm.xml</property>
- </emphasis> file will implement <property
moreinfo="none">IAuditable</property>!</para>
-
- <note>
- <title>Note:</title>
- <para>This applies to <emphasis>all</emphasis>
- <code><meta></code>-tags. Thus it can also e.g. be used
to specify that
- all fields should be declare protected, instead of the default private. This is
done by
- adding <code><meta
-
attribute="scope-field">protected</meta></code> at
e.g. just under
- the <code><class></code> tag and all fields of that
class will be
- protected.</para>
- </note>
-
- <para>To avoid having a <code><meta></code>
- tag inherited then you can simply specify <code> inherit =
"false"</code>
- for the attribute, e.g. <code> <meta attribute =
"scope-class" inherit =
- "false">public abstract</meta></code> will
restrict the <emphasis>
- <property
moreinfo="none">"class-scope"</property>
- </emphasis> to the current class, not the subclasses.</para>
-
- <section>
- <title>Recommendations</title>
-
- <para>The following are some good practices when using
- <code><meta></code>
- attributes.</para>
-
- <section>
- <title>Dangers of a class level <property
moreinfo="none">use-in-string and use-in-equals</property> meta
- attributes when having bi-directional associations</title>
-
- <para>If we have two entities with a bi-directional association between
them and define at
- class scope level the meta attributes: <emphasis>
- <property moreinfo="none">use-in-string</property>,
</emphasis>
- <emphasis>
- <property moreinfo="none">use-in-equals</property>:
</emphasis></para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<hibernate-mapping>
- <class name="Person">
- <meta attribute="use-in-tostring">true</meta>
- <meta attribute="use-in-equals">true</meta>
- ...
- </class>
-</hibernate-mapping>]]></programlisting>
-
- <para>And for <emphasis>
- <property moreinfo="none">Event.hbm</property>
- </emphasis> file:</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<hibernate-mapping>
- <class name="events.Event" table="EVENTS">
- <meta attribute="use-in-tostring">true</meta>
- <meta attribute="use-in-equals">true</meta>
- <id name="id" column="EVENT_ID">
- <generator class="native"/>
- </id>
- <property name="date" type="timestamp"
column="EVENT_DATE"/>
- <property name="title"/>
- <set name="participants" table="PERSON_EVENT"
inverse="true">
- <key column="EVENT_ID"/>
- <many-to-many column="PERSON_ID"
class="events.Person"/>
- </set>
- </class>
-</hibernate-mapping>]]></programlisting>
-
- <para>Then <code><hbm2java></code>
- will assume you want to include all properties and collections in the
- <code>toString()/equals()</code> methods and this can result in
infinite
- recursive calls.</para>
-
- <para>To remedy this you have to decide which side of the association will
include the other
- part (if at all) in the <code>toString()/equals()</code> methods.
Therefore it is
- not a good practice to put at class scope such <emphasis>
- <property moreinfo="none">meta</property>
- </emphasis> attributes, unless you are defining a class without
bi-directional
- associations.</para>
-
- <para>We recommend instead to add the <emphasis>
- <property moreinfo="none">meta</property>
- </emphasis> attributes at the property level:</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<hibernate-mapping>
- <class name="events.Event" table="EVENTS">
- <id name="id" column="EVENT_ID">
- <meta attribute="use-in-tostring">true</meta>
- <generator class="native"/>
- </id>
- <property name="date" type="timestamp"
column="EVENT_DATE"/>
- <property name="title">
- <meta attribute="use-in-tostring">true</meta>
- <meta attribute="use-in-equals">true</meta>
- </property>
- <set name="participants" table="PERSON_EVENT"
inverse="true">
- <key column="EVENT_ID"/>
- <many-to-many column="PERSON_ID"
class="events.Person"/>
- </set>
- </class>
-</hibernate-mapping>]]></programlisting>
-
- <para>and now for <property
moreinfo="none">Person</property>:</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<hibernate-mapping>
- <class name="Person">
- <meta attribute="class-description">
- Javadoc for the Person class
- @author Frodo
- </meta>
- <meta attribute="implements">IAuditable</meta>
- <id name="id" type="long">
- <meta attribute="scope-set">protected</meta>
- <meta attribute="use-in-tostring">true</meta>
- <generator class="increment"/>
- </id>
- <property name="name" type="string">
- <meta attribute="field-description">The name of the
person</meta>
- <meta attribute="use-in-tostring">true</meta>
- </property>
- </class>
-</hibernate-mapping>]]></programlisting>
- </section>
-
- <section>
- <title>Be aware of putting at class scope level <meta>
- attributeuse-in-equals</title>
-
- <para>For <code>equal()/hashCode()</code> method generation,
you have to take into
- account that the attributes that participate on such method definition, should
take into
- account only attributes with business meaning (the name, social security
number, etc, but
- no generated id's, for example).</para>
-
- <para>This is important because Java's hashbased collections, such as
- <property moreinfo="none">java.util.Set</property>
relies on <property moreinfo="none">equals()</property> and
- <property moreinfo="none">hashcode()</property> to be
correct and not change for objects in the set;
- this can be a problem if the id gets assigned for an object after you inserted
it into a
- set.</para>
-
- <para>Therefore automatically configuration of the generation of
- <property
moreinfo="none">equals()/hashCode()</property> methods specifying at
class scope level the <code><meta></code> attribute
<emphasis>
- <property moreinfo="none">use-in-equals</property>
- </emphasis> could be a dangerous decision that could produce non
expected
- side-effect.</para>
-
- <para><ulink
url="http://www.hibernate.org/109.html">On
www.hibernate.org </ulink> you can get more in-depth
- explanation on the subject of <property
moreinfo="none">equals()</property> and
- <property
moreinfo="none">hashcode()</property>.</para>
- </section>
- </section>
-
- <section>
- <title>Advanced <meta> attribute examples</title>
-
- <para>This section shows an example for using meta attributes (including
userspecific
- attributes) together with the code generation features in <property
moreinfo="none">Hibernate
- Tools</property>.</para>
-
- <para>The usecase being implemented is to automatically insert some pre- and
post-conditions
- into the getter and setters of the generated POJO. </para>
-
- <section>
- <title>Generate pre/post-conditions for methods</title>
-
- <para>With a <code> <meta
attribute="class-code"></code>, you can add
- additional methods on a given class, nevertheless such
<code><meta></code>
- attribute can not be used at a property scope level and <property
moreinfo="none">Hibernate
- Tools</property> does not provide such <code>
- ><meta>
- </code> attributes.</para>
-
- <para>A possible solution for this is to modify the freemarker templates
responsible for
- generating the POJO's. If you look inside <emphasis>
- <property
moreinfo="none">hibernate-tools.jar</property>, </emphasis> you
can find the template: <emphasis>
- <property
moreinfo="none">pojo/PojoPropertyAccessor.ftl</property>
- </emphasis></para>
-
- <para>This file is as the name indicates used to generate property
accessors for
- pojo's.</para>
-
- <para>Extract the <emphasis>
- <property
moreinfo="none">PojoPropertyAccessor.ftl</property>
- </emphasis> into a local folder i.e. <emphasis>
- <property
moreinfo="none">${hbm.template.path}</property>, </emphasis>
respecting the whole path, for
- example: <emphasis>
- <property
moreinfo="none">${hbm.template.path}/pojo/PojoPropertyAccessor.ftl</property>
- </emphasis></para>
-
- <para>The contents of the file is something like this:</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<#foreach property in
pojo.getAllPropertiesIterator()>
- ${pojo.getPropertyGetModifiers(property)}
- ${pojo.getJavaTypeName(property, jdk5)}
- ${pojo.getGetterSignature(property)}() {
- return this.${property.name};
- }
-
- ${pojo.getPropertySetModifiers(property)} void set${pojo.getPropertyName(property)}
- (${pojo.getJavaTypeName(property, jdk5)} ${property.name})
- {
- this.${property.name} = ${property.name};
- }
-</#foreach>]]></programlisting>
-
- <para>We can add conditionally pre/post-conditions on our <literal
moreinfo="none">set</literal> method
- generation just adding a little Freemarker syntax to the above source
code:</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<#foreach property in
pojo.getAllPropertiesIterator()>
- ${pojo.getPropertyGetModifiers(property)}
- ${pojo.getJavaTypeName(property, jdk5)}
- ${pojo.getGetterSignature(property)}()
- {
- return this.${property.name};
- }
-
- ${pojo.getPropertySetModifiers(property)} void set${pojo.getPropertyName(property)}
- (${pojo.getJavaTypeName(property, jdk5)} ${property.name})
- {
- <#if pojo.hasMetaAttribute(property, "pre-cond")>
- ${c2j.getMetaAsString(property, "pre-cond","\n")}
- </#if>
- this.${property.name} = ${property.name};
- <#if pojo.hasMetaAttribute(property, "post-cond")>
- ${c2j.getMetaAsString(property, "post-cond","\n")}
- </#if>
-}
-</#foreach>]]>
-</programlisting>
-
- <para>Now if in any <emphasis>
- <property moreinfo="none">.hbm.xml</property>
- </emphasis> file we define the <emphasis>
- <property
moreinfo="none"><meta></property>
- </emphasis> attributes: <code>pre-cond</code> or
<code>post-cond</code>, their
- contents will be generated into the body of the relevant <literal
moreinfo="none">set</literal>
- method.</para>
-
- <para>As an example let us add a pre-condition for property
<code>name</code>
- preventing no <property moreinfo="none">Person</property>
can have an empty name. Hence we have to modify
- the <emphasis>
- <property moreinfo="none">Person.hbm.xml</property>
- </emphasis> file like this:</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[<hibernate-mapping>
- <class name="Person">
- <id name="id" type="long">
- <generator class="increment"/>
- </id>
- <property name="firstName" type="string">
- <meta attribute="pre-cond">
- if ((firstName != null) && (firstName.length() == 0) ) {
- throw new IllegalArgumentException("firstName can not be an empty
String");
- }
- </meta>
- </property>
-</class>
-</hibernate-mapping>]]></programlisting>
-
- <note>
- <title>Note:</title>
- <para>I) To escape the & symbol we put &amp;. You can
use
- <code> <![CDATA[]]></code> instead.</para>
- <para>II) Note that we are referring to "firstName" directly
and this is the parameter
- name not the actual field name. If you want to refer the field you have to
use
- "this.firstName" instead. </para>
- </note>
-
- <para>Finally we have to generate the <emphasis>
- <property moreinfo="none">Person.java</property>
- </emphasis> class, for this we can use both Eclipse and Ant as long as
you remember to set
- or fill in the templatepath setting. For Ant we configure
<code><hibernatetool></code>
- task via <literal moreinfo="none">the
templatepath</literal> attribute as in:</para>
-
- <programlisting format="linespecific"
role="XML"><![CDATA[
- <target name="hbm2java">
- <taskdef name="hibernatetool"
- classname="org.hibernate.tool.ant.HibernateToolTask"
- classpathref="lib.classpath"/>
- <hibernatetool destdir="${hbm2java.dest.dir}"
- templatepath="${hbm.template.path}">
- <classpath>
- <path refid="pojo.classpath"/>
- </classpath>
- <configuration>
- <fileset dir="${hbm2java.src.dir}">
- <include name="**/*.hbm.xml"/>
- </fileset>
- </configuration>
- <hbm2java/>
- </hibernatetool>
- </target>]]></programlisting>
-
- <para>Invoking the target
<code><hbm2java></code>
- will generate on the <emphasis>
- <property
moreinfo="none">${hbm2java.dest.dir}</property>
- </emphasis> the file <emphasis>
- <property moreinfo="none">Person.java</property>
- </emphasis>:</para>
-
- <programlisting format="linespecific"
role="JAVA"><![CDATA[// default package
-import java.io.Serializable;
-public class Person implements Serializable {
-
- public Long id;
-
- public String name;
-
- public Person(java.lang.String name) {
- this.name = name;
- }
-
- public Person() {
- }
-
- public java.lang.Long getId() {
- return this.id;
- }
-
- public void setId(java.lang.Long id) {
- this.id = id;
- }
-
- public java.lang.String getName() {
- return this.name;
- }
-
- public void setName(java.lang.String name) {
- if ((name != null) && (name.length() == 0)) {
- throw new IllegalArgumentException("name can not be an empty
String");
- }
- this.name = name;
- }
- }]]></programlisting>
-
- <para>In conclusion, this document is intended to introduce you to
Hibernate plugin specific
- features related to tools bath for the Eclipse and Ant tasks.</para>
-
- <para>In the <link linkend="plugins">Eclipse
Plugins</link> chapter you've learnt
- about a set of wizards for creating Mapping files, Configuration file, Console
- Configuration, got familiar with Mapping and Configuration files editors,
tooling for
- organizing and controlling Reverse Engineering, Hibernate Console and Mapping
diagram as
- well.</para>
-
- <para>The rest chapters have shown the aspects of using the <property
moreinfo="none">Hibernate
- Tools</property> via Ant tasks.</para>
- <para>Please, visit <ulink
-
url="http://www.jboss.com/index.html?module=bb&op=viewforum&...
- Tools Users Forum</ulink> to leave questions or/and suggestions on the
topic. Your
- feedback is always appreciated.</para>
- </section>
- </section>
-
- </section>
-
-</chapter>
-
-
-
- </book>
Modified: trunk/hibernatetools/docs/reference/en-US/plugins.xml
===================================================================
--- trunk/hibernatetools/docs/reference/en-US/plugins.xml 2011-03-02 22:58:02 UTC (rev
29454)
+++ trunk/hibernatetools/docs/reference/en-US/plugins.xml 2011-03-02 23:34:47 UTC (rev
29455)
@@ -2,29 +2,29 @@
<chapter id="plugins" role="updated">
<title>Eclipse Plugins</title>
<para>
- This chapter will introduce you to the set of wizards and editors provided by
<productname>Hibernate Tools</productname> within Eclipse to simplify working
with <productname>Hibernate</productname>.
+ This chapter will introduce you to the set of wizards and editors provided by
<productname>Hibernate Tools</productname> within Eclipse, which are designed
to simplify working with <productname>Hibernate</productname>.
</para>
<section>
<title>Introduction</title>
<para>
- Hibernate Eclipse Tools includes wizards for creating Hibernate mapping files,
configuration files (<filename>.cfg.xml</filename>),
<filename>revenge.xml</filename> files as well as wizards for adjusting
Console Configuration and Code Generation. Special structured and XML editors, and editors
for executing HQL and Criteria queries are also provided in Hibernate Console. Refer to
<xref linkend="hibernate_key_features"/> to find all the benefits that are
provided by these tools within Eclipse.
+ Hibernate Eclipse Tools includes wizards for creating Hibernate mapping files,
configuration files (<filename>.cfg.xml</filename>),
<filename>revenge.xml</filename> files as well as wizards for adjusting
Console Configuration and Code Generation. Special structured and XML editors and editors
for executing HQL and Criteria queries are also provided in Hibernate Console. Refer to
<xref linkend="hibernate_key_features"/> to find all the benefits that are
provided by these tools within Eclipse.
</para>
<note>
<title>Note:</title>
<para>
- Please note that these tools do not try to hide any of
<productname>Hibernates</productname> functionality; rather the tools make
working with <productname>Hibernate</productname> easier. You are still
encouraged to read the <ulink
url="http://www.hibernate.org/5.html">Hibernate Documentation</ulink>
in order to be able to fully utilize <productname>Hibernate
Tools</productname> and especially <productname>Hibernate</productname>
it self.
+ Please note that these tools do not try to hide any of
<productname>Hibernates</productname> functionality; rather the tools make
working with <productname>Hibernate</productname> easier. You are still
encouraged to read the <ulink
url="http://hibernate.org/docs">Hibernate
Documentation</ulink> in order to be able to fully utilize
<productname>Hibernate Tools</productname> and especially
<productname>Hibernate</productname> itself.
</para>
</note>
<section id="download_base_project">
<title>Download base project</title>
<para>You can download the example projects that are used in this
chapter.</para>
<para>
- A <property>JPA base project</property> is available on the <ulink
url="http://docs.jboss.org/tools/resources/">documentation resources page
</ulink> together with a <ulink
url="http://docs.jboss.org/tools/resources/TestHibernateproject_for_...
Java project</ulink>.
+ A <property>JPA base project</property> is available on the <ulink
url="http://docs.jboss.org/tools/resources/">documentation resources
page</ulink> together with a <ulink
url="http://docs.jboss.org/tools/resources/TestHibernateproject_for_...
Java project</ulink>.
</para>
<para>Also you need start the <ulink
url="http://docs.jboss.org/tools/resources/GSG_database.zip">...
<note>
<title>Note:</title>
- <para>The steps for running the database are documented in the <ulink
url="http://docs.jboss.org/tools/3.0.1.GA/en/GettingStartedGuide/htm...
Started Guide</ulink>.</para>
+ <para>The steps for running the database are documented in the <ulink
url="http://docs.redhat.com/docs/en-US/JBoss_Developer_Studio/4.0/ht...
Started Guide</ulink>.</para>
</note>
</section>
</section>
@@ -32,7 +32,7 @@
<title>Creating a Hibernate Mapping File</title>
<para>Hibernate mapping files are used to specify how your objects relate to
database tables.</para>
<para>
- To create basic mappings for properties and associations, i. e. generate
<filename>.hbm.xml</filename> files, Hibernate Tools provide a basic wizard
which you can display by selecting
<menuchoice><guimenuitem>New</guimenuitem>
+ To create basic mappings for properties and associations, i. e. generate
<filename>.hbm.xml</filename> files, Hibernate Tools provide a basic wizard
which you can display by selecting
<menuchoice><guimenuitem>File</guimenuitem><guimenuitem>New</guimenuitem>
<guimenuitem>Hibernate XML mapping file</guimenuitem>
</menuchoice>.
</para>
@@ -262,9 +262,7 @@
<itemizedlist>
<listitem>
<para>
- <emphasis>
- <guilabel>Options</guilabel>
- </emphasis> for the optional settings</para>
+ The <guilabel>Options</guilabel> tab the optional
settings</para>
</listitem>
</itemizedlist>
<figure>
@@ -301,7 +299,7 @@
<para>Database dialect</para>
</entry>
<entry>
- <para>Define a database dialect. It is possible either to write your value
or choose from list. </para>
+ <para>Define a database dialect. It is possible either to enter your own
value or choose from list. </para>
</entry>
<entry>
<para>No default value</para>
@@ -312,7 +310,7 @@
<para>Naming strategy</para>
</entry>
<entry>
- <para>Fully qualified classname of a custom NamingStrategy. Only required
if you use a special naming strategy.</para>
+ <para>Fully qualified classname of a custom
<code>NamingStrategy</code>. Only required if you use a special naming
strategy.</para>
</entry>
<entry>
<para>No default value</para>
@@ -323,7 +321,7 @@
<para>Entity resolver</para>
</entry>
<entry>
- <para>Fully qualified classname of a custom EntityResolver. Only required
if you have special XML entity includes in your mapping files.</para>
+ <para>Fully qualified classname of a custom
<code>EntityResolver</code>. Only required if you have special XML entity
includes in your mapping files.</para>
</entry>
<entry>
<para>No default value</para>
@@ -511,7 +509,7 @@
</mediaobject>
</figure>
<para>
- The following table describes the available settings in the
<guilabel>Properties</guilabel> view. Most properties can be changed by left
clicking on them but some are not.
+ The following table describes the available settings in the
<guilabel>Properties</guilabel> view. Most properties can be changed by left
clicking on them, but some can not.
<table>
<title>Properties</title>
<tgroup cols="3">
@@ -624,7 +622,7 @@
<section id="closing_conf_config">
<title>Closing Hibernate Console Configuration</title>
<para>
- To close <guilabel>Hibernate Console Configuration</guilabel> you need to
right-click your configuration and choose the <guimenuitem>Close
Configuration</guimenuitem> option
+ To close <guilabel>Hibernate Console Configuration</guilabel> you need to
right-click your configuration and choose the <guimenuitem>Close
Configuration</guimenuitem> option.
</para>
<figure>
<title>Close Hibernate Console Configuration</title>
@@ -642,7 +640,7 @@
<section id="refeng_codegen" role="updated">
<title>Reverse Engineering and Code Generation</title>
<para>
- Hibernate provides "click-and-generate" reverse engineering and code
generation facilities. This allows you to generate a range of artifacts based on database
or an already existing Hibernate configuration, be that mapping files or annotated
classes. Some of these are POJO Java source files, Hibernate
<filename>.hbm.xml</filename>,
<filename>hibernate.cfg.xml</filename> generation and schema documentation.
+ Hibernate provides "click-and-generate" reverse engineering and code
generation facilities. This allows you to generate a range of artifacts based on database
or an existing Hibernate configuration, be that mapping files or annotated classes. Some
of these are POJO Java source files, Hibernate <filename>.hbm.xml</filename>
files, <filename>hibernate.cfg.xml</filename> generation and schema
documentation.
</para>
<para>
To start working with this process, start the <guilabel>Hibernate Code
Generation</guilabel> tool which is available from the toolbar via the
<property>Hibernate</property> icon or via the
<menuchoice><guimenuitem>Run</guimenuitem><guimenuitem>Hibernate
Code Generation</guimenuitem></menuchoice> menu item.
@@ -681,7 +679,7 @@
<note>
<title>Tip:</title>
<para>
- The "At least one exporter option must be selected" warning is
just stating that for this launch to work you need to select an exporter on the
<guilabel>Exporter</guilabel> tab. When an exporter has been selected the
warning will disappear.
+ The "At least one exporter option must be selected" warning
indicates that for this launcher to work you need to select an exporter on the
<guilabel>Exporter</guilabel> tab. When an exporter has been selected the
warning will disappear.
</para>
</note>
<para>
@@ -710,7 +708,7 @@
<para>Console Configuration</para>
</entry>
<entry>
- <para>The name of the console configuration which should be used when
generating code</para>
+ <para>The name of the console configuration that should be used when
generating code</para>
</entry>
</row>
<row>
@@ -729,7 +727,7 @@
</entry>
<entry>
<para>
- If enabled, the tools will reverse engineer the database available via the
connection information in the selected Hibernate Console Configuration, and generate code
based on the database schema. If not enabled, the code generation will just be based on
the mappings already specified in the Hibernate Console configuration.
+ If enabled, the tools will reverse engineer the database defined in the
connection information in the selected Hibernate Console Configuration, and generate code
based on the database schema. If not enabled, the code generation will be based on the
existing mappings specified in the Hibernate Console configuration.
</para>
</entry>
</row>
@@ -747,7 +745,7 @@
</entry>
<entry>
<para>
- Path to a <filename>reveng.xml</filename> file. A
<filename>reveng.xml</filename> file allows you to control certain aspects of
the reverse engineering such as how JDBC types are mapped to Hibernate types, and which
tables are included and excluded from the process (which is especially important).
Clicking the <guibutton>Setup</guibutton> button allows you to select an
existing <filename>reveng.xml</filename> file or create a new one. See more
details about the <filename>reveng.xml</filename> file in <xref
linkend="reverseengineering"/>.
+ Path to a <filename>reveng.xml</filename> file. A
<filename>reveng.xml</filename> file allows you to control certain aspects of
the reverse engineering process such as how JDBC types are mapped to Hibernate types, and
which tables are included and excluded from the process (which is especially important).
Clicking the <guibutton>Setup</guibutton> button allows you to select an
existing <filename>reveng.xml</filename> file, or create a new one. See more
details about the <filename>reveng.xml</filename> file in <xref
linkend="reverseengineering"/>.
</para>
</entry>
</row>
@@ -757,7 +755,7 @@
</entry>
<entry>
<para>
- If the <filename>reveng.xml</filename> file does not provide enough
customization you can provide your own implementation of a ReverseEngineeringStrategy. The
class needs to be in the classpath of the Console Configuration, otherwise you will get
class not found exceptions. See <xref linkend="custom-reveng-strategy"/>
for details and an example of a custom strategy.
+ If the <filename>reveng.xml</filename> file does not provide enough
customization you can provide your own implementation of a
<code>ReverseEngineeringStrategy</code>. The class needs to be in the
classpath of the Console Configuration, otherwise you will get class not found exceptions.
See <xref linkend="custom-reveng-strategy"/> for details and an example of
a custom strategy.
</para>
</entry>
</row>
@@ -767,7 +765,7 @@
</entry>
<entry>
<para>
- When a table that has a multi-column primary key a
<code><composite-id></code> mapping will always be created. If
this option is enabled and there are matching foreign-keys each key column is still
considered a 'basic' scalar (string, long, etc.) instead of a reference to an
entity. If you disable this option a
<code><key-many-to-one></code> instead. Note: a
<code><many-to-one></code> property is still created, but is
simply marked as non-updatable and non-insertable.
+ When a table that has a multi-column primary key a
<code><composite-id></code> mapping will always be created. If
this option is enabled and there are matching foreign-keys, each key column is still
considered a 'basic' scalar (string, long, etc.) instead of a reference to an
entity. If you disable this option a
<code><key-many-to-one></code> instead. Note: a
<code><many-to-one></code> property is still created, but is
simply marked as non-updatable and non-insertable.
</para>
</entry>
</row>
@@ -798,7 +796,7 @@
Reverse engineering detects one-to-one associations via primary key and both the
<filename>hbm.xml</filename> file and annotation generation generates the
proper code for it.
</para>
<para>
- The detection is enabled by default (except for Seam 1.2 and Seam 2.0) reverse
engineering. For Hibernate Tools generation there is a checkbox to disable if not wanted.
+ The detection is enabled by default (except for Seam 1.2 and Seam 2.0) reverse
engineering. For Hibernate Tools generation there is a checkbox to disable this feature if
it is not required.
</para>
</entry>
</row>
@@ -889,7 +887,7 @@
</entry>
<entry>
<para>
- Generate a <filename>hibernate.cfg.xml</filename> file. Used to keep
the <filename>hibernate.cfg.xml</filename> update with any new found mapping
files.
+ Generate a <filename>hibernate.cfg.xml</filename> file. Used to keep
the <filename>hibernate.cfg.xml</filename> file updated with any newly
discovered mapping files.
</para>
</entry>
</row>