bentobox/src/main/java/world/bentobox/bentobox/database/sql/mysql/MySQLDatabaseHandler.java

34 lines
1.2 KiB
Java

package world.bentobox.bentobox.database.sql.mysql;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.database.DatabaseConnector;
import world.bentobox.bentobox.database.sql.SQLConfiguration;
import world.bentobox.bentobox.database.sql.SQLDatabaseHandler;
/**
*
* Class that inserts a <T> into the corresponding database-table.
*
* @author tastybento
*
* @param <T>
*/
public class MySQLDatabaseHandler<T> extends SQLDatabaseHandler<T>
{
/**
* Handles the connection to the database and creation of the initial database schema (tables) for the class that
* will be stored.
*
* @param plugin - plugin object
* @param type - the type of class to be stored in the database. Must inherit DataObject
* @param dbConnecter - authentication details for the database
*/
MySQLDatabaseHandler(BentoBox plugin, Class<T> type, DatabaseConnector dbConnecter)
{
super(plugin,
type,
dbConnecter,
new SQLConfiguration(plugin, type).schema("CREATE TABLE IF NOT EXISTS `[tableName]` (json JSON, uniqueId VARCHAR(255) GENERATED ALWAYS AS (json->\"$.uniqueId\"), UNIQUE INDEX i (uniqueId) ) ENGINE = INNODB"));
}
}