org.h2.mvstore.tx

## Class TransactionStore

- java.lang.Object
- - org.h2.mvstore.tx.TransactionStore

    public class TransactionStore
    extends java.lang.Object

A store that supports concurrent MVCC read-committed transactions.

### Nested Class Summary

Nested Classes
`static class` `TransactionStore.ArrayType` A data type that contains an array of objects with the specified data types.
`static class` `TransactionStore.Change` A change in a map.
`static interface` `TransactionStore.RollbackListener` This listener can be registered with the transaction to be notified of every compensating change during transaction rollback.

### Constructor Summary

Constructors
Constructor and Description
`TransactionStore(MVStore store)` Create a new transaction store.
`TransactionStore(MVStore store, DataType dataType, int timeoutMillis)` Create a new transaction store.

### Method Summary

Methods
`Transaction` `begin()` Begin a new transaction.
`Transaction` `begin(TransactionStore.RollbackListener listener, int timeoutMillis, int ownerId)` Begin a new transaction.
`void` `close()` Close the transaction store.
`void` `endLeftoverTransactions()` Commit all transactions that are in the committed state, and rollback all open transactions.
`java.util.List<Transaction>` `getOpenTransactions()` Get the list of unclosed transactions that have pending writes.
`static java.lang.String` `getUndoLogName(boolean committed, int transactionId)` Generate a string used to name undo log map for a specific transaction.
`boolean` `hasMap(java.lang.String name)` Check whether a given map exists.
`void` `init()` Initialize the store.
`void` `setMaxTransactionId(int max)` Set the maximum transaction id, after which ids are re-used.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### TransactionStore

    public TransactionStore(MVStore store)

Create a new transaction store.

Parameters:
  `store` - the store

#### TransactionStore

    public TransactionStore(MVStore store,
                    DataType dataType,
                    int timeoutMillis)

Create a new transaction store.

Parameters:
  `store` - the store
  `dataType` - the data type for map keys and values
  `timeoutMillis` - lock acquisition timeout in milliseconds, 0 means no wait

### Method Detail

#### getUndoLogName

    public static java.lang.String getUndoLogName(boolean committed,
                                  int transactionId)

Generate a string used to name undo log map for a specific transaction. This name will contain transaction id and reflect the fact whether transaction is logically committed or not. This information might be used by recovery procedure after unclean shutdown (termination before transaction is fully committed).

Parameters:
  `committed` - true if transaction is logically committed, false otherwise
  `transactionId` - of the corresponding transaction
Returns:
  undo log name

#### init

    public void init()

Initialize the store. This is needed before a transaction can be opened. If the transaction store is corrupt, this method can throw an exception, in which case the store can only be used for reading.

#### endLeftoverTransactions

    public void endLeftoverTransactions()

Commit all transactions that are in the committed state, and rollback all open transactions.

#### setMaxTransactionId

    public void setMaxTransactionId(int max)

Set the maximum transaction id, after which ids are re-used. If the old transaction is still in use when re-using an old id, the new transaction fails.

Parameters:
  `max` - the maximum id

#### hasMap

    public boolean hasMap(java.lang.String name)

Check whether a given map exists.

Parameters:
  `name` - the map name
Returns:
  true if it exists

#### getOpenTransactions

    public java.util.List<Transaction> getOpenTransactions()

Get the list of unclosed transactions that have pending writes.

Returns:
  the list of transactions (sorted by id)

#### close

    public void close()

Close the transaction store.

#### begin

    public Transaction begin()

Begin a new transaction.

Returns:
  the transaction

#### begin

    public Transaction begin(TransactionStore.RollbackListener listener,
                    int timeoutMillis,
                    int ownerId)

Begin a new transaction.

Parameters:
  `listener` - to be notified in case of a rollback
  `timeoutMillis` - to wait for a blocking transaction
  `ownerId` - of the owner (Session?) to be reported by getBlockerId
Returns:
  the transaction