All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nl.vpro.services.TransactionService Maven / Gradle / Ivy

Go to download

Several domains like 'media', pages' and 'subtitles' in the POMS system share some common properties which are collected here

The newest version!
package nl.vpro.services;

import java.util.concurrent.Callable;
import java.util.function.*;

import jakarta.transaction.Transactional;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.meeuw.functional.ThrowAnyRunnable;

/**
 * Please note that transactions are only rolled back in case of a runtime exception
 * 

* Also note that in new transactions the currently existing hibernate filters will be gone. * * @author Danny Sedney */ public interface TransactionService { /** * Run callable in new transaction. Transaction is rolled back ONLY in case of an exception * @param callable The jobs to be processed in the new transaction * @return The result of the callable * @throws Exception The exception thrown by the callable */ T executeInNewTransaction(@NonNull Callable callable) throws Exception; /** * Run callable in transaction (creating a new one if there is none only). Transaction is rolled back ONLY in case of a runtime exception * @param callable The jobs to be processed in transaction * @return The result of the callable * @throws Exception The exception thrown by the callable * @since 8.3 */ T executeInTransaction(@NonNull Callable callable) throws Exception; /** * @since 8.3 */ void executeInTransaction(@NonNull Runnable runnable); T getInNewTransaction(@NonNull Supplier supplier); T getInTransaction(@NonNull Supplier supplier); void executeInNewTransaction(@NonNull Runnable runnable); T executeInNewTransaction(S argument, @NonNull Function function); void executeInNewTransaction(T argument,@NonNull Consumer consumer); T executeInReadonlyTransaction(@NonNull Callable callable) throws Exception; T getInReadonlyTransaction(@NonNull Supplier supplier); @Transactional(Transactional.TxType.REQUIRES_NEW) default void executeInReadonlyTransaction(@NonNull ThrowAnyRunnable runnable) { executeInReadonlyTransaction((Runnable) runnable); } void executeInReadonlyTransaction(@NonNull Runnable runnable); T executeInReadonlyTransaction(S argument, @NonNull Function function); void executeInReadonlyTransaction(T argument, @NonNull Consumer consumer); @Transactional(Transactional.TxType.NEVER) default void ensureNoTransaction() { } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy