OJB Block: An O/R mapping tool.

See Also: OJBWithJDO, UsingOJBWithJCS


Apache ObJectRelationalBridge (OJB) is an Object/Relational mapping tool that allows transparent persistence for Java objects against relational databases.

OJB has 3 methods for access to databases:

  • 1. PersistentBroker
  • 2. ODMG
  • 3. JDO.

Note: Since JDO is the recommended successor of ODMG, we started to create samples using JDO. Later we will build support for the other methods and create some examples of them.


The OJB Block can be found in the Cocoon 2.1.3 and later.


The OJB samples are part of the "Block Samples", you can go directly to http://localhost:8888/samples/ojb/.

To run the samples also requires the HSQLDB block that run the test database. The samples with Woody needs the Woody block.

JDO Samples

In order to run the JDO samples, you need:

  1. Download the JDO libraries:
    • jdo.jar - for the OjbStore JDORI Plugin only.
    • jdori.jar - for the OjbStore JDORI Plugin only.

Note: Since 2.1.4-dev and later you need JDO 1.01. In older version please use JDO 1.0

2. Copy jdo.jar and jdori.jar to lib/local in your Cocoon 2.1 directory

3. Rebuild Cocoon.

That is all!

Note: If you don't want to recompile Cocoon, just copy the jdo.jar and jdori.jar jars to the WEB-INF/lib of your running Cocoon.

Note2: ''The note above doesn't seem to work because the relevent classes in the Cocoon Forms JDO examples do not appear to have the necessary JDO hooks in them if Cocoon wasn't recompiled with the jdo jars in the lib/local directory

info about the samples internals

  • XSP sample: This sample insert a Department in the test database.
  • Woody sample: This sample retrieve an Employee with id=1, you can edit it and then update the row in the table.
  • No labels