diff --git a/docs/Drivers/Java/Reference/Collection/DocumentManipulation.md b/docs/Drivers/Java/Reference/Collection/DocumentManipulation.md index 211476d31..9468b0866 100644 --- a/docs/Drivers/Java/Reference/Collection/DocumentManipulation.md +++ b/docs/Drivers/Java/Reference/Collection/DocumentManipulation.md @@ -55,6 +55,10 @@ Retrieves the document with the given \_key from the collection. Whether or not catch possible thrown exceptions + - **streamTransactionId**: `String` + + If set, the operation will be executed within the transaction + **Examples** ```Java @@ -135,6 +139,10 @@ generated automatically. will be returned for the created document. This option can be used to save some network traffic. + - **streamTransactionId**: `String` + + If set, the operation will be executed within the transaction + **Examples** ```Java @@ -190,6 +198,10 @@ generated automatically. will be returned for the created document. This option can be used to save some network traffic. + - **streamTransactionId**: `String` + + If set, the operation will be executed within the transaction + **Examples** ```Java @@ -254,6 +266,10 @@ such a document and no precondition is violated. will be returned for the created document. This option can be used to save some network traffic. + - **streamTransactionId**: `String` + + If set, the operation will be executed within the transaction + **Examples** ```Java @@ -317,6 +333,10 @@ documents in values. will be returned for the created document. This option can be used to save some network traffic. + - **streamTransactionId**: `String` + + If set, the operation will be executed within the transaction + **Examples** ```Java @@ -385,6 +405,10 @@ such a document and no precondition is violated. will be returned for the created document. This option can be used to save some network traffic. + - **streamTransactionId**: `String` + + If set, the operation will be executed within the transaction + **Examples** ```Java @@ -448,6 +472,10 @@ documents in values. will be returned for the created document. This option can be used to save some network traffic. + - **streamTransactionId**: `String` + + If set, the operation will be executed within the transaction + **Examples** ```Java diff --git a/docs/Drivers/Java/Reference/Database/Queries.md b/docs/Drivers/Java/Reference/Database/Queries.md index 9966f1e70..4dd437fa7 100644 --- a/docs/Drivers/Java/Reference/Database/Queries.md +++ b/docs/Drivers/Java/Reference/Database/Queries.md @@ -151,6 +151,10 @@ a new _ArangoCursor_ instance for the result list. query statistics, warnings and profiling data will only be available after the query is finished. The default value is false. + - **streamTransactionId**: `String` + + If set, the operation will be executed within the transaction + - **type**: `Class` The type of the result (POJO class, `VPackSlice`, `String` for JSON, or `Collection`/`List`/`Map`) diff --git a/docs/Drivers/Java/Reference/Database/StreamTransactions.md b/docs/Drivers/Java/Reference/Database/StreamTransactions.md new file mode 100644 index 000000000..244bd6ae6 --- /dev/null +++ b/docs/Drivers/Java/Reference/Database/StreamTransactions.md @@ -0,0 +1,81 @@ +# Transactions + +See [HTTP Interface for Stream Transactions](https://docs.arangodb.com/latest/HTTP/transaction-stream-transaction.html). + + +## ArangoDatabase.beginStreamTransaction + +`ArangoDatabase.beginStreamTransaction(StreamTransactionOptions options) : StreamTransactionEntity` + +Begins a server-side transaction and returns information about it. + +**Arguments** + +- **options**: `StreamTransactionOptions` + + transaction options + + +## ArangoDatabase.getStreamTransaction + +`ArangoDatabase.getStreamTransaction(String id) : StreamTransactionEntity` + +Gets information about a Stream Transaction. + +**Arguments** + +- **id**: `String` + + transaction id + + +## ArangoDatabase.commitStreamTransaction + +`ArangoDatabase.commitStreamTransaction(String id) : StreamTransactionEntity` + +Commits a Stream Transaction. + +**Arguments** + +- **id**: `String` + + transaction id + + +## ArangoDatabase.abortStreamTransaction + +`ArangoDatabase.abortStreamTransaction(String id) : StreamTransactionEntity` + +Aborts a Stream Transaction. + +**Arguments** + +- **id**: `String` + + transaction id + + +## Examples + +```Java +ArangoDB arango = new ArangoDB.Builder().build(); +ArangoDatabase db = arango.db("myDB"); + +StreamTransactionEntity tx1 = db.beginStreamTransaction( + new StreamTransactionOptions().readCollections("collection").writeCollections("collection")); +db.collection("collection") + .insertDocument(new BaseDocument(), new DocumentCreateOptions().streamTransactionId(tx1.getId())); +db.commitStreamTransaction(tx1.getId()); +StreamTransactionEntity tx = db.getStreamTransaction(tx1.getId()); +assertThat(tx.getStatus(), is(StreamTransactionEntity.StreamTransactionStatus.committed)); + +StreamTransactionEntity tx2 = db.beginStreamTransaction( + new StreamTransactionOptions().readCollections("collection").writeCollections("collection")); +final Map bindVars = new HashMap<>(); +bindVars.put("@collection", COLLECTION_NAME); +bindVars.put("key", "myKey"); +ArangoCursor cursor = db + .query("FOR doc IN @@collection FILTER doc._key == @key RETURN doc", bindVars, + new AqlQueryOptions().streamTransactionId(tx2.getId()), BaseDocument.class); +db.abortStreamTransaction(tx2.getId()); +```