chapter is an introductory tutorial for new users of Hibernate. We
start with a simple command line application using an in-memory
database and develop it in easy to understand steps.
tutorial is intended for new users of Hibernate but requires Java and
SQL knowledge. It is based on a tutorial by Michael Gloegl, the
third-party libraries we name are for JDK 1.4 and 5.0. You might need
others for JDK 1.3.
The source code for the tutorial is included in the distribution in the doc/reference/tutorial/ directory.
1.2. Part 1 - The first Hibernate Application
we'll create a simple console-based Hibernate application. We use an
Java database (HSQL DB), so we do not have to install any database
Let's assume we need a small database application
that can store events we want to attend, and information about the
hosts of these events.
The first thing we do, is set up our
development directory and put all the Java libraries we need into it.
Download the Hibernate distribution from the Hibernate website. Extract
the package and place all required libraries found in /lib into into the /lib directory of your new development working directory. It should look like this:
. +lib antlr.jar cglib.jar asm.jar asm-attrs.jars commons-collections.jar commons-logging.jar hibernate3.jar jta.jar dom4j.jar log4j.jar
This is the minimum set of required libraries (note that we also copied hibernate3.jar, the main archive) for Hibernate at the time of writing. The Hibernate release you are using might require more or less libraries. See the README.txt file in the lib/
directory of the Hibernate distribution for more information about
required and optional third-party libraries. (Actually, Log4j is not
required but preferred by many developers.)
Next we create a class that represents the event we want to store in database