Interface GraphDatabaseService
GraphDatabaseService represents a graph database and is used to create
new transactions with beginTx().
-
Method Summary
Modifier and TypeMethodDescriptionbeginTx()Starts a newtransactionand associates it with the current thread.Starts a newtransactionwith custom timeout and associates it with the current thread.Return name of underlying databasevoidexecuteTransactionally(String query) Executes query in a separate transaction.voidexecuteTransactionally(String query, Map<String, Object> parameters) Executes query in a separate transaction.<T> TexecuteTransactionally(String query, Map<String, Object> parameters, ResultTransformer<T> resultTransformer) Executes query in a separate transaction and allow to query result to be consumed by providedResultTransformer.<T> TexecuteTransactionally(String query, Map<String, Object> parameters, ResultTransformer<T> resultTransformer, Duration timeout) Executes query in a separate transaction and allows query result to be consumed by providedResultTransformer.booleanCheck if the database is currently in a usable state.booleanisAvailable(long timeoutMillis) Check if the database is currently in a usable state.
-
Method Details
-
isAvailable
boolean isAvailable()Check if the database is currently in a usable state. This method is equivalent to callingisAvailable(long)with 0 as the requested timeout.- Returns:
- the state of the database:
trueif it is available, otherwisefalse - See Also:
-
isAvailable
boolean isAvailable(long timeoutMillis) Check if the database is currently in a usable state.- Parameters:
timeoutMillis- timeoutMillis (in milliseconds) to wait for the database to become available. If the database has been shut downfalseis returned immediately.- Returns:
- the state of the database:
trueif it is available, otherwisefalse
-
beginTx
Transaction beginTx()Starts a newtransactionand associates it with the current thread.All database operations must be wrapped in a transaction.
If you attempt to access the graph outside of a transaction, those operations will throw
NotInTransactionException.Please ensure that any returned
ResourceIterableis closed correctly and as soon as possible inside your transaction to avoid potential blocking of write operations.- Returns:
- a new transaction instance
-
beginTx
Starts a newtransactionwith custom timeout and associates it with the current thread. Timeout will be taken into account only when execution guard is enabled.All database operations must be wrapped in a transaction.
If you attempt to access the graph outside of a transaction, those operations will throw
NotInTransactionException.Please ensure that any returned
ResourceIterableis closed correctly and as soon as possible inside your transaction to avoid potential blocking of write operations.- Parameters:
timeout- transaction timeoutunit- time unit of timeout argument- Returns:
- a new transaction instance
-
executeTransactionally
Executes query in a separate transaction. Capable to execute queries with inner transactions.- Parameters:
query- The query to execute- Throws:
QueryExecutionException- If the Query contains errors
-
executeTransactionally
void executeTransactionally(String query, Map<String, Object> parameters) throws QueryExecutionExceptionExecutes query in a separate transaction. Capable to execute queries with inner transactions.- Parameters:
query- The query to executeparameters- Parameters for the query- Throws:
QueryExecutionException- If the Query contains errors
-
executeTransactionally
<T> T executeTransactionally(String query, Map<String, Object> parameters, ResultTransformer<T> resultTransformer) throws QueryExecutionExceptionExecutes query in a separate transaction and allow to query result to be consumed by providedResultTransformer. Capable to execute queries with inner transactions.- Parameters:
query- The query to executeparameters- Parameters for the queryresultTransformer- Query results consumer- Throws:
QueryExecutionException- If the query contains errors
-
executeTransactionally
<T> T executeTransactionally(String query, Map<String, Object> parameters, ResultTransformer<T> resultTransformer, Duration timeout) throws QueryExecutionExceptionExecutes query in a separate transaction and allows query result to be consumed by providedResultTransformer. If query will not gonna be able to complete within provided timeout time interval it will be terminated. Capable to execute queries with inner transactions.- Parameters:
query- The query to executeparameters- Parameters for the queryresultTransformer- Query results consumertimeout- Maximum duration of underlying transaction- Throws:
QueryExecutionException- If the query contains errors
-
databaseName
String databaseName()Return name of underlying database- Returns:
- database name
-