Interface GraphDatabaseService
-
public interface GraphDatabaseService
GraphDatabaseService represents a graph database and is used to create new transactions with
beginTx()
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Transaction
beginTx()
Starts a newtransaction
and associates it with the current thread.Transaction
beginTx(long timeout, TimeUnit unit)
Starts a newtransaction
with custom timeout and associates it with the current thread.String
databaseName()
Return name of underlying databasevoid
executeTransactionally(String query)
Executes query in a separate transaction.void
executeTransactionally(String query, Map<String,Object> parameters)
Executes query in a separate transaction.<T> T
executeTransactionally(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> T
executeTransactionally(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
.boolean
isAvailable(long timeout)
Use this method to check if the database is currently in a usable state.
-
-
-
Method Detail
-
isAvailable
boolean isAvailable(long timeout)
Use this method to check if the database is currently in a usable state.- Parameters:
timeout
- timeout (in milliseconds) to wait for the database to become available. If the database has been shut downfalse
is returned immediately.- Returns:
- the state of the database:
true
if it is available, otherwisefalse
-
beginTx
Transaction beginTx()
Starts a newtransaction
and 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
ResourceIterable
is closed correctly and as soon as possible inside your transaction to avoid potential blocking of write operations.- Returns:
- a new transaction instance
-
beginTx
Transaction beginTx(long timeout, TimeUnit unit)
Starts a newtransaction
with 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
ResourceIterable
is 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
void executeTransactionally(String query) throws QueryExecutionException
Executes query in a separate transaction. Capable to execute periodic commit queries.- Parameters:
query
- The query to execute- Throws:
QueryExecutionException
- If the Query contains errors
-
executeTransactionally
void executeTransactionally(String query, Map<String,Object> parameters) throws QueryExecutionException
Executes query in a separate transaction. Capable to execute periodic commit queries.- 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 QueryExecutionException
Executes query in a separate transaction and allow to query result to be consumed by providedResultTransformer
. Capable to execute periodic commit queries.- 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 QueryExecutionException
Executes 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 periodic commit queries.- 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
-
-