Class HistoryTableGenerator

java.lang.Object
com.randomnoun.common.db.history.HistoryTableGenerator

public class HistoryTableGenerator extends Object
This class will generate history table and triggers. If you get these error messages:
 Access denied; you need the SUPER privilege for this operation
 
then try this:
 GRANT ALL PRIVILEGES ON ON schema_name.* TO 'ON schema_name'@'%' WITH GRANT OPTION;
 
I've got a sqlserver version of this somewhere. Good luck finding that again.

This class is similar to the old HistoryTableGenerator, but uses templates instead.

TODO add other db types

TODO add stored procs to roll back table(s) to a given point in time

TODO add history partitions, if mysql supports it

  • Constructor Details

  • Method Details

    • setOptions

      public void setOptions(Map<String,Object> options)
      Set the options for the history generator.

      History options are specific to the generator being used, but typical options are:

      • undoEnabledTableNames - List
      • dropTables - Boolean
      • existingDataUserActionId - Boolean
      • alwaysRecreateTriggers - Boolean
      • alwaysRecreateStoredProcedures - Boolean
      • includeUpdateBitFields - Boolean
      • includeCurrentUser - Boolean

      Refer to the source code of the generator as to which options are supported ( e.g. src/main/resources/common/db/mysql/mysql-historyTable-2.sql.jessop )

      Parameters:
      options -
    • generateHistoryTableSql

      Returns the SQL that will create history tables, triggers and stored procedures.

      To break this String back into individual SQL statements, use SqlParser

      Returns:
      SQL that will create history tables, triggers and stored procedures
      Throws:
      ScriptException
    • getJessopScript

    • setJessopScript

      public void setJessopScript(String jessopScript)
    • getJessopScriptFilename

    • setJessopScriptFilename

      public void setJessopScriptFilename(String jessopScriptFilename)
    • getSchemaName

    • setSchemaName

      public void setSchemaName(String schemaName)
    • getOptions