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