Class DittoTransaction
java.lang.Object
com.ditto.java.DittoTransaction
- All Implemented Interfaces:
DittoQueryExecuting
Represents a database transaction for executing multiple DQL queries atomically.
A transaction allows you to group multiple database operations together so they either
all succeed (commit) or all fail (rollback), ensuring data consistency. Transactions are
created by calling DittoStore.transaction(DittoTransactionFunction).
This class implements DittoQueryExecuting, allowing you to execute DQL queries
within the transaction context.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents the result of a transaction, indicating whether to commit or rollback. -
Method Summary
Modifier and TypeMethodDescription@NonNull CompletionStage<DittoQueryResult> Executes a DQL query and returns items as a query result.@NonNull CompletionStage<DittoQueryResult> execute(@NonNull String query, @NonNull DittoCborSerializable.Dictionary arguments) Executes a DQL query and returns items as a query result.@NonNull DittoTransactionInfogetInfo()Returns information about the current transaction.
-
Method Details
-
getInfo
Returns information about the current transaction.- Returns:
- a
DittoTransactionInfoinstance containing transaction metadata.
-
execute
Executes a DQL query and returns items as a query result. This method only returns results from the local store without waiting for anyDittoSyncSubscriptions to have caught up with the latest changes. Only use this method if your program must proceed with immediate results. Use aDittoStoreObserverto receive updates to query results as soon as they have been synced to this peer.- Specified by:
executein interfaceDittoQueryExecuting- Parameters:
query- A string containing a valid query expressed in DQL.- Returns:
- A CompletionStage
containing a DittoQueryResultItemfor each match, or aDittoExceptionif there is a problem with the query or the store.
-
execute
public @NonNull CompletionStage<DittoQueryResult> execute(@NonNull String query, @NonNull DittoCborSerializable.Dictionary arguments) Executes a DQL query and returns items as a query result. This method only returns results from the local store without waiting for anyDittoSyncSubscriptions to have caught up with the latest changes. Only use this method if your program must proceed with immediate results. Use aDittoStoreObserverto receive updates to query results as soon as they have been synced to this peer.- Specified by:
executein interfaceDittoQueryExecuting- Parameters:
query- A string containing a valid query expressed in DQL.arguments- A map of values keyed by the placeholder name without the leading:. Example:["mileage": 123].- Returns:
- A CompletionStage
containing a DittoQueryResultItemfor each match, or aDittoExceptionif there is a problem with the query or the store.
-