io.ebeaninternal.server.core.TransWrapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ebean Show documentation
Show all versions of ebean Show documentation
composite of common runtime dependencies for all platforms
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