Interface GraphDatabaseService


public interface GraphDatabaseService

GraphDatabaseService represents a graph database and is used to create new transactions with beginTx().

  • Method Details

    • isAvailable

      boolean isAvailable()
      Check if the database is currently in a usable state. This method is equivalent to calling isAvailable(long) with 0 as the requested timeout.
      Returns:
      the state of the database: true if it is available, otherwise false
      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 down false is returned immediately.
      Returns:
      the state of the database: true if it is available, otherwise false
    • beginTx

      Transaction beginTx()
      Starts a new transaction 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 new transaction 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 timeout
      unit - 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 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 QueryExecutionException
      Executes query in a separate transaction. Capable to execute queries with inner transactions.
      Parameters:
      query - The query to execute
      parameters - 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 provided ResultTransformer. Capable to execute queries with inner transactions.
      Parameters:
      query - The query to execute
      parameters - Parameters for the query
      resultTransformer - 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 provided ResultTransformer. 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 execute
      parameters - Parameters for the query
      resultTransformer - Query results consumer
      timeout - Maximum duration of underlying transaction
      Throws:
      QueryExecutionException - If the query contains errors
    • databaseName

      String databaseName()
      Return name of underlying database
      Returns:
      database name