Debian Codegraph @

docs/java/com/sleepycat/persist/EntityIndex.html

raw symbols SCIP
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_51) on Mon Sep 09 11:47:06 EDT 2013 -->
6 <TITLE>
7 EntityIndex (Oracle - Berkeley DB Java API)
8 </TITLE>
9
10 <META NAME="date" CONTENT="2013-09-09">
11
12 <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../style.css" TITLE="Style">
13
14 <SCRIPT type="text/javascript">
15 function 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 5.3.28</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">
81 DETAIL:&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">
91 com.sleepycat.persist</FONT>
92 <BR>
93 Interface 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>
103 The 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://download.oracle.com/javase/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://download.oracle.com/javase/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 long sleepMillis = 0;
594 for (int i = 0; i &lt; maxTries; i++) {
595 // Sleep before retrying.
596 if (sleepMillis != 0) {
597 Thread.sleep(sleepMillis);
598 sleepMillis = 0;
599 }
600 Transaction txn = null;
601 try {
602 txn = env.beginTransaction(null, null);
603 final <code>EntityCursor&lt;Employee&gt;</code> cursor =
604 primaryIndex.entities(txn, null);
605 try {
606 // INSERT APP-SPECIFIC CODE HERE:
607 // Perform read and write operations, for example:
608 for (Employee entity : cursor) {
609 cursor.delete();
610 }
611 } finally {
612 cursor.close();
613 }
614 txn.commit();
615 success = true;
616 return;
617 } catch (DeadlockException e) {
618 sleepMillis = LOCK_CONFLICT_RETRY_SEC * 1000;
619 continue;
620 } finally {
621 if (!success) {
622 if (txn != null) {
623 txn.abort();
624 }
625 }
626 }
627 }
628 // INSERT APP-SPECIFIC CODE HERE:
629 // Transaction failed, despite retries.
630 // Take some app-specific course of action.
631 }</pre>
632
633 <h3>Low Level Access</h3>
634
635 <p>Each Direct Persistence Layer index is associated with an underlying
636 <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
637 the Berkeley DB Java Edition transactional storage engine. Although you may
638 never need to work at the <code>Base API</code> level, keep in mind that some
639 types of performance tuning can be done by configuring the underlying
640 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
641 database and sequence configuration.</p>
642
643 <p>If you wish to access an index using the <code>Base API</code>, you may call
644 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>
645 method to get the underlying database. To translate between entity or key
646 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
647 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>
648 <P>
649
650 <P>
651 <HR>
652
653 <P>
654
655 <!-- ========== METHOD SUMMARY =========== -->
656
657 <A NAME="method_summary"><!-- --></A>
658 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
659 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
660 <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
661 <B>Method Summary</B></FONT></TH>
662 </TR>
663 <TR BGCOLOR="white" CLASS="TableRowColor">
664 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
665 <CODE>&nbsp;boolean</CODE></FONT></TD>
666 <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>
667
668 <BR>
669 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Checks for existence of a key in this index.</TD>
670 </TR>
671 <TR BGCOLOR="white" CLASS="TableRowColor">
672 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
673 <CODE>&nbsp;boolean</CODE></FONT></TD>
674 <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,
675 <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;key,
676 <A HREF="../../../com/sleepycat/db/LockMode.html" title="class in com.sleepycat.db">LockMode</A>&nbsp;lockMode)</CODE>
677
678 <BR>
679 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Checks for existence of a key in this index.</TD>
680 </TR>
681 <TR BGCOLOR="white" CLASS="TableRowColor">
682 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
683 <CODE>&nbsp;long</CODE></FONT></TD>
684 <TD><CODE><B><A HREF="../../../com/sleepycat/persist/EntityIndex.html#count()">count</A></B>()</CODE>
685
686 <BR>
687 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a non-transactional count of the entities in this index.</TD>
688 </TR>
689 <TR BGCOLOR="white" CLASS="TableRowColor">
690 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
691 <CODE>&nbsp;boolean</CODE></FONT></TD>
692 <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>
693
694 <BR>
695 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deletes all entities with a given index key.</TD>
696 </TR>
697 <TR BGCOLOR="white" CLASS="TableRowColor">
698 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
699 <CODE>&nbsp;boolean</CODE></FONT></TD>
700 <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,
701 <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;key)</CODE>
702
703 <BR>
704 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deletes all entities with a given index key.</TD>
705 </TR>
706 <TR BGCOLOR="white" CLASS="TableRowColor">
707 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
708 <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>
709 <TD><CODE><B><A HREF="../../../com/sleepycat/persist/EntityIndex.html#entities()">entities</A></B>()</CODE>
710
711 <BR>
712 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Opens a cursor for traversing all entities in this index.</TD>
713 </TR>
714 <TR BGCOLOR="white" CLASS="TableRowColor">
715 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
716 <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>
717 <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,
718 boolean&nbsp;fromInclusive,
719 <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;toKey,
720 boolean&nbsp;toInclusive)</CODE>
721
722 <BR>
723 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Opens a cursor for traversing entities in a key range.</TD>
724 </TR>
725 <TR BGCOLOR="white" CLASS="TableRowColor">
726 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
727 <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>
728 <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,
729 <A HREF="../../../com/sleepycat/db/CursorConfig.html" title="class in com.sleepycat.db">CursorConfig</A>&nbsp;config)</CODE>
730
731 <BR>
732 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Opens a cursor for traversing all entities in this index.</TD>
733 </TR>
734 <TR BGCOLOR="white" CLASS="TableRowColor">
735 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
736 <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>
737 <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,
738 <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;fromKey,
739 boolean&nbsp;fromInclusive,
740 <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;toKey,
741 boolean&nbsp;toInclusive,
742 <A HREF="../../../com/sleepycat/db/CursorConfig.html" title="class in com.sleepycat.db">CursorConfig</A>&nbsp;config)</CODE>
743
744 <BR>
745 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Opens a cursor for traversing entities in a key range.</TD>
746 </TR>
747 <TR BGCOLOR="white" CLASS="TableRowColor">
748 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
749 <CODE>&nbsp;<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">V</A></CODE></FONT></TD>
750 <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>
751
752 <BR>
753 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Gets an entity via a key of this index.</TD>
754 </TR>
755 <TR BGCOLOR="white" CLASS="TableRowColor">
756 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
757 <CODE>&nbsp;<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">V</A></CODE></FONT></TD>
758 <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,
759 <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;key,
760 <A HREF="../../../com/sleepycat/db/LockMode.html" title="class in com.sleepycat.db">LockMode</A>&nbsp;lockMode)</CODE>
761
762 <BR>
763 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Gets an entity via a key of this index.</TD>
764 </TR>
765 <TR BGCOLOR="white" CLASS="TableRowColor">
766 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
767 <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>
768 <TD><CODE><B><A HREF="../../../com/sleepycat/persist/EntityIndex.html#keys()">keys</A></B>()</CODE>
769
770 <BR>
771 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Opens a cursor for traversing all keys in this index.</TD>
772 </TR>
773 <TR BGCOLOR="white" CLASS="TableRowColor">
774 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
775 <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>
776 <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,
777 boolean&nbsp;fromInclusive,
778 <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;toKey,
779 boolean&nbsp;toInclusive)</CODE>
780
781 <BR>
782 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Opens a cursor for traversing keys in a key range.</TD>
783 </TR>
784 <TR BGCOLOR="white" CLASS="TableRowColor">
785 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
786 <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>
787 <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,
788 <A HREF="../../../com/sleepycat/db/CursorConfig.html" title="class in com.sleepycat.db">CursorConfig</A>&nbsp;config)</CODE>
789
790 <BR>
791 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Opens a cursor for traversing all keys in this index.</TD>
792 </TR>
793 <TR BGCOLOR="white" CLASS="TableRowColor">
794 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
795 <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>
796 <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,
797 <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;fromKey,
798 boolean&nbsp;fromInclusive,
799 <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;toKey,
800 boolean&nbsp;toInclusive,
801 <A HREF="../../../com/sleepycat/db/CursorConfig.html" title="class in com.sleepycat.db">CursorConfig</A>&nbsp;config)</CODE>
802
803 <BR>
804 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Opens a cursor for traversing keys in a key range.</TD>
805 </TR>
806 <TR BGCOLOR="white" CLASS="TableRowColor">
807 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
808 <CODE>&nbsp;<A HREF="http://download.oracle.com/javase/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>
809 <TD><CODE><B><A HREF="../../../com/sleepycat/persist/EntityIndex.html#map()">map</A></B>()</CODE>
810
811 <BR>
812 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a standard Java map based on this entity index.</TD>
813 </TR>
814 <TR BGCOLOR="white" CLASS="TableRowColor">
815 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
816 <CODE>&nbsp;<A HREF="http://download.oracle.com/javase/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>
817 <TD><CODE><B><A HREF="../../../com/sleepycat/persist/EntityIndex.html#sortedMap()">sortedMap</A></B>()</CODE>
818
819 <BR>
820 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a standard Java sorted map based on this entity index.</TD>
821 </TR>
822 </TABLE>
823 &nbsp;
824 <P>
825
826 <!-- ============ METHOD DETAIL ========== -->
827
828 <A NAME="method_detail"><!-- --></A>
829 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
830 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
831 <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
832 <B>Method Detail</B></FONT></TH>
833 </TR>
834 </TABLE>
835
836 <A NAME="contains(java.lang.Object)"><!-- --></A><A NAME="contains(K)"><!-- --></A><H3>
837 contains</H3>
838 <PRE>
839 boolean <B>contains</B>(<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;key)
840 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
841 <DL>
842 <DD>Checks for existence of a key in this index.
843
844 <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>
845 <P>
846 <DD><DL>
847 <DT><B>Parameters:</B><DD><CODE>key</CODE> - the key to search for.
848 <DT><B>Returns:</B><DD>whether the key exists in the index.
849 <DT><B>Throws:</B>
850 <DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - the base class for all BDB exceptions.</DL>
851 </DD>
852 </DL>
853 <HR>
854
855 <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>
856 contains</H3>
857 <PRE>
858 boolean <B>contains</B>(<A HREF="../../../com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db">Transaction</A>&nbsp;txn,
859 <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;key,
860 <A HREF="../../../com/sleepycat/db/LockMode.html" title="class in com.sleepycat.db">LockMode</A>&nbsp;lockMode)
861 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
862 <DL>
863 <DD>Checks for existence of a key in this index.
864 <P>
865 <DD><DL>
866 <DT><B>Parameters:</B><DD><CODE>txn</CODE> - the transaction used to protect this operation, or null
867 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
868 use <A HREF="../../../com/sleepycat/db/LockMode.html#DEFAULT"><CODE>LockMode.DEFAULT</CODE></A>.
869 <DT><B>Returns:</B><DD>whether the key exists in the index.
870 <DT><B>Throws:</B>
871 <DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - the base class for all BDB exceptions.</DL>
872 </DD>
873 </DL>
874 <HR>
875
876 <A NAME="get(java.lang.Object)"><!-- --></A><A NAME="get(K)"><!-- --></A><H3>
877 get</H3>
878 <PRE>
879 <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)
880 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
881 <DL>
882 <DD>Gets an entity via a key of this index.
883
884 <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>
885 <P>
886 <DD><DL>
887 <DT><B>Parameters:</B><DD><CODE>key</CODE> - the key to search for.
888 <DT><B>Returns:</B><DD>the value mapped to the given key, or null if the key is not
889 present in the index.
890 <DT><B>Throws:</B>
891 <DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - the base class for all BDB exceptions.</DL>
892 </DD>
893 </DL>
894 <HR>
895
896 <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>
897 get</H3>
898 <PRE>
899 <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,
900 <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;key,
901 <A HREF="../../../com/sleepycat/db/LockMode.html" title="class in com.sleepycat.db">LockMode</A>&nbsp;lockMode)
902 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
903 <DL>
904 <DD>Gets an entity via a key of this index.
905 <P>
906 <DD><DL>
907 <DT><B>Parameters:</B><DD><CODE>txn</CODE> - the transaction used to protect this operation, or null
908 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
909 use <A HREF="../../../com/sleepycat/db/LockMode.html#DEFAULT"><CODE>LockMode.DEFAULT</CODE></A>.
910 <DT><B>Returns:</B><DD>the value mapped to the given key, or null if the key is not
911 present in the index.
912 <DT><B>Throws:</B>
913 <DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - the base class for all BDB exceptions.</DL>
914 </DD>
915 </DL>
916 <HR>
917
918 <A NAME="count()"><!-- --></A><H3>
919 count</H3>
920 <PRE>
921 long <B>count</B>()
922 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
923 <DL>
924 <DD>Returns a non-transactional count of the entities in this index.
925
926 <p>This operation is faster than obtaining a count by scanning the index
927 manually, and will not perturb the current contents of the cache.
928 However, the count is not guaranteed to be accurate if there are
929 concurrent updates. Note that this method does scan a significant
930 portion of the index and should be considered a fairly expensive
931 operation.</p>
932 <P>
933 <DD><DL>
934
935 <DT><B>Returns:</B><DD>the number of entities in this index.
936 <DT><B>Throws:</B>
937 <DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - the base class for all BDB exceptions.</DL>
938 </DD>
939 </DL>
940 <HR>
941
942 <A NAME="delete(java.lang.Object)"><!-- --></A><A NAME="delete(K)"><!-- --></A><H3>
943 delete</H3>
944 <PRE>
945 boolean <B>delete</B>(<A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;key)
946 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
947 <DL>
948 <DD>Deletes all entities with a given index key.
949
950 <p>Auto-commit is used implicitly if the store is transactional.</p>
951 <P>
952 <DD><DL>
953 <DT><B>Parameters:</B><DD><CODE>key</CODE> - the key to search for.
954 <DT><B>Returns:</B><DD>whether any entities were deleted.
955 <DT><B>Throws:</B>
956 <DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - the base class for all BDB exceptions.</DL>
957 </DD>
958 </DL>
959 <HR>
960
961 <A NAME="delete(com.sleepycat.db.Transaction,java.lang.Object)"><!-- --></A><A NAME="delete(com.sleepycat.db.Transaction, K)"><!-- --></A><H3>
962 delete</H3>
963 <PRE>
964 boolean <B>delete</B>(<A HREF="../../../com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db">Transaction</A>&nbsp;txn,
965 <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;key)
966 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
967 <DL>
968 <DD>Deletes all entities with a given index key.
969 <P>
970 <DD><DL>
971 <DT><B>Parameters:</B><DD><CODE>txn</CODE> - the transaction used to protect this operation, null to use
972 auto-commit, or null if the store is non-transactional.<DD><CODE>key</CODE> - the key to search for.
973 <DT><B>Returns:</B><DD>whether any entities were deleted.
974 <DT><B>Throws:</B>
975 <DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - the base class for all BDB exceptions.</DL>
976 </DD>
977 </DL>
978 <HR>
979
980 <A NAME="keys()"><!-- --></A><H3>
981 keys</H3>
982 <PRE>
983 <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>()
984 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
985 <DL>
986 <DD>Opens a cursor for traversing all keys in this index.
987
988 <p>The operations performed with the cursor will not be transaction
989 protected, and <A HREF="../../../com/sleepycat/db/CursorConfig.html#DEFAULT"><CODE>CursorConfig.DEFAULT</CODE></A> is used implicitly. If the
990 store is transactional, the cursor may not be used to update or delete
991 entities.</p>
992 <P>
993 <DD><DL>
994
995 <DT><B>Returns:</B><DD>the cursor.
996 <DT><B>Throws:</B>
997 <DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - the base class for all BDB exceptions.</DL>
998 </DD>
999 </DL>
1000 <HR>
1001
1002 <A NAME="keys(com.sleepycat.db.Transaction, com.sleepycat.db.CursorConfig)"><!-- --></A><H3>
1003 keys</H3>
1004 <PRE>
1005 <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,
1006 <A HREF="../../../com/sleepycat/db/CursorConfig.html" title="class in com.sleepycat.db">CursorConfig</A>&nbsp;config)
1007 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1008 <DL>
1009 <DD>Opens a cursor for traversing all keys in this index.
1010 <P>
1011 <DD><DL>
1012 <DT><B>Parameters:</B><DD><CODE>txn</CODE> - the transaction used to protect all operations performed with
1013 the cursor, or null if the operations should not be transaction
1014 protected. If the store is non-transactional, null must be specified.
1015 For a transactional store the transaction is optional for read-only
1016 access and required for read-write access.<DD><CODE>config</CODE> - the cursor configuration that determines the default lock
1017 mode used for all cursor operations, or null to implicitly use <A HREF="../../../com/sleepycat/db/CursorConfig.html#DEFAULT"><CODE>CursorConfig.DEFAULT</CODE></A>.
1018 <DT><B>Returns:</B><DD>the cursor.
1019 <DT><B>Throws:</B>
1020 <DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - the base class for all BDB exceptions.</DL>
1021 </DD>
1022 </DL>
1023 <HR>
1024
1025 <A NAME="entities()"><!-- --></A><H3>
1026 entities</H3>
1027 <PRE>
1028 <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>()
1029 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1030 <DL>
1031 <DD>Opens a cursor for traversing all entities in this index.
1032
1033 <p>The operations performed with the cursor will not be transaction
1034 protected, and <A HREF="../../../com/sleepycat/db/CursorConfig.html#DEFAULT"><CODE>CursorConfig.DEFAULT</CODE></A> is used implicitly. If the
1035 store is transactional, the cursor may not be used to update or delete
1036 entities.</p>
1037 <P>
1038 <DD><DL>
1039
1040 <DT><B>Returns:</B><DD>the cursor.
1041 <DT><B>Throws:</B>
1042 <DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - the base class for all BDB exceptions.</DL>
1043 </DD>
1044 </DL>
1045 <HR>
1046
1047 <A NAME="entities(com.sleepycat.db.Transaction, com.sleepycat.db.CursorConfig)"><!-- --></A><H3>
1048 entities</H3>
1049 <PRE>
1050 <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,
1051 <A HREF="../../../com/sleepycat/db/CursorConfig.html" title="class in com.sleepycat.db">CursorConfig</A>&nbsp;config)
1052 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1053 <DL>
1054 <DD>Opens a cursor for traversing all entities in this index.
1055 <P>
1056 <DD><DL>
1057 <DT><B>Parameters:</B><DD><CODE>txn</CODE> - the transaction used to protect all operations performed with
1058 the cursor, or null if the operations should not be transaction
1059 protected. If the store is non-transactional, null must be specified.
1060 For a transactional store the transaction is optional for read-only
1061 access and required for read-write access.<DD><CODE>config</CODE> - the cursor configuration that determines the default lock
1062 mode used for all cursor operations, or null to implicitly use <A HREF="../../../com/sleepycat/db/CursorConfig.html#DEFAULT"><CODE>CursorConfig.DEFAULT</CODE></A>.
1063 <DT><B>Returns:</B><DD>the cursor.
1064 <DT><B>Throws:</B>
1065 <DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - the base class for all BDB exceptions.</DL>
1066 </DD>
1067 </DL>
1068 <HR>
1069
1070 <A NAME="keys(java.lang.Object,boolean,java.lang.Object,boolean)"><!-- --></A><A NAME="keys(K, boolean, K, boolean)"><!-- --></A><H3>
1071 keys</H3>
1072 <PRE>
1073 <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,
1074 boolean&nbsp;fromInclusive,
1075 <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;toKey,
1076 boolean&nbsp;toInclusive)
1077 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1078 <DL>
1079 <DD>Opens a cursor for traversing keys in a key range.
1080
1081 <p>The operations performed with the cursor will not be transaction
1082 protected, and <A HREF="../../../com/sleepycat/db/CursorConfig.html#DEFAULT"><CODE>CursorConfig.DEFAULT</CODE></A> is used implicitly. If the
1083 store is transactional, the cursor may not be used to update or delete
1084 entities.</p>
1085 <P>
1086 <DD><DL>
1087 <DT><B>Parameters:</B><DD><CODE>fromKey</CODE> - is the lower bound of the key range, or null if the range
1088 has no lower bound.<DD><CODE>fromInclusive</CODE> - is true if keys greater than or equal to fromKey
1089 should be included in the key range, or false if only keys greater than
1090 fromKey should be included.<DD><CODE>toKey</CODE> - is the upper bound of the key range, or null if the range
1091 has no upper bound.<DD><CODE>toInclusive</CODE> - is true if keys less than or equal to toKey should be
1092 included in the key range, or false if only keys less than toKey should
1093 be included.
1094 <DT><B>Returns:</B><DD>the cursor.
1095 <DT><B>Throws:</B>
1096 <DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - the base class for all BDB exceptions.</DL>
1097 </DD>
1098 </DL>
1099 <HR>
1100
1101 <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>
1102 keys</H3>
1103 <PRE>
1104 <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,
1105 <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;fromKey,
1106 boolean&nbsp;fromInclusive,
1107 <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;toKey,
1108 boolean&nbsp;toInclusive,
1109 <A HREF="../../../com/sleepycat/db/CursorConfig.html" title="class in com.sleepycat.db">CursorConfig</A>&nbsp;config)
1110 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1111 <DL>
1112 <DD>Opens a cursor for traversing keys in a key range.
1113 <P>
1114 <DD><DL>
1115 <DT><B>Parameters:</B><DD><CODE>txn</CODE> - the transaction used to protect all operations performed with
1116 the cursor, or null if the operations should not be transaction
1117 protected. If the store is non-transactional, null must be specified.
1118 For a transactional store the transaction is optional for read-only
1119 access and required for read-write access.<DD><CODE>fromKey</CODE> - is the lower bound of the key range, or null if the range
1120 has no lower bound.<DD><CODE>fromInclusive</CODE> - is true if keys greater than or equal to fromKey
1121 should be included in the key range, or false if only keys greater than
1122 fromKey should be included.<DD><CODE>toKey</CODE> - is the upper bound of the key range, or null if the range
1123 has no upper bound.<DD><CODE>toInclusive</CODE> - is true if keys less than or equal to toKey should be
1124 included in the key range, or false if only keys less than toKey should
1125 be included.<DD><CODE>config</CODE> - the cursor configuration that determines the default lock
1126 mode used for all cursor operations, or null to implicitly use <A HREF="../../../com/sleepycat/db/CursorConfig.html#DEFAULT"><CODE>CursorConfig.DEFAULT</CODE></A>.
1127 <DT><B>Returns:</B><DD>the cursor.
1128 <DT><B>Throws:</B>
1129 <DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - the base class for all BDB exceptions.</DL>
1130 </DD>
1131 </DL>
1132 <HR>
1133
1134 <A NAME="entities(java.lang.Object,boolean,java.lang.Object,boolean)"><!-- --></A><A NAME="entities(K, boolean, K, boolean)"><!-- --></A><H3>
1135 entities</H3>
1136 <PRE>
1137 <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,
1138 boolean&nbsp;fromInclusive,
1139 <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;toKey,
1140 boolean&nbsp;toInclusive)
1141 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1142 <DL>
1143 <DD>Opens a cursor for traversing entities in a key range.
1144
1145 <p>The operations performed with the cursor will not be transaction
1146 protected, and <A HREF="../../../com/sleepycat/db/CursorConfig.html#DEFAULT"><CODE>CursorConfig.DEFAULT</CODE></A> is used implicitly. If the
1147 store is transactional, the cursor may not be used to update or delete
1148 entities.</p>
1149 <P>
1150 <DD><DL>
1151 <DT><B>Parameters:</B><DD><CODE>fromKey</CODE> - is the lower bound of the key range, or null if the range
1152 has no lower bound.<DD><CODE>fromInclusive</CODE> - is true if keys greater than or equal to fromKey
1153 should be included in the key range, or false if only keys greater than
1154 fromKey should be included.<DD><CODE>toKey</CODE> - is the upper bound of the key range, or null if the range
1155 has no upper bound.<DD><CODE>toInclusive</CODE> - is true if keys less than or equal to toKey should be
1156 included in the key range, or false if only keys less than toKey should
1157 be included.
1158 <DT><B>Returns:</B><DD>the cursor.
1159 <DT><B>Throws:</B>
1160 <DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - the base class for all BDB exceptions.</DL>
1161 </DD>
1162 </DL>
1163 <HR>
1164
1165 <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>
1166 entities</H3>
1167 <PRE>
1168 <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,
1169 <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;fromKey,
1170 boolean&nbsp;fromInclusive,
1171 <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="type parameter in EntityIndex">K</A>&nbsp;toKey,
1172 boolean&nbsp;toInclusive,
1173 <A HREF="../../../com/sleepycat/db/CursorConfig.html" title="class in com.sleepycat.db">CursorConfig</A>&nbsp;config)
1174 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1175 <DL>
1176 <DD>Opens a cursor for traversing entities in a key range.
1177 <P>
1178 <DD><DL>
1179 <DT><B>Parameters:</B><DD><CODE>txn</CODE> - the transaction used to protect all operations performed with
1180 the cursor, or null if the operations should not be transaction
1181 protected. If the store is non-transactional, null must be specified.
1182 For a transactional store the transaction is optional for read-only
1183 access and required for read-write access.<DD><CODE>fromKey</CODE> - is the lower bound of the key range, or null if the range
1184 has no lower bound.<DD><CODE>fromInclusive</CODE> - is true if keys greater than or equal to fromKey
1185 should be included in the key range, or false if only keys greater than
1186 fromKey should be included.<DD><CODE>toKey</CODE> - is the upper bound of the key range, or null if the range
1187 has no upper bound.<DD><CODE>toInclusive</CODE> - is true if keys less than or equal to toKey should be
1188 included in the key range, or false if only keys less than toKey should
1189 be included.<DD><CODE>config</CODE> - the cursor configuration that determines the default lock
1190 mode used for all cursor operations, or null to implicitly use <A HREF="../../../com/sleepycat/db/CursorConfig.html#DEFAULT"><CODE>CursorConfig.DEFAULT</CODE></A>.
1191 <DT><B>Returns:</B><DD>the cursor.
1192 <DT><B>Throws:</B>
1193 <DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - the base class for all BDB exceptions.</DL>
1194 </DD>
1195 </DL>
1196 <HR>
1197
1198 <A NAME="map()"><!-- --></A><H3>
1199 map</H3>
1200 <PRE>
1201 <A HREF="http://download.oracle.com/javase/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>
1202 <DL>
1203 <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
1204 to the standard Java collections framework interface.
1205 <P>
1206 <DD><DL>
1207
1208 <DT><B>Returns:</B><DD>the map.</DL>
1209 </DD>
1210 </DL>
1211 <HR>
1212
1213 <A NAME="sortedMap()"><!-- --></A><H3>
1214 sortedMap</H3>
1215 <PRE>
1216 <A HREF="http://download.oracle.com/javase/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>
1217 <DL>
1218 <DD>Returns a standard Java sorted map based on this entity index. The
1219 <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
1220 to the standard Java collections framework interface.
1221 <P>
1222 <DD><DL>
1223
1224 <DT><B>Returns:</B><DD>the map.</DL>
1225 </DD>
1226 </DL>
1227 <!-- ========= END OF CLASS DATA ========= -->
1228 <HR>
1229
1230
1231 <!-- ======= START OF BOTTOM NAVBAR ====== -->
1232 <A NAME="navbar_bottom"><!-- --></A>
1233 <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
1234 <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
1235 <TR>
1236 <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
1237 <A NAME="navbar_bottom_firstrow"><!-- --></A>
1238 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
1239 <TR ALIGN="center" VALIGN="top">
1240 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
1241 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
1242 <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
1243 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/EntityIndex.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
1244 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
1245 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
1246 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
1247 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
1248 </TR>
1249 </TABLE>
1250 </TD>
1251 <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
1252 <b>Berkeley DB</b><br><font size="-1"> version 5.3.28</font></EM>
1253 </TD>
1254 </TR>
1255
1256 <TR>
1257 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
1258 &nbsp;<A HREF="../../../com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist"><B>PREV CLASS</B></A>&nbsp;
1259 &nbsp;<A HREF="../../../com/sleepycat/persist/EntityJoin.html" title="class in com.sleepycat.persist"><B>NEXT CLASS</B></A></FONT></TD>
1260 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
1261 <A HREF="../../../index.html?com/sleepycat/persist/EntityIndex.html" target="_top"><B>FRAMES</B></A> &nbsp;
1262 &nbsp;<A HREF="EntityIndex.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
1263 &nbsp;<SCRIPT type="text/javascript">
1264 <!--
1265 if(window==top) {
1266 document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>');
1267 }
1268 //-->
1269 </SCRIPT>
1270 <NOSCRIPT>
1271 <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>
1272 </NOSCRIPT>
1273
1274
1275 </FONT></TD>
1276 </TR>
1277 <TR>
1278 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
1279 SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
1280 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
1281 DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
1282 </TR>
1283 </TABLE>
1284 <A NAME="skip-navbar_bottom"></A>
1285 <!-- ======== END OF BOTTOM NAVBAR ======= -->
1286
1287 <HR>
1288 <font size=1>Copyright (c) 1996, 2013 Oracle and/or its affiliates. All rights reserved.</font>
1289 </BODY>
1290 </HTML>