org.h2.mvstore.db

## Class TransactionStore.Transaction

- java.lang.Object
- - org.h2.mvstore.db.TransactionStore.Transaction

Enclosing class:
  TransactionStore

    public static class TransactionStore.Transaction
    extends java.lang.Object

A transaction.

### Field Summary

Fields
`static int` `STATUS_CLOSED` The status of a closed transaction (committed or rolled back).
`static int` `STATUS_COMMITTING` The status of a transaction that is being committed, but possibly not yet finished.
`static int` `STATUS_OPEN` The status of an open transaction.
`static int` `STATUS_PREPARED` The status of a prepared transaction.

### Method Summary

Methods
`void` `commit()` Commit the transaction.
`java.util.Iterator<TransactionStore.Change>` `getChanges(long savepointId)` Get the list of changes, starting with the latest change, up to the given savepoint (in reverse order than they occurred).
`int` `getId()`
`java.lang.String` `getName()`
`int` `getStatus()`
`<K,V> TransactionStore.TransactionMap<K,V>` `openMap(MVMap<K,org.h2.mvstore.db.TransactionStore.VersionedValue> map)` Open the transactional version of the given map.
`<K,V> TransactionStore.TransactionMap<K,V>` `openMap(java.lang.String name)` Open a data map.
`<K,V> TransactionStore.TransactionMap<K,V>` `openMap(java.lang.String name, DataType keyType, DataType valueType)` Open the map to store the data.
`void` `prepare()` Prepare the transaction.
`<K,V> void` `removeMap(TransactionStore.TransactionMap<K,V> map)` Remove the map.
`void` `rollback()` Roll the transaction back.
`void` `rollbackToSavepoint(long savepointId)` Roll back to the given savepoint.
`void` `setName(java.lang.String name)`
`long` `setSavepoint()` Create a new savepoint.
`java.lang.String` `toString()`

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

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

### Field Detail

#### STATUS_CLOSED

    public static final int STATUS_CLOSED

The status of a closed transaction (committed or rolled back).

See Also:
  Constant Field Values

#### STATUS_OPEN

    public static final int STATUS_OPEN

The status of an open transaction.

See Also:
  Constant Field Values

#### STATUS_PREPARED

    public static final int STATUS_PREPARED

The status of a prepared transaction.

See Also:
  Constant Field Values

#### STATUS_COMMITTING

    public static final int STATUS_COMMITTING

The status of a transaction that is being committed, but possibly not yet finished. A transactions can go into this state when the store is closed while the transaction is committing. When opening a store, such transactions should be committed.

See Also:
  Constant Field Values

### Method Detail

#### getId

    public int getId()

#### getStatus

    public int getStatus()

#### setName

    public void setName(java.lang.String name)

#### getName

    public java.lang.String getName()

#### setSavepoint

    public long setSavepoint()

Create a new savepoint.

Returns:
  the savepoint id

#### openMap

    public <K,V> TransactionStore.TransactionMap<K,V> openMap(java.lang.String name)

Open a data map.

Type Parameters:
  `K` - the key type
  `V` - the value type
Parameters:
  `name` - the name of the map
Returns:
  the transaction map

#### openMap

    public <K,V> TransactionStore.TransactionMap<K,V> openMap(java.lang.String name,
                                                     DataType keyType,
                                                     DataType valueType)

Open the map to store the data.

Type Parameters:
  `K` - the key type
  `V` - the value type
Parameters:
  `name` - the name of the map
  `keyType` - the key data type
  `valueType` - the value data type
Returns:
  the transaction map

#### openMap

    public <K,V> TransactionStore.TransactionMap<K,V> openMap(MVMap<K,org.h2.mvstore.db.TransactionStore.VersionedValue> map)

Open the transactional version of the given map.

Type Parameters:
  `K` - the key type
  `V` - the value type
Parameters:
  `map` - the base map
Returns:
  the transactional map

#### prepare

    public void prepare()

Prepare the transaction. Afterwards, the transaction can only be committed or rolled back.

#### commit

    public void commit()

Commit the transaction. Afterwards, this transaction is closed.

#### rollbackToSavepoint

    public void rollbackToSavepoint(long savepointId)

Roll back to the given savepoint. This is only allowed if the transaction is open.

Parameters:
  `savepointId` - the savepoint id

#### rollback

    public void rollback()

Roll the transaction back. Afterwards, this transaction is closed.

#### getChanges

    public java.util.Iterator<TransactionStore.Change> getChanges(long savepointId)

Get the list of changes, starting with the latest change, up to the given savepoint (in reverse order than they occurred). The value of the change is the value before the change was applied.

Parameters:
  `savepointId` - the savepoint id, 0 meaning the beginning of the transaction
Returns:
  the changes

#### removeMap

    public <K,V> void removeMap(TransactionStore.TransactionMap<K,V> map)

Remove the map.

Parameters:
  `map` - the map

#### toString

    public java.lang.String toString()

Overrides:
  `toString` in class `java.lang.Object`