Java Reference
In-Depth Information
exceptions, and transaction management. Appendix C explains how Hibernate can be config-
ured within a Spring application.
Regardless of the environment that you are integrating Hibernate into, certain requirements
remain constant. You will need to define the configuration details that apply—these are then
represented by a Configuration object. From the Configuration object, a single SessionFactory
object is created; and from this, Session objects are instantiated, through which your application
accesses Hibernate's representation of the database.
Deploying Hibernate
To integrate Hibernate with your Java application, you will need to use several Java libraries.
The first library is the Java Archive ( JAR) file for your JDBC driver, which you will need to find
for your specific relational database. The Hibernate download does not include any JDBC
drivers. You must obtain these yourself—typically, the database provider will offer them as
a separate download; or they may be bundled with your database installation.
Because every relational database—and hence every JDBC driver—behaves slightly differ-
ently, the Hibernate team created dialects to abstract away the differences. These dialects define
the SQL variant and the specific database features to use for each vendor's database. Every proj-
ect that uses Hibernate must specify one dialect in the Hibernate configuration file. We discuss
dialects in more detail further on in the chapter. The Hibernate web site also contains a platform-
specific FAQ that offers some solutions to several vendor-specific questions.
If you encounter problems getting Hibernate to work with older JDBC versions, disable
the following two JDBC 2-specific features: batch update and scrollable result sets. Use the fol-
lowing configuration values for Hibernate (we discuss the specifics of this configuration later
in this chapter):
hibernate.jdbc.batch_size=0
hibernate.jdbc.use_scrollable_resultsets=false
Once you have configured the JDBC driver, your next step is to deploy hibernate3.jar
with your application. This JAR file is provided with the Hibernate 3 binary distribution. The
file contains the classes in the org.hibernate package, along with several DTD and XML
Schema files. You will then need to deploy the other required libraries.
Required Libraries for Running Hibernate 3
Hibernate requires several libraries beyond hibernate3.jar . These libraries are included in
the lib directory of your Hibernate 3 installation. The up-to-date list of libraries shipped with
Hibernate 3 is in the lib/README.txt file in the Hibernate distribution.
There are several optional libraries included with the Hibernate 3 distribution. If you build
Hibernate from source, a few of these are necessary for Hibernate to compile. Other libraries
provide connection pools, additional caching functionality (the Session cache is mandatory),
and the JCA API. The purpose of each library is detailed in the README file, which also states
which libraries are optional and which are required.
Search WWH ::




Custom Search