Package io.objectbox
Class Transaction
- java.lang.Object
-
- io.objectbox.Transaction
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
@Internal @NotThreadSafe public class Transaction extends java.lang.Object implements java.io.Closeable
-
-
Field Summary
Fields Modifier and Type Field Description private booleanclosedvolatile because finalizer thread may interfere with "one thread, one TX" ruleprivate java.lang.ThrowablecreationThrowableprivate intinitialCommitCountprivate booleanreadOnlyprivate BoxStorestore(package private) static booleanTRACK_CREATION_STACKMay be set by testsprivate longtransaction
-
Constructor Summary
Constructors Constructor Description Transaction(BoxStore store, long transaction, int initialCommitCount)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabort()(package private) voidcheckOpen()voidclose()voidcommit()voidcommitAndClose()<T> Cursor<T>createCursor(java.lang.Class<T> entityClass)KeyValueCursorcreateKeyValueCursor()protected voidfinalize()Explicitly callclose()instead to avoid expensive finalization.BoxStoregetStore()(package private) longinternalHandle()booleanisActive()booleanisClosed()booleanisObsolete()Indicates if data returned from this transaction may be obsolete (another write TX was committed after this transaction was started).booleanisReadOnly()booleanisRecycled()(package private) voidnativeAbort(long transaction)(package private) int[]nativeCommit(long transaction)(package private) longnativeCreateCursor(long transaction, java.lang.String entityName, java.lang.Class<?> entityClass)(package private) longnativeCreateKeyValueCursor(long transaction)(package private) voidnativeDestroy(long transaction)(package private) booleannativeIsActive(long transaction)(package private) booleannativeIsOwnerThread(long transaction)(package private) booleannativeIsReadOnly(long transaction)(package private) booleannativeIsRecycled(long transaction)(package private) voidnativeRecycle(long transaction)(package private) voidnativeRenew(long transaction)(package private) voidnativeReset(long transaction)voidrecycle()For read transactions, this releases important native resources that hold on versions of potential old data.voidrenew()Renews a previously recycled transaction (seerecycle()).voidreset()Will throw if Cursors are still active for this TX.java.lang.StringtoString()
-
-
-
Field Detail
-
TRACK_CREATION_STACK
@Internal static boolean TRACK_CREATION_STACK
May be set by tests
-
transaction
private final long transaction
-
store
private final BoxStore store
-
readOnly
private final boolean readOnly
-
creationThrowable
private final java.lang.Throwable creationThrowable
-
initialCommitCount
private int initialCommitCount
-
closed
private volatile boolean closed
volatile because finalizer thread may interfere with "one thread, one TX" rule
-
-
Constructor Detail
-
Transaction
public Transaction(BoxStore store, long transaction, int initialCommitCount)
-
-
Method Detail
-
nativeDestroy
void nativeDestroy(long transaction)
-
nativeCommit
int[] nativeCommit(long transaction)
-
nativeAbort
void nativeAbort(long transaction)
-
nativeReset
void nativeReset(long transaction)
-
nativeRecycle
void nativeRecycle(long transaction)
-
nativeRenew
void nativeRenew(long transaction)
-
nativeCreateKeyValueCursor
long nativeCreateKeyValueCursor(long transaction)
-
nativeCreateCursor
long nativeCreateCursor(long transaction, java.lang.String entityName, java.lang.Class<?> entityClass)
-
nativeIsActive
boolean nativeIsActive(long transaction)
-
nativeIsOwnerThread
boolean nativeIsOwnerThread(long transaction)
-
nativeIsRecycled
boolean nativeIsRecycled(long transaction)
-
nativeIsReadOnly
boolean nativeIsReadOnly(long transaction)
-
finalize
protected void finalize() throws java.lang.ThrowableExplicitly callclose()instead to avoid expensive finalization.- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
checkOpen
void checkOpen()
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
commit
public void commit()
-
commitAndClose
public void commitAndClose()
-
abort
public void abort()
-
reset
@Experimental public void reset()
Will throw if Cursors are still active for this TX. Efficient for read transactions.
-
recycle
public void recycle()
For read transactions, this releases important native resources that hold on versions of potential old data. To continue, userenew().
-
renew
public void renew()
Renews a previously recycled transaction (seerecycle()). Efficient for read transactions.
-
createKeyValueCursor
public KeyValueCursor createKeyValueCursor()
-
createCursor
public <T> Cursor<T> createCursor(java.lang.Class<T> entityClass)
-
getStore
public BoxStore getStore()
-
isActive
public boolean isActive()
-
isRecycled
public boolean isRecycled()
-
isClosed
public boolean isClosed()
-
isReadOnly
public boolean isReadOnly()
-
isObsolete
public boolean isObsolete()
Indicates if data returned from this transaction may be obsolete (another write TX was committed after this transaction was started).
-
internalHandle
@Internal long internalHandle()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-