1768 lines
92 KiB
HTML
1768 lines
92 KiB
HTML
<!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.5.0) on Thu May 15 17:17:33 EDT 2008 -->
|
|
<TITLE>
|
|
SecondaryIndex (Oracle - Berkeley DB Java API)
|
|
</TITLE>
|
|
|
|
<META NAME="keywords" CONTENT="com.sleepycat.persist.SecondaryIndex class">
|
|
|
|
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../style.css" TITLE="Style">
|
|
|
|
<SCRIPT type="text/javascript">
|
|
function windowTitle()
|
|
{
|
|
parent.document.title="SecondaryIndex (Oracle - Berkeley DB Java API)";
|
|
}
|
|
</SCRIPT>
|
|
<NOSCRIPT>
|
|
</NOSCRIPT>
|
|
|
|
</HEAD>
|
|
|
|
<BODY BGCOLOR="white" onload="windowTitle();">
|
|
|
|
|
|
<!-- ========= 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/SecondaryIndex.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 4.7.25</font></EM>
|
|
</TD>
|
|
</TR>
|
|
|
|
<TR>
|
|
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
|
<A HREF="../../../com/sleepycat/persist/PrimaryIndex.html" title="class in com.sleepycat.persist"><B>PREV CLASS</B></A>
|
|
<A HREF="../../../com/sleepycat/persist/StoreConfig.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/SecondaryIndex.html" target="_top"><B>FRAMES</B></A>
|
|
<A HREF="SecondaryIndex.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 | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
|
|
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
|
|
DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <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>
|
|
Class SecondaryIndex<SK,PK,E></H2>
|
|
<PRE>
|
|
<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html" title="class or interface in java.lang">java.lang.Object</A>
|
|
<IMG SRC="../../../resources/inherit.gif" ALT="extended by "><B>com.sleepycat.persist.SecondaryIndex<SK,PK,E></B>
|
|
</PRE>
|
|
<DL>
|
|
<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>
|
|
</DL>
|
|
<HR>
|
|
<DL>
|
|
<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" title="class or interface in java.lang">Object</A></DL>
|
|
</PRE>
|
|
|
|
<P>
|
|
The secondary index for an entity class and a secondary key.
|
|
|
|
<p><code>SecondaryIndex</code> objects are thread-safe. Multiple threads may
|
|
safely call the methods of a shared <code>SecondaryIndex</code> object.</p>
|
|
|
|
<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
|
|
secondary key type (SK) to the entity type (E). In other words, entities
|
|
are accessed by secondary key values.</p>
|
|
|
|
<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
|
|
as shown in the following example.</p>
|
|
|
|
<pre class="code">
|
|
@Entity
|
|
class Employee {
|
|
|
|
@PrimaryKey
|
|
long id;
|
|
|
|
@SecondaryKey(relate=MANY_TO_ONE)
|
|
String department;
|
|
|
|
String name;
|
|
|
|
private Employee() {}
|
|
}</pre>
|
|
|
|
<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
|
|
be obtained for the entity class. To obtain the <code>SecondaryIndex</code> call
|
|
<A HREF="../../../com/sleepycat/persist/EntityStore.html#getSecondaryIndex(com.sleepycat.persist.PrimaryIndex, java.lang.Class, java.lang.String)"><CODE>EntityStore.getSecondaryIndex</CODE></A>, passing
|
|
the primary index, the secondary key class and the secondary key name. For
|
|
example:</p>
|
|
|
|
<pre class="code">
|
|
EntityStore store = new EntityStore(...);
|
|
|
|
<code>PrimaryIndex<Long,Employee></code> primaryIndex =
|
|
store.getPrimaryIndex(Long.class, Employee.class);
|
|
|
|
<code>SecondaryIndex<String,Long,Employee></code> secondaryIndex =
|
|
store.getSecondaryIndex(primaryIndex, String.class, "department");</pre>
|
|
|
|
<p>Since <code>SecondaryIndex</code> implements the <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="interface in com.sleepycat.persist"><CODE>EntityIndex</CODE></A>
|
|
interface, it shares the common index methods for retrieving and deleting
|
|
entities, opening cursors and using transactions. See <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="interface in com.sleepycat.persist"><CODE>EntityIndex</CODE></A>
|
|
for more information on these topics.</p>
|
|
|
|
<p><code>SecondaryIndex</code> does <em>not</em> provide methods for inserting
|
|
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>
|
|
|
|
<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
|
|
level of mapping: It maps from secondary key to primary key, and then from
|
|
primary key to entity. For example, consider this entity:</p>
|
|
|
|
<p><table class="code" border="1">
|
|
<tr><th>ID</th><th>Department</th><th>Name</th></tr>
|
|
<tr><td>1</td><td>Engineering</td><td>Jane Smith</td></tr>
|
|
</table></p>
|
|
|
|
<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
|
|
primary key 1 to the "Jane Smith" entity in the example. The <code>SecondaryIndex</code> maps from department to id, or from secondary key
|
|
"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>
|
|
|
|
<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
|
|
in the primary index. The main mapping of a <code>SecondaryIndex</code> is to
|
|
map from secondary key (SK) to entity (E), or in the example, from the
|
|
String department key to the Employee entity. The <code>SecondaryIndex</code>
|
|
itself, by implementing <code>EntityIndex<SK,E></code>, provides this
|
|
mapping.</p>
|
|
|
|
<p>The second mapping provided by <code>SecondaryIndex</code> is from secondary
|
|
key (SK) to primary key (PK), or in the example, from the String department
|
|
key to the Long id key. The <A HREF="../../../com/sleepycat/persist/SecondaryIndex.html#keysIndex"><CODE>keysIndex</CODE></A> method provides this
|
|
mapping. When accessing the keys index, the primary key is returned rather
|
|
than the entity. When only the primary key is needed and not the entire
|
|
entity, using the keys index is less expensive than using the secondary
|
|
index because the primary index does not have to be accessed.</p>
|
|
|
|
<p>The third mapping provided by <code>SecondaryIndex</code> is from primary key
|
|
(PK) to entity (E), for the subset of entities having a given secondary key
|
|
(SK). This mapping is provided by the <A HREF="../../../com/sleepycat/persist/SecondaryIndex.html#subIndex(SK)"><CODE>subIndex(SK)</CODE></A> method. A
|
|
sub-index is convenient when you are interested in working with the subset
|
|
of entities having a particular secondary key value, for example, all
|
|
employees in a given department.</p>
|
|
|
|
<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>
|
|
interface documentation. See <A HREF="../../../com/sleepycat/persist/EntityIndex.html" title="interface in com.sleepycat.persist"><CODE>EntityIndex</CODE></A> for more information.</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>One-to-One Relationships</h3>
|
|
|
|
<p>A <A HREF="../../../com/sleepycat/persist/model/Relationship.html#ONE_TO_ONE"><CODE>ONE_TO_ONE</CODE></A> relationship, although less
|
|
common than other types of relationships, is the simplest type of
|
|
relationship. A single entity is related to a single secondary key value.
|
|
For example:</p>
|
|
|
|
<pre class="code">
|
|
@Entity
|
|
class Employee {
|
|
|
|
@PrimaryKey
|
|
long id;
|
|
|
|
@SecondaryKey(relate=ONE_TO_ONE)
|
|
String ssn;
|
|
|
|
String name;
|
|
|
|
private Employee() {}
|
|
}
|
|
|
|
<code>SecondaryIndex<String,Long,Employee></code> employeeBySsn =
|
|
store.getSecondaryIndex(primaryIndex, String.class, "ssn");</pre>
|
|
|
|
<p>With a <A HREF="../../../com/sleepycat/persist/model/Relationship.html#ONE_TO_ONE"><CODE>ONE_TO_ONE</CODE></A> relationship, the
|
|
secondary key must be unique; in other words, no two entities may have the
|
|
same secondary key value. If an attempt is made to store an entity having
|
|
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>
|
|
|
|
<p>Because the secondary key is unique, it is useful to lookup entities by
|
|
secondary key using <A HREF="../../../com/sleepycat/persist/EntityIndex.html#get(K)"><CODE>EntityIndex.get(K)</CODE></A>. For example:</p>
|
|
|
|
<pre class="code">
|
|
Employee employee = employeeBySsn.get(mySsn);</pre>
|
|
|
|
<h3>Many-to-One Relationships</h3>
|
|
|
|
<p>A <A HREF="../../../com/sleepycat/persist/model/Relationship.html#MANY_TO_ONE"><CODE>MANY_TO_ONE</CODE></A> relationship is the most
|
|
common type of relationship. One or more entities is related to a single
|
|
secondary key value. For example:</p>
|
|
|
|
<pre class="code">
|
|
@Entity
|
|
class Employee {
|
|
|
|
@PrimaryKey
|
|
long id;
|
|
|
|
@SecondaryKey(relate=MANY_TO_ONE)
|
|
String department;
|
|
|
|
String name;
|
|
|
|
private Employee() {}
|
|
}
|
|
|
|
<code>SecondaryIndex<String,Long,Employee></code> employeeByDepartment =
|
|
store.getSecondaryIndex(primaryIndex, String.class, "department");</pre>
|
|
|
|
<p>With a <A HREF="../../../com/sleepycat/persist/model/Relationship.html#MANY_TO_ONE"><CODE>MANY_TO_ONE</CODE></A> relationship, the
|
|
secondary key is not required to be unique; in other words, more than one
|
|
entity may have the same secondary key value. In this example, more than
|
|
one employee may belong to the same department.</p>
|
|
|
|
<p>The most convenient way to access the employees in a given department is
|
|
by using a sub-index. For example:</p>
|
|
|
|
<pre class="code">
|
|
<code>EntityIndex<Long,Entity></code> subIndex = employeeByDepartment.subIndex(myDept);
|
|
<code>EntityCursor<Employee></code> cursor = subIndex.entities();
|
|
try {
|
|
for (Employee entity : cursor) {
|
|
// Do something with the entity...
|
|
}
|
|
} finally {
|
|
cursor.close();
|
|
}</pre>
|
|
|
|
<h3>One-to-Many Relationships</h3>
|
|
|
|
<p>In a <A HREF="../../../com/sleepycat/persist/model/Relationship.html#ONE_TO_MANY"><CODE>ONE_TO_MANY</CODE></A> relationship, a single
|
|
entity is related to one or more secondary key values. For example:</p>
|
|
|
|
<pre class="code">
|
|
@Entity
|
|
class Employee {
|
|
|
|
@PrimaryKey
|
|
long id;
|
|
|
|
@SecondaryKey(relate=ONE_TO_MANY)
|
|
Set<String> emailAddresses = new HashSet<String>;
|
|
|
|
String name;
|
|
|
|
private Employee() {}
|
|
}
|
|
|
|
<code>SecondaryIndex<String,Long,Employee></code> employeeByEmail =
|
|
store.getSecondaryIndex(primaryIndex, String.class, "emailAddresses");</pre>
|
|
|
|
<p>With a <A HREF="../../../com/sleepycat/persist/model/Relationship.html#ONE_TO_MANY"><CODE>ONE_TO_MANY</CODE></A> relationship, the
|
|
secondary key must be unique; in other words, no two entities may have the
|
|
same secondary key value. In this example, no two employees may have the
|
|
same email address. If an attempt is made to store an entity having 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>
|
|
|
|
<p>Because the secondary key is unique, it is useful to lookup entities by
|
|
secondary key using <A HREF="../../../com/sleepycat/persist/EntityIndex.html#get(K)"><CODE>EntityIndex.get(K)</CODE></A>. For example:</p>
|
|
|
|
<pre class="code">
|
|
Employee employee = employeeByEmail.get(myEmailAddress);</pre>
|
|
|
|
<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
|
|
the email addresses of an employee, simply access the collection field
|
|
directly. For example:</p>
|
|
|
|
<pre class="code">
|
|
Employee employee = primaryIndex.get(1); // Get the entity by primary key
|
|
employee.emailAddresses.add(myNewEmail); // Add an email address
|
|
primaryIndex.putNoReturn(1, employee); // Update the entity</pre>
|
|
|
|
<h3>Many-to-Many Relationships</h3>
|
|
|
|
<p>In a <A HREF="../../../com/sleepycat/persist/model/Relationship.html#MANY_TO_MANY"><CODE>MANY_TO_MANY</CODE></A> relationship, one
|
|
or more entities is related to one or more secondary key values. For
|
|
example:</p>
|
|
|
|
<pre class="code">
|
|
@Entity
|
|
class Employee {
|
|
|
|
@PrimaryKey
|
|
long id;
|
|
|
|
@SecondaryKey(relate=MANY_TO_MANY)
|
|
Set<String> organizations = new HashSet<String>;
|
|
|
|
String name;
|
|
|
|
private Employee() {}
|
|
}
|
|
|
|
<code>SecondaryIndex<String,Long,Employee></code> employeeByOrganization =
|
|
store.getSecondaryIndex(primaryIndex, String.class, "organizations");</pre>
|
|
|
|
<p>With a <A HREF="../../../com/sleepycat/persist/model/Relationship.html#MANY_TO_MANY"><CODE>MANY_TO_MANY</CODE></A> relationship, the
|
|
secondary key is not required to be unique; in other words, more than one
|
|
entity may have the same secondary key value. In this example, more than
|
|
one employee may belong to the same organization.</p>
|
|
|
|
<p>The most convenient way to access the employees in a given organization
|
|
is by using a sub-index. For example:</p>
|
|
|
|
<pre class="code">
|
|
<code>EntityIndex<Long,Entity></code> subIndex = employeeByOrganization.subIndex(myOrg);
|
|
<code>EntityCursor<Employee></code> cursor = subIndex.entities();
|
|
try {
|
|
for (Employee entity : cursor) {
|
|
// Do something with the entity...
|
|
}
|
|
} finally {
|
|
cursor.close();
|
|
}</pre>
|
|
|
|
<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
|
|
the organizations of an employee, simply access the collection field
|
|
directly. For example:</p>
|
|
|
|
<pre class="code">
|
|
Employee employee = primaryIndex.get(1); // Get the entity by primary key
|
|
employee.organizations.remove(myOldOrg); // Remove an organization
|
|
primaryIndex.putNoReturn(1, employee); // Update the entity</pre>
|
|
|
|
<h3>Foreign Key Constraints for Related Entities</h3>
|
|
|
|
<p>In all the examples above the secondary key is treated only as a simple
|
|
value, such as a <code>String</code> department field. In many cases, that is
|
|
sufficient. But in other cases, you may wish to constrain the secondary
|
|
keys of one entity class to be valid primary keys of another entity
|
|
class. For example, a Department entity may also be defined:</p>
|
|
|
|
<pre class="code">
|
|
@Entity
|
|
class Department {
|
|
|
|
@PrimaryKey
|
|
String name;
|
|
|
|
String missionStatement;
|
|
|
|
private Department() {}
|
|
}</pre>
|
|
|
|
<p>You may wish to constrain the department field values of the Employee
|
|
class in the examples above to be valid primary keys of the Department
|
|
entity class. In other words, you may wish to ensure that the department
|
|
field of an Employee will always refer to a valid Department entity.</p>
|
|
|
|
<p>You can implement this constraint yourself by validating the department
|
|
field before you store an Employee. For example:</p>
|
|
|
|
<pre class="code">
|
|
<code>PrimaryIndex<String,Department></code> departmentIndex =
|
|
store.getPrimaryIndex(String.class, Department.class);
|
|
|
|
void storeEmployee(Employee employee) throws DatabaseException {
|
|
if (departmentIndex.contains(employee.department)) {
|
|
primaryIndex.putNoReturn(employee);
|
|
} else {
|
|
throw new IllegalArgumentException("Department does not exist: " +
|
|
employee.department);
|
|
}
|
|
}</pre>
|
|
|
|
<p>Or, instead you could define the Employee department field as a foreign
|
|
key, and this validation will be done for you when you attempt to store the
|
|
Employee entity. For example:</p>
|
|
|
|
<pre class="code">
|
|
@Entity
|
|
class Employee {
|
|
|
|
@PrimaryKey
|
|
long id;
|
|
|
|
@SecondaryKey(relate=MANY_TO_ONE, relatedEntity=Department.class)
|
|
String department;
|
|
|
|
String name;
|
|
|
|
private Employee() {}
|
|
}</pre>
|
|
|
|
<p>The <code>relatedEntity=Department.class</code> above defines the department
|
|
field as a foreign key that refers to a Department entity. Whenever a
|
|
Employee entity is stored, its department field value will be checked to
|
|
ensure that a Department entity exists with that value as its primary key.
|
|
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
|
|
thrown, causing the transaction to be aborted (assuming that transactions
|
|
are used).</p>
|
|
|
|
<p>This begs the question: What happens when a Department entity is deleted
|
|
while one or more Employee entities have department fields that refer to
|
|
the deleted department's primary key? If the department were allowed to be
|
|
deleted, the foreign key constraint for the Employee department field would
|
|
be violated, because the Employee department field would refer to a
|
|
department that does not exist.</p>
|
|
|
|
<p>By default, when this situation arises the system does not allow the
|
|
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,
|
|
causing the transaction to be aborted. In this case, in order to delete a
|
|
department, the department field of all Employee entities must first be
|
|
updated to refer to a different existing department, or set to null. This
|
|
is the responsibility of the application.</p>
|
|
|
|
<p>There are two additional ways of handling deletion of a Department
|
|
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
|
|
property to <A HREF="../../../com/sleepycat/persist/model/DeleteAction.html#NULLIFY"><CODE>DeleteAction.NULLIFY</CODE></A> causes the Employee department
|
|
field to be automatically set to null when the department they refer to is
|
|
deleted. This may or may not be desirable, depending on application
|
|
policies. For example:</p>
|
|
|
|
<pre class="code">
|
|
@Entity
|
|
class Employee {
|
|
|
|
@PrimaryKey
|
|
long id;
|
|
|
|
<code>@SecondaryKey(relate=MANY_TO_ONE, relatedEntity=Department.class,
|
|
onRelatedEntityDelete=NULLIFY)</code>
|
|
String department;
|
|
|
|
String name;
|
|
|
|
private Employee() {}
|
|
}</pre>
|
|
|
|
<p>The <A HREF="../../../com/sleepycat/persist/model/DeleteAction.html#CASCADE"><CODE>DeleteAction.CASCADE</CODE></A> value, on the other hand, causes the
|
|
Employee entities to be automatically deleted when the department they refer
|
|
to is deleted. This is probably not desirable in this particular example,
|
|
but is useful for parent-child relationships. For example:</p>
|
|
|
|
<pre class="code">
|
|
@Entity
|
|
class Order {
|
|
|
|
@PrimaryKey
|
|
long id;
|
|
|
|
String description;
|
|
|
|
private Order() {}
|
|
}
|
|
|
|
@Entity
|
|
class OrderItem {
|
|
|
|
@PrimaryKey
|
|
long id;
|
|
|
|
<code>@SecondaryKey(relate=MANY_TO_ONE, relatedEntity=Order.class,
|
|
onRelatedEntityDelete=CASCADE)</code>
|
|
long orderId;
|
|
|
|
String description;
|
|
|
|
private OrderItem() {}
|
|
}</pre>
|
|
|
|
<p>The OrderItem orderId field refers to its "parent" Order entity. When an
|
|
Order entity is deleted, it may be useful to automatically delete its
|
|
"child" OrderItem entities.</p>
|
|
|
|
<p>For more information, see <A HREF="../../../com/sleepycat/persist/model/SecondaryKey.html#onRelatedEntityDelete()"><CODE>SecondaryKey.onRelatedEntityDelete()</CODE></A>.</p>
|
|
|
|
<h3>One-to-Many versus Many-to-One for Related Entities</h3>
|
|
|
|
<p>When there is a conceptual Many-to-One relationship such as Employee to
|
|
Department as illustrated in the examples above, the relationship may be
|
|
implemented either as Many-to-One in the Employee class or as One-to-Many in
|
|
the Department class.</p>
|
|
|
|
<p>Here is the Many-to-One approach.</p>
|
|
|
|
<pre class="code">
|
|
@Entity
|
|
class Employee {
|
|
|
|
@PrimaryKey
|
|
long id;
|
|
|
|
@SecondaryKey(relate=MANY_TO_ONE, relatedEntity=Department.class)
|
|
String department;
|
|
|
|
String name;
|
|
|
|
private Employee() {}
|
|
}
|
|
|
|
@Entity
|
|
class Department {
|
|
|
|
@PrimaryKey
|
|
String name;
|
|
|
|
String missionStatement;
|
|
|
|
private Department() {}
|
|
}</pre>
|
|
|
|
<p>And here is the One-to-Many approach.</p>
|
|
|
|
<pre class="code">
|
|
@Entity
|
|
class Employee {
|
|
|
|
@PrimaryKey
|
|
long id;
|
|
|
|
String name;
|
|
|
|
private Employee() {}
|
|
}
|
|
|
|
@Entity
|
|
class Department {
|
|
|
|
@PrimaryKey
|
|
String name;
|
|
|
|
String missionStatement;
|
|
|
|
@SecondaryKey(relate=ONE_TO_MANY, relatedEntity=Employee.class)
|
|
Set<Long> employees = new HashSet<Long>;
|
|
|
|
private Department() {}
|
|
}</pre>
|
|
|
|
<p>Which approach is best? The Many-to-One approach better handles large
|
|
number of entities on the to-Many side of the relationship because it
|
|
doesn't store a collection of keys as an entity field. With Many-to-One a
|
|
Btree is used to store the collection of keys and the Btree can easily
|
|
handle very large numbers of keys. With One-to-Many, each time a related
|
|
key is added or removed the entity on the One side of the relationship,
|
|
along with the complete collection of related keys, must be updated.
|
|
Therefore, if large numbers of keys may be stored per relationship,
|
|
Many-to-One is recommended.</p>
|
|
|
|
<p>If the number of entities per relationship is not a concern, then you may
|
|
wish to choose the approach that is most natural in your application data
|
|
model. For example, if you think of a Department as containing employees
|
|
and you wish to modify the Department object each time an employee is added
|
|
or removed, then you may wish to store a collection of Employee keys in the
|
|
Department object (One-to-Many).</p>
|
|
|
|
<p>Note that if you have a One-to-Many relationship and there is no related
|
|
entity, then you don't have a choice -- you have to use One-to-Many because
|
|
there is no entity on the to-Many side of the relationship where a
|
|
Many-to-One key could be defined. An example is the Employee to email
|
|
addresses relationship discussed above:</p>
|
|
|
|
<pre class="code">
|
|
@Entity
|
|
class Employee {
|
|
|
|
@PrimaryKey
|
|
long id;
|
|
|
|
@SecondaryKey(relate=ONE_TO_MANY)
|
|
Set<String> emailAddresses = new HashSet<String>;
|
|
|
|
String name;
|
|
|
|
private Employee() {}
|
|
}</pre>
|
|
|
|
<p>For sake of argument imagine that each employee has thousands of email
|
|
addresses and employees frequently add and remove email addresses. To
|
|
avoid the potential performance problems associated with updating the
|
|
Employee entity every time an email address is added or removed, you could
|
|
create an EmployeeEmailAddress entity and use a Many-to-One relationship as
|
|
shown below:</p>
|
|
|
|
<pre class="code">
|
|
@Entity
|
|
class Employee {
|
|
|
|
@PrimaryKey
|
|
long id;
|
|
|
|
String name;
|
|
|
|
private Employee() {}
|
|
}
|
|
|
|
@Entity
|
|
class EmployeeEmailAddress {
|
|
|
|
@PrimaryKey
|
|
String emailAddress;
|
|
|
|
@SecondaryKey(relate=MANY_TO_ONE, relatedEntity=Employee.class)
|
|
long employeeId;
|
|
|
|
private EmployeeEmailAddress() {}
|
|
}</pre>
|
|
|
|
<h3>Key Placement with Many-to-Many for Related Entities</h3>
|
|
|
|
<p>As discussed in the section above, one drawback of a to-Many relationship
|
|
(One-to-Many was discussed above and Many-to-Many is discussed here) is that
|
|
it requires storing a collection of keys in an entity. Each time a key is
|
|
added or removed, the containing entity must be updated. This has potential
|
|
performance problems when there are large numbers of entities on the to-Many
|
|
side of the relationship, in other words, when there are large numbers of
|
|
keys in each secondary key field collection.</p>
|
|
|
|
<p>If you have a Many-to-Many relationship with a reasonably small number of
|
|
entities on one side of the relationship and a large number of entities on
|
|
the other side, you can avoid the potential performance problems by defining
|
|
the secondary key field on the side with a small number of entities.</p>
|
|
|
|
<p>For example, in an Employee-to-Organization relationship, the number of
|
|
organizations per employee will normally be reasonably small but the number
|
|
of employees per organization may be very large. Therefore, to avoid
|
|
potential performance problems, the secondary key field should be defined in
|
|
the Employee class as shown below.</p>
|
|
|
|
<pre class="code">
|
|
@Entity
|
|
class Employee {
|
|
|
|
@PrimaryKey
|
|
long id;
|
|
|
|
@SecondaryKey(relate=MANY_TO_MANY, relatedEntity=Organization.class)
|
|
Set<String> organizations = new HashSet<String>;
|
|
|
|
String name;
|
|
|
|
private Employee() {}
|
|
}
|
|
|
|
@Entity
|
|
class Organization {
|
|
|
|
@PrimaryKey
|
|
String name;
|
|
|
|
String description;
|
|
}</pre>
|
|
|
|
<p>If instead a <code>Set<Long> members</code> key had been defined in the
|
|
Organization class, this set could potentially have a large number of
|
|
elements and performance problems could result.</p>
|
|
|
|
<h3>Many-to-Many Versus a Relationship Entity</h3>
|
|
|
|
<p>If you have a Many-to-Many relationship with a large number of entities
|
|
on <em>both</em> sides of the relationship, you can avoid the potential
|
|
performance problems by using a <em>relationship entity</em>. A
|
|
relationship entity defines the relationship between two other entities
|
|
using two Many-to-One relationships.</p>
|
|
|
|
<p>Imagine a relationship between cars and trucks indicating whenever a
|
|
particular truck was passed on the road by a particular car. A given car
|
|
may pass a large number of trucks and a given truck may be passed by a large
|
|
number of cars. First look at a Many-to-Many relationship between these two
|
|
entities:</p>
|
|
|
|
<pre class="code">
|
|
@Entity
|
|
class Car {
|
|
|
|
@PrimaryKey
|
|
String licenseNumber;
|
|
|
|
@SecondaryKey(relate=MANY_TO_MANY, relatedEntity=Truck.class)
|
|
Set<String> trucksPassed = new HashSet<String>;
|
|
|
|
String color;
|
|
|
|
private Car() {}
|
|
}
|
|
|
|
@Entity
|
|
class Truck {
|
|
|
|
@PrimaryKey
|
|
String licenseNumber;
|
|
|
|
int tons;
|
|
|
|
private Truck() {}
|
|
}</pre>
|
|
|
|
<p>With the Many-to-Many approach above, the <code>trucksPassed</code> set could
|
|
potentially have a large number of elements and performance problems could
|
|
result.</p>
|
|
|
|
<p>To apply the relationship entity approach we define a new entity class
|
|
named CarPassedTruck representing a single truck passed by a single car. We
|
|
remove the secondary key from the Car class and use two secondary keys in
|
|
the CarPassedTruck class instead.</p>
|
|
|
|
<pre class="code">
|
|
@Entity
|
|
class Car {
|
|
|
|
@PrimaryKey
|
|
String licenseNumber;
|
|
|
|
String color;
|
|
|
|
private Car() {}
|
|
}
|
|
|
|
@Entity
|
|
class Truck {
|
|
|
|
@PrimaryKey
|
|
String licenseNumber;
|
|
|
|
int tons;
|
|
|
|
private Truck() {}
|
|
}
|
|
|
|
@Entity
|
|
class CarPassedTruck {
|
|
|
|
@PrimaryKey
|
|
long id;
|
|
|
|
@SecondaryKey(relate=MANY_TO_ONE, relatedEntity=Car.class)
|
|
String carLicense;
|
|
|
|
@SecondaryKey(relate=MANY_TO_ONE, relatedEntity=Truck.class)
|
|
String truckLicense;
|
|
|
|
private CarPassedTruck() {}
|
|
}</pre>
|
|
|
|
<p>The CarPassedTruck entity can be used to access the relationship by car
|
|
license or by truck license.</p>
|
|
|
|
<p>You may use the relationship entity approach because of the potential
|
|
performance problems mentioned above. Or, you may choose to use this
|
|
approach in order to store other information about the relationship. For
|
|
example, if for each car that passes a truck you wish to record how much
|
|
faster the car was going than the truck, then a relationship entity is the
|
|
logical place to store that property. In the example below the
|
|
speedDifference property is added to the CarPassedTruck class.</p>
|
|
|
|
<pre class="code">
|
|
@Entity
|
|
class CarPassedTruck {
|
|
|
|
@PrimaryKey
|
|
long id;
|
|
|
|
@SecondaryKey(relate=MANY_TO_ONE, relatedEntity=Car.class)
|
|
String carLicense;
|
|
|
|
@SecondaryKey(relate=MANY_TO_ONE, relatedEntity=Truck.class)
|
|
String truckLicense;
|
|
|
|
int speedDifference;
|
|
|
|
private CarPassedTruck() {}
|
|
}</pre>
|
|
|
|
<p>Be aware that the relationship entity approach adds overhead compared to
|
|
Many-to-Many. There is one additional entity and one additional secondary
|
|
key. These factors should be weighed against its advantages and the
|
|
relevant application access patterns should be considered.</p>
|
|
<P>
|
|
|
|
<P>
|
|
<HR>
|
|
|
|
<P>
|
|
|
|
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
|
|
|
|
<A NAME="constructor_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>Constructor Summary</B></FONT></TH>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<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,
|
|
<A HREF="../../../com/sleepycat/db/Database.html" title="class in com.sleepycat.db">Database</A> keysDatabase,
|
|
<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,
|
|
<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html" title="class or interface in java.lang">Class</A><<A HREF="../../../com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">SK</A>> secondaryKeyClass,
|
|
<A HREF="../../../com/sleepycat/bind/EntryBinding.html" title="interface in com.sleepycat.bind">EntryBinding</A> secondaryKeyBinding)</CODE>
|
|
|
|
<BR>
|
|
Creates a secondary index without using an <code>EntityStore</code>.</TD>
|
|
</TR>
|
|
</TABLE>
|
|
|
|
<!-- ========== 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/SecondaryIndex.html#contains(K)">contains</A></B>(K 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/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,
|
|
K 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/SecondaryIndex.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/SecondaryIndex.html#delete(K)">delete</A></B>(K 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/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,
|
|
K 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><E></CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../../com/sleepycat/persist/SecondaryIndex.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><E></CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../../com/sleepycat/persist/SecondaryIndex.html#entities(K, boolean, K, boolean)">entities</A></B>(K fromKey,
|
|
boolean fromInclusive,
|
|
K 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><E></CODE></FONT></TD>
|
|
<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,
|
|
<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><E></CODE></FONT></TD>
|
|
<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,
|
|
K fromKey,
|
|
boolean fromInclusive,
|
|
K 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/SecondaryIndex.html" title="type parameter in SecondaryIndex">E</A></CODE></FONT></TD>
|
|
<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>
|
|
|
|
<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/SecondaryIndex.html" title="type parameter in SecondaryIndex">E</A></CODE></FONT></TD>
|
|
<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,
|
|
<A HREF="../../../com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">SK</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/db/SecondaryDatabase.html" title="class in com.sleepycat.db">SecondaryDatabase</A></CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../../com/sleepycat/persist/SecondaryIndex.html#getDatabase()">getDatabase</A></B>()</CODE>
|
|
|
|
<BR>
|
|
Returns the underlying secondary database for this index.</TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE> <A HREF="../../../com/sleepycat/bind/EntryBinding.html" title="interface in com.sleepycat.bind">EntryBinding</A></CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../../com/sleepycat/persist/SecondaryIndex.html#getKeyBinding()">getKeyBinding</A></B>()</CODE>
|
|
|
|
<BR>
|
|
Returns the secondary key binding for the index.</TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE> <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html" title="class or interface in java.lang">Class</A><<A HREF="../../../com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">SK</A>></CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../../com/sleepycat/persist/SecondaryIndex.html#getKeyClass()">getKeyClass</A></B>()</CODE>
|
|
|
|
<BR>
|
|
Returns the secondary key class for this index.</TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE> <A HREF="../../../com/sleepycat/db/Database.html" title="class in com.sleepycat.db">Database</A></CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../../com/sleepycat/persist/SecondaryIndex.html#getKeysDatabase()">getKeysDatabase</A></B>()</CODE>
|
|
|
|
<BR>
|
|
Returns the underlying secondary database that is not associated with
|
|
the primary database and is used for the <A HREF="../../../com/sleepycat/persist/SecondaryIndex.html#keysIndex"><CODE>keysIndex</CODE></A>.</TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<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>
|
|
<TD><CODE><B><A HREF="../../../com/sleepycat/persist/SecondaryIndex.html#getPrimaryIndex()">getPrimaryIndex</A></B>()</CODE>
|
|
|
|
<BR>
|
|
Returns the primary index associated with this secondary 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><K></CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../../com/sleepycat/persist/SecondaryIndex.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><K></CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../../com/sleepycat/persist/SecondaryIndex.html#keys(K, boolean, K, boolean)">keys</A></B>(K fromKey,
|
|
boolean fromInclusive,
|
|
K 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><K></CODE></FONT></TD>
|
|
<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,
|
|
<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><K></CODE></FONT></TD>
|
|
<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,
|
|
K fromKey,
|
|
boolean fromInclusive,
|
|
K 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="../../../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>
|
|
<TD><CODE><B><A HREF="../../../com/sleepycat/persist/SecondaryIndex.html#keysIndex()">keysIndex</A></B>()</CODE>
|
|
|
|
<BR>
|
|
Returns a read-only keys index that maps secondary key to primary key.</TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE> <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Map.html" title="class or interface in java.util">Map</A><<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>
|
|
<TD><CODE><B><A HREF="../../../com/sleepycat/persist/SecondaryIndex.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://java.sun.com/j2se/1.5.0/docs/api/java/util/SortedMap.html" 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>
|
|
<TD><CODE><B><A HREF="../../../com/sleepycat/persist/SecondaryIndex.html#sortedMap()">sortedMap</A></B>()</CODE>
|
|
|
|
<BR>
|
|
Returns a standard Java sorted 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="../../../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>
|
|
<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>
|
|
|
|
<BR>
|
|
Returns an index that maps primary key to entity for the subset of
|
|
entities having a given secondary key (duplicates).</TD>
|
|
</TR>
|
|
</TABLE>
|
|
<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
|
|
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
|
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
|
|
<TH ALIGN="left"><B>Methods inherited from class java.lang.<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A></B></TH>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<TD><CODE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#clone()" title="class or interface in java.lang">clone</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#equals(java.lang.Object)" title="class or interface in java.lang">equals</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#finalize()" title="class or interface in java.lang">finalize</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#getClass()" title="class or interface in java.lang">getClass</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#hashCode()" title="class or interface in java.lang">hashCode</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#notify()" title="class or interface in java.lang">notify</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#notifyAll()" title="class or interface in java.lang">notifyAll</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#toString()" title="class or interface in java.lang">toString</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#wait()" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#wait(long)" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#wait(long, int)" title="class or interface in java.lang">wait</A></CODE></TD>
|
|
</TR>
|
|
</TABLE>
|
|
|
|
<P>
|
|
|
|
<!-- ========= CONSTRUCTOR DETAIL ======== -->
|
|
|
|
<A NAME="constructor_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>Constructor Detail</B></FONT></TH>
|
|
</TR>
|
|
</TABLE>
|
|
|
|
<A NAME="SecondaryIndex(com.sleepycat.db.SecondaryDatabase, com.sleepycat.db.Database, com.sleepycat.persist.PrimaryIndex, java.lang.Class, com.sleepycat.bind.EntryBinding)"><!-- --></A><H3>
|
|
SecondaryIndex</H3>
|
|
<PRE>
|
|
public <B>SecondaryIndex</B>(<A HREF="../../../com/sleepycat/db/SecondaryDatabase.html" title="class in com.sleepycat.db">SecondaryDatabase</A> database,
|
|
<A HREF="../../../com/sleepycat/db/Database.html" title="class in com.sleepycat.db">Database</A> keysDatabase,
|
|
<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,
|
|
<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html" title="class or interface in java.lang">Class</A><<A HREF="../../../com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">SK</A>> secondaryKeyClass,
|
|
<A HREF="../../../com/sleepycat/bind/EntryBinding.html" title="interface in com.sleepycat.bind">EntryBinding</A> secondaryKeyBinding)
|
|
throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
|
|
<DL>
|
|
<DD>Creates a secondary index without using an <code>EntityStore</code>.
|
|
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.
|
|
|
|
<p>This constructor is not normally needed and is provided for
|
|
applications that wish to use custom bindings along with the Direct
|
|
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>
|
|
<P>
|
|
<DL>
|
|
<DT><B>Parameters:</B><DD><CODE>database</CODE> - the secondary database used for all access other than
|
|
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
|
|
without association to the primary, and used only for access via a
|
|
<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>
|
|
method is called, then the keys database will be opened automatically;
|
|
however, the user is then responsible for closing the keys database. To
|
|
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
|
|
index.<DD><CODE>secondaryKeyClass</CODE> - the class of the secondary key.<DD><CODE>secondaryKeyBinding</CODE> - the binding to be used for secondary keys.
|
|
<DT><B>Throws:</B>
|
|
<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
|
|
</DL>
|
|
|
|
<!-- ============ 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="getDatabase()"><!-- --></A><H3>
|
|
getDatabase</H3>
|
|
<PRE>
|
|
public <A HREF="../../../com/sleepycat/db/SecondaryDatabase.html" title="class in com.sleepycat.db">SecondaryDatabase</A> <B>getDatabase</B>()</PRE>
|
|
<DL>
|
|
<DD>Returns the underlying secondary database for this index.
|
|
<P>
|
|
<DD><DL>
|
|
|
|
<DT><B>Returns:</B><DD>the secondary database.</DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="getKeysDatabase()"><!-- --></A><H3>
|
|
getKeysDatabase</H3>
|
|
<PRE>
|
|
public <A HREF="../../../com/sleepycat/db/Database.html" title="class in com.sleepycat.db">Database</A> <B>getKeysDatabase</B>()</PRE>
|
|
<DL>
|
|
<DD>Returns the underlying secondary database that is not associated with
|
|
the primary database and is used for the <A HREF="../../../com/sleepycat/persist/SecondaryIndex.html#keysIndex"><CODE>keysIndex</CODE></A>.
|
|
<P>
|
|
<DD><DL>
|
|
|
|
<DT><B>Returns:</B><DD>the keys database.</DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="getPrimaryIndex()"><!-- --></A><H3>
|
|
getPrimaryIndex</H3>
|
|
<PRE>
|
|
public <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>
|
|
<DL>
|
|
<DD>Returns the primary index associated with this secondary index.
|
|
<P>
|
|
<DD><DL>
|
|
|
|
<DT><B>Returns:</B><DD>the primary index.</DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="getKeyClass()"><!-- --></A><H3>
|
|
getKeyClass</H3>
|
|
<PRE>
|
|
public <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html" title="class or interface in java.lang">Class</A><<A HREF="../../../com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">SK</A>> <B>getKeyClass</B>()</PRE>
|
|
<DL>
|
|
<DD>Returns the secondary key class for this index.
|
|
<P>
|
|
<DD><DL>
|
|
|
|
<DT><B>Returns:</B><DD>the class.</DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="getKeyBinding()"><!-- --></A><H3>
|
|
getKeyBinding</H3>
|
|
<PRE>
|
|
public <A HREF="../../../com/sleepycat/bind/EntryBinding.html" title="interface in com.sleepycat.bind">EntryBinding</A> <B>getKeyBinding</B>()</PRE>
|
|
<DL>
|
|
<DD>Returns the secondary key binding for the index.
|
|
<P>
|
|
<DD><DL>
|
|
|
|
<DT><B>Returns:</B><DD>the key binding.</DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="keysIndex()"><!-- --></A><H3>
|
|
keysIndex</H3>
|
|
<PRE>
|
|
public <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>()
|
|
throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
|
|
<DL>
|
|
<DD>Returns a read-only keys index that maps secondary key to primary key.
|
|
When accessing the keys index, the primary key is returned rather than
|
|
the entity. When only the primary key is needed and not the entire
|
|
entity, using the keys index is less expensive than using the secondary
|
|
index because the primary index does not have to be accessed.
|
|
|
|
<p>Note the following in the unusual case that you are <em>not</em>
|
|
using an <code>EntityStore</code>: This method will open the keys
|
|
database, a second database handle for the secondary database, if it is
|
|
not already open. In this case, if you are <em>not</em> using an
|
|
<code>EntityStore</code>, then you are responsible for closing the
|
|
database returned by <A HREF="../../../com/sleepycat/persist/SecondaryIndex.html#getKeysDatabase()"><CODE>getKeysDatabase()</CODE></A> before closing the
|
|
environment. If you <em>are</em> using an <code>EntityStore</code>, the
|
|
keys database will be closed automatically by <A HREF="../../../com/sleepycat/persist/EntityStore.html#close()"><CODE>EntityStore.close()</CODE></A>.</p>
|
|
<P>
|
|
<DD><DL>
|
|
|
|
<DT><B>Returns:</B><DD>the keys index.
|
|
<DT><B>Throws:</B>
|
|
<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="subIndex(java.lang.Object)"><!-- --></A><A NAME="subIndex(SK)"><!-- --></A><H3>
|
|
subIndex</H3>
|
|
<PRE>
|
|
public <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)
|
|
throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
|
|
<DL>
|
|
<DD>Returns an index that maps primary key to entity for the subset of
|
|
entities having a given secondary key (duplicates). A sub-index is
|
|
convenient when you are interested in working with the subset of
|
|
entities having a particular secondary key value.
|
|
|
|
<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
|
|
represents the left (MANY) side of a relationship.</p>
|
|
<P>
|
|
<DD><DL>
|
|
<DT><B>Parameters:</B><DD><CODE>key</CODE> - the secondary key that identifies the entities in the
|
|
sub-index.
|
|
<DT><B>Returns:</B><DD>the sub-index.
|
|
<DT><B>Throws:</B>
|
|
<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="get(java.lang.Object)"><!-- --></A><A NAME="get(SK)"><!-- --></A><H3>
|
|
get</H3>
|
|
<PRE>
|
|
public <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)
|
|
throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
|
|
<DL>
|
|
<DD><B>Description copied from interface: <CODE><A HREF="../../../com/sleepycat/persist/EntityIndex.html#get(K)">EntityIndex</A></CODE></B></DD>
|
|
<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></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, SK, com.sleepycat.db.LockMode)"><!-- --></A><H3>
|
|
get</H3>
|
|
<PRE>
|
|
public <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,
|
|
<A HREF="../../../com/sleepycat/persist/SecondaryIndex.html" title="type parameter in SecondaryIndex">SK</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><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>
|
|
<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></DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="map()"><!-- --></A><H3>
|
|
map</H3>
|
|
<PRE>
|
|
public <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Map.html" title="class or interface in java.util">Map</A><<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>
|
|
<DL>
|
|
<DD><B>Description copied from interface: <CODE><A HREF="../../../com/sleepycat/persist/EntityIndex.html#map()">EntityIndex</A></CODE></B></DD>
|
|
<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>
|
|
public <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/SortedMap.html" title="class or interface in java.util">SortedMap</A><<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>
|
|
<DL>
|
|
<DD><B>Description copied from interface: <CODE><A HREF="../../../com/sleepycat/persist/EntityIndex.html#sortedMap()">EntityIndex</A></CODE></B></DD>
|
|
<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>
|
|
<HR>
|
|
|
|
<A NAME="contains(java.lang.Object)"><!-- --></A><A NAME="contains(K)"><!-- --></A><H3>
|
|
contains</H3>
|
|
<PRE>
|
|
public boolean <B>contains</B>(K key)
|
|
throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
|
|
<DL>
|
|
<DD><B>Description copied from interface: <CODE><A HREF="../../../com/sleepycat/persist/EntityIndex.html#contains(K)">EntityIndex</A></CODE></B></DD>
|
|
<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>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>
|
|
</DD>
|
|
<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></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>
|
|
public boolean <B>contains</B>(<A HREF="../../../com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db">Transaction</A> txn,
|
|
K 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><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>
|
|
<DD>Checks for existence of a key in this index.
|
|
<P>
|
|
<DD><DL>
|
|
<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>
|
|
</DD>
|
|
<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></DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="count()"><!-- --></A><H3>
|
|
count</H3>
|
|
<PRE>
|
|
public long <B>count</B>()
|
|
throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
|
|
<DL>
|
|
<DD><B>Description copied from interface: <CODE><A HREF="../../../com/sleepycat/persist/EntityIndex.html#count()">EntityIndex</A></CODE></B></DD>
|
|
<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.</p>
|
|
<P>
|
|
<DD><DL>
|
|
<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>
|
|
</DD>
|
|
<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></DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="delete(java.lang.Object)"><!-- --></A><A NAME="delete(K)"><!-- --></A><H3>
|
|
delete</H3>
|
|
<PRE>
|
|
public boolean <B>delete</B>(K key)
|
|
throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
|
|
<DL>
|
|
<DD><B>Description copied from interface: <CODE><A HREF="../../../com/sleepycat/persist/EntityIndex.html#delete(K)">EntityIndex</A></CODE></B></DD>
|
|
<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>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>
|
|
</DD>
|
|
<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></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>
|
|
public boolean <B>delete</B>(<A HREF="../../../com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db">Transaction</A> txn,
|
|
K key)
|
|
throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
|
|
<DL>
|
|
<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>
|
|
<DD>Deletes all entities with a given index key.
|
|
<P>
|
|
<DD><DL>
|
|
<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>
|
|
</DD>
|
|
<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></DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="keys()"><!-- --></A><H3>
|
|
keys</H3>
|
|
<PRE>
|
|
public <A HREF="../../../com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A><K> <B>keys</B>()
|
|
throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
|
|
<DL>
|
|
<DD><B>Description copied from interface: <CODE><A HREF="../../../com/sleepycat/persist/EntityIndex.html#keys()">EntityIndex</A></CODE></B></DD>
|
|
<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>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>
|
|
</DD>
|
|
<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></DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="keys(com.sleepycat.db.Transaction, com.sleepycat.db.CursorConfig)"><!-- --></A><H3>
|
|
keys</H3>
|
|
<PRE>
|
|
public <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,
|
|
<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><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>
|
|
<DD>Opens a cursor for traversing all keys in this index.
|
|
<P>
|
|
<DD><DL>
|
|
<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>
|
|
</DD>
|
|
<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 null is specified and the store is transactional, the
|
|
cursor may not be used to update or delete entities.<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></DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="entities()"><!-- --></A><H3>
|
|
entities</H3>
|
|
<PRE>
|
|
public <A HREF="../../../com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A><E> <B>entities</B>()
|
|
throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
|
|
<DL>
|
|
<DD><B>Description copied from interface: <CODE><A HREF="../../../com/sleepycat/persist/EntityIndex.html#entities()">EntityIndex</A></CODE></B></DD>
|
|
<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>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>
|
|
</DD>
|
|
<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></DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="entities(com.sleepycat.db.Transaction, com.sleepycat.db.CursorConfig)"><!-- --></A><H3>
|
|
entities</H3>
|
|
<PRE>
|
|
public <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,
|
|
<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><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>
|
|
<DD>Opens a cursor for traversing all entities in this index.
|
|
<P>
|
|
<DD><DL>
|
|
<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>
|
|
</DD>
|
|
<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 null is specified and the store is transactional, the
|
|
cursor may not be used to update or delete entities.<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></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>
|
|
public <A HREF="../../../com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A><K> <B>keys</B>(K fromKey,
|
|
boolean fromInclusive,
|
|
K toKey,
|
|
boolean toInclusive)
|
|
throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
|
|
<DL>
|
|
<DD><B>Description copied from interface: <CODE><A HREF="../../../com/sleepycat/persist/EntityIndex.html#keys(K, boolean, K, boolean)">EntityIndex</A></CODE></B></DD>
|
|
<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>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>
|
|
</DD>
|
|
<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></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>
|
|
public <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,
|
|
K fromKey,
|
|
boolean fromInclusive,
|
|
K 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><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>
|
|
<DD>Opens a cursor for traversing keys in a key range.
|
|
<P>
|
|
<DD><DL>
|
|
<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>
|
|
</DD>
|
|
<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 null is specified and the store is transactional, the
|
|
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
|
|
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></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>
|
|
public <A HREF="../../../com/sleepycat/persist/EntityCursor.html" title="interface in com.sleepycat.persist">EntityCursor</A><E> <B>entities</B>(K fromKey,
|
|
boolean fromInclusive,
|
|
K toKey,
|
|
boolean toInclusive)
|
|
throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE>
|
|
<DL>
|
|
<DD><B>Description copied from interface: <CODE><A HREF="../../../com/sleepycat/persist/EntityIndex.html#entities(K, boolean, K, boolean)">EntityIndex</A></CODE></B></DD>
|
|
<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>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>
|
|
</DD>
|
|
<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></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>
|
|
public <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,
|
|
K fromKey,
|
|
boolean fromInclusive,
|
|
K 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><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>
|
|
<DD>Opens a cursor for traversing entities in a key range.
|
|
<P>
|
|
<DD><DL>
|
|
<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>
|
|
</DD>
|
|
<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 null is specified and the store is transactional, the
|
|
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
|
|
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></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/SecondaryIndex.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 4.7.25</font></EM>
|
|
</TD>
|
|
</TR>
|
|
|
|
<TR>
|
|
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
|
<A HREF="../../../com/sleepycat/persist/PrimaryIndex.html" title="class in com.sleepycat.persist"><B>PREV CLASS</B></A>
|
|
<A HREF="../../../com/sleepycat/persist/StoreConfig.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/SecondaryIndex.html" target="_top"><B>FRAMES</B></A>
|
|
<A HREF="SecondaryIndex.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 | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
|
|
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
|
|
DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <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,2008 Oracle. All rights reserved.</font>
|
|
</BODY>
|
|
</HTML>
|