Interface JpaWork<T,​E extends Exception>

  • Type Parameters:
    T - the type of the result. Return DTOs, never entities or lazy proxies, they are detached once the transaction is over.
    E - the type of the checked exception the work may throw, or RuntimeException if it throws none.
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface JpaWork<T,​E extends Exception>
    Work that runs in a JPA transaction and returns a result, executed by JpaTransactionRunner.inTransaction(JpaWork).
    Since:
    8.5.6
    Author:
    Norman Lorenz
    • Method Detail

      • execute

        T execute​(JpaUnitOfWork unitOfWork)
           throws E extends Exception
        Performs the work.
        Parameters:
        unitOfWork - the unit of work to use, which grants access to the entity manager.
        Returns:
        the result of the work.
        Throws:
        E - if the work fails, in which case the transaction is not committed.
        E extends Exception
        Since:
        8.5.6