Berkeley DB Java Edition Collections Tutorial

Legal Notice

This work is licensed under the Creative Commons Attribution-ShareAlike License. To view a copy of this license, visit or send a letter to:

     Creative Commons
     559 Nathan Abbott Way
     StanfordCalifornia 94305

The text and example code included in this document are distributed under the Creative Commons license.

Sleepycat Software, Berkeley DB, Berkeley DB XML and the Sleepycat logo are trademarks or service marks of Sleepycat Software, Inc. All rights to these marks are reserved. No third-party use is permitted without the express prior written consent of Sleepycat Software, Inc.

Java™ and all Java-based marks are a trademark or registered trademark of Sun Microsystems, Inc, in the United States and other countries.

To obtain a copy of this document's original source code, please write to .


Table of Contents

Conventions Used in this Book
1. Sleepycat Java Collections API Overview
Using Data Bindings
Selecting Binding Formats
Selecting Data Bindings
Implementing Bindings
Using Bindings
Secondary Key Creators
Using Sleepycat Java Collections API
Using Transactions
Transaction Rollback
Access Method Restrictions
Using Stored Collections
Stored Collection and Access Methods
Stored Collections Versus Standard Java Collections
Other Stored Collection Characteristics
Why Java Collections for Berkeley DB Java Edition
Serialized Object Storage
2. Introduction to the Sleepycat Java Collections API Tutorial
3. The Basic Program
Defining Serialized Key and Value Classes
Opening and Closing the Database Environment
Opening and Closing the Class Catalog
Opening and Closing Databases
Creating Bindings and Collections
Implementing the Main Program
Using Transactions
Adding Database Items
Retrieving Database Items
Handling Exceptions
4. Using Secondary Indices and Foreign keys
Opening Secondary Key Indices
Opening Foreign Key Indices
Creating Indexed Collections
Retrieving Items by Index Key
5. Using Entity Classes
Defining Entity Classes
Creating Entity Bindings
Creating Collections with Entity Bindings
Using Entities with Collections
6. Using Tuples
Using the Tuple Format
Using Tuples with Key Creators
Creating Tuple Key Bindings
Creating Tuple-Serial Entity Bindings
Using Sorted Collections
7. Using Serializable Entities
Using Transient Fields in and Entity Class
Using Transient Fields in an Entity Binding
Removing the Redundant Value Classes
8. Summary