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