<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>SimpleDA.class</title> <link rel="stylesheet" href="gettingStarted.css" type="text/css" /> <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> <link rel="start" href="index.html" title="Getting Started with Berkeley DB" /> <link rel="up" href="persist_access.html" title="Chapter 5. Saving and Retrieving Objects" /> <link rel="prev" href="persist_access.html" title="Chapter 5. Saving and Retrieving Objects" /> <link rel="next" href="simpleput.html" title="Placing Objects in an Entity Store" /> </head> <body> <div xmlns="" class="navheader"> <div class="libver"> <p>Library Version 12.1.6.1</p> </div> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">SimpleDA.class</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="persist_access.html">Prev</a> </td> <th width="60%" align="center">Chapter 5. Saving and Retrieving Objects</th> <td width="20%" align="right"> <a accesskey="n" href="simpleput.html">Next</a></td> </tr> </table> <hr /> </div> <div class="sect1" lang="en" xml:lang="en"> <div class="titlepage"> <div> <div> <h2 class="title" style="clear: both"><a id="simpleda"></a>SimpleDA.class</h2> </div> </div> </div> <p> As mentioned above, we organize our primary and secondary indexes using a specialize data accessor class. The main reason for this class to exist is to provide convenient access to all the indexes in use for our entity class (see the previous section, <a class="xref" href="persist_access.html#simpleentity" title="A Simple Entity Class">A Simple Entity Class</a>, for that implementation). </p> <p> For a description on retrieving primary and secondary indexes under the DPL, see <a class="xref" href="persist_index.html" title="Chapter 4. Working with Indices">Working with Indices</a> </p> <pre class="programlisting">package persist.gettingStarted; import java.io.File; import com.sleepycat.db.DatabaseException; import com.sleepycat.persist.EntityStore; import com.sleepycat.persist.PrimaryIndex; import com.sleepycat.persist.SecondaryIndex; public class SimpleDA { // Open the indices public SimpleDA(EntityStore store) throws DatabaseException { // Primary key for SimpleEntityClass classes pIdx = store.getPrimaryIndex( String.class, SimpleEntityClass.class); // Secondary key for SimpleEntityClass classes // Last field in the getSecondaryIndex() method must be // the name of a class member; in this case, an // SimpleEntityClass.class data member. sIdx = store.getSecondaryIndex( pIdx, String.class, "sKey"); } // Index Accessors PrimaryIndex<String,SimpleEntityClass> pIdx; SecondaryIndex<String,String,SimpleEntityClass> sIdx; } </pre> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="persist_access.html">Prev</a> </td> <td width="20%" align="center"> <a accesskey="u" href="persist_access.html">Up</a> </td> <td width="40%" align="right"> <a accesskey="n" href="simpleput.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">Chapter 5. Saving and Retrieving Objects </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> Placing Objects in an Entity Store</td> </tr> </table> </div> </body> </html>