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

io.ebeaninternal.server.core.TransWrapper Maven / Gradle / Ivy

There is a newer version: 15.8.1
Show newest version
package io.ebeaninternal.server.core;

import io.ebeaninternal.api.SpiTransaction;

/**
 * Used to temporarily wrap a thread local based transaction.
 * 

* Additionally notes if the transaction was created by the request in which * case it needs to be commited after the request has been processed. *

*/ final class TransWrapper { final SpiTransaction transaction; private final boolean wasCreated; /** * Wrap the transaction indicating if it was just created. */ TransWrapper(SpiTransaction t, boolean created) { transaction = t; wasCreated = created; } void batchEscalateOnCollection() { transaction.checkBatchEscalationOnCollection(); } void flushBatchOnCollection() { if (!wasCreated) { transaction.flushBatchOnCollection(); } } void commitIfCreated() { if (wasCreated) { transaction.commit(); } } void rollbackIfCreated() { if (wasCreated) { transaction.rollbackIfActive(); } } /** * Return true if the transaction was just created. If true it should be * committed after the request has been processed. */ boolean wasCreated() { return wasCreated; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy