Transactions can now be executed within other Transactions:

- No save point/connection management overhead.
This commit is contained in:
Rsl1122 2019-01-30 19:32:49 +02:00
parent edb6a6eb72
commit 3ab30f8b9f
2 changed files with 7 additions and 3 deletions

View File

@ -83,9 +83,7 @@ public class CleanTransaction extends Transaction {
.map(Map.Entry::getKey)
.collect(Collectors.toList());
for (UUID uuid : inactivePlayers) {
// TODO Figure out a better way to schedule transactions from within transactions
// or figure out a way to execute the transaction within this transaction.
db.executeTransaction(new RemovePlayerTransaction(uuid));
executeOther(new RemovePlayerTransaction(uuid));
}
return inactivePlayers.size();
}

View File

@ -146,6 +146,12 @@ public abstract class Transaction {
}
}
protected void executeOther(Transaction transaction) {
transaction.connection = this.connection;
transaction.performOperations();
transaction.connection = null;
}
protected DBType getDBType() {
return db.getType();
}