Package org.axonframework.common.jpa
Class EntityManagerExecutor
java.lang.Object
org.axonframework.common.jpa.EntityManagerExecutor
- All Implemented Interfaces:
TransactionalExecutor<jakarta.persistence.EntityManager>
@Internal
public class EntityManagerExecutor
extends Object
implements TransactionalExecutor<jakarta.persistence.EntityManager>
A
TransactionalExecutor implementation for EntityManagers.- Since:
- 5.0.2
- Author:
- John Hendrikx
-
Constructor Summary
ConstructorsConstructorDescriptionEntityManagerExecutor(EntityManagerProvider provider) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescription<R> CompletableFuture<R> apply(ThrowingFunction<jakarta.persistence.EntityManager, R, Exception> function) Executes a transactional operation that returns a result.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.common.tx.TransactionalExecutor
accept
-
Constructor Details
-
EntityManagerExecutor
Creates a new instance.- Parameters:
provider- AnEntityManagerProvider, cannot benull.- Throws:
NullPointerException- If any argument isnull.
-
-
Method Details
-
apply
public <R> CompletableFuture<R> apply(@Nonnull ThrowingFunction<jakarta.persistence.EntityManager, R, Exception> function) Description copied from interface:TransactionalExecutorExecutes a transactional operation that returns a result.Implementations are responsible for managing the lifecycle of the provided resource, including obtaining, closing, commit and rollback.
- Specified by:
applyin interfaceTransactionalExecutor<jakarta.persistence.EntityManager>- Type Parameters:
R- The type of the result returned by the function.- Parameters:
function- A function that accepts the transactional resource of typeTand produces a result of typeR; cannot benull.- Returns:
- A
CompletableFuturewhich when it completes contains the result of the provided function, nevernull.
-