Java Reference
In-Depth Information
Property Name
Description
hibernate.transaction.flush_before_completion
Automatically flushes before completion.
hibernate.transaction.manager_lookup_class
Specifies a class that implements the
org.hibernate.transaction.
TransactionManagerLookup interface.
hibernate.use_identifier_rollback
Determines whether Hibernate uses identifier
rollback.
hibernate.use_sql_comments
Generates SQL with comments.
hibernate.wrap_result_sets
Turns on JDBC result set wrapping with col-
umn names.
hibernate.xml.output_stylesheet
Specifies an XSLT stylesheet for Hibernate's
XML data binder. Requires xalan.jar .
jta.UserTransaction
The JNDI name for the UserTransaction
object.
XML Configuration
As we have already mentioned, Hibernate offers XML configuration capabilities. To use them,
you must create an XML configuration file, normally called hibernate.cfg.xml , and place it in
the root of your application's classpath. The XML configuration file must conform to the
Hibernate 3 Configuration DTD, which is available from http://hibernate.sourceforge.net/
hibernate-configuration-3.0.dtd .
Listing 2-2 shows an example XML configuration for Hibernate.
Listing 2-2. An XML Configuration for Hibernate
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration SYSTEM å
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>
<mapping jar="hibernate-mappings.jar"/>
<mapping resource="com/apress/hibernate/User.hbm.xml"/>
</session-factory>
</hibernate-configuration>
When you use the XML configuration file, you do not need to use the hibernate. prefix
for properties. As you can see in Listing 2-2, the dialect property is simply dialect , not
hibernate.dialect . However, we usually elect to include the prefix for the sake of consistency.
If you are already using hibernate.properties , hibernate.cfg.xml will override any settings
in hibernate.properties .
In addition to specifying the properties listed in Table 2-1 to configure a session factory,
with the <property> tag you can also configure mapping files, caching, listeners, and the JNDI
name for the session factory in the XML configuration. Listing 2-2 includes two <mapping> ele-
ments, which identify a JAR file containing mapping files, and a specific mapping file available
Search WWH ::




Custom Search