Class DbModification

All Implemented Interfaces:
Serializable, Comparable<DbModification>, ModificationLoggable, org.tentackle.misc.Identifiable, org.tentackle.misc.Immutable, org.tentackle.misc.SerialNumbered, SessionDependable, SessionProvider

@ClassId(1) @TableName("modification") public class DbModification extends AbstractDbObject<DbModification>
Modification information per table.
Author:
harald
See Also:
  • Field Details

  • Constructor Details

    • DbModification

      public DbModification(Db db, String trackedName)
      Creates a modification object for a given tablename.
      Parameters:
      db - the session, null if thread-local
      trackedName - the tracked name
    • DbModification

      public DbModification(Db db)
      Creates an empty modification object.
      Parameters:
      db - the session
    • DbModification

      public DbModification()
      Creates an empty modification object.
  • Method Details

    • initializeModificationTable

      public static void initializeModificationTable(Db db)
      Initializes the modification table.
      Parameters:
      db - the session
    • getClassVariables

      public DbObjectClassVariables<DbModification> getClassVariables()
      Description copied from class: AbstractDbObject
      Gets some attributes and variables common to all objects of the same class. Class variables for classes derived from AbstractDbObject are kept in an instance of DbObjectClassVariables.
      Overrides:
      getClassVariables in class AbstractDbObject<DbModification>
      Returns:
      the class variables
    • toString

      public String toString()
      Description copied from class: AbstractDbObject
      Gets the default string value.
      The default implementation invokes AbstractDbObject.toGenericString().
      Overrides:
      toString in class AbstractDbObject<DbModification>
      Returns:
      the string value of this AbstractDbObject
    • getFields

      public void getFields(ResultSetWrapper rs)
      Description copied from class: AbstractDbObject
      Retrieves the values of all fields.
      Overrides:
      getFields in class AbstractDbObject<DbModification>
      Parameters:
      rs - the result set
    • setFields

      public int setFields(PreparedStatementWrapper st)
      Description copied from class: AbstractDbObject
      Sets the values of all fields (all columns of the database table) in the given PreparedStatementWrapper from the object's attributes.
      Overrides:
      setFields in class AbstractDbObject<DbModification>
      Parameters:
      st - the statement
      Returns:
      the number of fields set
    • createInsertSql

      public String createInsertSql(Backend backend)
      Description copied from class: AbstractDbObject
      Creates the SQL code for the insert statement.
      Overrides:
      createInsertSql in class AbstractDbObject<DbModification>
      Parameters:
      backend - the backend
      Returns:
      the SQL code
    • createUpdateSql

      public String createUpdateSql(Backend backend)
      Description copied from class: AbstractDbObject
      Creates the SQL code for the update statement.
      Overrides:
      createUpdateSql in class AbstractDbObject<DbModification>
      Parameters:
      backend - the backend
      Returns:
      the SQL code
    • getTrackedName

      @Persistent(ordinal=0, comment="the tablename") public String getTrackedName()
      Gets the attribute trackedName.
      Returns:
      the tablename
    • setTrackedName

      public void setTrackedName(String trackedName)
      Sets the attribute trackedName.
      Parameters:
      trackedName - the tablename
    • countModification

      public int countModification(long count)
      Counts modifications.
      Adds the count to the table's entry and the master entry.
      Parameters:
      count - the number of modifications to add
      Returns:
      the number of modification rows updated (should be 2)
    • addToModificationTable

      public void addToModificationTable(boolean tableExists, String tableSerialTableName)
      Adds an entry for this counter (== database object class) to the modification table. The tableserial is derived from the highest serial of all objects (i.e. class) this counter refers to.
      Parameters:
      tableExists - true if related to a PDO, false if just a name
      tableSerialTableName - the table to scan for max tableserial if PDO manages a tableserial
    • refresh

      public long refresh()
      Refreshes the contents of this modification entry by its name.
      Returns:
      the modification count
    • selectIdSerial

      public org.tentackle.misc.IdSerialTuple selectIdSerial(String tableName)
      Selects the id and serial by tablename.
      Parameters:
      tableName - the database tablename
      Returns:
      the id/serial tuple, null if no such table registered so far
    • selectTableNameForId

      public String selectTableNameForId(long id)
      Selects the tablename for a given ID.
      Parameters:
      id - the table ID
      Returns:
      the tablename, null if the such an ID does not exist
    • selectMasterSerial

      public long selectMasterSerial()
      Reads the master-serial.
      Returns:
      the master serial