public abstract class SQLDialect extends Dialect
Dialect.MigrationData| Modifier and Type | Field and Description |
|---|---|
@NotNull java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.concurrent.ConcurrentHashMap<java.lang.String,Value>>> |
cache
Key: table name
Value:
Key: target
Value:
Key: data key
Value: data value
|
@NotNull java.sql.Connection |
connection
The
connection to the database |
dataManager| Constructor and Description |
|---|
SQLDialect(@NotNull DataManager dataManager)
Construct a new
SQLDialect with the given DataManager |
| Modifier and Type | Method and Description |
|---|---|
@Nullable java.sql.PreparedStatement |
createKey(@NotNull java.lang.String table,
@NotNull java.lang.String key)
Create a key in the given table (converts the key to lowercase)
|
protected abstract @Nullable java.sql.PreparedStatement |
createKeyImpl(@NotNull java.lang.String table,
@NotNull java.lang.String key)
Create a key in the given table
|
@NotNull java.sql.PreparedStatement |
createTable(@NotNull java.lang.String table)
Create a table in the database
|
protected abstract @NotNull java.sql.PreparedStatement |
createTableImpl(@NotNull java.lang.String table)
Create a table in the database
|
void |
createTablesKeys(@NotNull java.util.Map<java.lang.String,java.util.Set<java.lang.String>> tablesKeys)
Create the given tables and keys in the database
|
@NotNull java.sql.PreparedStatement |
getAllValuesFromDatabase(@NotNull java.lang.String table)
Get all values from the database
|
protected abstract @NotNull java.sql.PreparedStatement |
getAllValuesFromDatabaseImpl(@NotNull java.lang.String table)
Get all values from the database
|
@Nullable Value |
getFromCacheImpl(@NotNull java.lang.String table,
@NotNull java.lang.String target,
@NotNull java.lang.String key)
Get a value from the cache
|
@NotNull java.util.Optional<Dialect.MigrationData> |
getMigrationDataFromDatabaseImpl(@NotNull DataManager newManager)
Get migration data from the database
|
@NotNull java.sql.PreparedStatement |
getTables()
Get all tables from the database
|
protected abstract @NotNull java.sql.PreparedStatement |
getTablesImpl()
Get all tables from the database
|
void |
markRemovedInCacheImpl(@NotNull java.lang.String table,
@NotNull java.lang.String target,
@NotNull java.lang.String key)
Mark a value as removed in the cache
|
void |
saveCacheImpl()
Save all cache data to the database
|
void |
saveCacheImpl(@NotNull java.lang.String table,
@NotNull java.lang.String target)
Save a specific target in a table to the cache
|
void |
setToCacheImpl(@NotNull java.lang.String table,
@NotNull java.lang.String target,
@NotNull java.lang.String key,
@NotNull Value value)
Set a value to the cache
|
protected @NotNull java.sql.PreparedStatement |
setValuesParameters(@NotNull java.lang.String target,
@NotNull java.util.List<Value> values,
@NotNull java.lang.StringBuilder insertBuilder,
@NotNull java.lang.StringBuilder valuesBuilder,
@Nullable java.lang.StringBuilder updateBuilder)
Used for
Dialect.setToDatabaseImpl(String, String, String, String) to set the parameters of the PreparedStatement |
getFromCache, getFromDatabase, getFromDatabaseImpl, getMigrationDataFromDatabase, markRemovedInCache, removeFromDatabaseImpl, removeValueFromDatabase, saveCache, saveCache, setToCache, setToDatabase, setToDatabase, setToDatabase, setToDatabaseImpl, setToDatabaseImpl@NotNull public final @NotNull java.sql.Connection connection
connection to the database@NotNull public final @NotNull java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.concurrent.ConcurrentHashMap<java.lang.String,Value>>> cache
public SQLDialect(@NotNull
@NotNull DataManager dataManager)
throws ConnectionException
SQLDialect with the given DataManagerdataManager - Dialect.dataManagerConnectionException - if a database connection error occurs@Nullable public @Nullable Value getFromCacheImpl(@NotNull @NotNull java.lang.String table, @NotNull @NotNull java.lang.String target, @NotNull @NotNull java.lang.String key)
DialectgetFromCacheImpl in class Dialecttable - the tabletarget - the targetkey - the keyValue, null if it isn't cachedpublic void setToCacheImpl(@NotNull
@NotNull java.lang.String table,
@NotNull
@NotNull java.lang.String target,
@NotNull
@NotNull java.lang.String key,
@NotNull
@NotNull Value value)
DialectsetToCacheImpl in class Dialecttable - the tabletarget - the targetkey - the keyvalue - the value inside a Valuepublic void markRemovedInCacheImpl(@NotNull
@NotNull java.lang.String table,
@NotNull
@NotNull java.lang.String target,
@NotNull
@NotNull java.lang.String key)
DialectmarkRemovedInCacheImpl in class Dialecttable - the tabletarget - the targetkey - the keypublic void saveCacheImpl()
DialectsaveCacheImpl in class Dialectpublic void saveCacheImpl(@NotNull
@NotNull java.lang.String table,
@NotNull
@NotNull java.lang.String target)
DialectsaveCacheImpl in class Dialecttable - the table to save intarget - the target to save@NotNull public @NotNull java.util.Optional<Dialect.MigrationData> getMigrationDataFromDatabaseImpl(@NotNull @NotNull DataManager newManager)
DialectgetMigrationDataFromDatabaseImpl in class DialectnewManager - the new DataManager to migrate topublic void createTablesKeys(@NotNull
@NotNull java.util.Map<java.lang.String,java.util.Set<java.lang.String>> tablesKeys)
tablesKeys - the tables and keys to create@NotNull
protected @NotNull java.sql.PreparedStatement setValuesParameters(@NotNull
@NotNull java.lang.String target,
@NotNull
@NotNull java.util.List<Value> values,
@NotNull
@NotNull java.lang.StringBuilder insertBuilder,
@NotNull
@NotNull java.lang.StringBuilder valuesBuilder,
@Nullable
@Nullable java.lang.StringBuilder updateBuilder)
throws java.sql.SQLException
Dialect.setToDatabaseImpl(String, String, String, String) to set the parameters of the PreparedStatementtarget - the target to set the value tovalues - the values to set as ValuesinsertBuilder - the insert query buildervaluesBuilder - the values query builderupdateBuilder - the update query builderPreparedStatement with the set parametersjava.sql.SQLException - if a database access error occurs@NotNull
public final @NotNull java.sql.PreparedStatement getTables()
throws java.sql.SQLException
PreparedStatement with the set parametersjava.sql.SQLException - if a database error occurs@NotNull
public final @NotNull java.sql.PreparedStatement createTable(@NotNull
@NotNull java.lang.String table)
throws java.sql.SQLException
table - the table to createPreparedStatement with the set parametersjava.sql.SQLException - if a database error occurs@Nullable
public final @Nullable java.sql.PreparedStatement createKey(@NotNull
@NotNull java.lang.String table,
@NotNull
@NotNull java.lang.String key)
throws java.sql.SQLException
table - the table to create the key inkey - the key to createPreparedStatement with the set parametersjava.sql.SQLException - if a database error occurs@NotNull
public final @NotNull java.sql.PreparedStatement getAllValuesFromDatabase(@NotNull
@NotNull java.lang.String table)
throws java.sql.SQLException
table - the table to get the values fromPreparedStatement with the set parametersjava.sql.SQLException - if a database error occurs@NotNull
protected abstract @NotNull java.sql.PreparedStatement getTablesImpl()
throws java.sql.SQLException
PreparedStatement with the set parametersjava.sql.SQLException - if a database error occurs@NotNull
protected abstract @NotNull java.sql.PreparedStatement createTableImpl(@NotNull
@NotNull java.lang.String table)
throws java.sql.SQLException
table - the table to createPreparedStatement with the set parametersjava.sql.SQLException - if a database error occurs@Nullable
protected abstract @Nullable java.sql.PreparedStatement createKeyImpl(@NotNull
@NotNull java.lang.String table,
@NotNull
@NotNull java.lang.String key)
throws java.sql.SQLException
table - the table to create the key inkey - the key to createPreparedStatement with the set parametersjava.sql.SQLException - if a database error occurs@NotNull
protected abstract @NotNull java.sql.PreparedStatement getAllValuesFromDatabaseImpl(@NotNull
@NotNull java.lang.String table)
throws java.sql.SQLException
table - the table to get the values fromPreparedStatement with the set parametersjava.sql.SQLException - if a database error occurs