org.apache.empire.db
Class DBRelation

java.lang.Object
  extended by org.apache.empire.db.DBObject
      extended by org.apache.empire.db.DBRelation
All Implemented Interfaces:
Serializable

public class DBRelation
extends DBObject

This class creates a DBReferene object for a foreing key relation.

See Also:
Serialized Form

Nested Class Summary
static class DBRelation.DBCascadeAction
          DBCascadeAction enum
static class DBRelation.DBReference
           
 
Constructor Summary
DBRelation(DBDatabase db, String name, DBRelation.DBReference[] references)
          Creates a DBRelation object for a foreing key relation.
DBRelation(DBDatabase db, String name, DBRelation.DBReference[] references, DBRelation.DBCascadeAction onDeleteAction)
          Creates a DBRelation object for a foreing key relation.
 
Method Summary
 DBDatabase getDatabase()
          Returns the database object to which this object belongs to.
 String getEnableDisableStatement(boolean enable)
          Appends the required DLL command to enable or disable a foreign key constraint to the supplied DBDQLScript.
 String getEnableDisableStmt(boolean enable, DBDatabaseDriver driver)
          Appends the required DLL command to enable or disable a foreign key constraint to the supplied DBDQLScript.
 DBTable getForeignKeyTable()
          Returns the table that is containing the foreign key (source table)
 String getFullName()
          Returns the full qualified table name.
 String getName()
          Returns the name.
 DBRelation.DBCascadeAction getOnDeleteAction()
          return the action to perform when deleting affected records.
 DBTable getReferencedTable()
          Returns the table that is referenced by this foreign key relation (target table)
 DBRelation.DBReference[] getReferences()
          Returns the references.
 void onDeleteCascade()
          short for
 void onDeleteCascadeRecords()
          short for
 void setOnDeleteAction(DBRelation.DBCascadeAction onDeleteAction)
          sets the action taken when deleting records that affect this foreign key relation See DBCascadeAction enum for details.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

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 Detail

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

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 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,
                                   DBDatabaseDriver driver)
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
driver - the driver for which to enable or disable the relation

getEnableDisableStatement

public final String getEnableDisableStatement(boolean enable)
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

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2008–2014 Apache Software Foundation. All rights reserved.