14.01.2013 Views

IBM Informix Developer's Handbook - IBM Redbooks

IBM Informix Developer's Handbook - IBM Redbooks

IBM Informix Developer's Handbook - IBM Redbooks

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Note: You can find a patch that adds <strong>Informix</strong> SQL optimizations to the original<br />

Hibernate dialect for <strong>Informix</strong> databases at:<br />

http://www.iiug.org/opensource/files/hibernate-3.3.2_informix.tar.gz<br />

The XML configuration file allows the inclusion of XML mapping files. Use the<br />

mapping resource property to specify the XML file that contains the mapping<br />

between the SQL table and the Java object.<br />

Example 6-3 on page 196 includes the State.hbm.xml mapping file as part of the<br />

hibernate configuration, as shown in the following line:<br />

<br />

Properties, such as hibernate.show_sql or hbm2ddl.auto, control the behavior<br />

of the Hibernate service. Use the hibernate.show_sql property to dump all the<br />

SQL statements to the console, which might be useful for debugging purposes.<br />

Set the hbm2ddl.auto property to update to specify that the schema for the SQL<br />

table is updated automatically if it differs from the definition in the XML definition.<br />

For more information regarding all the supported properties for the Hibernate<br />

configuration files, refer to:<br />

http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration<br />

.html<br />

XML mapping file<br />

You can use the XML mapping file to specify the relations between a Java object<br />

and an SQL database object. These mapping definitions are used to provide<br />

Hibernate with the information that is needed to persist the Java objects into the<br />

relational database. They also provide support features, such as creating the<br />

database schema and relationship between the objects.<br />

XML mapping files are not required when using Java annotations. The mapping<br />

information is added using annotations in the Java source code.<br />

Example 6-4 shows a basic XML file used to map the States table to the State<br />

Java object.<br />

Example 6-4 The State.hbm.xml file<br />

<br />

<br />

<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!