Added Database#query and Database#executeTransaction

This commit is contained in:
Rsl1122 2019-01-18 18:07:34 +02:00
parent f75ab956c6
commit 4b0526c6d3
2 changed files with 46 additions and 0 deletions

View File

@ -18,6 +18,8 @@ package com.djrapitops.plan.db;
import com.djrapitops.plan.api.exceptions.database.DBException;
import com.djrapitops.plan.api.exceptions.database.DBInitException;
import com.djrapitops.plan.db.access.QueryStatement;
import com.djrapitops.plan.db.access.transactions.Transaction;
import com.djrapitops.plan.system.database.databases.operation.*;
/**
@ -33,6 +35,24 @@ public interface Database {
boolean isOpen();
/**
* Execute an SQL Query statement to get a result.
* <p>
* This method should only be called from an asynchronous thread.
*
* @param query QueryStatement to execute.
* @param <T> Type of the object to be returned.
* @return Result of the query.
*/
<T> T query(QueryStatement<T> query);
/**
* Execute an SQL Transaction.
*
* @param transaction Transaction to execute.
*/
void executeTransaction(Transaction transaction);
@Deprecated
BackupOperations backup();

View File

@ -0,0 +1,26 @@
/*
* This file is part of Player Analytics (Plan).
*
* Plan is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License v3 as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Plan is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
*/
package com.djrapitops.plan.db.access.transactions;
/**
* Represents a database transaction.
*
* @author Rsl1122
*/
public abstract class Transaction {
}