Interface TransactionManager

  • All Known Implementing Classes:
    TransactionManagerImpl

    public interface TransactionManager

    Interface for transaction management

    Since:
    1.0
    Author:
    Andreas Pointner, Christoph Praschl
    • Method Detail

      • beginTransaction

        org.neo4j.driver.Transaction beginTransaction()
        Begins a new Transaction with default access mode. If a transaction is already running returns a inner transaction as a decorate for the other transaction
        Returns:
        returns the transaction
      • beginTransaction

        org.neo4j.driver.Transaction beginTransaction​(org.neo4j.driver.AccessMode accessMode)
        Same as beginTransaction() but with manual access mode
        Parameters:
        accessMode - the access mode
        Returns:
        the transaction
      • run

        default void run​(Consumer<org.neo4j.driver.Transaction> consumer,
                         org.neo4j.driver.AccessMode accessMode)
        Runs a code block in a transaction
        Parameters:
        consumer - the code block to be executed
        accessMode - the access mode
      • closeSession

        void closeSession()
        Closes the current session (on start of a new transaction a new session will be created automatially). As a session is a "logical container for a causally chained series of transactions" closing a session is entirely up to the developer.
      • execute

        default <T> T execute​(Function<org.neo4j.driver.Transaction,​T> function,
                              org.neo4j.driver.AccessMode accessMode)
        Executes a code block with a return value in a transaction
        Type Parameters:
        T - the type of the return value
        Parameters:
        function - the function that is executed in the transaction
        accessMode - the access mode
        Returns:
        the result of the function
      • executeRead

        default <T> T executeRead​(Function<org.neo4j.driver.Transaction,​T> function)
        execute(Function, AccessMode) with access mode AccessMode.READ
        Type Parameters:
        T - the type of the return value
        Parameters:
        function - the function that is executed in the transaction
        Returns:
        the result of the function
      • executeWrite

        default <T> T executeWrite​(Function<org.neo4j.driver.Transaction,​T> function)
        execute(Function, AccessMode) with access mode AccessMode.WRITE
        Type Parameters:
        T - the type of the return value
        Parameters:
        function - the function that is executed in the transaction
        Returns:
        the result of the function