The Apache DB Project
ObJectRelationalBridge

OJB

Downloads

Documentation

Development

Translated (Web)

Getting Started with OJB
Building OJB

First, ensure that you have Ant installed and have the ANT_HOME and JAVA_HOME environment variables set so that you can build OJB. Setting these up is described in Ant documentation.

Next download the latest source distribution. It is easiest to start with the source distribution rather than the binary as the unit tests provide excellent sample code, and it makes the ojb-blank task available for setting up a basic project.

Unpack the source distribution and retrieve the additional required libaries. Place these jar files in the lib directory of the OJB distribution.

Change to the OJB installation directory and run ant ojb-blank. This will build OJB and an additional jar file containing a rudimentary project which uses OJB. After the build finishes you will find the ojb-blank.jar library in the dist directory.

Your Project

Copy the ojb-blank.jar file to your project directory and unpack it via the jar xvf ojb-blank.jar command. This will unpack it into the ojb-blank directory under wherever you unpacked it from. You can move things out of that directory into your project directory, or, more simply, rename the ojb-blank directory to be whatever you want your project directory to be named.

The ojb-blank project provides the libraries, basic configuration files, and an ant build file which can be used to get started with OJB. The first thing you will need to do is edit the build.properties file to enter your database information. By default it is set up to work against an embedded HSQLDB instance. This will work fine for learning, but you will probably want to configure it to run against a different RDBMS for most projects. For example configurations you can look in the profiles directory in the OJB install directory. The build file will copy the properties out of the project's build.properties into the repository_database.xml located in the src/resources/ directory when the project is built.

If you are not using HSQLDB make sure to copy your JDBC driver into the lib directory and ensure it is in the classpath used by the build.xml.

The ojb-blank project also includes the Torque schema for OJB's required tables. You do not need to use Torque to build your database, but it can also be used generate the DDL for you to modify an existing database. The OJB tables are required for specific options, such as clustered locking and OJB managed sequences. More information on these tables is available platform documentation

The repository metadata files are located in the src/resources/ directory. The repository_user.xml file should be used for describing your specific mappings.

Learning More

The next step is to go through the tutorials for the things you need to do. The Mapping Tutorial in particular is required to learn how to map your objects to relational tables.


Copyright © 1999-2003, Apache Software Foundation