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