Package science.aist.neo4j.transaction
Interface TransactionManager
-
- All Known Implementing Classes:
TransactionManagerImpl
public interface TransactionManager
Interface for transaction management
- Since:
- 1.0
- Author:
- Andreas Pointner, Christoph Praschl
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description org.neo4j.driver.Transaction
beginTransaction()
Begins a new Transaction with default access mode.org.neo4j.driver.Transaction
beginTransaction(org.neo4j.driver.AccessMode accessMode)
Same asbeginTransaction()
but with manual access modevoid
closeSession()
Closes the current session (on start of a new transaction a new session will be created automatially).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 transactiondefault <T> T
executeRead(Function<org.neo4j.driver.Transaction,T> function)
execute(Function, AccessMode)
with access modeAccessMode.READ
default <T> T
executeWrite(Function<org.neo4j.driver.Transaction,T> function)
execute(Function, AccessMode)
with access modeAccessMode.WRITE
default void
run(Consumer<org.neo4j.driver.Transaction> consumer, org.neo4j.driver.AccessMode accessMode)
Runs a code block in a transactiondefault void
runRead(Consumer<org.neo4j.driver.Transaction> consumer)
run(Consumer, AccessMode)
with access modeAccessMode.READ
default void
runWrite(Consumer<org.neo4j.driver.Transaction> consumer)
run(Consumer, AccessMode)
with access modeAccessMode.WRITE
-
-
-
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 asbeginTransaction()
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 executedaccessMode
- 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 transactionaccessMode
- the access mode- Returns:
- the result of the function
-
runRead
default void runRead(Consumer<org.neo4j.driver.Transaction> consumer)
run(Consumer, AccessMode)
with access modeAccessMode.READ
- Parameters:
consumer
- the code block to be executed- See Also:
run(Consumer, AccessMode)
-
runWrite
default void runWrite(Consumer<org.neo4j.driver.Transaction> consumer)
run(Consumer, AccessMode)
with access modeAccessMode.WRITE
- Parameters:
consumer
- the code block to be executed- See Also:
run(Consumer, AccessMode)
-
executeRead
default <T> T executeRead(Function<org.neo4j.driver.Transaction,T> function)
execute(Function, AccessMode)
with access modeAccessMode.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 modeAccessMode.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
-
-