Java Doc for EntityIndex.java in  » JMX » je » com » sleepycat » persist » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » JMX » je » com.sleepycat.persist 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


com.sleepycat.persist.EntityIndex

EntityIndex
public interface EntityIndex (Code)
The interface for accessing keys and entities via a primary or secondary index.

EntityIndex objects are thread-safe. Multiple threads may safely call the methods of a shared EntityIndex object.

An index is conceptually a map. {key:value} mappings are stored in the index and accessed by key. In fact, for interoperability with other libraries that use the standard Java Map or SortedMap interfaces, an EntityIndex may be accessed via these standard interfaces by calling the EntityIndex.map or EntityIndex.sortedMap methods.

EntityIndex is an interface that is implemented by several classes in this package for different purposes. Depending on the context, the key type (K) and value type (V) of the index take on different meanings. The different classes that implement EntityIndex are:

In all cases, the index key type (K) is a primary or secondary key class. The index value type (V) is an entity class in all cases except for a SecondaryIndex.keysIndex , when it is a primary key class.

In the following example, a Employee entity with a MANY_TO_ONE secondary key is defined.

 class Employee {
 long id;
 String department;
 String name;
 private Employee() {}
 }

Consider that we have stored the entities below:

Entities
IDDepartmentName
1EngineeringJane Smith
2SalesJoan Smith
3EngineeringJohn Smith
4SalesJim Smith

PrimaryIndex maps primary keys to entities:

  PrimaryIndex   primaryIndex =
 store.getPrimaryIndex(Long.class, Employee.class);

primaryIndex
Primary KeyEntity
11EngineeringJane Smith
22SalesJoan Smith
33EngineeringJohn Smith
44SalesJim Smith

SecondaryIndex maps secondary keys to entities:

  SecondaryIndex   secondaryIndex =
 store.getSecondaryIndex(primaryIndex, String.class, "department");

secondaryIndex
Secondary KeyEntity
Engineering1EngineeringJane Smith
Engineering3EngineeringJohn Smith
Sales2SalesJoan Smith
Sales4SalesJim Smith

SecondaryIndex.keysIndex maps secondary keys to primary keys:

  EntityIndex   keysIndex = secondaryIndex.keysIndex();

keysIndex
Secondary KeyPrimary Key
Engineering1
Engineering3
Sales2
Sales4

SecondaryIndex.subIndex maps primary keys to entities, for the subset of entities having a specified secondary key:

  EntityIndex   subIndex = secondaryIndex.subIndex("Engineering");

subIndex
Primary KeyEntity
11EngineeringJane Smith
33EngineeringJohn Smith

Accessing the Index

An EntityIndex provides a variety of methods for retrieving entities from an index. It also provides methods for deleting entities. However, it does not provide methods for inserting and updating. To insert and update entities, use the PrimaryIndex.put family of methods in the PrimaryIndex class.

An EntityIndex supports two mechanisms for retrieving entities:

  1. The EntityIndex.get mehod returns a single value for a given key. If there are multiple values with the same secondary key (duplicates), it returns the first entity in the duplicate set.
  2. An EntityCursor can be obtained using the EntityIndex.keys and EntityIndex.entities family of methods. A cursor can be used to return all values in the index, including duplicates. A cursor can also be used to return values within a specified range of keys.

Using the example entities above, calling EntityIndex.get on the primary index will always return the employee with the given ID, or null if no such ID exists. But calling EntityIndex.get on the secondary index will retrieve the first employee in the given department, which may not be very useful:

 Employee emp = primaryIndex.get(1);      // Returns by unique ID
 emp = secondaryIndex.get("Engineering"); // Returns first in department

Using a cursor, you can iterate through all duplicates in the secondary index:

  EntityCursor   cursor = secondaryIndex.entities();
 try {
 for (Employee entity : cursor) {
 if (entity.department.equals("Engineering")) {
 // Do something with the entity...
 }
 }
 } finally {
 cursor.close();
 }

But for a large database it is much more efficient to iterate over only those entities with the secondary key you're searching for. This could be done by restricting a cursor to a range of keys:

  EntityCursor   cursor =
 secondaryIndex.entities("Engineering", true, "Engineering", true);
 try {
 for (Employee entity : cursor) {
 // Do something with the entity...
 }
 } finally {
 cursor.close();
 }

However, when you are interested only in the entities with a particular secondary key value, it is more convenient to use a sub-index:

  EntityIndex   subIndex = secondaryIndex.subIndex("Engineering");
  EntityCursor   cursor = subIndex.entities();
 try {
 for (Employee entity : cursor) {
 // Do something with the entity...
 }
 } finally {
 cursor.close();
 }

In addition to being more convenient than a cursor range, a sub-index allows retrieving by primary key:

 Employee emp = subIndex.get(1);

When using a sub-index, all operations performed on the sub-index are restricted to the single key that was specified when the sub-index was created. For example, the following returns null because employee 2 is not in the Engineering department and therefore is not part of the sub-index:

 Employee emp = subIndex.get(2);

For more information on using cursors and cursor ranges, see EntityCursor .

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.

 MyKey key = ...;
 MyEntity entity1 = index.get(key);
 MyEntity entity2 = index.get(key);
 assert entity1 == entity2; // always fails!
 

Deleting from the Index

Any type of index may be used to delete entities with a specified key by calling EntityIndex.delete . The important thing to keep in mind is that all entities with the specified key are deleted. In a primay index, at most a single entity is deleted:

 primaryIndex.delete(1); // Deletes a single employee by unique ID

But in a secondary index, multiple entities may be deleted:

 secondaryIndex.delete("Engineering"); // Deletes all Engineering employees

This begs this question: How can a single entity be deleted without knowing its primary key? The answer is to use cursors. After locating an entity using a cursor, the entity can be deleted by calling EntityCursor.delete .

Transactions

Transactions can be used to provide standard ACID (Atomicity, Consistency, Integrity and Durability) guarantees when retrieving, storing and deleting entities. This section provides a brief overview of how to use transactions with the Direct Persistence Layer. For more information on using transactions, see Writing Transactional Applications.

Transactions may be used only with a transactional EntityStore , which is one for which StoreConfig.setTransactionalStoreConfig.setTransactional(true) has been called. Likewise, a transactional store may only be used with a transactional Environment , which is one for which EnvironmentConfig.setTransactional EnvironmentConfig.setTransactional(true) has been called. For example:

 EnvironmentConfig envConfig = new EnvironmentConfig();
 envConfig.setTransactional(true);
 envConfig.setAllowCreate(true);
 Environment env = new Environment(new File("/my/data"), envConfig);
 StoreConfig storeConfig = new StoreConfig();
 storeConfig.setTransactional(true);
 storeConfig.setAllowCreate(true);
 EntityStore store = new EntityStore(env, "myStore", storeConfig);

Transactions are represented by Transaction objects, which are part of the com.sleepycat.je Base API . Transactions are created using the Environment.beginTransaction Environment.beginTransaction method.

A transaction will include all operations for which the transaction object is passed as a method argument. All retrieval, storage and deletion methods have an optional Transaction parameter for this purpose. When a transaction is passed to a method that opens a cursor, all retrieval, storage and deletion operations performed using that cursor will be included in the transaction.

A transaction may be committed by calling Transaction.commit or aborted by calling Transaction.abort . For example, two employees may be deleted atomically with a transaction; other words, either both are deleted or neither is deleted:

 Transaction txn = env.beginTransaction(null, null);
 try {
 primaryIndex.delete(txn, 1);
 primaryIndex.delete(txn, 2);
 txn.commit();
 txn = null;
 } finally {
 if (txn != null) {
 txn.abort();
 }
 }

WARNING: Transactions must always be committed or aborted to prevent resource leaks which could lead to the index becoming unusable or cause an OutOfMemoryError. To ensure that a transaction is aborted in the face of exceptions, call Transaction.abort in a finally block.

For a transactional store, storage and deletion operations are always transaction protected, whether or not a transaction is explicitly used. A null transaction argument means to perform the operation using auto-commit, or the implied thread transaction if an XAEnvironment is being used. A transaction is automatically started as part of the operation and is automatically committed if the operation completes successfully. The transaction is automatically aborted if an exception occurs during the operation, and the exception is re-thrown to the caller. For example, each employee is deleted using a an auto-commit transaction below, but it is possible that employee 1 will be deleted and employee 2 will not be deleted, if an error or crash occurs while deleting employee 2:

 primaryIndex.delete(null, 1);
 primaryIndex.delete(null, 2);

When retrieving entities, a null transaction argument means to perform the operation non-transactionally. The operation is performed outside the scope of any transaction, without providing transactional ACID guarantees. If an implied thread transaction is present (i.e. if an XAEnvironment is being used), that transaction is used. When a non-transactional store is used, transactional ACID guarantees are also not provided.

For non-transactional and auto-commit usage, overloaded signatures for retrieval, storage and deletion methods are provided to avoid having to pass a null transaction argument. For example, EntityIndex.delete may be called instead of EntityIndex.delete(Transaction,Object) . For example, the following code is equivalent to the code above where null was passed for the transaction:

 primaryIndex.delete(1);
 primaryIndex.delete(2);

For retrieval methods the overloaded signatures also include an optional LockMode parameter, and overloaded signatures for opening cursors include an optional CursorConfig parameter. These parameters are described further below in the Locking and Lock Modes section.

Transactions and Cursors

There are two special consideration when using cursors with transactions. First, for a transactional store, a non-null transaction must be passed to methods that open a cursor if that cursor will be used to delete or update entities. Cursors do not perform auto-commit when a null transaction is explicitly passed or implied by the method signature. For example, the following code will throw DatabaseException when the EntityCursor.delete method is called:

 // Does not work with a transactional store!
  EntityCursor   cursor = primaryIndex.entities();
 try {
 for (Employee entity : cursor) {
 cursor.delete(); // Will throw DatabaseException.
 }
 } finally {
 cursor.close();
 }

Instead, the EntityIndex.entities(Transaction,CursorConfig) signature must be used and a non-null transaction must be passed:

  EntityCursor   cursor = primaryIndex.entities(txn, null);
 try {
 for (Employee entity : cursor) {
 cursor.delete();
 }
 } finally {
 cursor.close();
 }

The second consideration is that error handling is more complex when using both transactions and cursors, for the following reasons:

  1. When an exception occurs, the transaction should be aborted.
  2. Cursors must be closed whether or not an exception occurs.
  3. Cursors must be closed before committing or aborting the transaction.

For example:

 Transaction txn = env.beginTransaction(null, null);
  EntityCursor   cursor = null;
 try {
 cursor = primaryIndex.entities(txn, null);
 for (Employee entity : cursor) {
 cursor.delete();
 }
 cursor.close();
 cursor = null;
 txn.commit();
 txn = null;
 } finally {
 if (cursor != null) {
 cursor.close();
 }
 if (txn != null) {
 txn.abort();
 }
 }

Locking and Lock Modes

This section provides a brief overview of locking and describes how lock modes are used with the Direct Persistence Layer. For more information on locking, see Writing Transactional Applications.

When using transactions, locks are normally acquired on each entity that is retrieved or stored. The locks are used to isolate one transaction from another. Locks are normally released only when the transaction is committed or aborted.

When not using transactions, locks are also normally acquired on each entity that is retrieved or stored. However, these locks are released when the operation is complete. When using cursors, in order to provide cursor stability locks are held until the cursor is moved to a different entity or closed.

This default locking behavior provides full transactional ACID guarantees and cursor stability. However, application performance can sometimes be improved by compromising these guarantees. As described in Writing Transactional Applications, the LockMode and CursorConfig parameters are two of the mechanisms that can be used to make compromises.

For example, imagine that you need an approximate count of all entities matching certain criterion, and it is acceptable for entities to be changed by other threads or other transactions while performing this query. LockMode.READ_UNCOMMITTED can be used to perform the retrievals without acquiring any locks. This reduces memory consumption, does less processing, and can improve concurrency.

  EntityCursor   cursor = primaryIndex.entities(txn, null);
 try {
 Employee entity;
 while ((entity = cursor.next(LockMode.READ_UNCOMMITTED)) != null) {
 // Examine the entity and accumulate totals...
 }
 } finally {
 cursor.close();
 }

The LockMode parameter specifies locking behavior on a per-operation basis. If null or LockMode.DEFAULT is specified, the default lock mode is used.

It is also possible to specify the default locking behavior for a cursor using CursorConfig . The example below is equivalent to the example above:

 CursorConfig config = new CursorConfig();
 config.setReadUncommitted(true);
  EntityCursor   cursor = primaryIndex.entities(txn, config);
 try {
 Employee entity;
 while ((entity = cursor.next()) != null) {
 // Examine the entity and accumulate totals...
 }
 } finally {
 cursor.close();
 }

The use of other lock modes, cursor configuration, and transaction configuration are discussed in Writing Transactional Applications.

Deadlock handling is another important topic discussed in Writing Transactional Applications. To go along with that material, here we show a deadlock handling loop in the context of the Direct Persistence Layer. The example below shows deleting all entities in a primary index in a single transaction. If a deadlock occurs, the transaction is aborted and the operation is retried.

 int retryCount = 0;
 boolean retry = true;
 while (retry) {
 Transaction txn = env.beginTransaction(null, null);
  EntityCursor   cursor = null;
 try {
 cursor = primaryIndex.entities(txn, null);
 for (Employee entity : cursor) {
 cursor.delete();
 }
 cursor.close();
 cursor = null;
 txn.commit();
 txn = null;
 retry = false;
 } catch (DeadlockException e) {
 retryCount += 1;
 if (retryCount >= MAX_DEADLOCK_RETRIES) {
 throw e;
 }
 } finally {
 if (cursor != null) {
 cursor.close();
 }
 if (txn != null) {
 txn.abort();
 }
 }
 }

Low Level Access

Each Direct Persistence Layer index is associated with an underlying Database or SecondaryDatabase defined in the com.sleepycat.je Base API . At this level, an index is a Btree managed by the Berkeley DB Java Edition transactional storage engine. Although you may never need to work at the Base API level, keep in mind that some types of performance tuning can be done by configuring the underlying databases. See the EntityStore class for more information on database and sequence configuration.

If you wish to access an index using the Base API , you may call the PrimaryIndex.getDatabase or SecondaryIndex.getDatabase method to get the underying database. To translate between entity or key objects and DatabaseEntry objects at this level, use the bindings returned by PrimaryIndex.getEntityBinding , PrimaryIndex.getKeyBinding , and SecondaryIndex.getKeyBinding .


author:
   Mark Hayes




Method Summary
 booleancontains(K key)
     Checks for existence of a key in this index.

The operation will not be transaction protected, and LockMode.DEFAULT is used implicitly.


Parameters:
  key - the key to search for.
 booleancontains(Transaction txn, K key, LockMode lockMode)
     Checks for existence of a key in this index.
Parameters:
  txn - the transaction used to protect this operation, or nullif the operation should not be transaction protected.
Parameters:
  key - the key to search for.
Parameters:
  lockMode - the lock mode to use for this operation, or null touse LockMode.DEFAULT.
 longcount()
     Returns a non-transactional count of the entities in this index.
 booleandelete(K key)
     Deletes all entities with a given index key.

Auto-commit is used implicitly if the store is transactional.


Parameters:
  key - the key to search for.
 booleandelete(Transaction txn, K key)
     Deletes all entities with a given index key.
Parameters:
  txn - the transaction used to protect this operation, null to useauto-commit, or null if the store is non-transactional.
Parameters:
  key - the key to search for.
 EntityCursor<V>entities()
     Opens a cursor for traversing all entities in this index.

The operations performed with the cursor will not be transaction protected, and CursorConfig.DEFAULT is used implicitly.

 EntityCursor<V>entities(Transaction txn, CursorConfig config)
     Opens a cursor for traversing all entities in this index.
Parameters:
  txn - the transaction used to protect all operations performed withthe cursor, or null if the operations should not be transactionprotected.
 EntityCursor<V>entities(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive)
     Opens a cursor for traversing entities in a key range.

The operations performed with the cursor will not be transaction protected, and CursorConfig.DEFAULT is used implicitly.

 EntityCursor<V>entities(Transaction txn, K fromKey, boolean fromInclusive, K toKey, boolean toInclusive, CursorConfig config)
     Opens a cursor for traversing entities in a key range.
Parameters:
  txn - the transaction used to protect all operations performed withthe cursor, or null if the operations should not be transactionprotected.
 Vget(K key)
     Gets an entity via a key of this index.

The operation will not be transaction protected, and LockMode.DEFAULT is used implicitly.


Parameters:
  key - the key to search for.
 Vget(Transaction txn, K key, LockMode lockMode)
     Gets an entity via a key of this index.
Parameters:
  txn - the transaction used to protect this operation, or nullif the operation should not be transaction protected.
Parameters:
  key - the key to search for.
Parameters:
  lockMode - the lock mode to use for this operation, or null touse LockMode.DEFAULT.
 EntityCursor<K>keys()
     Opens a cursor for traversing all keys in this index.

The operations performed with the cursor will not be transaction protected, and CursorConfig.DEFAULT is used implicitly.

 EntityCursor<K>keys(Transaction txn, CursorConfig config)
     Opens a cursor for traversing all keys in this index.
Parameters:
  txn - the transaction used to protect all operations performed withthe cursor, or null if the operations should not be transactionprotected.
 EntityCursor<K>keys(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive)
     Opens a cursor for traversing keys in a key range.

The operations performed with the cursor will not be transaction protected, and CursorConfig.DEFAULT is used implicitly.

 EntityCursor<K>keys(Transaction txn, K fromKey, boolean fromInclusive, K toKey, boolean toInclusive, CursorConfig config)
     Opens a cursor for traversing keys in a key range.
Parameters:
  txn - the transaction used to protect all operations performed withthe cursor, or null if the operations should not be transactionprotected.
 Map<K, V>map()
     Returns a standard Java map based on this entity index.
 SortedMap<K, V>sortedMap()
     Returns a standard Java sorted map based on this entity index.



Method Detail
contains
boolean contains(K key) throws DatabaseException(Code)
Checks for existence of a key in this index.

The operation will not be transaction protected, and LockMode.DEFAULT is used implicitly.


Parameters:
  key - the key to search for. whether the key exists in the index.



contains
boolean contains(Transaction txn, K key, LockMode lockMode) throws DatabaseException(Code)
Checks for existence of a key in this index.
Parameters:
  txn - the transaction used to protect this operation, or nullif the operation should not be transaction protected.
Parameters:
  key - the key to search for.
Parameters:
  lockMode - the lock mode to use for this operation, or null touse LockMode.DEFAULT. whether the key exists in the index.



count
long count() throws DatabaseException(Code)
Returns a non-transactional count of the entities in this index.

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.

the number of entities in this index.



delete
boolean delete(K key) throws DatabaseException(Code)
Deletes all entities with a given index key.

Auto-commit is used implicitly if the store is transactional.


Parameters:
  key - the key to search for. whether any entities were deleted.



delete
boolean delete(Transaction txn, K key) throws DatabaseException(Code)
Deletes all entities with a given index key.
Parameters:
  txn - the transaction used to protect this operation, null to useauto-commit, or null if the store is non-transactional.
Parameters:
  key - the key to search for. whether any entities were deleted.



entities
EntityCursor<V> entities() throws DatabaseException(Code)
Opens a cursor for traversing all entities in this index.

The operations performed with the cursor will not be transaction protected, and CursorConfig.DEFAULT is used implicitly. If the store is transactional, the cursor may not be used to update or delete entities.

the cursor.



entities
EntityCursor<V> entities(Transaction txn, CursorConfig config) throws DatabaseException(Code)
Opens a cursor for traversing all entities in this index.
Parameters:
  txn - the transaction used to protect all operations performed withthe cursor, or null if the operations should not be transactionprotected. If null is specified and the store is transactional, thecursor may not be used to update or delete entities.
Parameters:
  config - the cursor configuration that determines the default lockmode used for all cursor operations, or null to implicitly use CursorConfig.DEFAULT. the cursor.



entities
EntityCursor<V> entities(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) throws DatabaseException(Code)
Opens a cursor for traversing entities in a key range.

The operations performed with the cursor will not be transaction protected, and CursorConfig.DEFAULT is used implicitly. If the store is transactional, the cursor may not be used to update or delete entities.


Parameters:
  fromKey - is the lower bound of the key range, or null if the rangehas no lower bound.
Parameters:
  fromInclusive - is true if keys greater than or equal to fromKeyshould be included in the key range, or false if only keys greater thanfromKey should be included.
Parameters:
  toKey - is the upper bound of the key range, or null if the rangehas no upper bound.
Parameters:
  toInclusive - is true if keys less than or equal to toKey should beincluded in the key range, or false if only keys less than toKey shouldbe included. the cursor.



entities
EntityCursor<V> entities(Transaction txn, K fromKey, boolean fromInclusive, K toKey, boolean toInclusive, CursorConfig config) throws DatabaseException(Code)
Opens a cursor for traversing entities in a key range.
Parameters:
  txn - the transaction used to protect all operations performed withthe cursor, or null if the operations should not be transactionprotected. If null is specified and the store is transactional, thecursor may not be used to update or delete entities.
Parameters:
  fromKey - is the lower bound of the key range, or null if the rangehas no lower bound.
Parameters:
  fromInclusive - is true if keys greater than or equal to fromKeyshould be included in the key range, or false if only keys greater thanfromKey should be included.
Parameters:
  toKey - is the upper bound of the key range, or null if the rangehas no upper bound.
Parameters:
  toInclusive - is true if keys less than or equal to toKey should beincluded in the key range, or false if only keys less than toKey shouldbe included.
Parameters:
  config - the cursor configuration that determines the default lockmode used for all cursor operations, or null to implicitly use CursorConfig.DEFAULT. the cursor.



get
V get(K key) throws DatabaseException(Code)
Gets an entity via a key of this index.

The operation will not be transaction protected, and LockMode.DEFAULT is used implicitly.


Parameters:
  key - the key to search for. the value mapped to the given key, or null if the key is notpresent in the index.



get
V get(Transaction txn, K key, LockMode lockMode) throws DatabaseException(Code)
Gets an entity via a key of this index.
Parameters:
  txn - the transaction used to protect this operation, or nullif the operation should not be transaction protected.
Parameters:
  key - the key to search for.
Parameters:
  lockMode - the lock mode to use for this operation, or null touse LockMode.DEFAULT. the value mapped to the given key, or null if the key is notpresent in the index.



keys
EntityCursor<K> keys() throws DatabaseException(Code)
Opens a cursor for traversing all keys in this index.

The operations performed with the cursor will not be transaction protected, and CursorConfig.DEFAULT is used implicitly. If the store is transactional, the cursor may not be used to update or delete entities.

the cursor.



keys
EntityCursor<K> keys(Transaction txn, CursorConfig config) throws DatabaseException(Code)
Opens a cursor for traversing all keys in this index.
Parameters:
  txn - the transaction used to protect all operations performed withthe cursor, or null if the operations should not be transactionprotected. If null is specified and the store is transactional, thecursor may not be used to update or delete entities.
Parameters:
  config - the cursor configuration that determines the default lockmode used for all cursor operations, or null to implicitly use CursorConfig.DEFAULT. the cursor.



keys
EntityCursor<K> keys(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) throws DatabaseException(Code)
Opens a cursor for traversing keys in a key range.

The operations performed with the cursor will not be transaction protected, and CursorConfig.DEFAULT is used implicitly. If the store is transactional, the cursor may not be used to update or delete entities.


Parameters:
  fromKey - is the lower bound of the key range, or null if the rangehas no lower bound.
Parameters:
  fromInclusive - is true if keys greater than or equal to fromKeyshould be included in the key range, or false if only keys greater thanfromKey should be included.
Parameters:
  toKey - is the upper bound of the key range, or null if the rangehas no upper bound.
Parameters:
  toInclusive - is true if keys less than or equal to toKey should beincluded in the key range, or false if only keys less than toKey shouldbe included. the cursor.



keys
EntityCursor<K> keys(Transaction txn, K fromKey, boolean fromInclusive, K toKey, boolean toInclusive, CursorConfig config) throws DatabaseException(Code)
Opens a cursor for traversing keys in a key range.
Parameters:
  txn - the transaction used to protect all operations performed withthe cursor, or null if the operations should not be transactionprotected. If null is specified and the store is transactional, thecursor may not be used to update or delete entities.
Parameters:
  fromKey - is the lower bound of the key range, or null if the rangehas no lower bound.
Parameters:
  fromInclusive - is true if keys greater than or equal to fromKeyshould be included in the key range, or false if only keys greater thanfromKey should be included.
Parameters:
  toKey - is the upper bound of the key range, or null if the rangehas no upper bound.
Parameters:
  toInclusive - is true if keys less than or equal to toKey should beincluded in the key range, or false if only keys less than toKey shouldbe included.
Parameters:
  config - the cursor configuration that determines the default lockmode used for all cursor operations, or null to implicitly use CursorConfig.DEFAULT. the cursor.



map
Map<K, V> map()(Code)
Returns a standard Java map based on this entity index. The StoredMap returned is defined by the . Stored collections conform to the standard Java collections framework interface. the map.



sortedMap
SortedMap<K, V> sortedMap()(Code)
Returns a standard Java sorted map based on this entity index. The StoredSortedMap returned is defined by the . Stored collections conform to the standard Java collections framework interface. the map.



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.