Berkeley DB Reference Version 5.3.35

Part I. Programming with the Direct Persistence Layer

This section discusses how to build an application using the DPL. The DPL is ideally suited for those applications that want a mechanism for storing and managing Java class objects in a DB database. Note that the DPL is best suited for applications that work with classes with a relatively static schema.

Also, the DPL requires Java 1.5.

If you want to use Java 1.4 for your DB application, or if you are porting an application from the Berkeley DB API, then you probably want to use the base API instead of the DPL. For information on using the base API, see Programming with the Base API.

Table of Contents

3. Direct Persistence Layer First Steps

Entity Stores

Opening and Closing Environments and Stores

Persistent Objects

Saving and Retrieving Data

4. Working with Indices

Accessing Indexes

Accessing Primary Indices

Accessing Secondary Indices

Creating Indexes

Declaring a Primary Indexes

Declaring Secondary Indexes

Foreign Key Constraints

5. Saving and Retrieving Objects

A Simple Entity Class

SimpleDA.class

Placing Objects in an Entity Store

Retrieving Objects from an Entity Store

Retrieving Multiple Objects

Cursor Initialization

Working with Duplicate Keys

Key Ranges

Join Cursors

Deleting Entity Objects

Replacing Entity Objects

6. A DPL Example

Vendor.java

Inventory.java

MyDbEnv

DataAccessor.java

ExampleDatabasePut.java

ExampleInventoryRead.java