• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/ap/gpl/timemachine/db-4.7.25.NC/docs/java/com/sleepycat/persist/
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<!--NewPage-->
3<HTML>
4<HEAD>
5<!-- Generated by javadoc (build 1.5.0) on Thu May 15 17:17:33 EDT 2008 -->
6<TITLE>
7EntityIndex (Oracle - Berkeley DB Java API)
8</TITLE>
9
10<META NAME="keywords" CONTENT="com.sleepycat.persist.EntityIndex interface">
11
12<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../style.css" TITLE="Style">
13
14<SCRIPT type="text/javascript">
15function windowTitle()
16{
17    parent.document.title="EntityIndex (Oracle - Berkeley DB Java API)";
18}
19</SCRIPT>
20<NOSCRIPT>
21</NOSCRIPT>
22
23</HEAD>
24
25<BODY BGCOLOR="white" onload="windowTitle();">
26
27
28<!-- ========= START OF TOP NAVBAR ======= -->
29<A NAME="navbar_top"><!-- --></A>
30<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
31<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
32<TR>
33<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
34<A NAME="navbar_top_firstrow"><!-- --></A>
35<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
36  <TR ALIGN="center" VALIGN="top">
37  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
38  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
39  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
40  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/EntityIndex.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
41  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
42  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
43  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
44  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
45  </TR>
46</TABLE>
47</TD>
48<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
49<b>Berkeley DB</b><br><font size="-1"> version 4.7.25</font></EM>
50</TD>
51</TR>
52
53<TR>
54<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
55&nbsp;<A HREF="../../../com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist"><B>PREV CLASS</B></A>&nbsp;
56&nbsp;<A HREF="../../../com/sleepycat/persist/EntityJoin.html" title="class in com.sleepycat.persist"><B>NEXT CLASS</B></A></FONT></TD>
57<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
58  <A HREF="../../../index.html?com/sleepycat/persist/EntityIndex.html" target="_top"><B>FRAMES</B></A>  &nbsp;
59&nbsp;<A HREF="EntityIndex.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
60&nbsp;<SCRIPT type="text/javascript">
61  <!--
62  if(window==top) {
63    document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>');
64  }
65  //-->
66</SCRIPT>
67<NOSCRIPT>
68  <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>
69</NOSCRIPT>
70
71
72</FONT></TD>
73</TR>
74<TR>
75<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
76  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
77<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
78DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
79</TR>
80</TABLE>
81<A NAME="skip-navbar_top"></A>
82<!-- ========= END OF TOP NAVBAR ========= -->
83
84<HR>
85<!-- ======== START OF CLASS DATA ======== -->
86<H2>
87<FONT SIZE="-1">
88com.sleepycat.persist</FONT>
89<BR>
90Interface EntityIndex&lt;K,V&gt;</H2>
91<DL>
92<DT><B>All Known Implementing Classes:</B> <DD><A HREF="../../../com/sleepycat/persist/PrimaryIndex.html" title="class in com.sleepycat.persist">PrimaryIndex</A>, <A HREF="../../../com/sleepycat/persist/SecondaryIndex.html" title="class in com.sleepycat.persist">SecondaryIndex</A></DD>
93</DL>
94<HR>
95<DL>
96<DT><PRE>public interface <B>EntityIndex&lt;K,V&gt;</B></DL>
97</PRE>
98
99<P>
100The interface for accessing keys and entities via a primary or secondary
101 index.
102
103 <p><code>EntityIndex</code> objects are thread-safe.  Multiple threads may safely
104 call the methods of a shared <code>EntityIndex</code> object.</p>
105
106 <p>An index is conceptually a <em>map</em>. {key:value} mappings are
107 stored in the index and accessed by key.  In fact, for interoperability with
108 other libraries that use the standard Java <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Map.html" title="class or interface in java.util"><CODE>Map</CODE></A> or <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/SortedMap.html" title="class or interface in java.util"><CODE>SortedMap</CODE></A>
109 interfaces, an <code>EntityIndex</code> may be accessed via these standard
110 interfaces by calling the <A HREF="../../../com/sleepycat/persist/EntityIndex.html#map()"><CODE>map()</CODE></A> or <A HREF="../../../com/sleepycat/persist/EntityIndex.html#sortedMap()"><CODE>sortedMap()</CODE></A> methods.</p>
111
112 <p><code>EntityIndex</code> is an interface that is implemented by several
113 classes in this package for different purposes.  Depending on the context,
114 the key type (K) and value type (V) of the index take on different meanings.
115 The different classes that implement <code>EntityIndex</code> are:</p>
116 <ul>
117 <li><A HREF="../../../com/sleepycat/persist/PrimaryIndex.html" title="class in com.sleepycat.persist"><CODE>PrimaryIndex</CODE></A> maps primary keys to entities.</li>
118 <li><A HREF="../../../com/sleepycat/persist/SecondaryIndex.html" title="class in com.sleepycat.persist"><CODE>SecondaryIndex</CODE></A> maps secondary keys to entities.</li>
119 <li><A HREF="../../../com/sleepycat/persist/SecondaryIndex.html#keysIndex"><CODE>SecondaryIndex.keysIndex</CODE></A> maps secondary keys to primary
120 keys.</li>
121 <li><A HREF="../../../com/sleepycat/persist/SecondaryIndex.html#subIndex(SK)"><CODE>SecondaryIndex.subIndex(SK)</CODE></A> maps primary keys to entities, for the
122 subset of entities having a specified secondary key.</li>
123 </ul>
124
125 <p>In all cases, the index key type (K) is a primary or secondary key class.
126 The index value type (V) is an entity class in all cases except for a <A HREF="../../../com/sleepycat/persist/SecondaryIndex.html#keysIndex"><CODE>SecondaryIndex.keysIndex</CODE></A>, when it is a primary key class.</p>
127
128 <p>In the following example, a <code>Employee</code> entity with a <code>MANY_TO_ONE</code> secondary key is defined.</p>
129
130 <pre class="code">
131 @Entity
132 class Employee {
133
134     @PrimaryKey
135     long id;
136
137     @SecondaryKey(relate=MANY_TO_ONE)
138     String department;
139
140     String name;
141
142     private Employee() {}
143 }</pre>
144
145 <p>Consider that we have stored the entities below:</p>
146
147 <p><table class="code" border="1">
148   <tr><th colspan="3">Entities</th></tr>
149   <tr><th>ID</th><th>Department</th><th>Name</th></tr>
150   <tr><td>1</td><td>Engineering</td><td>Jane Smith</td></tr>
151   <tr><td>2</td><td>Sales</td><td>Joan Smith</td></tr>
152   <tr><td>3</td><td>Engineering</td><td>John Smith</td></tr>
153   <tr><td>4</td><td>Sales</td><td>Jim Smith</td></tr>
154 </table></p>
155
156 <p><A HREF="../../../com/sleepycat/persist/PrimaryIndex.html" title="class in com.sleepycat.persist"><CODE>PrimaryIndex</CODE></A> maps primary keys to entities:</p>
157
158 <pre class="code">
159 <code>PrimaryIndex&lt;Long,Employee&gt;</code> primaryIndex =
160     store.getPrimaryIndex(Long.class, Employee.class);</pre>
161
162 <p><table class="code" border="1">
163   <tr><th colspan="4">primaryIndex</th></tr>
164   <tr><th>Primary Key</th><th colspan="3">Entity</th></tr>
165   <tr><td>1</td><td>1</td><td>Engineering</td><td>Jane Smith</td></tr>
166   <tr><td>2</td><td>2</td><td>Sales</td><td>Joan Smith</td></tr>
167   <tr><td>3</td><td>3</td><td>Engineering</td><td>John Smith</td></tr>
168   <tr><td>4</td><td>4</td><td>Sales</td><td>Jim Smith</td></tr>
169 </table></p>
170
171 <p><A HREF="../../../com/sleepycat/persist/SecondaryIndex.html" title="class in com.sleepycat.persist"><CODE>SecondaryIndex</CODE></A> maps secondary keys to entities:</p>
172
173 <pre class="code">
174 <code>SecondaryIndex&lt;String,Long,Employee&gt;</code> secondaryIndex =
175     store.getSecondaryIndex(primaryIndex, String.class, "department");</pre>
176
177 <p><table class="code" border="1">
178   <tr><th colspan="4">secondaryIndex</th></tr>
179   <tr><th>Secondary Key</th><th colspan="3">Entity</th></tr>
180   <tr><td>Engineering</td><td>1</td><td>Engineering</td><td>Jane Smith</td></tr>
181   <tr><td>Engineering</td><td>3</td><td>Engineering</td><td>John Smith</td></tr>
182   <tr><td>Sales</td><td>2</td><td>Sales</td><td>Joan Smith</td></tr>
183   <tr><td>Sales</td><td>4</td><td>Sales</td><td>Jim Smith</td></tr>
184 </table></p>
185
186 <p><A HREF="../../../com/sleepycat/persist/SecondaryIndex.html#keysIndex"><CODE>SecondaryIndex.keysIndex</CODE></A> maps secondary keys to primary
187 keys:</p>
188
189 <pre class="code">
190 <code>EntityIndex&lt;String,Long&gt;</code> keysIndex = secondaryIndex.keysIndex();</pre>
191
192 <p><table class="code" border="1">
193   <tr><th colspan="4">keysIndex</th></tr>
194   <tr><th>Secondary Key</th><th colspan="3">Primary Key</th></tr>
195   <tr><td>Engineering</td><td>1</td></tr>
196   <tr><td>Engineering</td><td>3</td></tr>
197   <tr><td>Sales</td><td>2</td></tr>
198   <tr><td>Sales</td><td>4</td></tr>
199 </table></p>
200
201 <p><A HREF="../../../com/sleepycat/persist/SecondaryIndex.html#subIndex(SK)"><CODE>SecondaryIndex.subIndex(SK)</CODE></A> maps primary keys to entities, for the
202 subset of entities having a specified secondary key:</p>
203
204 <pre class="code">
205 <code>EntityIndex&lt;Long,Entity&gt;</code> subIndex = secondaryIndex.subIndex("Engineering");</pre>
206
207 <p><table class="code" border="1">
208   <tr><th colspan="4">subIndex</th></tr>
209   <tr><th>Primary Key</th><th colspan="3">Entity</th></tr>
210   <tr><td>1</td><td>1</td><td>Engineering</td><td>Jane Smith</td></tr>
211   <tr><td>3</td><td>3</td><td>Engineering</td><td>John Smith</td></tr>
212 </table></p>
213
214 <h3>Accessing the Index</h3>
215
216 <p>An <code>EntityIndex</code> provides a variety of methods for retrieving
217 entities from an index.  It also provides methods for deleting entities.
218 However, it does not provide methods for inserting and updating.  To insert
219 and update entities, use the <A HREF="../../../com/sleepycat/persist/PrimaryIndex.html#put(E)"><CODE>PrimaryIndex.put(E)</CODE></A> family of methods in
220 the <A HREF="../../../com/sleepycat/persist/PrimaryIndex.html" title="class in com.sleepycat.persist"><CODE>PrimaryIndex</CODE></A> class.</p>
221
222 <p>An <code>EntityIndex</code> supports two mechanisms for retrieving
223 entities:</p>
224 <ol>
225 <li>The <A HREF="../../../com/sleepycat/persist/EntityIndex.html#get(K)"><CODE>get(K)</CODE></A> method returns a single value for a given key.  If there
226 are multiple values with the same secondary key (duplicates), it returns the
227 first entity in the duplicate set.</li>
228 <li>An <A HREF="../../../com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist"><CODE>EntityCursor</CODE></A> can be obtained using the <A HREF="../../../com/sleepycat/persist/EntityIndex.html#keys()"><CODE>keys()</CODE></A> and
229 <A HREF="../../../com/sleepycat/persist/EntityIndex.html#entities()"><CODE>entities()</CODE></A> family of methods.  A cursor can be used to return all
230 values in the index, including duplicates.  A cursor can also be used to
231 return values within a specified range of keys.</li>
232 </ol>
233
234 <p>Using the example entities above, calling <A HREF="../../../com/sleepycat/persist/EntityIndex.html#get(K)"><CODE>get(K)</CODE></A> on the primary
235 index will always return the employee with the given ID, or null if no such
236 ID exists.  But calling <A HREF="../../../com/sleepycat/persist/EntityIndex.html#get(K)"><CODE>get(K)</CODE></A> on the secondary index will retrieve
237 the first employee in the given department, which may not be very
238 useful:</p>
239
240 <pre class="code">
241 Employee emp = primaryIndex.get(1);      // Returns by unique ID
242 emp = secondaryIndex.get("Engineering"); // Returns first in department</pre>
243
244 <p>Using a cursor, you can iterate through all duplicates in the secondary
245 index:</p>
246
247 <pre class="code">
248 <code>EntityCursor&lt;Employee&gt;</code> cursor = secondaryIndex.entities();
249 try {
250     for (Employee entity : cursor) {
251         if (entity.department.equals("Engineering")) {
252             // Do something with the entity...
253         }
254     }
255 } finally {
256     cursor.close();
257 }</pre>
258
259 <p>But for a large database it is much more efficient to iterate over only
260 those entities with the secondary key you're searching for.  This could be
261 done by restricting a cursor to a range of keys:</p>
262
263 <pre class="code">
264 <code>EntityCursor&lt;Employee&gt;</code> cursor =
265     secondaryIndex.entities("Engineering", true, "Engineering", true);
266 try {
267     for (Employee entity : cursor) {
268         // Do something with the entity...
269     }
270 } finally {
271     cursor.close();
272 }</pre>
273
274 <p>However, when you are interested only in the entities with a particular
275 secondary key value, it is more convenient to use a sub-index:</p>
276
277 <pre class="code">
278 <code>EntityIndex&lt;Long,Entity&gt;</code> subIndex = secondaryIndex.subIndex("Engineering");
279 <code>EntityCursor&lt;Employee&gt;</code> cursor = subIndex.entities();
280 try {
281     for (Employee entity : cursor) {
282         // Do something with the entity...
283     }
284 } finally {
285     cursor.close();
286 }</pre>
287
288 <p>In addition to being more convenient than a cursor range, a sub-index
289 allows retrieving by primary key:</p>
290
291 <pre class="code">
292 Employee emp = subIndex.get(1);</pre>
293
294 <p>When using a sub-index, all operations performed on the sub-index are
295 restricted to the single key that was specified when the sub-index was
296 created.  For example, the following returns null because employee 2 is not
297 in the Engineering department and therefore is not part of the
298 sub-index:</p>
299
300 <pre class="code">
301 Employee emp = subIndex.get(2);</pre>
302
303 <p>For more information on using cursors and cursor ranges, see <A HREF="../../../com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist"><CODE>EntityCursor</CODE></A>.</p>
304
305 <p>Note that when using an index, keys and values are stored and retrieved
306 by value not by reference.  In other words, if an entity object is stored
307 and then retrieved, or retrieved twice, each object will be a separate
308 instance.  For example, in the code below the assertion will always
309 fail.</p>
310 <pre class="code">
311 MyKey key = ...;
312 MyEntity entity1 = index.get(key);
313 MyEntity entity2 = index.get(key);
314 assert entity1 == entity2; // always fails!
315 </pre>
316
317 <h3>Deleting from the Index</h3>
318
319 <p>Any type of index may be used to delete entities with a specified key by
320 calling <A HREF="../../../com/sleepycat/persist/EntityIndex.html#delete(K)"><CODE>delete(K)</CODE></A>.  The important thing to keep in mind is that
321 <em>all entities</em> with the specified key are deleted.  In a primary index,
322 at most a single entity is deleted:</p>
323
324 <pre class="code">
325 primaryIndex.delete(1); // Deletes a single employee by unique ID</pre>
326
327 <p>But in a secondary index, multiple entities may be deleted:</p>
328
329 <pre class="code">
330 secondaryIndex.delete("Engineering"); // Deletes all Engineering employees</pre>
331
332 <p>This begs this question: How can a single entity be deleted without
333 knowing its primary key?  The answer is to use cursors.  After locating an
334 entity using a cursor, the entity can be deleted by calling <A HREF="../../../com/sleepycat/persist/EntityCursor.html#delete()"><CODE>EntityCursor.delete()</CODE></A>.</p>
335
336 <h3>Transactions</h3>
337
338 <p>Transactions can be used to provide standard ACID (Atomicity,
339 Consistency, Integrity and Durability) guarantees when retrieving, storing
340 and deleting entities.  This section provides a brief overview of how to use
341 transactions with the Direct Persistence Layer.  For more information on
342 using transactions, see <a
343 href="../../../../gsg_txn/JAVA/index.html">Writing
344 Transactional Applications</a>.</p>
345
346 <p>Transactions may be used only with a transactional <A HREF="../../../com/sleepycat/persist/EntityStore.html" title="class in com.sleepycat.persist"><CODE>EntityStore</CODE></A>,
347 which is one for which <A HREF="../../../com/sleepycat/persist/StoreConfig.html#setTransactional(boolean)"><CODE>StoreConfig.setTransactional(true)</CODE></A> has been called.  Likewise, a
348 transactional store may only be used with a transactional <A HREF="../../../com/sleepycat/db/Environment.html" title="class in com.sleepycat.db"><CODE>Environment</CODE></A>, which is one for which <A HREF="../../../com/sleepycat/db/EnvironmentConfig.html#setTransactional(boolean)"><CODE>EnvironmentConfig.setTransactional(true)</CODE></A>
349 has been called.  For example:</p>
350
351 <pre class="code">
352 EnvironmentConfig envConfig = new EnvironmentConfig();
353 envConfig.setTransactional(true);
354 envConfig.setAllowCreate(true);
355 Environment env = new Environment(new File("/my/data"), envConfig);
356
357 StoreConfig storeConfig = new StoreConfig();
358 storeConfig.setTransactional(true);
359 storeConfig.setAllowCreate(true);
360 EntityStore store = new EntityStore(env, "myStore", storeConfig);</pre>
361
362 <p>Transactions are represented by <A HREF="../../../com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db"><CODE>Transaction</CODE></A> objects, which are
363 part of the <A HREF="../../../com/sleepycat/db/package-summary.html"><CODE>Base API</CODE></A>.  Transactions are created
364 using the <A HREF="../../../com/sleepycat/db/Environment.html#beginTransaction(com.sleepycat.db.Transaction, com.sleepycat.db.TransactionConfig)"><CODE>Environment.beginTransaction</CODE></A>
365 method.</p>
366
367 <p>A transaction will include all operations for which the transaction
368 object is passed as a method argument.  All retrieval, storage and deletion
369 methods have an optional <A HREF="../../../com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db"><CODE>Transaction</CODE></A> parameter for this purpose.
370 When a transaction is passed to a method that opens a cursor, all retrieval,
371 storage and deletion operations performed using that cursor will be included
372 in the transaction.</p>
373
374 <p>A transaction may be committed by calling <A HREF="../../../com/sleepycat/db/Transaction.html#commit()"><CODE>Transaction.commit()</CODE></A> or
375 aborted by calling <A HREF="../../../com/sleepycat/db/Transaction.html#abort()"><CODE>Transaction.abort()</CODE></A>.  For example, two employees
376 may be deleted atomically with a transaction; other words, either both are
377 deleted or neither is deleted:</p>
378
379 <pre class="code">
380 Transaction txn = env.beginTransaction(null, null);
381 try {
382     primaryIndex.delete(txn, 1);
383     primaryIndex.delete(txn, 2);
384     txn.commit();
385     txn = null;
386 } finally {
387     if (txn != null) {
388         txn.abort();
389     }
390 }</pre>
391
392 <p><em>WARNING:</em> Transactions must always be committed or aborted to
393 prevent resource leaks which could lead to the index becoming unusable or
394 cause an <code>OutOfMemoryError</code>.  To ensure that a transaction is
395 aborted in the face of exceptions, call <A HREF="../../../com/sleepycat/db/Transaction.html#abort()"><CODE>Transaction.abort()</CODE></A> in a
396 finally block.</p>
397
398 <p>For a transactional store, storage and deletion operations are always
399 transaction protected, whether or not a transaction is explicitly used.  A
400 null transaction argument means to perform the operation using auto-commit,
401 or the implied thread transaction if an XAEnvironment is being used.  A
402 transaction is automatically started as part of the operation and is
403 automatically committed if the operation completes successfully.  The
404 transaction is automatically aborted if an exception occurs during the
405 operation, and the exception is re-thrown to the caller.  For example, each
406 employee is deleted using a an auto-commit transaction below, but it is
407 possible that employee 1 will be deleted and employee 2 will not be deleted,
408 if an error or crash occurs while deleting employee 2:</p>
409
410 <pre class="code">
411 primaryIndex.delete(null, 1);
412 primaryIndex.delete(null, 2);</pre>
413
414 <p>When retrieving entities, a null transaction argument means to perform
415 the operation non-transactionally.  The operation is performed outside the
416 scope of any transaction, without providing transactional ACID guarantees.
417 If an implied thread transaction is present (i.e. if an XAEnvironment is
418 being used), that transaction is used.  When a non-transactional store is
419 used, transactional ACID guarantees are also not provided.</p>
420
421 <p>For non-transactional and auto-commit usage, overloaded signatures for
422 retrieval, storage and deletion methods are provided to avoid having to pass
423 a null transaction argument.  For example, <A HREF="../../../com/sleepycat/persist/EntityIndex.html#delete(K)"><CODE>delete(K)</CODE></A> may be called
424 instead of <A HREF="../../../com/sleepycat/persist/EntityIndex.html#delete(com.sleepycat.db.Transaction, K)"><CODE>delete(Transaction,Object)</CODE></A>.  For example, the following
425 code is equivalent to the code above where null was passed for the
426 transaction:</p>
427
428 <pre class="code">
429 primaryIndex.delete(1);
430 primaryIndex.delete(2);</pre>
431
432 <p>For retrieval methods the overloaded signatures also include an optional
433 <A HREF="../../../com/sleepycat/db/LockMode.html" title="class in com.sleepycat.db"><CODE>LockMode</CODE></A> parameter, and overloaded signatures for opening cursors
434 include an optional <A HREF="../../../com/sleepycat/db/CursorConfig.html" title="class in com.sleepycat.db"><CODE>CursorConfig</CODE></A> parameter.  These parameters are
435 described further below in the Locking and Lock Modes section.</p>
436
437 <h3>Transactions and Cursors</h3>
438
439 <p>There are two special consideration when using cursors with transactions.
440 First, for a transactional store, a non-null transaction must be passed to
441 methods that open a cursor if that cursor will be used to delete or update
442 entities.  Cursors do not perform auto-commit when a null transaction is
443 explicitly passed or implied by the method signature.  For example, the
444 following code will throw <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db"><CODE>DatabaseException</CODE></A> when the <A HREF="../../../com/sleepycat/persist/EntityCursor.html#delete()"><CODE>EntityCursor.delete()</CODE></A> method is called:</p>
445
446 <pre class="code">
447 // <strong>Does not work with a transactional store!</strong>
448 <code>EntityCursor&lt;Employee&gt;</code> cursor = primaryIndex.entities();
449 try {
450     for (Employee entity : cursor) {
451         cursor.delete(); // <strong>Will throw DatabaseException.</strong>
452     }
453 } finally {
454     cursor.close();
455 }</pre>
456
457 <p>Instead, the <A HREF="../../../com/sleepycat/persist/EntityIndex.html#entities(com.sleepycat.db.Transaction, com.sleepycat.db.CursorConfig)"><CODE>entities(Transaction,CursorConfig)</CODE></A> signature must
458 be used and a non-null transaction must be passed:</p>
459
460 <pre class="code">
461 <code>EntityCursor&lt;Employee&gt;</code> cursor = primaryIndex.entities(txn, null);
462 try {
463     for (Employee entity : cursor) {
464         cursor.delete();
465     }
466 } finally {
467     cursor.close();
468 }</pre>
469
470 <p>The second consideration is that error handling is more complex when
471 using both transactions and cursors, for the following reasons:</p>
472 <ol>
473 <li>When an exception occurs, the transaction should be aborted.</li>
474 <li>Cursors must be closed whether or not an exception occurs.</li>
475 <li>Cursors must be closed before committing or aborting the
476 transaction.</li>
477 </ol>
478
479 <p>For example:</p>
480
481 <pre class="code">
482 Transaction txn = env.beginTransaction(null, null);
483 <code>EntityCursor&lt;Employee&gt;</code> cursor = null;
484 try {
485     cursor = primaryIndex.entities(txn, null);
486     for (Employee entity : cursor) {
487         cursor.delete();
488     }
489     cursor.close();
490     cursor = null;
491     txn.commit();
492     txn = null;
493 } finally {
494     if (cursor != null) {
495         cursor.close();
496     }
497     if (txn != null) {
498         txn.abort();
499     }
500 }</pre>
501
502 <h3>Locking and Lock Modes</h3>
503
504 <p>This section provides a brief overview of locking and describes how lock
505 modes are used with the Direct Persistence Layer.  For more information on
506 locking, see <a
507 href="../../../../gsg_txn/JAVA/index.html">Writing
508 Transactional Applications</a>.</p>
509
510 <p>When using transactions, locks are normally acquired on each entity that
511 is retrieved or stored.  The locks are used to isolate one transaction from
512 another.  Locks are normally released only when the transaction is committed
513 or aborted.</p>
514
515 <p>When not using transactions, locks are also normally acquired on each
516 entity that is retrieved or stored.  However, these locks are released when
517 the operation is complete.  When using cursors, in order to provide
518 <em>cursor stability</em> locks are held until the cursor is moved to a
519 different entity or closed.</p>
520
521 <p>This default locking behavior provides full transactional ACID guarantees
522 and cursor stability.  However, application performance can sometimes be
523 improved by compromising these guarantees.  As described in <a
524 href="../../../../gsg_txn/JAVA/index.html">Writing
525 Transactional Applications</a>, the <A HREF="../../../com/sleepycat/db/LockMode.html" title="class in com.sleepycat.db"><CODE>LockMode</CODE></A> and <A HREF="../../../com/sleepycat/db/CursorConfig.html" title="class in com.sleepycat.db"><CODE>CursorConfig</CODE></A> parameters are two of the mechanisms that can be used to make
526 compromises.</p>
527
528 <p>For example, imagine that you need an approximate count of all entities
529 matching certain criterion, and it is acceptable for entities to be changed
530 by other threads or other transactions while performing this query.  <A HREF="../../../com/sleepycat/db/LockMode.html#READ_UNCOMMITTED"><CODE>LockMode.READ_UNCOMMITTED</CODE></A> can be used to perform the retrievals without
531 acquiring any locks.  This reduces memory consumption, does less processing,
532 and can improve concurrency.</p>
533
534 <pre class="code">
535 <code>EntityCursor&lt;Employee&gt;</code> cursor = primaryIndex.entities(txn, null);
536 try {
537     Employee entity;
538     while ((entity = cursor.next(LockMode.READ_UNCOMMITTED)) != null) {
539         // Examine the entity and accumulate totals...
540     }
541 } finally {
542     cursor.close();
543 }</pre>
544
545 <p>The <A HREF="../../../com/sleepycat/db/LockMode.html" title="class in com.sleepycat.db"><CODE>LockMode</CODE></A> parameter specifies locking behavior on a
546 per-operation basis.  If null or <A HREF="../../../com/sleepycat/db/LockMode.html#DEFAULT"><CODE>LockMode.DEFAULT</CODE></A> is specified, the
547 default lock mode is used.</p>
548
549 <p>It is also possible to specify the default locking behavior for a cursor
550 using <A HREF="../../../com/sleepycat/db/CursorConfig.html" title="class in com.sleepycat.db"><CODE>CursorConfig</CODE></A>.  The example below is equivalent to the example
551 above:</p>
552
553 <pre class="code">
554 CursorConfig config = new CursorConfig();
555 config.setReadUncommitted(true);
556 <code>EntityCursor&lt;Employee&gt;</code> cursor = primaryIndex.entities(txn, config);
557 try {
558     Employee entity;
559     while ((entity = cursor.next()) != null) {
560         // Examine the entity and accumulate totals...
561     }
562 } finally {
563     cursor.close();
564 }</pre>
565
566 <p>The use of other lock modes, cursor configuration, and transaction
567 configuration are discussed in <a
568 href="../../../../gsg_txn/JAVA/index.html">Writing
569 Transactional Applications</a>.</p>
570
571 <p>Deadlock handling is another important topic discussed in <a
572 href="../../../../gsg_txn/JAVA/index.html">Writing
573 Transactional Applications</a>.  To go along with that material, here we
574 show a deadlock handling loop in the context of the Direct Persistence
575 Layer.  The example below shows deleting all entities in a primary index in
576 a single transaction.  If a deadlock occurs, the transaction is aborted and
577 the operation is retried.</p>
578
579 <pre class="code">
580 int retryCount = 0;
581 boolean retry = true;
582 while (retry) {
583     Transaction txn = env.beginTransaction(null, null);
584     <code>EntityCursor&lt;Employee&gt;</code> cursor = null;
585     try {
586         cursor = primaryIndex.entities(txn, null);
587         for (Employee entity : cursor) {
588             cursor.delete();
589         }
590         cursor.close();
591         cursor = null;
592         txn.commit();
593         txn = null;
594         retry = false;
595     } catch (DeadlockException e) {
596         retryCount += 1;
597         if (retryCount &gt;= MAX_DEADLOCK_RETRIES) {
598             throw e;
599         }
600     } finally {
601         if (cursor != null) {
602             cursor.close();
603         }
604         if (txn != null) {
605             txn.abort();
606         }
607     }
608  }</pre>
609
610 <h3>Low Level Access</h3>
611
612 <p>Each Direct Persistence Layer index is associated with an underlying
613 <A HREF="../../../com/sleepycat/db/Database.html" title="class in com.sleepycat.db"><CODE>Database</CODE></A> or <A HREF="../../../com/sleepycat/db/SecondaryDatabase.html" title="class in com.sleepycat.db"><CODE>SecondaryDatabase</CODE></A> defined in the <A HREF="../../../com/sleepycat/db/package-summary.html"><CODE>Base API</CODE></A>.  At this level, an index is a Btree managed by
614 the Berkeley DB Java Edition transactional storage engine.  Although you may
615 never need to work at the <code>Base API</code> level, keep in mind that some
616 types of performance tuning can be done by configuring the underlying
617 databases.  See the <A HREF="../../../com/sleepycat/persist/EntityStore.html" title="class in com.sleepycat.persist"><CODE>EntityStore</CODE></A> class for more information on
618 database and sequence configuration.</p>
619
620 <p>If you wish to access an index using the <code>Base API</code>, you may call
621 the <A HREF="../../../com/sleepycat/persist/PrimaryIndex.html#getDatabase()"><CODE>PrimaryIndex.getDatabase()</CODE></A> or <A HREF="../../../com/sleepycat/persist/SecondaryIndex.html#getDatabase()"><CODE>SecondaryIndex.getDatabase()</CODE></A>
622 method to get the underlying database.  To translate between entity or key
623 objects and <A HREF="../../../com/sleepycat/db/DatabaseEntry.html" title="class in com.sleepycat.db"><CODE>DatabaseEntry</CODE></A> objects at this level, use the bindings
624 returned by <A HREF="../../../com/sleepycat/persist/PrimaryIndex.html#getEntityBinding()"><CODE>PrimaryIndex.getEntityBinding()</CODE></A>, <A HREF="../../../com/sleepycat/persist/PrimaryIndex.html#getKeyBinding()"><CODE>PrimaryIndex.getKeyBinding()</CODE></A>, and <A HREF="../../../com/sleepycat/persist/SecondaryIndex.html#getKeyBinding()"><CODE>SecondaryIndex.getKeyBinding()</CODE></A>.</p>
625<P>
626
627<P>
628<HR>
629
630<P>
631
632<!-- ========== METHOD SUMMARY =========== -->
633
634<A NAME="method_summary"><!-- --></A>
635<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
636<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
637<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
638<B>Method Summary</B></FONT></TH>
639</TR>
640<TR BGCOLOR="white" CLASS="TableRowColor">
641<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
642<CODE>&nbsp;boolean</CODE></FONT></TD>
643<TD><CODE><B><A HREF="../../../com/sleepycat/persist/EntityIndex.html#contains(K)">contains</A></B>(<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;key)</CODE>
644
645<BR>
646&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Checks for existence of a key in this index.</TD>
647</TR>
648<TR BGCOLOR="white" CLASS="TableRowColor">
649<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
650<CODE>&nbsp;boolean</CODE></FONT></TD>
651<TD><CODE><B><A HREF="../../../com/sleepycat/persist/EntityIndex.html#contains(com.sleepycat.db.Transaction, K, com.sleepycat.db.LockMode)">contains</A></B>(<A HREF="../../../com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db">Transaction</A>&nbsp;txn,
652         <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;key,
653         <A HREF="../../../com/sleepycat/db/LockMode.html" title="class in com.sleepycat.db">LockMode</A>&nbsp;lockMode)</CODE>
654
655<BR>
656&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Checks for existence of a key in this index.</TD>
657</TR>
658<TR BGCOLOR="white" CLASS="TableRowColor">
659<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
660<CODE>&nbsp;long</CODE></FONT></TD>
661<TD><CODE><B><A HREF="../../../com/sleepycat/persist/EntityIndex.html#count()">count</A></B>()</CODE>
662
663<BR>
664&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a non-transactional count of the entities in this index.</TD>
665</TR>
666<TR BGCOLOR="white" CLASS="TableRowColor">
667<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
668<CODE>&nbsp;boolean</CODE></FONT></TD>
669<TD><CODE><B><A HREF="../../../com/sleepycat/persist/EntityIndex.html#delete(K)">delete</A></B>(<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;key)</CODE>
670
671<BR>
672&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deletes all entities with a given index key.</TD>
673</TR>
674<TR BGCOLOR="white" CLASS="TableRowColor">
675<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
676<CODE>&nbsp;boolean</CODE></FONT></TD>
677<TD><CODE><B><A HREF="../../../com/sleepycat/persist/EntityIndex.html#delete(com.sleepycat.db.Transaction, K)">delete</A></B>(<A HREF="../../../com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db">Transaction</A>&nbsp;txn,
678       <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;key)</CODE>
679
680<BR>
681&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deletes all entities with a given index key.</TD>
682</TR>
683<TR BGCOLOR="white" CLASS="TableRowColor">
684<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
685<CODE>&nbsp;<A HREF="../../../com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">V</A>&gt;</CODE></FONT></TD>
686<TD><CODE><B><A HREF="../../../com/sleepycat/persist/EntityIndex.html#entities()">entities</A></B>()</CODE>
687
688<BR>
689&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Opens a cursor for traversing all entities in this index.</TD>
690</TR>
691<TR BGCOLOR="white" CLASS="TableRowColor">
692<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
693<CODE>&nbsp;<A HREF="../../../com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">V</A>&gt;</CODE></FONT></TD>
694<TD><CODE><B><A HREF="../../../com/sleepycat/persist/EntityIndex.html#entities(K, boolean, K, boolean)">entities</A></B>(<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;fromKey,
695         boolean&nbsp;fromInclusive,
696         <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;toKey,
697         boolean&nbsp;toInclusive)</CODE>
698
699<BR>
700&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Opens a cursor for traversing entities in a key range.</TD>
701</TR>
702<TR BGCOLOR="white" CLASS="TableRowColor">
703<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
704<CODE>&nbsp;<A HREF="../../../com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">V</A>&gt;</CODE></FONT></TD>
705<TD><CODE><B><A HREF="../../../com/sleepycat/persist/EntityIndex.html#entities(com.sleepycat.db.Transaction, com.sleepycat.db.CursorConfig)">entities</A></B>(<A HREF="../../../com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db">Transaction</A>&nbsp;txn,
706         <A HREF="../../../com/sleepycat/db/CursorConfig.html" title="class in com.sleepycat.db">CursorConfig</A>&nbsp;config)</CODE>
707
708<BR>
709&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Opens a cursor for traversing all entities in this index.</TD>
710</TR>
711<TR BGCOLOR="white" CLASS="TableRowColor">
712<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
713<CODE>&nbsp;<A HREF="../../../com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">V</A>&gt;</CODE></FONT></TD>
714<TD><CODE><B><A HREF="../../../com/sleepycat/persist/EntityIndex.html#entities(com.sleepycat.db.Transaction, K, boolean, K, boolean, com.sleepycat.db.CursorConfig)">entities</A></B>(<A HREF="../../../com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db">Transaction</A>&nbsp;txn,
715         <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;fromKey,
716         boolean&nbsp;fromInclusive,
717         <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;toKey,
718         boolean&nbsp;toInclusive,
719         <A HREF="../../../com/sleepycat/db/CursorConfig.html" title="class in com.sleepycat.db">CursorConfig</A>&nbsp;config)</CODE>
720
721<BR>
722&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Opens a cursor for traversing entities in a key range.</TD>
723</TR>
724<TR BGCOLOR="white" CLASS="TableRowColor">
725<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
726<CODE>&nbsp;<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">V</A></CODE></FONT></TD>
727<TD><CODE><B><A HREF="../../../com/sleepycat/persist/EntityIndex.html#get(K)">get</A></B>(<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;key)</CODE>
728
729<BR>
730&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Gets an entity via a key of this index.</TD>
731</TR>
732<TR BGCOLOR="white" CLASS="TableRowColor">
733<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
734<CODE>&nbsp;<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">V</A></CODE></FONT></TD>
735<TD><CODE><B><A HREF="../../../com/sleepycat/persist/EntityIndex.html#get(com.sleepycat.db.Transaction, K, com.sleepycat.db.LockMode)">get</A></B>(<A HREF="../../../com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db">Transaction</A>&nbsp;txn,
736    <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;key,
737    <A HREF="../../../com/sleepycat/db/LockMode.html" title="class in com.sleepycat.db">LockMode</A>&nbsp;lockMode)</CODE>
738
739<BR>
740&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Gets an entity via a key of this index.</TD>
741</TR>
742<TR BGCOLOR="white" CLASS="TableRowColor">
743<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
744<CODE>&nbsp;<A HREF="../../../com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&gt;</CODE></FONT></TD>
745<TD><CODE><B><A HREF="../../../com/sleepycat/persist/EntityIndex.html#keys()">keys</A></B>()</CODE>
746
747<BR>
748&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Opens a cursor for traversing all keys in this index.</TD>
749</TR>
750<TR BGCOLOR="white" CLASS="TableRowColor">
751<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
752<CODE>&nbsp;<A HREF="../../../com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&gt;</CODE></FONT></TD>
753<TD><CODE><B><A HREF="../../../com/sleepycat/persist/EntityIndex.html#keys(K, boolean, K, boolean)">keys</A></B>(<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;fromKey,
754     boolean&nbsp;fromInclusive,
755     <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;toKey,
756     boolean&nbsp;toInclusive)</CODE>
757
758<BR>
759&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Opens a cursor for traversing keys in a key range.</TD>
760</TR>
761<TR BGCOLOR="white" CLASS="TableRowColor">
762<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
763<CODE>&nbsp;<A HREF="../../../com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&gt;</CODE></FONT></TD>
764<TD><CODE><B><A HREF="../../../com/sleepycat/persist/EntityIndex.html#keys(com.sleepycat.db.Transaction, com.sleepycat.db.CursorConfig)">keys</A></B>(<A HREF="../../../com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db">Transaction</A>&nbsp;txn,
765     <A HREF="../../../com/sleepycat/db/CursorConfig.html" title="class in com.sleepycat.db">CursorConfig</A>&nbsp;config)</CODE>
766
767<BR>
768&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Opens a cursor for traversing all keys in this index.</TD>
769</TR>
770<TR BGCOLOR="white" CLASS="TableRowColor">
771<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
772<CODE>&nbsp;<A HREF="../../../com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&gt;</CODE></FONT></TD>
773<TD><CODE><B><A HREF="../../../com/sleepycat/persist/EntityIndex.html#keys(com.sleepycat.db.Transaction, K, boolean, K, boolean, com.sleepycat.db.CursorConfig)">keys</A></B>(<A HREF="../../../com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db">Transaction</A>&nbsp;txn,
774     <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;fromKey,
775     boolean&nbsp;fromInclusive,
776     <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;toKey,
777     boolean&nbsp;toInclusive,
778     <A HREF="../../../com/sleepycat/db/CursorConfig.html" title="class in com.sleepycat.db">CursorConfig</A>&nbsp;config)</CODE>
779
780<BR>
781&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Opens a cursor for traversing keys in a key range.</TD>
782</TR>
783<TR BGCOLOR="white" CLASS="TableRowColor">
784<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
785<CODE>&nbsp;<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Map.html" title="class or interface in java.util">Map</A>&lt;<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>,<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">V</A>&gt;</CODE></FONT></TD>
786<TD><CODE><B><A HREF="../../../com/sleepycat/persist/EntityIndex.html#map()">map</A></B>()</CODE>
787
788<BR>
789&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a standard Java map based on this entity index.</TD>
790</TR>
791<TR BGCOLOR="white" CLASS="TableRowColor">
792<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
793<CODE>&nbsp;<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/SortedMap.html" title="class or interface in java.util">SortedMap</A>&lt;<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>,<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">V</A>&gt;</CODE></FONT></TD>
794<TD><CODE><B><A HREF="../../../com/sleepycat/persist/EntityIndex.html#sortedMap()">sortedMap</A></B>()</CODE>
795
796<BR>
797&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a standard Java sorted map based on this entity index.</TD>
798</TR>
799</TABLE>
800&nbsp;
801<P>
802
803<!-- ============ METHOD DETAIL ========== -->
804
805<A NAME="method_detail"><!-- --></A>
806<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
807<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
808<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
809<B>Method Detail</B></FONT></TH>
810</TR>
811</TABLE>
812
813<A NAME="contains(java.lang.Object)"><!-- --></A><A NAME="contains(K)"><!-- --></A><H3>
814contains</H3>
815<PRE>
816boolean <B>contains</B>(<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;key)
817                 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
818<DL>
819<DD>Checks for existence of a key in this index.
820
821 <p>The operation will not be transaction protected, and <A HREF="../../../com/sleepycat/db/LockMode.html#DEFAULT"><CODE>LockMode.DEFAULT</CODE></A> is used implicitly.</p>
822<P>
823<DD><DL>
824<DT><B>Parameters:</B><DD><CODE>key</CODE> - the key to search for.
825<DT><B>Returns:</B><DD>whether the key exists in the index.
826<DT><B>Throws:</B>
827<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
828</DD>
829</DL>
830<HR>
831
832<A NAME="contains(com.sleepycat.db.Transaction,java.lang.Object,com.sleepycat.db.LockMode)"><!-- --></A><A NAME="contains(com.sleepycat.db.Transaction, K, com.sleepycat.db.LockMode)"><!-- --></A><H3>
833contains</H3>
834<PRE>
835boolean <B>contains</B>(<A HREF="../../../com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db">Transaction</A>&nbsp;txn,
836                 <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;key,
837                 <A HREF="../../../com/sleepycat/db/LockMode.html" title="class in com.sleepycat.db">LockMode</A>&nbsp;lockMode)
838                 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
839<DL>
840<DD>Checks for existence of a key in this index.
841<P>
842<DD><DL>
843<DT><B>Parameters:</B><DD><CODE>txn</CODE> - the transaction used to protect this operation, or null
844 if the operation should not be transaction protected.<DD><CODE>key</CODE> - the key to search for.<DD><CODE>lockMode</CODE> - the lock mode to use for this operation, or null to
845 use <A HREF="../../../com/sleepycat/db/LockMode.html#DEFAULT"><CODE>LockMode.DEFAULT</CODE></A>.
846<DT><B>Returns:</B><DD>whether the key exists in the index.
847<DT><B>Throws:</B>
848<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
849</DD>
850</DL>
851<HR>
852
853<A NAME="get(java.lang.Object)"><!-- --></A><A NAME="get(K)"><!-- --></A><H3>
854get</H3>
855<PRE>
856<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">V</A> <B>get</B>(<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;key)
857      throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
858<DL>
859<DD>Gets an entity via a key of this index.
860
861 <p>The operation will not be transaction protected, and <A HREF="../../../com/sleepycat/db/LockMode.html#DEFAULT"><CODE>LockMode.DEFAULT</CODE></A> is used implicitly.</p>
862<P>
863<DD><DL>
864<DT><B>Parameters:</B><DD><CODE>key</CODE> - the key to search for.
865<DT><B>Returns:</B><DD>the value mapped to the given key, or null if the key is not
866 present in the index.
867<DT><B>Throws:</B>
868<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
869</DD>
870</DL>
871<HR>
872
873<A NAME="get(com.sleepycat.db.Transaction,java.lang.Object,com.sleepycat.db.LockMode)"><!-- --></A><A NAME="get(com.sleepycat.db.Transaction, K, com.sleepycat.db.LockMode)"><!-- --></A><H3>
874get</H3>
875<PRE>
876<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">V</A> <B>get</B>(<A HREF="../../../com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db">Transaction</A>&nbsp;txn,
877      <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;key,
878      <A HREF="../../../com/sleepycat/db/LockMode.html" title="class in com.sleepycat.db">LockMode</A>&nbsp;lockMode)
879      throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
880<DL>
881<DD>Gets an entity via a key of this index.
882<P>
883<DD><DL>
884<DT><B>Parameters:</B><DD><CODE>txn</CODE> - the transaction used to protect this operation, or null
885 if the operation should not be transaction protected.<DD><CODE>key</CODE> - the key to search for.<DD><CODE>lockMode</CODE> - the lock mode to use for this operation, or null to
886 use <A HREF="../../../com/sleepycat/db/LockMode.html#DEFAULT"><CODE>LockMode.DEFAULT</CODE></A>.
887<DT><B>Returns:</B><DD>the value mapped to the given key, or null if the key is not
888 present in the index.
889<DT><B>Throws:</B>
890<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
891</DD>
892</DL>
893<HR>
894
895<A NAME="count()"><!-- --></A><H3>
896count</H3>
897<PRE>
898long <B>count</B>()
899           throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
900<DL>
901<DD>Returns a non-transactional count of the entities in this index.
902
903 <p>This operation is faster than obtaining a count by scanning the index
904 manually, and will not perturb the current contents of the cache.
905 However, the count is not guaranteed to be accurate if there are
906 concurrent updates.</p>
907<P>
908<DD><DL>
909
910<DT><B>Returns:</B><DD>the number of entities in this index.
911<DT><B>Throws:</B>
912<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
913</DD>
914</DL>
915<HR>
916
917<A NAME="delete(java.lang.Object)"><!-- --></A><A NAME="delete(K)"><!-- --></A><H3>
918delete</H3>
919<PRE>
920boolean <B>delete</B>(<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;key)
921               throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
922<DL>
923<DD>Deletes all entities with a given index key.
924
925 <p>Auto-commit is used implicitly if the store is transactional.</p>
926<P>
927<DD><DL>
928<DT><B>Parameters:</B><DD><CODE>key</CODE> - the key to search for.
929<DT><B>Returns:</B><DD>whether any entities were deleted.
930<DT><B>Throws:</B>
931<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
932</DD>
933</DL>
934<HR>
935
936<A NAME="delete(com.sleepycat.db.Transaction,java.lang.Object)"><!-- --></A><A NAME="delete(com.sleepycat.db.Transaction, K)"><!-- --></A><H3>
937delete</H3>
938<PRE>
939boolean <B>delete</B>(<A HREF="../../../com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db">Transaction</A>&nbsp;txn,
940               <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;key)
941               throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
942<DL>
943<DD>Deletes all entities with a given index key.
944<P>
945<DD><DL>
946<DT><B>Parameters:</B><DD><CODE>txn</CODE> - the transaction used to protect this operation, null to use
947 auto-commit, or null if the store is non-transactional.<DD><CODE>key</CODE> - the key to search for.
948<DT><B>Returns:</B><DD>whether any entities were deleted.
949<DT><B>Throws:</B>
950<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
951</DD>
952</DL>
953<HR>
954
955<A NAME="keys()"><!-- --></A><H3>
956keys</H3>
957<PRE>
958<A HREF="../../../com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&gt; <B>keys</B>()
959                     throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
960<DL>
961<DD>Opens a cursor for traversing all keys in this index.
962
963 <p>The operations performed with the cursor will not be transaction
964 protected, and <A HREF="../../../com/sleepycat/db/CursorConfig.html#DEFAULT"><CODE>CursorConfig.DEFAULT</CODE></A> is used implicitly.  If the
965 store is transactional, the cursor may not be used to update or delete
966 entities.</p>
967<P>
968<DD><DL>
969
970<DT><B>Returns:</B><DD>the cursor.
971<DT><B>Throws:</B>
972<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
973</DD>
974</DL>
975<HR>
976
977<A NAME="keys(com.sleepycat.db.Transaction, com.sleepycat.db.CursorConfig)"><!-- --></A><H3>
978keys</H3>
979<PRE>
980<A HREF="../../../com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&gt; <B>keys</B>(<A HREF="../../../com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db">Transaction</A>&nbsp;txn,
981                     <A HREF="../../../com/sleepycat/db/CursorConfig.html" title="class in com.sleepycat.db">CursorConfig</A>&nbsp;config)
982                     throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
983<DL>
984<DD>Opens a cursor for traversing all keys in this index.
985<P>
986<DD><DL>
987<DT><B>Parameters:</B><DD><CODE>txn</CODE> - the transaction used to protect all operations performed with
988 the cursor, or null if the operations should not be transaction
989 protected.  If null is specified and the store is transactional, the
990 cursor may not be used to update or delete entities.<DD><CODE>config</CODE> - the cursor configuration that determines the default lock
991 mode used for all cursor operations, or null to implicitly use <A HREF="../../../com/sleepycat/db/CursorConfig.html#DEFAULT"><CODE>CursorConfig.DEFAULT</CODE></A>.
992<DT><B>Returns:</B><DD>the cursor.
993<DT><B>Throws:</B>
994<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
995</DD>
996</DL>
997<HR>
998
999<A NAME="entities()"><!-- --></A><H3>
1000entities</H3>
1001<PRE>
1002<A HREF="../../../com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">V</A>&gt; <B>entities</B>()
1003                         throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1004<DL>
1005<DD>Opens a cursor for traversing all entities in this index.
1006
1007 <p>The operations performed with the cursor will not be transaction
1008 protected, and <A HREF="../../../com/sleepycat/db/CursorConfig.html#DEFAULT"><CODE>CursorConfig.DEFAULT</CODE></A> is used implicitly.  If the
1009 store is transactional, the cursor may not be used to update or delete
1010 entities.</p>
1011<P>
1012<DD><DL>
1013
1014<DT><B>Returns:</B><DD>the cursor.
1015<DT><B>Throws:</B>
1016<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
1017</DD>
1018</DL>
1019<HR>
1020
1021<A NAME="entities(com.sleepycat.db.Transaction, com.sleepycat.db.CursorConfig)"><!-- --></A><H3>
1022entities</H3>
1023<PRE>
1024<A HREF="../../../com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">V</A>&gt; <B>entities</B>(<A HREF="../../../com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db">Transaction</A>&nbsp;txn,
1025                         <A HREF="../../../com/sleepycat/db/CursorConfig.html" title="class in com.sleepycat.db">CursorConfig</A>&nbsp;config)
1026                         throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1027<DL>
1028<DD>Opens a cursor for traversing all entities in this index.
1029<P>
1030<DD><DL>
1031<DT><B>Parameters:</B><DD><CODE>txn</CODE> - the transaction used to protect all operations performed with
1032 the cursor, or null if the operations should not be transaction
1033 protected.  If null is specified and the store is transactional, the
1034 cursor may not be used to update or delete entities.<DD><CODE>config</CODE> - the cursor configuration that determines the default lock
1035 mode used for all cursor operations, or null to implicitly use <A HREF="../../../com/sleepycat/db/CursorConfig.html#DEFAULT"><CODE>CursorConfig.DEFAULT</CODE></A>.
1036<DT><B>Returns:</B><DD>the cursor.
1037<DT><B>Throws:</B>
1038<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
1039</DD>
1040</DL>
1041<HR>
1042
1043<A NAME="keys(java.lang.Object,boolean,java.lang.Object,boolean)"><!-- --></A><A NAME="keys(K, boolean, K, boolean)"><!-- --></A><H3>
1044keys</H3>
1045<PRE>
1046<A HREF="../../../com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&gt; <B>keys</B>(<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;fromKey,
1047                     boolean&nbsp;fromInclusive,
1048                     <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;toKey,
1049                     boolean&nbsp;toInclusive)
1050                     throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1051<DL>
1052<DD>Opens a cursor for traversing keys in a key range.
1053
1054 <p>The operations performed with the cursor will not be transaction
1055 protected, and <A HREF="../../../com/sleepycat/db/CursorConfig.html#DEFAULT"><CODE>CursorConfig.DEFAULT</CODE></A> is used implicitly.  If the
1056 store is transactional, the cursor may not be used to update or delete
1057 entities.</p>
1058<P>
1059<DD><DL>
1060<DT><B>Parameters:</B><DD><CODE>fromKey</CODE> - is the lower bound of the key range, or null if the range
1061 has no lower bound.<DD><CODE>fromInclusive</CODE> - is true if keys greater than or equal to fromKey
1062 should be included in the key range, or false if only keys greater than
1063 fromKey should be included.<DD><CODE>toKey</CODE> - is the upper bound of the key range, or null if the range
1064 has no upper bound.<DD><CODE>toInclusive</CODE> - is true if keys less than or equal to toKey should be
1065 included in the key range, or false if only keys less than toKey should
1066 be included.
1067<DT><B>Returns:</B><DD>the cursor.
1068<DT><B>Throws:</B>
1069<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
1070</DD>
1071</DL>
1072<HR>
1073
1074<A NAME="keys(com.sleepycat.db.Transaction,java.lang.Object,boolean,java.lang.Object,boolean,com.sleepycat.db.CursorConfig)"><!-- --></A><A NAME="keys(com.sleepycat.db.Transaction, K, boolean, K, boolean, com.sleepycat.db.CursorConfig)"><!-- --></A><H3>
1075keys</H3>
1076<PRE>
1077<A HREF="../../../com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&gt; <B>keys</B>(<A HREF="../../../com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db">Transaction</A>&nbsp;txn,
1078                     <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;fromKey,
1079                     boolean&nbsp;fromInclusive,
1080                     <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;toKey,
1081                     boolean&nbsp;toInclusive,
1082                     <A HREF="../../../com/sleepycat/db/CursorConfig.html" title="class in com.sleepycat.db">CursorConfig</A>&nbsp;config)
1083                     throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1084<DL>
1085<DD>Opens a cursor for traversing keys in a key range.
1086<P>
1087<DD><DL>
1088<DT><B>Parameters:</B><DD><CODE>txn</CODE> - the transaction used to protect all operations performed with
1089 the cursor, or null if the operations should not be transaction
1090 protected.  If null is specified and the store is transactional, the
1091 cursor may not be used to update or delete entities.<DD><CODE>fromKey</CODE> - is the lower bound of the key range, or null if the range
1092 has no lower bound.<DD><CODE>fromInclusive</CODE> - is true if keys greater than or equal to fromKey
1093 should be included in the key range, or false if only keys greater than
1094 fromKey should be included.<DD><CODE>toKey</CODE> - is the upper bound of the key range, or null if the range
1095 has no upper bound.<DD><CODE>toInclusive</CODE> - is true if keys less than or equal to toKey should be
1096 included in the key range, or false if only keys less than toKey should
1097 be included.<DD><CODE>config</CODE> - the cursor configuration that determines the default lock
1098 mode used for all cursor operations, or null to implicitly use <A HREF="../../../com/sleepycat/db/CursorConfig.html#DEFAULT"><CODE>CursorConfig.DEFAULT</CODE></A>.
1099<DT><B>Returns:</B><DD>the cursor.
1100<DT><B>Throws:</B>
1101<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
1102</DD>
1103</DL>
1104<HR>
1105
1106<A NAME="entities(java.lang.Object,boolean,java.lang.Object,boolean)"><!-- --></A><A NAME="entities(K, boolean, K, boolean)"><!-- --></A><H3>
1107entities</H3>
1108<PRE>
1109<A HREF="../../../com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">V</A>&gt; <B>entities</B>(<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;fromKey,
1110                         boolean&nbsp;fromInclusive,
1111                         <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;toKey,
1112                         boolean&nbsp;toInclusive)
1113                         throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1114<DL>
1115<DD>Opens a cursor for traversing entities in a key range.
1116
1117 <p>The operations performed with the cursor will not be transaction
1118 protected, and <A HREF="../../../com/sleepycat/db/CursorConfig.html#DEFAULT"><CODE>CursorConfig.DEFAULT</CODE></A> is used implicitly.  If the
1119 store is transactional, the cursor may not be used to update or delete
1120 entities.</p>
1121<P>
1122<DD><DL>
1123<DT><B>Parameters:</B><DD><CODE>fromKey</CODE> - is the lower bound of the key range, or null if the range
1124 has no lower bound.<DD><CODE>fromInclusive</CODE> - is true if keys greater than or equal to fromKey
1125 should be included in the key range, or false if only keys greater than
1126 fromKey should be included.<DD><CODE>toKey</CODE> - is the upper bound of the key range, or null if the range
1127 has no upper bound.<DD><CODE>toInclusive</CODE> - is true if keys less than or equal to toKey should be
1128 included in the key range, or false if only keys less than toKey should
1129 be included.
1130<DT><B>Returns:</B><DD>the cursor.
1131<DT><B>Throws:</B>
1132<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
1133</DD>
1134</DL>
1135<HR>
1136
1137<A NAME="entities(com.sleepycat.db.Transaction,java.lang.Object,boolean,java.lang.Object,boolean,com.sleepycat.db.CursorConfig)"><!-- --></A><A NAME="entities(com.sleepycat.db.Transaction, K, boolean, K, boolean, com.sleepycat.db.CursorConfig)"><!-- --></A><H3>
1138entities</H3>
1139<PRE>
1140<A HREF="../../../com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">V</A>&gt; <B>entities</B>(<A HREF="../../../com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db">Transaction</A>&nbsp;txn,
1141                         <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;fromKey,
1142                         boolean&nbsp;fromInclusive,
1143                         <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;toKey,
1144                         boolean&nbsp;toInclusive,
1145                         <A HREF="../../../com/sleepycat/db/CursorConfig.html" title="class in com.sleepycat.db">CursorConfig</A>&nbsp;config)
1146                         throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1147<DL>
1148<DD>Opens a cursor for traversing entities in a key range.
1149<P>
1150<DD><DL>
1151<DT><B>Parameters:</B><DD><CODE>txn</CODE> - the transaction used to protect all operations performed with
1152 the cursor, or null if the operations should not be transaction
1153 protected.  If null is specified and the store is transactional, the
1154 cursor may not be used to update or delete entities.<DD><CODE>fromKey</CODE> - is the lower bound of the key range, or null if the range
1155 has no lower bound.<DD><CODE>fromInclusive</CODE> - is true if keys greater than or equal to fromKey
1156 should be included in the key range, or false if only keys greater than
1157 fromKey should be included.<DD><CODE>toKey</CODE> - is the upper bound of the key range, or null if the range
1158 has no upper bound.<DD><CODE>toInclusive</CODE> - is true if keys less than or equal to toKey should be
1159 included in the key range, or false if only keys less than toKey should
1160 be included.<DD><CODE>config</CODE> - the cursor configuration that determines the default lock
1161 mode used for all cursor operations, or null to implicitly use <A HREF="../../../com/sleepycat/db/CursorConfig.html#DEFAULT"><CODE>CursorConfig.DEFAULT</CODE></A>.
1162<DT><B>Returns:</B><DD>the cursor.
1163<DT><B>Throws:</B>
1164<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
1165</DD>
1166</DL>
1167<HR>
1168
1169<A NAME="map()"><!-- --></A><H3>
1170map</H3>
1171<PRE>
1172<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Map.html" title="class or interface in java.util">Map</A>&lt;<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>,<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">V</A>&gt; <B>map</B>()</PRE>
1173<DL>
1174<DD>Returns a standard Java map based on this entity index.  The <A HREF="../../../com/sleepycat/collections/StoredMap.html" title="class in com.sleepycat.collections"><CODE>StoredMap</CODE></A> returned is defined by the <A HREF="../../../com/sleepycat/collections/package-summary.html">Collections API</A>.  Stored collections conform
1175 to the standard Java collections framework interface.
1176<P>
1177<DD><DL>
1178
1179<DT><B>Returns:</B><DD>the map.</DL>
1180</DD>
1181</DL>
1182<HR>
1183
1184<A NAME="sortedMap()"><!-- --></A><H3>
1185sortedMap</H3>
1186<PRE>
1187<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/SortedMap.html" title="class or interface in java.util">SortedMap</A>&lt;<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>,<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">V</A>&gt; <B>sortedMap</B>()</PRE>
1188<DL>
1189<DD>Returns a standard Java sorted map based on this entity index.  The
1190 <A HREF="../../../com/sleepycat/collections/StoredSortedMap.html" title="class in com.sleepycat.collections"><CODE>StoredSortedMap</CODE></A> returned is defined by the <A HREF="../../../com/sleepycat/collections/package-summary.html">Collections API</A>.  Stored collections conform
1191 to the standard Java collections framework interface.
1192<P>
1193<DD><DL>
1194
1195<DT><B>Returns:</B><DD>the map.</DL>
1196</DD>
1197</DL>
1198<!-- ========= END OF CLASS DATA ========= -->
1199<HR>
1200
1201
1202<!-- ======= START OF BOTTOM NAVBAR ====== -->
1203<A NAME="navbar_bottom"><!-- --></A>
1204<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
1205<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
1206<TR>
1207<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
1208<A NAME="navbar_bottom_firstrow"><!-- --></A>
1209<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
1210  <TR ALIGN="center" VALIGN="top">
1211  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
1212  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
1213  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
1214  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/EntityIndex.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
1215  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
1216  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
1217  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
1218  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
1219  </TR>
1220</TABLE>
1221</TD>
1222<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
1223<b>Berkeley DB</b><br><font size="-1"> version 4.7.25</font></EM>
1224</TD>
1225</TR>
1226
1227<TR>
1228<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
1229&nbsp;<A HREF="../../../com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist"><B>PREV CLASS</B></A>&nbsp;
1230&nbsp;<A HREF="../../../com/sleepycat/persist/EntityJoin.html" title="class in com.sleepycat.persist"><B>NEXT CLASS</B></A></FONT></TD>
1231<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
1232  <A HREF="../../../index.html?com/sleepycat/persist/EntityIndex.html" target="_top"><B>FRAMES</B></A>  &nbsp;
1233&nbsp;<A HREF="EntityIndex.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
1234&nbsp;<SCRIPT type="text/javascript">
1235  <!--
1236  if(window==top) {
1237    document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>');
1238  }
1239  //-->
1240</SCRIPT>
1241<NOSCRIPT>
1242  <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>
1243</NOSCRIPT>
1244
1245
1246</FONT></TD>
1247</TR>
1248<TR>
1249<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
1250  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
1251<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
1252DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
1253</TR>
1254</TABLE>
1255<A NAME="skip-navbar_bottom"></A>
1256<!-- ======== END OF BOTTOM NAVBAR ======= -->
1257
1258<HR>
1259<font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
1260</BODY>
1261</HTML>
1262