Class SQLDialect

    • Field Detail

      • connection

        @NotNull
        public final @NotNull java.sql.Connection connection
        The connection to the database
      • cache

        @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
        • Key: table name
        • Value:
          • Key: target
          • Value:
            • Key: data key
            • Value: data value
    • Method Detail

      • getFromCacheImpl

        @Nullable
        public @Nullable Value getFromCacheImpl​(@NotNull
                                                @NotNull java.lang.String table,
                                                @NotNull
                                                @NotNull java.lang.String target,
                                                @NotNull
                                                @NotNull java.lang.String key)
        Description copied from class: Dialect
        Get a value from the cache
        Specified by:
        getFromCacheImpl in class Dialect
        Parameters:
        table - the table
        target - the target
        key - the key
        Returns:
        the value inside a Value, null if it isn't cached
      • setToCacheImpl

        public void setToCacheImpl​(@NotNull
                                   @NotNull java.lang.String table,
                                   @NotNull
                                   @NotNull java.lang.String target,
                                   @NotNull
                                   @NotNull java.lang.String key,
                                   @NotNull
                                   @NotNull Value value)
        Description copied from class: Dialect
        Set a value to the cache
        Specified by:
        setToCacheImpl in class Dialect
        Parameters:
        table - the table
        target - the target
        key - the key
        value - the value inside a Value
      • markRemovedInCacheImpl

        public void markRemovedInCacheImpl​(@NotNull
                                           @NotNull java.lang.String table,
                                           @NotNull
                                           @NotNull java.lang.String target,
                                           @NotNull
                                           @NotNull java.lang.String key)
        Description copied from class: Dialect
        Mark a value as removed in the cache
        Specified by:
        markRemovedInCacheImpl in class Dialect
        Parameters:
        table - the table
        target - the target
        key - the key
      • saveCacheImpl

        public void saveCacheImpl()
        Description copied from class: Dialect
        Save all cache data to the database
        Specified by:
        saveCacheImpl in class Dialect
      • saveCacheImpl

        public void saveCacheImpl​(@NotNull
                                  @NotNull java.lang.String table,
                                  @NotNull
                                  @NotNull java.lang.String target)
        Description copied from class: Dialect
        Save a specific target in a table to the cache
        Specified by:
        saveCacheImpl in class Dialect
        Parameters:
        table - the table to save in
        target - the target to save
      • createTablesKeys

        public void createTablesKeys​(@NotNull
                                     @NotNull java.util.Map<java.lang.String,​java.util.Set<java.lang.String>> tablesKeys)
        Create the given tables and keys in the database
        Parameters:
        tablesKeys - the tables and keys to create
      • setValuesParameters

        @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
        Used for Dialect.setToDatabaseImpl(String, String, String, String) to set the parameters of the PreparedStatement
        Parameters:
        target - the target to set the value to
        values - the values to set as Values
        insertBuilder - the insert query builder
        valuesBuilder - the values query builder
        updateBuilder - the update query builder
        Returns:
        the PreparedStatement with the set parameters
        Throws:
        java.sql.SQLException - if a database access error occurs
      • getTables

        @NotNull
        public final @NotNull java.sql.PreparedStatement getTables()
                                                            throws java.sql.SQLException
        Get all tables from the database
        Returns:
        the PreparedStatement with the set parameters
        Throws:
        java.sql.SQLException - if a database error occurs
      • createTable

        @NotNull
        public final @NotNull java.sql.PreparedStatement createTable​(@NotNull
                                                                     @NotNull java.lang.String table)
                                                              throws java.sql.SQLException
        Create a table in the database
        Parameters:
        table - the table to create
        Returns:
        the PreparedStatement with the set parameters
        Throws:
        java.sql.SQLException - if a database error occurs
      • createKey

        @Nullable
        public final @Nullable java.sql.PreparedStatement createKey​(@NotNull
                                                                    @NotNull java.lang.String table,
                                                                    @NotNull
                                                                    @NotNull java.lang.String key)
                                                             throws java.sql.SQLException
        Create a key in the given table (converts the key to lowercase)
        Parameters:
        table - the table to create the key in
        key - the key to create
        Returns:
        the PreparedStatement with the set parameters
        Throws:
        java.sql.SQLException - if a database error occurs
      • getAllValuesFromDatabase

        @NotNull
        public final @NotNull java.sql.PreparedStatement getAllValuesFromDatabase​(@NotNull
                                                                                  @NotNull java.lang.String table)
                                                                           throws java.sql.SQLException
        Get all values from the database
        Parameters:
        table - the table to get the values from
        Returns:
        the PreparedStatement with the set parameters
        Throws:
        java.sql.SQLException - if a database error occurs
      • getTablesImpl

        @NotNull
        protected abstract @NotNull java.sql.PreparedStatement getTablesImpl()
                                                                      throws java.sql.SQLException
        Get all tables from the database
        Returns:
        the PreparedStatement with the set parameters
        Throws:
        java.sql.SQLException - if a database error occurs
      • createTableImpl

        @NotNull
        protected abstract @NotNull java.sql.PreparedStatement createTableImpl​(@NotNull
                                                                               @NotNull java.lang.String table)
                                                                        throws java.sql.SQLException
        Create a table in the database
        Parameters:
        table - the table to create
        Returns:
        the PreparedStatement with the set parameters
        Throws:
        java.sql.SQLException - if a database error occurs
      • createKeyImpl

        @Nullable
        protected abstract @Nullable java.sql.PreparedStatement createKeyImpl​(@NotNull
                                                                              @NotNull java.lang.String table,
                                                                              @NotNull
                                                                              @NotNull java.lang.String key)
                                                                       throws java.sql.SQLException
        Create a key in the given table
        Parameters:
        table - the table to create the key in
        key - the key to create
        Returns:
        the PreparedStatement with the set parameters
        Throws:
        java.sql.SQLException - if a database error occurs
      • getAllValuesFromDatabaseImpl

        @NotNull
        protected abstract @NotNull java.sql.PreparedStatement getAllValuesFromDatabaseImpl​(@NotNull
                                                                                            @NotNull java.lang.String table)
                                                                                     throws java.sql.SQLException
        Get all values from the database
        Parameters:
        table - the table to get the values from
        Returns:
        the PreparedStatement with the set parameters
        Throws:
        java.sql.SQLException - if a database error occurs