Package io.objectbox

Class Transaction

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    @Internal
    @NotThreadSafe
    public class Transaction
    extends java.lang.Object
    implements java.io.Closeable
    • Field Detail

      • TRACK_CREATION_STACK

        @Internal
        static boolean TRACK_CREATION_STACK
        May be set by tests
      • transaction

        private final long transaction
      • 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.Throwable
        Explicitly call close() instead to avoid expensive finalization.
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable
      • checkOpen

        void checkOpen()
      • close

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

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

        public <T> Cursor<T> createCursor​(java.lang.Class<T> entityClass)
      • 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:
        toString in class java.lang.Object