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

org.cloudfoundry.multiapps.controller.persistence.TransactionalExecutor Maven / Gradle / Ivy

There is a newer version: 1.176.0
Show newest version
package org.cloudfoundry.multiapps.controller.persistence;

import java.util.function.Function;

import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;

public class TransactionalExecutor extends Executor {

    public TransactionalExecutor(EntityManager manager) {
        super(manager);
    }

    @Override
    public T execute(Function function) {
        T result = null;
        try {
            EntityTransaction transaction = manager.getTransaction();
            transaction.begin();

            result = function.apply(manager);

            transaction.commit();
        } finally {
            cleanUp();
        }
        return result;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy