public class CursorConfig
extends java.lang.Object
implements java.lang.Cloneable
Modifier and Type | Field and Description |
---|---|
static CursorConfig |
DEFAULT
Default configuration used if null is passed to methods that create a
cursor.
|
static CursorConfig |
READ_COMMITTED
A convenience instance to configure a cursor for read committed
isolation.
|
static CursorConfig |
READ_UNCOMMITTED
A convenience instance to configure read operations performed by the
cursor to return modified but not yet committed data.
|
Constructor and Description |
---|
CursorConfig()
An instance created using the default constructor is initialized with
the system's default settings.
|
Modifier and Type | Method and Description |
---|---|
CursorConfig |
clone()
Returns a copy of this configuration object.
|
boolean |
getNonSticky()
Returns the non-sticky setting.
|
boolean |
getReadCommitted()
Returns true if read operations performed by the cursor are configured
to obey read committed isolation.
|
boolean |
getReadUncommitted()
Returns true if read operations performed by the cursor are configured
to return modified but not yet committed data.
|
CursorConfig |
setNonSticky(boolean nonSticky)
Configures the behavior of the cursor when a cursor movement operation
returns
OperationStatus.NOTFOUND . |
CursorConfig |
setReadCommitted(boolean readCommitted)
Configures read operations performed by the cursor to obey read
committed isolation.
|
CursorConfig |
setReadUncommitted(boolean readUncommitted)
Configures read operations performed by the cursor to return modified
but not yet committed data.
|
java.lang.String |
toString()
Returns the values for each configuration attribute.
|
public static final CursorConfig DEFAULT
public static final CursorConfig READ_UNCOMMITTED
public static final CursorConfig READ_COMMITTED
public CursorConfig()
public CursorConfig setReadUncommitted(boolean readUncommitted)
readUncommitted
- If true, configure read operations performed by
the cursor to return modified but not yet committed data.LockMode.READ_UNCOMMITTED
public boolean getReadUncommitted()
LockMode.READ_UNCOMMITTED
public CursorConfig setReadCommitted(boolean readCommitted)
readCommitted
- If true, configure read operations performed by
the cursor to obey read committed isolation.LockMode.READ_COMMITTED
public boolean getReadCommitted()
LockMode.READ_COMMITTED
public CursorConfig setNonSticky(boolean nonSticky)
OperationStatus.NOTFOUND
.
By default, a cursor is "sticky", meaning that the prior position is
maintained by cursor movement operations, and the cursor stays at the
prior position when the operation does not succeed. For example, if
Cursor.getFirst(com.sleepycat.je.DatabaseEntry, com.sleepycat.je.DatabaseEntry, com.sleepycat.je.LockMode)
is called successfully, and then
Cursor.getNext(com.sleepycat.je.DatabaseEntry, com.sleepycat.je.DatabaseEntry, com.sleepycat.je.LockMode)
is called, if getNext
returns
NOTFOUND
the cursor will remain positioned on the first record.
Also, as part of maintaining the prior position, the lock on the record
at the current position will be held (at least) until after a cursor
movement operation succeeds and acquires a lock on the record at the new
position. In the example above, a lock on the first record will still
be held after getNext
returns NOTFOUND
.
If the cursor is configured to be non-sticky, the prior position is not maintained, and this has certain performance advantages:
However, when the cursor is configured as non-sticky and getNext
returns NOTFOUND
in the example above, the cursor position will
be uninitialized, as if it had just been opened. Also, the lock on the
first record will have been released (except when repeatable-read or
serializable isolation is configured.) To move to the first record (and
lock it), getFirst
must be called again.
Also note that in certain circumstances, internal algorithms require that the prior position is retained, and the operation will behave as if the cursor is sticky. Specifically, these are only the following methods, and only when called on a database with duplicates configured:
Cursor.putNoOverwrite(com.sleepycat.je.DatabaseEntry, com.sleepycat.je.DatabaseEntry)
Cursor.getNextDup(com.sleepycat.je.DatabaseEntry, com.sleepycat.je.DatabaseEntry, com.sleepycat.je.LockMode)
}Cursor.getPrevDup(com.sleepycat.je.DatabaseEntry, com.sleepycat.je.DatabaseEntry, com.sleepycat.je.LockMode)
}Cursor.getNextNoDup(com.sleepycat.je.DatabaseEntry, com.sleepycat.je.DatabaseEntry, com.sleepycat.je.LockMode)
}Cursor.getPrevNoDup(com.sleepycat.je.DatabaseEntry, com.sleepycat.je.DatabaseEntry, com.sleepycat.je.LockMode)
}nonSticky
- if false (the default), the prior position is
maintained by cursor movement operations, and the cursor stays at the
prior position when NOTFOUND
is returned. If true, the prior
position is not maintained, and the cursor is reinitialized when
NOTFOUND
is returned.public boolean getNonSticky()
setNonSticky(boolean)
public CursorConfig clone()
clone
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
Copyright (c) 2002, 2017 Oracle and/or its affiliates. All rights reserved.