Package io.objectbox

Class Transaction

java.lang.Object
io.objectbox.Transaction
All Implemented Interfaces:
Closeable, AutoCloseable

@Internal @NotThreadSafe public class Transaction extends Object implements Closeable
  • Field Details

    • 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 Throwable creationThrowable
    • initialCommitCount

      private int initialCommitCount
    • closed

      private volatile boolean closed
      volatile because finalizer thread may interfere with "one thread, one TX" rule
  • Constructor Details

    • Transaction

      public Transaction(BoxStore store, long transaction, int initialCommitCount)
  • Method Details

    • 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, String entityName, 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 Throwable
      Explicitly call close() instead to avoid expensive finalization.
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • checkOpen

      void checkOpen()
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface 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, use renew().
    • renew

      public void renew()
      Renews a previously recycled transaction (see recycle()). Efficient for read transactions.
    • createKeyValueCursor

      public KeyValueCursor createKeyValueCursor()
    • createCursor

      public <T> Cursor<T> createCursor(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 String toString()
      Overrides:
      toString in class Object