Class Transaction
java.lang.Object
com.surrealdb.Native
com.surrealdb.Transaction
- All Implemented Interfaces:
AutoCloseable
Client-side transaction. Use
Surreal.beginTransaction() to start a
transaction. Operations (e.g. query(String)) run within the
transaction until commit() or cancel() is called. With
try-with-resources, a transaction that was not committed is cancelled:
try (Transaction txn = db.beginTransaction()) {
txn.query("CREATE person:tobie");
txn.commit();
}
-
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()Cancels (rolls back) the transaction.voidclose()Cancels the transaction if it was neither committed nor cancelled, so a try-with-resources block rolls back unlesscommit()was called.voidcommit()Commits the transaction.Runs a SurrealQL query within this transaction.Runs a parameterized SurrealQL query within this transaction.
-
Method Details
-
commit
public void commit()Commits the transaction. After this call, the transaction is completed and must not be used. On failure the native layer throws; the return value is only true on success. -
cancel
public void cancel()Cancels (rolls back) the transaction. After this call, the transaction is completed and must not be used. On failure the native layer throws; the return value is only true on success. -
close
-
query
-
query
-