Class DBRelation

java.lang.Object
org.apache.empire.db.DBObject
org.apache.empire.db.DBRelation

public class DBRelation extends DBObject
This class creates a DBReferene object for a foreing key relation.
  • Constructor Details

    • DBRelation

      public DBRelation(DBDatabase db, String name, DBRelation.DBReference[] references, DBRelation.DBCascadeAction onDeleteAction)
      Creates a DBRelation object for a foreing key relation.
      Parameters:
      db - the database object
      name - the name
      references - the references for this relation
      onDeleteAction - specifies the action performed when deleting affected records.
    • DBRelation

      public DBRelation(DBDatabase db, String name, DBRelation.DBReference[] references)
      Creates a DBRelation object for a foreing key relation.
      Parameters:
      db - the database object
      name - the name
      references - the references for this relation
  • Method Details

    • getName

      public String getName()
      Returns the name.
      Returns:
      Returns the name
    • getFullName

      public String getFullName()
      Returns the full qualified table name.
      Returns:
      the full qualified table name
    • getReferences

      public DBRelation.DBReference[] getReferences()
      Returns the references.
      Returns:
      the references
    • isOnColumns

      public boolean isOnColumns(DBColumn[] keyColumns)
      Checks if the relation references the given key
      Parameters:
      keyColumns - the key columns (primary key)
      Returns:
      true if the relation references the given key or false otherwise
    • getForeignKeyTable

      public DBTable getForeignKeyTable()
      Returns the table that is containing the foreign key (source table)
      Returns:
      true if the relation's source table is the given table
    • getReferencedTable

      public DBTable getReferencedTable()
      Returns the table that is referenced by this foreign key relation (target table)
      Returns:
      true if the relation's target table
    • getDatabase

      public final DBDatabase getDatabase()
      Description copied from class: DBObject
      Returns the database object to which this object belongs to. For the database object itself this function will return the this pointer.
      Specified by:
      getDatabase in class DBObject
      Returns:
      the database object
    • getOnDeleteAction

      public DBRelation.DBCascadeAction getOnDeleteAction()
      return the action to perform when deleting affected records. See DBCascadeAction enum for details.
      Returns:
      the action to perform when deleting affected records
    • setOnDeleteAction

      public void setOnDeleteAction(DBRelation.DBCascadeAction onDeleteAction)
      sets the action taken when deleting records that affect this foreign key relation See DBCascadeAction enum for details.
      Parameters:
      onDeleteAction - the action to perform when deleting affected records
    • onDeleteCascade

      public void onDeleteCascade()
      short for
       
        setOnDeleteAction(DBCascadeAction.CASCADE);
       
      See DBCascadeAction enum for details.
    • onDeleteCascadeRecords

      public void onDeleteCascadeRecords()
      short for
       
        setOnDeleteAction(DBCascadeAction.CASCADE);
       
      See DBCascadeAction enum for details.
    • getEnableDisableStmt

      public String getEnableDisableStmt(boolean enable, DBContext context)
      Appends the required DLL command to enable or disable a foreign key constraint to the supplied DBDQLScript.
      Parameters:
      enable - true if the constraint should be enabled or false to disable the constraint
      context - the context for which to enable or disable the relation
      Returns:
      the sql statement
    • toString

      public String toString()
      Overrides:
      toString in class Object