1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<!--NewPage-->
3<HTML>
4<HEAD>
5<!-- Generated by javadoc (build 1.5.0) on Thu May 15 17:17:33 EDT 2008 -->
6<TITLE>
7SecondaryIndex (Oracle - Berkeley DB Java API)
8</TITLE>
9
10<META NAME="keywords" CONTENT="com.sleepycat.persist.SecondaryIndex class">
11
12<LINK REL ="stylesheet" TYPE="text/css" HREF="/style.css" TITLE="Style">
13
14<SCRIPT type="text/javascript">
15function windowTitle()
16{
17    parent.document.title="SecondaryIndex (Oracle - Berkeley DB Java API)";
18}
19</SCRIPT>
20<NOSCRIPT>
21</NOSCRIPT>
22
23</HEAD>
24
25<BODY BGCOLOR="white" onload="windowTitle();">
26
27
28<!-- ========= START OF TOP NAVBAR ======= -->
29<A NAME="navbar_top"><!-- --></A>
30<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
31<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
32<TR>
33<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
34<A NAME="navbar_top_firstrow"><!-- --></A>
35<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
36  <TR ALIGN="center" VALIGN="top">
37  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="/overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
38  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
39  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
40  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/SecondaryIndex.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
41  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
42  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="/deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
43  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="/index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
44  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="/help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
45  </TR>
46</TABLE>
47</TD>
48<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
49<b>Berkeley DB</b><br><font size="-1"> version 4.7.25</font></EM>
50</TD>
51</TR>
52
53<TR>
54<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
55&nbsp;<A HREF="/com/sleepycat/persist/PrimaryIndex.html" title="class in com.sleepycat.persist"><B>PREV CLASS</B></A>&nbsp;
56&nbsp;<A HREF="/com/sleepycat/persist/StoreConfig.html" title="class in com.sleepycat.persist"><B>NEXT CLASS</B></A></FONT></TD>
57<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
58  <A HREF="/index.html?com/sleepycat/persist/SecondaryIndex.html" target="_top"><B>FRAMES</B></A>  &nbsp;
59&nbsp;<A HREF="SecondaryIndex.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
60&nbsp;<SCRIPT type="text/javascript">
61  <!--
62  if(window==top) {
63    document.writeln('<A HREF="/allclasses-noframe.html"><B>All Classes</B></A>');
64  }
65  //-->
66</SCRIPT>
67<NOSCRIPT>
68  <A HREF="/allclasses-noframe.html"><B>All Classes</B></A>
69</NOSCRIPT>
70
71
72</FONT></TD>
73</TR>
74<TR>
75<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
76  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
77<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
78DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
79</TR>
80</TABLE>
81<A NAME="skip-navbar_top"></A>
82<!-- ========= END OF TOP NAVBAR ========= -->
83
84<HR>
85<!-- ======== START OF CLASS DATA ======== -->
86<H2>
87<FONT SIZE="-1">
88com.sleepycat.persist</FONT>
89<BR>
90Class SecondaryIndex&lt;SK,PK,E&gt;</H2>
91<PRE>
92<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html" title="class or interface in java.lang">java.lang.Object</A>
93  <IMG SRC="/resources/inherit.gif" ALT="extended by "><B>com.sleepycat.persist.SecondaryIndex&lt;SK,PK,E&gt;</B>
94</PRE>
95<DL>
96<DT><B>All Implemented Interfaces:</B> <DD><A HREF="/com/sleepycat/persist/EntityIndex.html" title="interface in com.sleepycat.persist">EntityIndex</A>&lt;SK,E&gt;</DD>
97</DL>
98<HR>
99<DL>
100<DT><PRE>public class <B>SecondaryIndex&lt;SK,PK,E&gt;</B><DT>extends <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A></DL>
101</PRE>
102
103<P>
104The secondary index for an entity class and a secondary key.
105
106 <p><code>SecondaryIndex</code> objects are thread-safe.  Multiple threads may
107 safely call the methods of a shared <code>SecondaryIndex</code> object.</p>
108
109 <p><code>SecondaryIndex</code> implements <A HREF="/com/sleepycat/persist/EntityIndex.html" title="interface in com.sleepycat.persist"><CODE>EntityIndex</CODE></A> to map the
110 secondary key type (SK) to the entity type (E).  In other words, entities
111 are accessed by secondary key values.</p>
112
113 <p>The <A HREF="/com/sleepycat/persist/model/SecondaryKey.html" title="annotation in com.sleepycat.persist.model"><CODE>SecondaryKey</CODE></A> annotation may be used to define a secondary key
114 as shown in the following example.</p>
115
116 <pre class="code">
117 @Entity
118 class Employee {
119
120     @PrimaryKey
121     long id;
122
123     @SecondaryKey(relate=MANY_TO_ONE)
124     String department;
125
126     String name;
127
128     private Employee() {}
129 }</pre>
130
131 <p>Before obtaining a <code>SecondaryIndex</code>, the <A HREF="/com/sleepycat/persist/PrimaryIndex.html" title="class in com.sleepycat.persist"><CODE>PrimaryIndex</CODE></A> must
132 be obtained for the entity class.  To obtain the <code>SecondaryIndex</code> call
133 <A HREF="/com/sleepycat/persist/EntityStore.html#getSecondaryIndex(com.sleepycat.persist.PrimaryIndex, java.lang.Class, java.lang.String)"><CODE>EntityStore.getSecondaryIndex</CODE></A>, passing
134 the primary index, the secondary key class and the secondary key name.  For
135 example:</p>
136
137 <pre class="code">
138 EntityStore store = new EntityStore(...);
139
140 <code>PrimaryIndex&lt;Long,Employee&gt;</code> primaryIndex =
141     store.getPrimaryIndex(Long.class, Employee.class);
142
143 <code>SecondaryIndex&lt;String,Long,Employee&gt;</code> secondaryIndex =
144     store.getSecondaryIndex(primaryIndex, String.class, "department");</pre>
145
146 <p>Since <code>SecondaryIndex</code> implements the <A HREF="/com/sleepycat/persist/EntityIndex.html" title="interface in com.sleepycat.persist"><CODE>EntityIndex</CODE></A>
147 interface, it shares the common index methods for retrieving and deleting
148 entities, opening cursors and using transactions.  See <A HREF="/com/sleepycat/persist/EntityIndex.html" title="interface in com.sleepycat.persist"><CODE>EntityIndex</CODE></A>
149 for more information on these topics.</p>
150
151 <p><code>SecondaryIndex</code> does <em>not</em> provide methods for inserting
152 and updating entities.  That must be done using the <A HREF="/com/sleepycat/persist/PrimaryIndex.html" title="class in com.sleepycat.persist"><CODE>PrimaryIndex</CODE></A>.</p>
153
154 <p>Note that a <code>SecondaryIndex</code> has three type parameters <code>&lt;SK,PK,E&gt;</code> or in the example <code>&lt;String,Long,Employee&gt;</code> while a <A HREF="/com/sleepycat/persist/PrimaryIndex.html" title="class in com.sleepycat.persist"><CODE>PrimaryIndex</CODE></A> has only two type parameters <code>&lt;PK,E&gt;</code> or <code>&lt;Long,Employee&gt;</code>.  This is because a <code>SecondaryIndex</code> has an extra
155 level of mapping:  It maps from secondary key to primary key, and then from
156 primary key to entity.  For example, consider this entity:</p>
157
158 <p><table class="code" border="1">
159   <tr><th>ID</th><th>Department</th><th>Name</th></tr>
160   <tr><td>1</td><td>Engineering</td><td>Jane Smith</td></tr>
161 </table></p>
162
163 <p>The <A HREF="/com/sleepycat/persist/PrimaryIndex.html" title="class in com.sleepycat.persist"><CODE>PrimaryIndex</CODE></A> maps from id directly to the entity, or from
164 primary key 1 to the "Jane Smith" entity in the example.  The <code>SecondaryIndex</code> maps from department to id, or from secondary key
165 "Engineering" to primary key 1 in the example, and then uses the <code>PrimaryIndex</code> to map from the primary key to the entity.</p>
166
167 <p>Because of this extra type parameter and extra level of mapping, a <code>SecondaryIndex</code> can provide more than one mapping, or view, of the entities
168 in the primary index.  The main mapping of a <code>SecondaryIndex</code> is to
169 map from secondary key (SK) to entity (E), or in the example, from the
170 String department key to the Employee entity.  The <code>SecondaryIndex</code>
171 itself, by implementing <code>EntityIndex&lt;SK,E&gt;</code>, provides this
172 mapping.</p>
173
174 <p>The second mapping provided by <code>SecondaryIndex</code> is from secondary
175 key (SK) to primary key (PK), or in the example, from the String department
176 key to the Long id key.  The <A HREF="/com/sleepycat/persist/SecondaryIndex.html#keysIndex"><CODE>keysIndex</CODE></A> method provides this
177 mapping.  When accessing the keys index, the primary key is returned rather
178 than the entity.  When only the primary key is needed and not the entire
179 entity, using the keys index is less expensive than using the secondary
180 index because the primary index does not have to be accessed.</p>
181
182 <p>The third mapping provided by <code>SecondaryIndex</code> is from primary key
183 (PK) to entity (E), for the subset of entities having a given secondary key
184 (SK).  This mapping is provided by the <A HREF="/com/sleepycat/persist/SecondaryIndex.html#subIndex(SK)"><CODE>subIndex(SK)</CODE></A> method.  A
185 sub-index is convenient when you are interested in working with the subset
186 of entities having a particular secondary key value, for example, all
187 employees in a given department.</p>
188
189 <p>All three mappings, along with the mapping provided by the <A HREF="/com/sleepycat/persist/PrimaryIndex.html" title="class in com.sleepycat.persist"><CODE>PrimaryIndex</CODE></A>, are shown using example data in the <A HREF="/com/sleepycat/persist/EntityIndex.html" title="interface in com.sleepycat.persist"><CODE>EntityIndex</CODE></A>
190 interface documentation.  See <A HREF="/com/sleepycat/persist/EntityIndex.html" title="interface in com.sleepycat.persist"><CODE>EntityIndex</CODE></A> for more information.</p>
191
192 <p>Note that when using an index, keys and values are stored and retrieved
193 by value not by reference.  In other words, if an entity object is stored
194 and then retrieved, or retrieved twice, each object will be a separate
195 instance.  For example, in the code below the assertion will always
196 fail.</p>
197 <pre class="code">
198 MyKey key = ...;
199 MyEntity entity1 = index.get(key);
200 MyEntity entity2 = index.get(key);
201 assert entity1 == entity2; // always fails!
202 </pre>
203
204 <h3>One-to-One Relationships</h3>
205
206 <p>A <A HREF="/com/sleepycat/persist/model/Relationship.html#ONE_TO_ONE"><CODE>ONE_TO_ONE</CODE></A> relationship, although less
207 common than other types of relationships, is the simplest type of
208 relationship.  A single entity is related to a single secondary key value.
209 For example:</p>
210
211 <pre class="code">
212 @Entity
213 class Employee {
214
215     @PrimaryKey
216     long id;
217
218     @SecondaryKey(relate=ONE_TO_ONE)
219     String ssn;
220
221     String name;
222
223     private Employee() {}
224 }
225
226 <code>SecondaryIndex&lt;String,Long,Employee&gt;</code> employeeBySsn =
227     store.getSecondaryIndex(primaryIndex, String.class, "ssn");</pre>
228
229 <p>With a <A HREF="/com/sleepycat/persist/model/Relationship.html#ONE_TO_ONE"><CODE>ONE_TO_ONE</CODE></A> relationship, the
230 secondary key must be unique; in other words, no two entities may have the
231 same secondary key value.  If an attempt is made to store an entity having
232 the same secondary key value as another existing entity, a <A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db"><CODE>DatabaseException</CODE></A> will be thrown.</p>
233
234 <p>Because the secondary key is unique, it is useful to lookup entities by
235 secondary key using <A HREF="/com/sleepycat/persist/EntityIndex.html#get(K)"><CODE>EntityIndex.get(K)</CODE></A>.  For example:</p>
236
237 <pre class="code">
238 Employee employee = employeeBySsn.get(mySsn);</pre>
239
240 <h3>Many-to-One Relationships</h3>
241
242 <p>A <A HREF="/com/sleepycat/persist/model/Relationship.html#MANY_TO_ONE"><CODE>MANY_TO_ONE</CODE></A> relationship is the most
243 common type of relationship.  One or more entities is related to a single
244 secondary key value.  For example:</p>
245
246 <pre class="code">
247 @Entity
248 class Employee {
249
250     @PrimaryKey
251     long id;
252
253     @SecondaryKey(relate=MANY_TO_ONE)
254     String department;
255
256     String name;
257
258     private Employee() {}
259 }
260
261 <code>SecondaryIndex&lt;String,Long,Employee&gt;</code> employeeByDepartment =
262     store.getSecondaryIndex(primaryIndex, String.class, "department");</pre>
263
264 <p>With a <A HREF="/com/sleepycat/persist/model/Relationship.html#MANY_TO_ONE"><CODE>MANY_TO_ONE</CODE></A> relationship, the
265 secondary key is not required to be unique; in other words, more than one
266 entity may have the same secondary key value.  In this example, more than
267 one employee may belong to the same department.</p>
268
269 <p>The most convenient way to access the employees in a given department is
270 by using a sub-index.  For example:</p>
271
272 <pre class="code">
273 <code>EntityIndex&lt;Long,Entity&gt;</code> subIndex = employeeByDepartment.subIndex(myDept);
274 <code>EntityCursor&lt;Employee&gt;</code> cursor = subIndex.entities();
275 try {
276     for (Employee entity : cursor) {
277         // Do something with the entity...
278     }
279 } finally {
280     cursor.close();
281 }</pre>
282
283 <h3>One-to-Many Relationships</h3>
284
285 <p>In a <A HREF="/com/sleepycat/persist/model/Relationship.html#ONE_TO_MANY"><CODE>ONE_TO_MANY</CODE></A> relationship, a single
286 entity is related to one or more secondary key values.  For example:</p>
287
288 <pre class="code">
289 @Entity
290 class Employee {
291
292     @PrimaryKey
293     long id;
294
295     @SecondaryKey(relate=ONE_TO_MANY)
296     Set&lt;String&gt; emailAddresses = new HashSet&lt;String&gt;;
297
298     String name;
299
300     private Employee() {}
301 }
302
303 <code>SecondaryIndex&lt;String,Long,Employee&gt;</code> employeeByEmail =
304     store.getSecondaryIndex(primaryIndex, String.class, "emailAddresses");</pre>
305
306 <p>With a <A HREF="/com/sleepycat/persist/model/Relationship.html#ONE_TO_MANY"><CODE>ONE_TO_MANY</CODE></A> relationship, the
307 secondary key must be unique; in other words, no two entities may have the
308 same secondary key value.  In this example, no two employees may have the
309 same email address.  If an attempt is made to store an entity having the
310 same secondary key value as another existing entity, a <A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db"><CODE>DatabaseException</CODE></A> will be thrown.</p>
311
312 <p>Because the secondary key is unique, it is useful to lookup entities by
313 secondary key using <A HREF="/com/sleepycat/persist/EntityIndex.html#get(K)"><CODE>EntityIndex.get(K)</CODE></A>.  For example:</p>
314
315 <pre class="code">
316 Employee employee = employeeByEmail.get(myEmailAddress);</pre>
317
318 <p>The secondary key field for a <A HREF="/com/sleepycat/persist/model/Relationship.html#ONE_TO_MANY"><CODE>ONE_TO_MANY</CODE></A> relationship must be an array or collection type.  To access
319 the email addresses of an employee, simply access the collection field
320 directly.  For example:</p>
321
322 <pre class="code">
323 Employee employee = primaryIndex.get(1); // Get the entity by primary key
324 employee.emailAddresses.add(myNewEmail); // Add an email address
325 primaryIndex.putNoReturn(1, employee);   // Update the entity</pre>
326
327 <h3>Many-to-Many Relationships</h3>
328
329 <p>In a <A HREF="/com/sleepycat/persist/model/Relationship.html#MANY_TO_MANY"><CODE>MANY_TO_MANY</CODE></A> relationship, one
330 or more entities is related to one or more secondary key values.  For
331 example:</p>
332
333 <pre class="code">
334 @Entity
335 class Employee {
336
337     @PrimaryKey
338     long id;
339
340     @SecondaryKey(relate=MANY_TO_MANY)
341     Set&lt;String&gt; organizations = new HashSet&lt;String&gt;;
342
343     String name;
344
345     private Employee() {}
346 }
347
348 <code>SecondaryIndex&lt;String,Long,Employee&gt;</code> employeeByOrganization =
349     store.getSecondaryIndex(primaryIndex, String.class, "organizations");</pre>
350
351 <p>With a <A HREF="/com/sleepycat/persist/model/Relationship.html#MANY_TO_MANY"><CODE>MANY_TO_MANY</CODE></A> relationship, the
352 secondary key is not required to be unique; in other words, more than one
353 entity may have the same secondary key value.  In this example, more than
354 one employee may belong to the same organization.</p>
355
356 <p>The most convenient way to access the employees in a given organization
357 is by using a sub-index.  For example:</p>
358
359 <pre class="code">
360 <code>EntityIndex&lt;Long,Entity&gt;</code> subIndex = employeeByOrganization.subIndex(myOrg);
361 <code>EntityCursor&lt;Employee&gt;</code> cursor = subIndex.entities();
362 try {
363     for (Employee entity : cursor) {
364         // Do something with the entity...
365     }
366 } finally {
367     cursor.close();
368 }</pre>
369
370 <p>The secondary key field for a <A HREF="/com/sleepycat/persist/model/Relationship.html#MANY_TO_MANY"><CODE>MANY_TO_MANY</CODE></A> relationship must be an array or collection type.  To access
371 the organizations of an employee, simply access the collection field
372 directly.  For example:</p>
373
374 <pre class="code">
375 Employee employee = primaryIndex.get(1); // Get the entity by primary key
376 employee.organizations.remove(myOldOrg); // Remove an organization
377 primaryIndex.putNoReturn(1, employee);   // Update the entity</pre>
378
379 <h3>Foreign Key Constraints for Related Entities</h3>
380
381 <p>In all the examples above the secondary key is treated only as a simple
382 value, such as a <code>String</code> department field.  In many cases, that is
383 sufficient.  But in other cases, you may wish to constrain the secondary
384 keys of one entity class to be valid primary keys of another entity
385 class.  For example, a Department entity may also be defined:</p>
386
387 <pre class="code">
388 @Entity
389 class Department {
390
391     @PrimaryKey
392     String name;
393
394     String missionStatement;
395
396     private Department() {}
397 }</pre>
398
399 <p>You may wish to constrain the department field values of the Employee
400 class in the examples above to be valid primary keys of the Department
401 entity class.  In other words, you may wish to ensure that the department
402 field of an Employee will always refer to a valid Department entity.</p>
403
404 <p>You can implement this constraint yourself by validating the department
405 field before you store an Employee.  For example:</p>
406
407 <pre class="code">
408 <code>PrimaryIndex&lt;String,Department&gt;</code> departmentIndex =
409     store.getPrimaryIndex(String.class, Department.class);
410
411 void storeEmployee(Employee employee) throws DatabaseException {
412     if (departmentIndex.contains(employee.department)) {
413         primaryIndex.putNoReturn(employee);
414     } else {
415         throw new IllegalArgumentException("Department does not exist: " +
416                                            employee.department);
417     }
418 }</pre>
419
420 <p>Or, instead you could define the Employee department field as a foreign
421 key, and this validation will be done for you when you attempt to store the
422 Employee entity.  For example:</p>
423
424 <pre class="code">
425 @Entity
426 class Employee {
427
428     @PrimaryKey
429     long id;
430
431     @SecondaryKey(relate=MANY_TO_ONE, relatedEntity=Department.class)
432     String department;
433
434     String name;
435
436     private Employee() {}
437 }</pre>
438
439 <p>The <code>relatedEntity=Department.class</code> above defines the department
440 field as a foreign key that refers to a Department entity.  Whenever a
441 Employee entity is stored, its department field value will be checked to
442 ensure that a Department entity exists with that value as its primary key.
443 If no such Department entity exists, then a <A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db"><CODE>DatabaseException</CODE></A> is
444 thrown, causing the transaction to be aborted (assuming that transactions
445 are used).</p>
446
447 <p>This begs the question:  What happens when a Department entity is deleted
448 while one or more Employee entities have department fields that refer to
449 the deleted department's primary key?  If the department were allowed to be
450 deleted, the foreign key constraint for the Employee department field would
451 be violated, because the Employee department field would refer to a
452 department that does not exist.</p>
453
454 <p>By default, when this situation arises the system does not allow the
455 department to be deleted.  Instead, a <A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db"><CODE>DatabaseException</CODE></A> is thrown,
456 causing the transaction to be aborted.  In this case, in order to delete a
457 department, the department field of all Employee entities must first be
458 updated to refer to a different existing department, or set to null.  This
459 is the responsibility of the application.</p>
460
461 <p>There are two additional ways of handling deletion of a Department
462 entity.  These alternatives are configured using the <A HREF="/com/sleepycat/persist/model/SecondaryKey.html#onRelatedEntityDelete()"><CODE>SecondaryKey.onRelatedEntityDelete()</CODE></A> annotation property.  Setting this
463 property to <A HREF="/com/sleepycat/persist/model/DeleteAction.html#NULLIFY"><CODE>DeleteAction.NULLIFY</CODE></A> causes the Employee department
464 field to be automatically set to null when the department they refer to is
465 deleted.  This may or may not be desirable, depending on application
466 policies.  For example:</p>
467
468 <pre class="code">
469 @Entity
470 class Employee {
471
472     @PrimaryKey
473     long id;
474
475     <code>@SecondaryKey(relate=MANY_TO_ONE, relatedEntity=Department.class,
476                                       onRelatedEntityDelete=NULLIFY)</code>
477     String department;
478
479     String name;
480
481     private Employee() {}
482 }</pre>
483
484 <p>The <A HREF="/com/sleepycat/persist/model/DeleteAction.html#CASCADE"><CODE>DeleteAction.CASCADE</CODE></A> value, on the other hand, causes the
485 Employee entities to be automatically deleted when the department they refer
486 to is deleted.  This is probably not desirable in this particular example,
487 but is useful for parent-child relationships.  For example:</p>
488
489 <pre class="code">
490 @Entity
491 class Order {
492
493     @PrimaryKey
494     long id;
495
496     String description;
497
498     private Order() {}
499 }
500
501 @Entity
502 class OrderItem {
503
504     @PrimaryKey
505     long id;
506
507     <code>@SecondaryKey(relate=MANY_TO_ONE, relatedEntity=Order.class,
508                                       onRelatedEntityDelete=CASCADE)</code>
509     long orderId;
510
511     String description;
512
513     private OrderItem() {}
514 }</pre>
515
516 <p>The OrderItem orderId field refers to its "parent" Order entity.  When an
517 Order entity is deleted, it may be useful to automatically delete its
518 "child" OrderItem entities.</p>
519
520 <p>For more information, see <A HREF="/com/sleepycat/persist/model/SecondaryKey.html#onRelatedEntityDelete()"><CODE>SecondaryKey.onRelatedEntityDelete()</CODE></A>.</p>
521
522 <h3>One-to-Many versus Many-to-One for Related Entities</h3>
523
524 <p>When there is a conceptual Many-to-One relationship such as Employee to
525 Department as illustrated in the examples above, the relationship may be
526 implemented either as Many-to-One in the Employee class or as One-to-Many in
527 the Department class.</p>
528
529 <p>Here is the Many-to-One approach.</p>
530
531 <pre class="code">
532 @Entity
533 class Employee {
534
535     @PrimaryKey
536     long id;
537
538     @SecondaryKey(relate=MANY_TO_ONE, relatedEntity=Department.class)
539     String department;
540
541     String name;
542
543     private Employee() {}
544 }
545
546 @Entity
547 class Department {
548
549     @PrimaryKey
550     String name;
551
552     String missionStatement;
553
554     private Department() {}
555 }</pre>
556
557 <p>And here is the One-to-Many approach.</p>
558
559 <pre class="code">
560 @Entity
561 class Employee {
562
563     @PrimaryKey
564     long id;
565
566     String name;
567
568     private Employee() {}
569 }
570
571 @Entity
572 class Department {
573
574     @PrimaryKey
575     String name;
576
577     String missionStatement;
578
579     @SecondaryKey(relate=ONE_TO_MANY, relatedEntity=Employee.class)
580     Set&lt;Long&gt; employees = new HashSet&lt;Long&gt;;
581
582     private Department() {}
583 }</pre>
584
585 <p>Which approach is best?  The Many-to-One approach better handles large
586 number of entities on the to-Many side of the relationship because it
587 doesn't store a collection of keys as an entity field.  With Many-to-One a
588 Btree is used to store the collection of keys and the Btree can easily
589 handle very large numbers of keys.  With One-to-Many, each time a related
590 key is added or removed the entity on the One side of the relationship,
591 along with the complete collection of related keys, must be updated.
592 Therefore, if large numbers of keys may be stored per relationship,
593 Many-to-One is recommended.</p>
594
595 <p>If the number of entities per relationship is not a concern, then you may
596 wish to choose the approach that is most natural in your application data
597 model.  For example, if you think of a Department as containing employees
598 and you wish to modify the Department object each time an employee is added
599 or removed, then you may wish to store a collection of Employee keys in the
600 Department object (One-to-Many).</p>
601
602 <p>Note that if you have a One-to-Many relationship and there is no related
603 entity, then you don't have a choice -- you have to use One-to-Many because
604 there is no entity on the to-Many side of the relationship where a
605 Many-to-One key could be defined.  An example is the Employee to email
606 addresses relationship discussed above:</p>
607
608 <pre class="code">
609 @Entity
610 class Employee {
611
612     @PrimaryKey
613     long id;
614
615     @SecondaryKey(relate=ONE_TO_MANY)
616     Set&lt;String&gt; emailAddresses = new HashSet&lt;String&gt;;
617
618     String name;
619
620     private Employee() {}
621 }</pre>
622
623 <p>For sake of argument imagine that each employee has thousands of email
624 addresses and employees frequently add and remove email addresses.  To
625 avoid the potential performance problems associated with updating the
626 Employee entity every time an email address is added or removed, you could
627 create an EmployeeEmailAddress entity and use a Many-to-One relationship as
628 shown below:</p>
629
630 <pre class="code">
631 @Entity
632 class Employee {
633
634     @PrimaryKey
635     long id;
636
637     String name;
638
639     private Employee() {}
640 }
641
642 @Entity
643 class EmployeeEmailAddress {
644
645     @PrimaryKey
646     String emailAddress;
647
648     @SecondaryKey(relate=MANY_TO_ONE, relatedEntity=Employee.class)
649     long employeeId;
650
651     private EmployeeEmailAddress() {}
652 }</pre>
653
654 <h3>Key Placement with Many-to-Many for Related Entities</h3>
655
656 <p>As discussed in the section above, one drawback of a to-Many relationship
657 (One-to-Many was discussed above and Many-to-Many is discussed here) is that
658 it requires storing a collection of keys in an entity.  Each time a key is
659 added or removed, the containing entity must be updated.  This has potential
660 performance problems when there are large numbers of entities on the to-Many
661 side of the relationship, in other words, when there are large numbers of
662 keys in each secondary key field collection.</p>
663
664 <p>If you have a Many-to-Many relationship with a reasonably small number of
665 entities on one side of the relationship and a large number of entities on
666 the other side, you can avoid the potential performance problems by defining
667 the secondary key field on the side with a small number of entities.</p>
668
669 <p>For example, in an Employee-to-Organization relationship, the number of
670 organizations per employee will normally be reasonably small but the number
671 of employees per organization may be very large.  Therefore, to avoid
672 potential performance problems, the secondary key field should be defined in
673 the Employee class as shown below.</p>
674
675 <pre class="code">
676 @Entity
677 class Employee {
678
679     @PrimaryKey
680     long id;
681
682     @SecondaryKey(relate=MANY_TO_MANY, relatedEntity=Organization.class)
683     Set&lt;String&gt; organizations = new HashSet&lt;String&gt;;
684
685     String name;
686
687     private Employee() {}
688 }
689
690 @Entity
691 class Organization {
692
693     @PrimaryKey
694     String name;
695
696     String description;
697 }</pre>
698
699 <p>If instead a <code>Set&lt;Long&gt; members</code> key had been defined in the
700 Organization class, this set could potentially have a large number of
701 elements and performance problems could result.</p>
702
703 <h3>Many-to-Many Versus a Relationship Entity</h3>
704
705 <p>If you have a Many-to-Many relationship with a large number of entities
706 on <em>both</em> sides of the relationship, you can avoid the potential
707 performance problems by using a <em>relationship entity</em>.  A
708 relationship entity defines the relationship between two other entities
709 using two Many-to-One relationships.</p>
710
711 <p>Imagine a relationship between cars and trucks indicating whenever a
712 particular truck was passed on the road by a particular car.  A given car
713 may pass a large number of trucks and a given truck may be passed by a large
714 number of cars.  First look at a Many-to-Many relationship between these two
715 entities:</p>
716
717 <pre class="code">
718 @Entity
719 class Car {
720
721     @PrimaryKey
722     String licenseNumber;
723
724     @SecondaryKey(relate=MANY_TO_MANY, relatedEntity=Truck.class)
725     Set&lt;String&gt; trucksPassed = new HashSet&lt;String&gt;;
726
727     String color;
728
729     private Car() {}
730 }
731
732 @Entity
733 class Truck {
734
735     @PrimaryKey
736     String licenseNumber;
737
738     int tons;
739
740     private Truck() {}
741 }</pre>
742
743 <p>With the Many-to-Many approach above, the <code>trucksPassed</code> set could
744 potentially have a large number of elements and performance problems could
745 result.</p>
746
747 <p>To apply the relationship entity approach we define a new entity class
748 named CarPassedTruck representing a single truck passed by a single car.  We
749 remove the secondary key from the Car class and use two secondary keys in
750 the CarPassedTruck class instead.</p>
751
752 <pre class="code">
753 @Entity
754 class Car {
755
756     @PrimaryKey
757     String licenseNumber;
758
759     String color;
760
761     private Car() {}
762 }
763
764 @Entity
765 class Truck {
766
767     @PrimaryKey
768     String licenseNumber;
769
770     int tons;
771
772     private Truck() {}
773 }
774
775 @Entity
776 class CarPassedTruck {
777
778     @PrimaryKey
779     long id;
780
781     @SecondaryKey(relate=MANY_TO_ONE, relatedEntity=Car.class)
782     String carLicense;
783
784     @SecondaryKey(relate=MANY_TO_ONE, relatedEntity=Truck.class)
785     String truckLicense;
786
787     private CarPassedTruck() {}
788 }</pre>
789
790 <p>The CarPassedTruck entity can be used to access the relationship by car
791 license or by truck license.</p>
792
793 <p>You may use the relationship entity approach because of the potential
794 performance problems mentioned above.  Or, you may choose to use this
795 approach in order to store other information about the relationship.  For
796 example, if for each car that passes a truck you wish to record how much
797 faster the car was going than the truck, then a relationship entity is the
798 logical place to store that property.  In the example below the
799 speedDifference property is added to the CarPassedTruck class.</p>
800
801 <pre class="code">
802 @Entity
803 class CarPassedTruck {
804
805     @PrimaryKey
806     long id;
807
808     @SecondaryKey(relate=MANY_TO_ONE, relatedEntity=Car.class)
809     String carLicense;
810
811     @SecondaryKey(relate=MANY_TO_ONE, relatedEntity=Truck.class)
812     String truckLicense;
813
814     int speedDifference;
815
816     private CarPassedTruck() {}
817 }</pre>
818
819 <p>Be aware that the relationship entity approach adds overhead compared to
820 Many-to-Many.  There is one additional entity and one additional secondary
821 key.  These factors should be weighed against its advantages and the
822 relevant application access patterns should be considered.</p>
823<P>
824
825<P>
826<HR>
827
828<P>
829
830<!-- ======== CONSTRUCTOR SUMMARY ======== -->
831
832<A NAME="constructor_summary"><!-- --></A>
833<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
834<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
835<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
836<B>Constructor Summary</B></FONT></TH>
837</TR>
838<TR BGCOLOR="white" CLASS="TableRowColor">
839<TD><CODE><B><A HREF="/com/sleepycat/persist/SecondaryIndex.html#SecondaryIndex(com.sleepycat.db.SecondaryDatabase, com.sleepycat.db.Database, com.sleepycat.persist.PrimaryIndex, java.lang.Class, com.sleepycat.bind.EntryBinding)">SecondaryIndex</A></B>(<A HREF="/com/sleepycat/db/SecondaryDatabase.html" title="class in com.sleepycat.db">SecondaryDatabase</A>&nbsp;database,
840               <A HREF="/com/sleepycat/db/Database.html" title="class in com.sleepycat.db">Database</A>&nbsp;keysDatabase,
841               <A HREF="/com/sleepycat/persist/PrimaryIndex.html" title="class in com.sleepycat.persist">PrimaryIndex</A>&lt;<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">PK</A>,<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">E</A>&gt;&nbsp;primaryIndex,
842               <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html" title="class or interface in java.lang">Class</A>&lt;<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">SK</A>&gt;&nbsp;secondaryKeyClass,
843               <A HREF="/com/sleepycat/bind/EntryBinding.html" title="interface in com.sleepycat.bind">EntryBinding</A>&nbsp;secondaryKeyBinding)</CODE>
844
845<BR>
846&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Creates a secondary index without using an <code>EntityStore</code>.</TD>
847</TR>
848</TABLE>
849&nbsp;
850<!-- ========== METHOD SUMMARY =========== -->
851
852<A NAME="method_summary"><!-- --></A>
853<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
854<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
855<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
856<B>Method Summary</B></FONT></TH>
857</TR>
858<TR BGCOLOR="white" CLASS="TableRowColor">
859<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
860<CODE>&nbsp;boolean</CODE></FONT></TD>
861<TD><CODE><B><A HREF="/com/sleepycat/persist/SecondaryIndex.html#contains(K)">contains</A></B>(K&nbsp;key)</CODE>
862
863<BR>
864&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Checks for existence of a key in this index.</TD>
865</TR>
866<TR BGCOLOR="white" CLASS="TableRowColor">
867<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
868<CODE>&nbsp;boolean</CODE></FONT></TD>
869<TD><CODE><B><A HREF="/com/sleepycat/persist/SecondaryIndex.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,
870         K&nbsp;key,
871         <A HREF="/com/sleepycat/db/LockMode.html" title="class in com.sleepycat.db">LockMode</A>&nbsp;lockMode)</CODE>
872
873<BR>
874&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Checks for existence of a key in this index.</TD>
875</TR>
876<TR BGCOLOR="white" CLASS="TableRowColor">
877<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
878<CODE>&nbsp;long</CODE></FONT></TD>
879<TD><CODE><B><A HREF="/com/sleepycat/persist/SecondaryIndex.html#count()">count</A></B>()</CODE>
880
881<BR>
882&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a non-transactional count of the entities in this index.</TD>
883</TR>
884<TR BGCOLOR="white" CLASS="TableRowColor">
885<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
886<CODE>&nbsp;boolean</CODE></FONT></TD>
887<TD><CODE><B><A HREF="/com/sleepycat/persist/SecondaryIndex.html#delete(K)">delete</A></B>(K&nbsp;key)</CODE>
888
889<BR>
890&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deletes all entities with a given index key.</TD>
891</TR>
892<TR BGCOLOR="white" CLASS="TableRowColor">
893<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
894<CODE>&nbsp;boolean</CODE></FONT></TD>
895<TD><CODE><B><A HREF="/com/sleepycat/persist/SecondaryIndex.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,
896       K&nbsp;key)</CODE>
897
898<BR>
899&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deletes all entities with a given index key.</TD>
900</TR>
901<TR BGCOLOR="white" CLASS="TableRowColor">
902<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
903<CODE>&nbsp;<A HREF="/com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;E&gt;</CODE></FONT></TD>
904<TD><CODE><B><A HREF="/com/sleepycat/persist/SecondaryIndex.html#entities()">entities</A></B>()</CODE>
905
906<BR>
907&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Opens a cursor for traversing all entities in this index.</TD>
908</TR>
909<TR BGCOLOR="white" CLASS="TableRowColor">
910<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
911<CODE>&nbsp;<A HREF="/com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;E&gt;</CODE></FONT></TD>
912<TD><CODE><B><A HREF="/com/sleepycat/persist/SecondaryIndex.html#entities(K, boolean, K, boolean)">entities</A></B>(K&nbsp;fromKey,
913         boolean&nbsp;fromInclusive,
914         K&nbsp;toKey,
915         boolean&nbsp;toInclusive)</CODE>
916
917<BR>
918&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Opens a cursor for traversing entities in a key range.</TD>
919</TR>
920<TR BGCOLOR="white" CLASS="TableRowColor">
921<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
922<CODE>&nbsp;<A HREF="/com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;E&gt;</CODE></FONT></TD>
923<TD><CODE><B><A HREF="/com/sleepycat/persist/SecondaryIndex.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,
924         <A HREF="/com/sleepycat/db/CursorConfig.html" title="class in com.sleepycat.db">CursorConfig</A>&nbsp;config)</CODE>
925
926<BR>
927&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Opens a cursor for traversing all entities in this index.</TD>
928</TR>
929<TR BGCOLOR="white" CLASS="TableRowColor">
930<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
931<CODE>&nbsp;<A HREF="/com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;E&gt;</CODE></FONT></TD>
932<TD><CODE><B><A HREF="/com/sleepycat/persist/SecondaryIndex.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,
933         K&nbsp;fromKey,
934         boolean&nbsp;fromInclusive,
935         K&nbsp;toKey,
936         boolean&nbsp;toInclusive,
937         <A HREF="/com/sleepycat/db/CursorConfig.html" title="class in com.sleepycat.db">CursorConfig</A>&nbsp;config)</CODE>
938
939<BR>
940&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Opens a cursor for traversing entities in a key range.</TD>
941</TR>
942<TR BGCOLOR="white" CLASS="TableRowColor">
943<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
944<CODE>&nbsp;<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">E</A></CODE></FONT></TD>
945<TD><CODE><B><A HREF="/com/sleepycat/persist/SecondaryIndex.html#get(SK)">get</A></B>(<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">SK</A>&nbsp;key)</CODE>
946
947<BR>
948&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Gets an entity via a key of this index.</TD>
949</TR>
950<TR BGCOLOR="white" CLASS="TableRowColor">
951<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
952<CODE>&nbsp;<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">E</A></CODE></FONT></TD>
953<TD><CODE><B><A HREF="/com/sleepycat/persist/SecondaryIndex.html#get(com.sleepycat.db.Transaction, SK, com.sleepycat.db.LockMode)">get</A></B>(<A HREF="/com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db">Transaction</A>&nbsp;txn,
954    <A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">SK</A>&nbsp;key,
955    <A HREF="/com/sleepycat/db/LockMode.html" title="class in com.sleepycat.db">LockMode</A>&nbsp;lockMode)</CODE>
956
957<BR>
958&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Gets an entity via a key of this index.</TD>
959</TR>
960<TR BGCOLOR="white" CLASS="TableRowColor">
961<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
962<CODE>&nbsp;<A HREF="/com/sleepycat/db/SecondaryDatabase.html" title="class in com.sleepycat.db">SecondaryDatabase</A></CODE></FONT></TD>
963<TD><CODE><B><A HREF="/com/sleepycat/persist/SecondaryIndex.html#getDatabase()">getDatabase</A></B>()</CODE>
964
965<BR>
966&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the underlying secondary database for this index.</TD>
967</TR>
968<TR BGCOLOR="white" CLASS="TableRowColor">
969<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
970<CODE>&nbsp;<A HREF="/com/sleepycat/bind/EntryBinding.html" title="interface in com.sleepycat.bind">EntryBinding</A></CODE></FONT></TD>
971<TD><CODE><B><A HREF="/com/sleepycat/persist/SecondaryIndex.html#getKeyBinding()">getKeyBinding</A></B>()</CODE>
972
973<BR>
974&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the secondary key binding for the index.</TD>
975</TR>
976<TR BGCOLOR="white" CLASS="TableRowColor">
977<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
978<CODE>&nbsp;<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html" title="class or interface in java.lang">Class</A>&lt;<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">SK</A>&gt;</CODE></FONT></TD>
979<TD><CODE><B><A HREF="/com/sleepycat/persist/SecondaryIndex.html#getKeyClass()">getKeyClass</A></B>()</CODE>
980
981<BR>
982&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the secondary key class for this index.</TD>
983</TR>
984<TR BGCOLOR="white" CLASS="TableRowColor">
985<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
986<CODE>&nbsp;<A HREF="/com/sleepycat/db/Database.html" title="class in com.sleepycat.db">Database</A></CODE></FONT></TD>
987<TD><CODE><B><A HREF="/com/sleepycat/persist/SecondaryIndex.html#getKeysDatabase()">getKeysDatabase</A></B>()</CODE>
988
989<BR>
990&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the underlying secondary database that is not associated with
991 the primary database and is used for the <A HREF="/com/sleepycat/persist/SecondaryIndex.html#keysIndex"><CODE>keysIndex</CODE></A>.</TD>
992</TR>
993<TR BGCOLOR="white" CLASS="TableRowColor">
994<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
995<CODE>&nbsp;<A HREF="/com/sleepycat/persist/PrimaryIndex.html" title="class in com.sleepycat.persist">PrimaryIndex</A>&lt;<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">PK</A>,<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">E</A>&gt;</CODE></FONT></TD>
996<TD><CODE><B><A HREF="/com/sleepycat/persist/SecondaryIndex.html#getPrimaryIndex()">getPrimaryIndex</A></B>()</CODE>
997
998<BR>
999&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the primary index associated with this secondary index.</TD>
1000</TR>
1001<TR BGCOLOR="white" CLASS="TableRowColor">
1002<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
1003<CODE>&nbsp;<A HREF="/com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;K&gt;</CODE></FONT></TD>
1004<TD><CODE><B><A HREF="/com/sleepycat/persist/SecondaryIndex.html#keys()">keys</A></B>()</CODE>
1005
1006<BR>
1007&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Opens a cursor for traversing all keys in this index.</TD>
1008</TR>
1009<TR BGCOLOR="white" CLASS="TableRowColor">
1010<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
1011<CODE>&nbsp;<A HREF="/com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;K&gt;</CODE></FONT></TD>
1012<TD><CODE><B><A HREF="/com/sleepycat/persist/SecondaryIndex.html#keys(K, boolean, K, boolean)">keys</A></B>(K&nbsp;fromKey,
1013     boolean&nbsp;fromInclusive,
1014     K&nbsp;toKey,
1015     boolean&nbsp;toInclusive)</CODE>
1016
1017<BR>
1018&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Opens a cursor for traversing keys in a key range.</TD>
1019</TR>
1020<TR BGCOLOR="white" CLASS="TableRowColor">
1021<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
1022<CODE>&nbsp;<A HREF="/com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;K&gt;</CODE></FONT></TD>
1023<TD><CODE><B><A HREF="/com/sleepycat/persist/SecondaryIndex.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,
1024     <A HREF="/com/sleepycat/db/CursorConfig.html" title="class in com.sleepycat.db">CursorConfig</A>&nbsp;config)</CODE>
1025
1026<BR>
1027&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Opens a cursor for traversing all keys in this index.</TD>
1028</TR>
1029<TR BGCOLOR="white" CLASS="TableRowColor">
1030<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
1031<CODE>&nbsp;<A HREF="/com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;K&gt;</CODE></FONT></TD>
1032<TD><CODE><B><A HREF="/com/sleepycat/persist/SecondaryIndex.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,
1033     K&nbsp;fromKey,
1034     boolean&nbsp;fromInclusive,
1035     K&nbsp;toKey,
1036     boolean&nbsp;toInclusive,
1037     <A HREF="/com/sleepycat/db/CursorConfig.html" title="class in com.sleepycat.db">CursorConfig</A>&nbsp;config)</CODE>
1038
1039<BR>
1040&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Opens a cursor for traversing keys in a key range.</TD>
1041</TR>
1042<TR BGCOLOR="white" CLASS="TableRowColor">
1043<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
1044<CODE>&nbsp;<A HREF="/com/sleepycat/persist/EntityIndex.html" title="interface in com.sleepycat.persist">EntityIndex</A>&lt;<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">SK</A>,<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">PK</A>&gt;</CODE></FONT></TD>
1045<TD><CODE><B><A HREF="/com/sleepycat/persist/SecondaryIndex.html#keysIndex()">keysIndex</A></B>()</CODE>
1046
1047<BR>
1048&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a read-only keys index that maps secondary key to primary key.</TD>
1049</TR>
1050<TR BGCOLOR="white" CLASS="TableRowColor">
1051<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
1052<CODE>&nbsp;<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Map.html" title="class or interface in java.util">Map</A>&lt;<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">SK</A>,<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">E</A>&gt;</CODE></FONT></TD>
1053<TD><CODE><B><A HREF="/com/sleepycat/persist/SecondaryIndex.html#map()">map</A></B>()</CODE>
1054
1055<BR>
1056&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a standard Java map based on this entity index.</TD>
1057</TR>
1058<TR BGCOLOR="white" CLASS="TableRowColor">
1059<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
1060<CODE>&nbsp;<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/SortedMap.html" title="class or interface in java.util">SortedMap</A>&lt;<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">SK</A>,<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">E</A>&gt;</CODE></FONT></TD>
1061<TD><CODE><B><A HREF="/com/sleepycat/persist/SecondaryIndex.html#sortedMap()">sortedMap</A></B>()</CODE>
1062
1063<BR>
1064&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a standard Java sorted map based on this entity index.</TD>
1065</TR>
1066<TR BGCOLOR="white" CLASS="TableRowColor">
1067<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
1068<CODE>&nbsp;<A HREF="/com/sleepycat/persist/EntityIndex.html" title="interface in com.sleepycat.persist">EntityIndex</A>&lt;<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">PK</A>,<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">E</A>&gt;</CODE></FONT></TD>
1069<TD><CODE><B><A HREF="/com/sleepycat/persist/SecondaryIndex.html#subIndex(SK)">subIndex</A></B>(<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">SK</A>&nbsp;key)</CODE>
1070
1071<BR>
1072&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns an index that maps primary key to entity for the subset of
1073 entities having a given secondary key (duplicates).</TD>
1074</TR>
1075</TABLE>
1076&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
1077<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
1078<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
1079<TH ALIGN="left"><B>Methods inherited from class java.lang.<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A></B></TH>
1080</TR>
1081<TR BGCOLOR="white" CLASS="TableRowColor">
1082<TD><CODE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#clone()" title="class or interface in java.lang">clone</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#equals(java.lang.Object)" title="class or interface in java.lang">equals</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#finalize()" title="class or interface in java.lang">finalize</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#getClass()" title="class or interface in java.lang">getClass</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#hashCode()" title="class or interface in java.lang">hashCode</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#notify()" title="class or interface in java.lang">notify</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#notifyAll()" title="class or interface in java.lang">notifyAll</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#toString()" title="class or interface in java.lang">toString</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#wait()" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#wait(long)" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#wait(long, int)" title="class or interface in java.lang">wait</A></CODE></TD>
1083</TR>
1084</TABLE>
1085&nbsp;
1086<P>
1087
1088<!-- ========= CONSTRUCTOR DETAIL ======== -->
1089
1090<A NAME="constructor_detail"><!-- --></A>
1091<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
1092<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
1093<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
1094<B>Constructor Detail</B></FONT></TH>
1095</TR>
1096</TABLE>
1097
1098<A NAME="SecondaryIndex(com.sleepycat.db.SecondaryDatabase, com.sleepycat.db.Database, com.sleepycat.persist.PrimaryIndex, java.lang.Class, com.sleepycat.bind.EntryBinding)"><!-- --></A><H3>
1099SecondaryIndex</H3>
1100<PRE>
1101public <B>SecondaryIndex</B>(<A HREF="/com/sleepycat/db/SecondaryDatabase.html" title="class in com.sleepycat.db">SecondaryDatabase</A>&nbsp;database,
1102                      <A HREF="/com/sleepycat/db/Database.html" title="class in com.sleepycat.db">Database</A>&nbsp;keysDatabase,
1103                      <A HREF="/com/sleepycat/persist/PrimaryIndex.html" title="class in com.sleepycat.persist">PrimaryIndex</A>&lt;<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">PK</A>,<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">E</A>&gt;&nbsp;primaryIndex,
1104                      <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html" title="class or interface in java.lang">Class</A>&lt;<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">SK</A>&gt;&nbsp;secondaryKeyClass,
1105                      <A HREF="/com/sleepycat/bind/EntryBinding.html" title="interface in com.sleepycat.bind">EntryBinding</A>&nbsp;secondaryKeyBinding)
1106               throws <A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1107<DL>
1108<DD>Creates a secondary index without using an <code>EntityStore</code>.
1109 When using an <A HREF="/com/sleepycat/persist/EntityStore.html" title="class in com.sleepycat.persist"><CODE>EntityStore</CODE></A>, call <A HREF="/com/sleepycat/persist/EntityStore.html#getSecondaryIndex(com.sleepycat.persist.PrimaryIndex, java.lang.Class, java.lang.String)"><CODE>getSecondaryIndex</CODE></A> instead.
1110
1111 <p>This constructor is not normally needed and is provided for
1112 applications that wish to use custom bindings along with the Direct
1113 Persistence Layer.  Normally, <A HREF="/com/sleepycat/persist/EntityStore.html#getSecondaryIndex(com.sleepycat.persist.PrimaryIndex, java.lang.Class, java.lang.String)"><CODE>getSecondaryIndex</CODE></A> is used instead.</p>
1114<P>
1115<DL>
1116<DT><B>Parameters:</B><DD><CODE>database</CODE> - the secondary database used for all access other than
1117 via a <A HREF="/com/sleepycat/persist/SecondaryIndex.html#keysIndex"><CODE>keysIndex</CODE></A>.<DD><CODE>keysDatabase</CODE> - another handle on the secondary database, opened
1118 without association to the primary, and used only for access via a
1119 <A HREF="/com/sleepycat/persist/SecondaryIndex.html#keysIndex"><CODE>keysIndex</CODE></A>.  If this argument is null and the <A HREF="/com/sleepycat/persist/SecondaryIndex.html#keysIndex"><CODE>keysIndex</CODE></A>
1120 method is called, then the keys database will be opened automatically;
1121 however, the user is then responsible for closing the keys database.  To
1122 get the keys database in order to close it, call <A HREF="/com/sleepycat/persist/SecondaryIndex.html#getKeysDatabase()"><CODE>getKeysDatabase()</CODE></A>.<DD><CODE>primaryIndex</CODE> - the primary index associated with this secondary
1123 index.<DD><CODE>secondaryKeyClass</CODE> - the class of the secondary key.<DD><CODE>secondaryKeyBinding</CODE> - the binding to be used for secondary keys.
1124<DT><B>Throws:</B>
1125<DD><CODE><A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
1126</DL>
1127
1128<!-- ============ METHOD DETAIL ========== -->
1129
1130<A NAME="method_detail"><!-- --></A>
1131<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
1132<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
1133<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
1134<B>Method Detail</B></FONT></TH>
1135</TR>
1136</TABLE>
1137
1138<A NAME="getDatabase()"><!-- --></A><H3>
1139getDatabase</H3>
1140<PRE>
1141public <A HREF="/com/sleepycat/db/SecondaryDatabase.html" title="class in com.sleepycat.db">SecondaryDatabase</A> <B>getDatabase</B>()</PRE>
1142<DL>
1143<DD>Returns the underlying secondary database for this index.
1144<P>
1145<DD><DL>
1146
1147<DT><B>Returns:</B><DD>the secondary database.</DL>
1148</DD>
1149</DL>
1150<HR>
1151
1152<A NAME="getKeysDatabase()"><!-- --></A><H3>
1153getKeysDatabase</H3>
1154<PRE>
1155public <A HREF="/com/sleepycat/db/Database.html" title="class in com.sleepycat.db">Database</A> <B>getKeysDatabase</B>()</PRE>
1156<DL>
1157<DD>Returns the underlying secondary database that is not associated with
1158 the primary database and is used for the <A HREF="/com/sleepycat/persist/SecondaryIndex.html#keysIndex"><CODE>keysIndex</CODE></A>.
1159<P>
1160<DD><DL>
1161
1162<DT><B>Returns:</B><DD>the keys database.</DL>
1163</DD>
1164</DL>
1165<HR>
1166
1167<A NAME="getPrimaryIndex()"><!-- --></A><H3>
1168getPrimaryIndex</H3>
1169<PRE>
1170public <A HREF="/com/sleepycat/persist/PrimaryIndex.html" title="class in com.sleepycat.persist">PrimaryIndex</A>&lt;<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">PK</A>,<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">E</A>&gt; <B>getPrimaryIndex</B>()</PRE>
1171<DL>
1172<DD>Returns the primary index associated with this secondary index.
1173<P>
1174<DD><DL>
1175
1176<DT><B>Returns:</B><DD>the primary index.</DL>
1177</DD>
1178</DL>
1179<HR>
1180
1181<A NAME="getKeyClass()"><!-- --></A><H3>
1182getKeyClass</H3>
1183<PRE>
1184public <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html" title="class or interface in java.lang">Class</A>&lt;<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">SK</A>&gt; <B>getKeyClass</B>()</PRE>
1185<DL>
1186<DD>Returns the secondary key class for this index.
1187<P>
1188<DD><DL>
1189
1190<DT><B>Returns:</B><DD>the class.</DL>
1191</DD>
1192</DL>
1193<HR>
1194
1195<A NAME="getKeyBinding()"><!-- --></A><H3>
1196getKeyBinding</H3>
1197<PRE>
1198public <A HREF="/com/sleepycat/bind/EntryBinding.html" title="interface in com.sleepycat.bind">EntryBinding</A> <B>getKeyBinding</B>()</PRE>
1199<DL>
1200<DD>Returns the secondary key binding for the index.
1201<P>
1202<DD><DL>
1203
1204<DT><B>Returns:</B><DD>the key binding.</DL>
1205</DD>
1206</DL>
1207<HR>
1208
1209<A NAME="keysIndex()"><!-- --></A><H3>
1210keysIndex</H3>
1211<PRE>
1212public <A HREF="/com/sleepycat/persist/EntityIndex.html" title="interface in com.sleepycat.persist">EntityIndex</A>&lt;<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">SK</A>,<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">PK</A>&gt; <B>keysIndex</B>()
1213                             throws <A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1214<DL>
1215<DD>Returns a read-only keys index that maps secondary key to primary key.
1216 When accessing the keys index, the primary key is returned rather than
1217 the entity.  When only the primary key is needed and not the entire
1218 entity, using the keys index is less expensive than using the secondary
1219 index because the primary index does not have to be accessed.
1220
1221 <p>Note the following in the unusual case that you are <em>not</em>
1222 using an <code>EntityStore</code>: This method will open the keys
1223 database, a second database handle for the secondary database, if it is
1224 not already open.  In this case, if you are <em>not</em> using an
1225 <code>EntityStore</code>, then you are responsible for closing the
1226 database returned by <A HREF="/com/sleepycat/persist/SecondaryIndex.html#getKeysDatabase()"><CODE>getKeysDatabase()</CODE></A> before closing the
1227 environment.  If you <em>are</em> using an <code>EntityStore</code>, the
1228 keys database will be closed automatically by <A HREF="/com/sleepycat/persist/EntityStore.html#close()"><CODE>EntityStore.close()</CODE></A>.</p>
1229<P>
1230<DD><DL>
1231
1232<DT><B>Returns:</B><DD>the keys index.
1233<DT><B>Throws:</B>
1234<DD><CODE><A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
1235</DD>
1236</DL>
1237<HR>
1238
1239<A NAME="subIndex(java.lang.Object)"><!-- --></A><A NAME="subIndex(SK)"><!-- --></A><H3>
1240subIndex</H3>
1241<PRE>
1242public <A HREF="/com/sleepycat/persist/EntityIndex.html" title="interface in com.sleepycat.persist">EntityIndex</A>&lt;<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">PK</A>,<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">E</A>&gt; <B>subIndex</B>(<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">SK</A>&nbsp;key)
1243                           throws <A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1244<DL>
1245<DD>Returns an index that maps primary key to entity for the subset of
1246 entities having a given secondary key (duplicates).  A sub-index is
1247 convenient when you are interested in working with the subset of
1248 entities having a particular secondary key value.
1249
1250 <p>When using a <A HREF="/com/sleepycat/persist/model/Relationship.html#MANY_TO_ONE"><CODE>MANY_TO_ONE</CODE></A> or <A HREF="/com/sleepycat/persist/model/Relationship.html#MANY_TO_MANY"><CODE>MANY_TO_MANY</CODE></A> secondary key, the sub-index
1251 represents the left (MANY) side of a relationship.</p>
1252<P>
1253<DD><DL>
1254<DT><B>Parameters:</B><DD><CODE>key</CODE> - the secondary key that identifies the entities in the
1255 sub-index.
1256<DT><B>Returns:</B><DD>the sub-index.
1257<DT><B>Throws:</B>
1258<DD><CODE><A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
1259</DD>
1260</DL>
1261<HR>
1262
1263<A NAME="get(java.lang.Object)"><!-- --></A><A NAME="get(SK)"><!-- --></A><H3>
1264get</H3>
1265<PRE>
1266public <A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">E</A> <B>get</B>(<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">SK</A>&nbsp;key)
1267      throws <A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1268<DL>
1269<DD><B>Description copied from interface: <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#get(K)">EntityIndex</A></CODE></B></DD>
1270<DD>Gets an entity via a key of this index.
1271
1272 <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>
1273<P>
1274<DD><DL>
1275<DT><B>Parameters:</B><DD><CODE>key</CODE> - the key to search for.
1276<DT><B>Returns:</B><DD>the value mapped to the given key, or null if the key is not
1277 present in the index.
1278<DT><B>Throws:</B>
1279<DD><CODE><A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
1280</DD>
1281</DL>
1282<HR>
1283
1284<A NAME="get(com.sleepycat.db.Transaction,java.lang.Object,com.sleepycat.db.LockMode)"><!-- --></A><A NAME="get(com.sleepycat.db.Transaction, SK, com.sleepycat.db.LockMode)"><!-- --></A><H3>
1285get</H3>
1286<PRE>
1287public <A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">E</A> <B>get</B>(<A HREF="/com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db">Transaction</A>&nbsp;txn,
1288             <A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">SK</A>&nbsp;key,
1289             <A HREF="/com/sleepycat/db/LockMode.html" title="class in com.sleepycat.db">LockMode</A>&nbsp;lockMode)
1290      throws <A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1291<DL>
1292<DD><B>Description copied from interface: <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#get(com.sleepycat.db.Transaction, K, com.sleepycat.db.LockMode)">EntityIndex</A></CODE></B></DD>
1293<DD>Gets an entity via a key of this index.
1294<P>
1295<DD><DL>
1296<DT><B>Parameters:</B><DD><CODE>txn</CODE> - the transaction used to protect this operation, or null
1297 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
1298 use <A HREF="/com/sleepycat/db/LockMode.html#DEFAULT"><CODE>LockMode.DEFAULT</CODE></A>.
1299<DT><B>Returns:</B><DD>the value mapped to the given key, or null if the key is not
1300 present in the index.
1301<DT><B>Throws:</B>
1302<DD><CODE><A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
1303</DD>
1304</DL>
1305<HR>
1306
1307<A NAME="map()"><!-- --></A><H3>
1308map</H3>
1309<PRE>
1310public <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Map.html" title="class or interface in java.util">Map</A>&lt;<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">SK</A>,<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">E</A>&gt; <B>map</B>()</PRE>
1311<DL>
1312<DD><B>Description copied from interface: <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#map()">EntityIndex</A></CODE></B></DD>
1313<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
1314 to the standard Java collections framework interface.
1315<P>
1316<DD><DL>
1317
1318<DT><B>Returns:</B><DD>the map.</DL>
1319</DD>
1320</DL>
1321<HR>
1322
1323<A NAME="sortedMap()"><!-- --></A><H3>
1324sortedMap</H3>
1325<PRE>
1326public <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/SortedMap.html" title="class or interface in java.util">SortedMap</A>&lt;<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">SK</A>,<A HREF="/com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">E</A>&gt; <B>sortedMap</B>()</PRE>
1327<DL>
1328<DD><B>Description copied from interface: <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#sortedMap()">EntityIndex</A></CODE></B></DD>
1329<DD>Returns a standard Java sorted map based on this entity index.  The
1330 <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
1331 to the standard Java collections framework interface.
1332<P>
1333<DD><DL>
1334
1335<DT><B>Returns:</B><DD>the map.</DL>
1336</DD>
1337</DL>
1338<HR>
1339
1340<A NAME="contains(java.lang.Object)"><!-- --></A><A NAME="contains(K)"><!-- --></A><H3>
1341contains</H3>
1342<PRE>
1343public boolean <B>contains</B>(K&nbsp;key)
1344                 throws <A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1345<DL>
1346<DD><B>Description copied from interface: <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#contains(K)">EntityIndex</A></CODE></B></DD>
1347<DD>Checks for existence of a key in this index.
1348
1349 <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>
1350<P>
1351<DD><DL>
1352<DT><B>Specified by:</B><DD><CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#contains(K)">contains</A></CODE> in interface <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html" title="interface in com.sleepycat.persist">EntityIndex</A>&lt;K,E&gt;</CODE></DL>
1353</DD>
1354<DD><DL>
1355<DT><B>Parameters:</B><DD><CODE>key</CODE> - the key to search for.
1356<DT><B>Returns:</B><DD>whether the key exists in the index.
1357<DT><B>Throws:</B>
1358<DD><CODE><A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
1359</DD>
1360</DL>
1361<HR>
1362
1363<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>
1364contains</H3>
1365<PRE>
1366public boolean <B>contains</B>(<A HREF="/com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db">Transaction</A>&nbsp;txn,
1367                        K&nbsp;key,
1368                        <A HREF="/com/sleepycat/db/LockMode.html" title="class in com.sleepycat.db">LockMode</A>&nbsp;lockMode)
1369                 throws <A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1370<DL>
1371<DD><B>Description copied from interface: <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#contains(com.sleepycat.db.Transaction, K, com.sleepycat.db.LockMode)">EntityIndex</A></CODE></B></DD>
1372<DD>Checks for existence of a key in this index.
1373<P>
1374<DD><DL>
1375<DT><B>Specified by:</B><DD><CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#contains(com.sleepycat.db.Transaction, K, com.sleepycat.db.LockMode)">contains</A></CODE> in interface <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html" title="interface in com.sleepycat.persist">EntityIndex</A>&lt;K,E&gt;</CODE></DL>
1376</DD>
1377<DD><DL>
1378<DT><B>Parameters:</B><DD><CODE>txn</CODE> - the transaction used to protect this operation, or null
1379 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
1380 use <A HREF="/com/sleepycat/db/LockMode.html#DEFAULT"><CODE>LockMode.DEFAULT</CODE></A>.
1381<DT><B>Returns:</B><DD>whether the key exists in the index.
1382<DT><B>Throws:</B>
1383<DD><CODE><A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
1384</DD>
1385</DL>
1386<HR>
1387
1388<A NAME="count()"><!-- --></A><H3>
1389count</H3>
1390<PRE>
1391public long <B>count</B>()
1392           throws <A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1393<DL>
1394<DD><B>Description copied from interface: <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#count()">EntityIndex</A></CODE></B></DD>
1395<DD>Returns a non-transactional count of the entities in this index.
1396
1397 <p>This operation is faster than obtaining a count by scanning the index
1398 manually, and will not perturb the current contents of the cache.
1399 However, the count is not guaranteed to be accurate if there are
1400 concurrent updates.</p>
1401<P>
1402<DD><DL>
1403<DT><B>Specified by:</B><DD><CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#count()">count</A></CODE> in interface <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html" title="interface in com.sleepycat.persist">EntityIndex</A>&lt;K,E&gt;</CODE></DL>
1404</DD>
1405<DD><DL>
1406
1407<DT><B>Returns:</B><DD>the number of entities in this index.
1408<DT><B>Throws:</B>
1409<DD><CODE><A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
1410</DD>
1411</DL>
1412<HR>
1413
1414<A NAME="delete(java.lang.Object)"><!-- --></A><A NAME="delete(K)"><!-- --></A><H3>
1415delete</H3>
1416<PRE>
1417public boolean <B>delete</B>(K&nbsp;key)
1418               throws <A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1419<DL>
1420<DD><B>Description copied from interface: <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#delete(K)">EntityIndex</A></CODE></B></DD>
1421<DD>Deletes all entities with a given index key.
1422
1423 <p>Auto-commit is used implicitly if the store is transactional.</p>
1424<P>
1425<DD><DL>
1426<DT><B>Specified by:</B><DD><CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#delete(K)">delete</A></CODE> in interface <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html" title="interface in com.sleepycat.persist">EntityIndex</A>&lt;K,E&gt;</CODE></DL>
1427</DD>
1428<DD><DL>
1429<DT><B>Parameters:</B><DD><CODE>key</CODE> - the key to search for.
1430<DT><B>Returns:</B><DD>whether any entities were deleted.
1431<DT><B>Throws:</B>
1432<DD><CODE><A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
1433</DD>
1434</DL>
1435<HR>
1436
1437<A NAME="delete(com.sleepycat.db.Transaction,java.lang.Object)"><!-- --></A><A NAME="delete(com.sleepycat.db.Transaction, K)"><!-- --></A><H3>
1438delete</H3>
1439<PRE>
1440public boolean <B>delete</B>(<A HREF="/com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db">Transaction</A>&nbsp;txn,
1441                      K&nbsp;key)
1442               throws <A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1443<DL>
1444<DD><B>Description copied from interface: <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#delete(com.sleepycat.db.Transaction, K)">EntityIndex</A></CODE></B></DD>
1445<DD>Deletes all entities with a given index key.
1446<P>
1447<DD><DL>
1448<DT><B>Specified by:</B><DD><CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#delete(com.sleepycat.db.Transaction, K)">delete</A></CODE> in interface <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html" title="interface in com.sleepycat.persist">EntityIndex</A>&lt;K,E&gt;</CODE></DL>
1449</DD>
1450<DD><DL>
1451<DT><B>Parameters:</B><DD><CODE>txn</CODE> - the transaction used to protect this operation, null to use
1452 auto-commit, or null if the store is non-transactional.<DD><CODE>key</CODE> - the key to search for.
1453<DT><B>Returns:</B><DD>whether any entities were deleted.
1454<DT><B>Throws:</B>
1455<DD><CODE><A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
1456</DD>
1457</DL>
1458<HR>
1459
1460<A NAME="keys()"><!-- --></A><H3>
1461keys</H3>
1462<PRE>
1463public <A HREF="/com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;K&gt; <B>keys</B>()
1464                     throws <A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1465<DL>
1466<DD><B>Description copied from interface: <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#keys()">EntityIndex</A></CODE></B></DD>
1467<DD>Opens a cursor for traversing all keys in this index.
1468
1469 <p>The operations performed with the cursor will not be transaction
1470 protected, and <A HREF="/com/sleepycat/db/CursorConfig.html#DEFAULT"><CODE>CursorConfig.DEFAULT</CODE></A> is used implicitly.  If the
1471 store is transactional, the cursor may not be used to update or delete
1472 entities.</p>
1473<P>
1474<DD><DL>
1475<DT><B>Specified by:</B><DD><CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#keys()">keys</A></CODE> in interface <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html" title="interface in com.sleepycat.persist">EntityIndex</A>&lt;K,E&gt;</CODE></DL>
1476</DD>
1477<DD><DL>
1478
1479<DT><B>Returns:</B><DD>the cursor.
1480<DT><B>Throws:</B>
1481<DD><CODE><A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
1482</DD>
1483</DL>
1484<HR>
1485
1486<A NAME="keys(com.sleepycat.db.Transaction, com.sleepycat.db.CursorConfig)"><!-- --></A><H3>
1487keys</H3>
1488<PRE>
1489public <A HREF="/com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;K&gt; <B>keys</B>(<A HREF="/com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db">Transaction</A>&nbsp;txn,
1490                            <A HREF="/com/sleepycat/db/CursorConfig.html" title="class in com.sleepycat.db">CursorConfig</A>&nbsp;config)
1491                     throws <A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1492<DL>
1493<DD><B>Description copied from interface: <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#keys(com.sleepycat.db.Transaction, com.sleepycat.db.CursorConfig)">EntityIndex</A></CODE></B></DD>
1494<DD>Opens a cursor for traversing all keys in this index.
1495<P>
1496<DD><DL>
1497<DT><B>Specified by:</B><DD><CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#keys(com.sleepycat.db.Transaction, com.sleepycat.db.CursorConfig)">keys</A></CODE> in interface <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html" title="interface in com.sleepycat.persist">EntityIndex</A>&lt;K,E&gt;</CODE></DL>
1498</DD>
1499<DD><DL>
1500<DT><B>Parameters:</B><DD><CODE>txn</CODE> - the transaction used to protect all operations performed with
1501 the cursor, or null if the operations should not be transaction
1502 protected.  If null is specified and the store is transactional, the
1503 cursor may not be used to update or delete entities.<DD><CODE>config</CODE> - the cursor configuration that determines the default lock
1504 mode used for all cursor operations, or null to implicitly use <A HREF="/com/sleepycat/db/CursorConfig.html#DEFAULT"><CODE>CursorConfig.DEFAULT</CODE></A>.
1505<DT><B>Returns:</B><DD>the cursor.
1506<DT><B>Throws:</B>
1507<DD><CODE><A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
1508</DD>
1509</DL>
1510<HR>
1511
1512<A NAME="entities()"><!-- --></A><H3>
1513entities</H3>
1514<PRE>
1515public <A HREF="/com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;E&gt; <B>entities</B>()
1516                         throws <A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1517<DL>
1518<DD><B>Description copied from interface: <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#entities()">EntityIndex</A></CODE></B></DD>
1519<DD>Opens a cursor for traversing all entities in this index.
1520
1521 <p>The operations performed with the cursor will not be transaction
1522 protected, and <A HREF="/com/sleepycat/db/CursorConfig.html#DEFAULT"><CODE>CursorConfig.DEFAULT</CODE></A> is used implicitly.  If the
1523 store is transactional, the cursor may not be used to update or delete
1524 entities.</p>
1525<P>
1526<DD><DL>
1527<DT><B>Specified by:</B><DD><CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#entities()">entities</A></CODE> in interface <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html" title="interface in com.sleepycat.persist">EntityIndex</A>&lt;K,E&gt;</CODE></DL>
1528</DD>
1529<DD><DL>
1530
1531<DT><B>Returns:</B><DD>the cursor.
1532<DT><B>Throws:</B>
1533<DD><CODE><A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
1534</DD>
1535</DL>
1536<HR>
1537
1538<A NAME="entities(com.sleepycat.db.Transaction, com.sleepycat.db.CursorConfig)"><!-- --></A><H3>
1539entities</H3>
1540<PRE>
1541public <A HREF="/com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;E&gt; <B>entities</B>(<A HREF="/com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db">Transaction</A>&nbsp;txn,
1542                                <A HREF="/com/sleepycat/db/CursorConfig.html" title="class in com.sleepycat.db">CursorConfig</A>&nbsp;config)
1543                         throws <A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1544<DL>
1545<DD><B>Description copied from interface: <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#entities(com.sleepycat.db.Transaction, com.sleepycat.db.CursorConfig)">EntityIndex</A></CODE></B></DD>
1546<DD>Opens a cursor for traversing all entities in this index.
1547<P>
1548<DD><DL>
1549<DT><B>Specified by:</B><DD><CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#entities(com.sleepycat.db.Transaction, com.sleepycat.db.CursorConfig)">entities</A></CODE> in interface <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html" title="interface in com.sleepycat.persist">EntityIndex</A>&lt;K,E&gt;</CODE></DL>
1550</DD>
1551<DD><DL>
1552<DT><B>Parameters:</B><DD><CODE>txn</CODE> - the transaction used to protect all operations performed with
1553 the cursor, or null if the operations should not be transaction
1554 protected.  If null is specified and the store is transactional, the
1555 cursor may not be used to update or delete entities.<DD><CODE>config</CODE> - the cursor configuration that determines the default lock
1556 mode used for all cursor operations, or null to implicitly use <A HREF="/com/sleepycat/db/CursorConfig.html#DEFAULT"><CODE>CursorConfig.DEFAULT</CODE></A>.
1557<DT><B>Returns:</B><DD>the cursor.
1558<DT><B>Throws:</B>
1559<DD><CODE><A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
1560</DD>
1561</DL>
1562<HR>
1563
1564<A NAME="keys(java.lang.Object,boolean,java.lang.Object,boolean)"><!-- --></A><A NAME="keys(K, boolean, K, boolean)"><!-- --></A><H3>
1565keys</H3>
1566<PRE>
1567public <A HREF="/com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;K&gt; <B>keys</B>(K&nbsp;fromKey,
1568                            boolean&nbsp;fromInclusive,
1569                            K&nbsp;toKey,
1570                            boolean&nbsp;toInclusive)
1571                     throws <A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1572<DL>
1573<DD><B>Description copied from interface: <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#keys(K, boolean, K, boolean)">EntityIndex</A></CODE></B></DD>
1574<DD>Opens a cursor for traversing keys in a key range.
1575
1576 <p>The operations performed with the cursor will not be transaction
1577 protected, and <A HREF="/com/sleepycat/db/CursorConfig.html#DEFAULT"><CODE>CursorConfig.DEFAULT</CODE></A> is used implicitly.  If the
1578 store is transactional, the cursor may not be used to update or delete
1579 entities.</p>
1580<P>
1581<DD><DL>
1582<DT><B>Specified by:</B><DD><CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#keys(K, boolean, K, boolean)">keys</A></CODE> in interface <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html" title="interface in com.sleepycat.persist">EntityIndex</A>&lt;K,E&gt;</CODE></DL>
1583</DD>
1584<DD><DL>
1585<DT><B>Parameters:</B><DD><CODE>fromKey</CODE> - is the lower bound of the key range, or null if the range
1586 has no lower bound.<DD><CODE>fromInclusive</CODE> - is true if keys greater than or equal to fromKey
1587 should be included in the key range, or false if only keys greater than
1588 fromKey should be included.<DD><CODE>toKey</CODE> - is the upper bound of the key range, or null if the range
1589 has no upper bound.<DD><CODE>toInclusive</CODE> - is true if keys less than or equal to toKey should be
1590 included in the key range, or false if only keys less than toKey should
1591 be included.
1592<DT><B>Returns:</B><DD>the cursor.
1593<DT><B>Throws:</B>
1594<DD><CODE><A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
1595</DD>
1596</DL>
1597<HR>
1598
1599<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>
1600keys</H3>
1601<PRE>
1602public <A HREF="/com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;K&gt; <B>keys</B>(<A HREF="/com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db">Transaction</A>&nbsp;txn,
1603                            K&nbsp;fromKey,
1604                            boolean&nbsp;fromInclusive,
1605                            K&nbsp;toKey,
1606                            boolean&nbsp;toInclusive,
1607                            <A HREF="/com/sleepycat/db/CursorConfig.html" title="class in com.sleepycat.db">CursorConfig</A>&nbsp;config)
1608                     throws <A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1609<DL>
1610<DD><B>Description copied from interface: <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#keys(com.sleepycat.db.Transaction, K, boolean, K, boolean, com.sleepycat.db.CursorConfig)">EntityIndex</A></CODE></B></DD>
1611<DD>Opens a cursor for traversing keys in a key range.
1612<P>
1613<DD><DL>
1614<DT><B>Specified by:</B><DD><CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#keys(com.sleepycat.db.Transaction, K, boolean, K, boolean, com.sleepycat.db.CursorConfig)">keys</A></CODE> in interface <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html" title="interface in com.sleepycat.persist">EntityIndex</A>&lt;K,E&gt;</CODE></DL>
1615</DD>
1616<DD><DL>
1617<DT><B>Parameters:</B><DD><CODE>txn</CODE> - the transaction used to protect all operations performed with
1618 the cursor, or null if the operations should not be transaction
1619 protected.  If null is specified and the store is transactional, the
1620 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
1621 has no lower bound.<DD><CODE>fromInclusive</CODE> - is true if keys greater than or equal to fromKey
1622 should be included in the key range, or false if only keys greater than
1623 fromKey should be included.<DD><CODE>toKey</CODE> - is the upper bound of the key range, or null if the range
1624 has no upper bound.<DD><CODE>toInclusive</CODE> - is true if keys less than or equal to toKey should be
1625 included in the key range, or false if only keys less than toKey should
1626 be included.<DD><CODE>config</CODE> - the cursor configuration that determines the default lock
1627 mode used for all cursor operations, or null to implicitly use <A HREF="/com/sleepycat/db/CursorConfig.html#DEFAULT"><CODE>CursorConfig.DEFAULT</CODE></A>.
1628<DT><B>Returns:</B><DD>the cursor.
1629<DT><B>Throws:</B>
1630<DD><CODE><A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
1631</DD>
1632</DL>
1633<HR>
1634
1635<A NAME="entities(java.lang.Object,boolean,java.lang.Object,boolean)"><!-- --></A><A NAME="entities(K, boolean, K, boolean)"><!-- --></A><H3>
1636entities</H3>
1637<PRE>
1638public <A HREF="/com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;E&gt; <B>entities</B>(K&nbsp;fromKey,
1639                                boolean&nbsp;fromInclusive,
1640                                K&nbsp;toKey,
1641                                boolean&nbsp;toInclusive)
1642                         throws <A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1643<DL>
1644<DD><B>Description copied from interface: <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#entities(K, boolean, K, boolean)">EntityIndex</A></CODE></B></DD>
1645<DD>Opens a cursor for traversing entities in a key range.
1646
1647 <p>The operations performed with the cursor will not be transaction
1648 protected, and <A HREF="/com/sleepycat/db/CursorConfig.html#DEFAULT"><CODE>CursorConfig.DEFAULT</CODE></A> is used implicitly.  If the
1649 store is transactional, the cursor may not be used to update or delete
1650 entities.</p>
1651<P>
1652<DD><DL>
1653<DT><B>Specified by:</B><DD><CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#entities(K, boolean, K, boolean)">entities</A></CODE> in interface <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html" title="interface in com.sleepycat.persist">EntityIndex</A>&lt;K,E&gt;</CODE></DL>
1654</DD>
1655<DD><DL>
1656<DT><B>Parameters:</B><DD><CODE>fromKey</CODE> - is the lower bound of the key range, or null if the range
1657 has no lower bound.<DD><CODE>fromInclusive</CODE> - is true if keys greater than or equal to fromKey
1658 should be included in the key range, or false if only keys greater than
1659 fromKey should be included.<DD><CODE>toKey</CODE> - is the upper bound of the key range, or null if the range
1660 has no upper bound.<DD><CODE>toInclusive</CODE> - is true if keys less than or equal to toKey should be
1661 included in the key range, or false if only keys less than toKey should
1662 be included.
1663<DT><B>Returns:</B><DD>the cursor.
1664<DT><B>Throws:</B>
1665<DD><CODE><A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
1666</DD>
1667</DL>
1668<HR>
1669
1670<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>
1671entities</H3>
1672<PRE>
1673public <A HREF="/com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A>&lt;E&gt; <B>entities</B>(<A HREF="/com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db">Transaction</A>&nbsp;txn,
1674                                K&nbsp;fromKey,
1675                                boolean&nbsp;fromInclusive,
1676                                K&nbsp;toKey,
1677                                boolean&nbsp;toInclusive,
1678                                <A HREF="/com/sleepycat/db/CursorConfig.html" title="class in com.sleepycat.db">CursorConfig</A>&nbsp;config)
1679                         throws <A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
1680<DL>
1681<DD><B>Description copied from interface: <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#entities(com.sleepycat.db.Transaction, K, boolean, K, boolean, com.sleepycat.db.CursorConfig)">EntityIndex</A></CODE></B></DD>
1682<DD>Opens a cursor for traversing entities in a key range.
1683<P>
1684<DD><DL>
1685<DT><B>Specified by:</B><DD><CODE><A HREF="/com/sleepycat/persist/EntityIndex.html#entities(com.sleepycat.db.Transaction, K, boolean, K, boolean, com.sleepycat.db.CursorConfig)">entities</A></CODE> in interface <CODE><A HREF="/com/sleepycat/persist/EntityIndex.html" title="interface in com.sleepycat.persist">EntityIndex</A>&lt;K,E&gt;</CODE></DL>
1686</DD>
1687<DD><DL>
1688<DT><B>Parameters:</B><DD><CODE>txn</CODE> - the transaction used to protect all operations performed with
1689 the cursor, or null if the operations should not be transaction
1690 protected.  If null is specified and the store is transactional, the
1691 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
1692 has no lower bound.<DD><CODE>fromInclusive</CODE> - is true if keys greater than or equal to fromKey
1693 should be included in the key range, or false if only keys greater than
1694 fromKey should be included.<DD><CODE>toKey</CODE> - is the upper bound of the key range, or null if the range
1695 has no upper bound.<DD><CODE>toInclusive</CODE> - is true if keys less than or equal to toKey should be
1696 included in the key range, or false if only keys less than toKey should
1697 be included.<DD><CODE>config</CODE> - the cursor configuration that determines the default lock
1698 mode used for all cursor operations, or null to implicitly use <A HREF="/com/sleepycat/db/CursorConfig.html#DEFAULT"><CODE>CursorConfig.DEFAULT</CODE></A>.
1699<DT><B>Returns:</B><DD>the cursor.
1700<DT><B>Throws:</B>
1701<DD><CODE><A HREF="/com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
1702</DD>
1703</DL>
1704<!-- ========= END OF CLASS DATA ========= -->
1705<HR>
1706
1707
1708<!-- ======= START OF BOTTOM NAVBAR ====== -->
1709<A NAME="navbar_bottom"><!-- --></A>
1710<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
1711<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
1712<TR>
1713<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
1714<A NAME="navbar_bottom_firstrow"><!-- --></A>
1715<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
1716  <TR ALIGN="center" VALIGN="top">
1717  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="/overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
1718  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
1719  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
1720  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/SecondaryIndex.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
1721  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
1722  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="/deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
1723  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="/index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
1724  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="/help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
1725  </TR>
1726</TABLE>
1727</TD>
1728<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
1729<b>Berkeley DB</b><br><font size="-1"> version 4.7.25</font></EM>
1730</TD>
1731</TR>
1732
1733<TR>
1734<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
1735&nbsp;<A HREF="/com/sleepycat/persist/PrimaryIndex.html" title="class in com.sleepycat.persist"><B>PREV CLASS</B></A>&nbsp;
1736&nbsp;<A HREF="/com/sleepycat/persist/StoreConfig.html" title="class in com.sleepycat.persist"><B>NEXT CLASS</B></A></FONT></TD>
1737<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
1738  <A HREF="/index.html?com/sleepycat/persist/SecondaryIndex.html" target="_top"><B>FRAMES</B></A>  &nbsp;
1739&nbsp;<A HREF="SecondaryIndex.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
1740&nbsp;<SCRIPT type="text/javascript">
1741  <!--
1742  if(window==top) {
1743    document.writeln('<A HREF="/allclasses-noframe.html"><B>All Classes</B></A>');
1744  }
1745  //-->
1746</SCRIPT>
1747<NOSCRIPT>
1748  <A HREF="/allclasses-noframe.html"><B>All Classes</B></A>
1749</NOSCRIPT>
1750
1751
1752</FONT></TD>
1753</TR>
1754<TR>
1755<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
1756  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
1757<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
1758DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
1759</TR>
1760</TABLE>
1761<A NAME="skip-navbar_bottom"></A>
1762<!-- ======== END OF BOTTOM NAVBAR ======= -->
1763
1764<HR>
1765<font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
1766</BODY>
1767</HTML>
1768