public class ForeignKey extends Constraint
DatabaseMetaData
.Modifier and Type | Class and Description |
---|---|
static class |
ForeignKey.FKMapKey |
Modifier and Type | Field and Description |
---|---|
static int |
ACTION_CASCADE
Cascade any modification of the joined primary key columns to
this table.
|
static int |
ACTION_DEFAULT
Set the local columns to their default values if the primary key
columns are modified.
|
static int |
ACTION_NONE
Logical foreign key; links columns, but does not perform any action
when the joined primary key columns are modified.
|
static int |
ACTION_NULL
Null the local columns if the joined primary key columns are modified.
|
static int |
ACTION_RESTRICT
Throw an exception if joined primary key columns are modified.
|
Constructor and Description |
---|
ForeignKey()
Default constructor.
|
ForeignKey(DBIdentifier name,
Table table) |
ForeignKey(String name,
Table table)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
addColumn(ForeignKey fk)
Joins the column of a single column FK to this FK.
|
boolean |
columnsMatch(Column[] fkCols,
Column[] fkPKCols)
Return true if the given local and foreign columns match those
on this key.
|
boolean |
containsColumn(Column col)
Return true if the fk includes the given local column.
|
boolean |
containsConstantColumn(Column col)
Return true if the fk includes the given local column.
|
boolean |
containsConstantPrimaryKeyColumn(Column col)
Return true if the fk includes the given primary key column.
|
boolean |
containsPrimaryKeyColumn(Column col)
Return true if the fk includes the given primary key column.
|
void |
deref() |
void |
derefColumns()
Deref all columns in this key.
|
boolean |
equalsForeignKey(ForeignKey fk)
Foreign keys are equal if the satisfy the equality constraints of
Constraint and they have the same local and primary key
columns and action. |
static int |
getAction(String name)
Return the foreign key action constant for the given action name.
|
static String |
getActionName(int action)
Return the foreign key action name for the given action constant.
|
Column |
getColumn(Column pk)
Return the local column joined to the given primary key column.
|
Column[] |
getColumns()
Return the local columns in the foreign key local table order.
|
Object |
getConstant(Column local)
Return the constant value assigned to the given local column.
|
Column[] |
getConstantColumns()
Return the local columns that we link to using constant values.
|
Column[] |
getConstantPrimaryKeyColumns()
Return the primary key columns that we link to using constant values.
|
Object[] |
getConstants()
Return the constant values assigned to the local columns
returned by
getConstantColumns() . |
int |
getDeleteAction()
Return the delete action for the key.
|
int |
getIndex()
Return the foreign key's 0-based index in the owning table.
|
int |
getKeySequence()
The sequence of this join in the foreign key.
|
Column |
getPrimaryKeyColumn(Column local)
Return the primary key column joined to the given local column.
|
DBIdentifier |
getPrimaryKeyColumnIdentifier() |
String |
getPrimaryKeyColumnName()
Deprecated.
|
Column[] |
getPrimaryKeyColumns()
Return the foreign columns in the foreign key, in join-order with
the result of
getColumns() . |
Object |
getPrimaryKeyConstant(Column pk)
Return the constant value assigned to the given primary key column.
|
Object[] |
getPrimaryKeyConstants()
Return the constant values assigned to the primary key columns
returned by
getConstantPrimaryKeyColumns() . |
DBIdentifier |
getPrimaryKeySchemaIdentifier() |
String |
getPrimaryKeySchemaName()
Deprecated.
|
Table |
getPrimaryKeyTable()
Returns the table this foreign key is linking to, if it is known yet.
|
DBIdentifier |
getPrimaryKeyTableIdentifier() |
String |
getPrimaryKeyTableName()
Deprecated.
|
int |
getRefCount() |
int |
getUpdateAction()
Return the update action for the key.
|
boolean |
hasNotNullColumns()
Checks for non-nullable local columns.
|
boolean |
isLogical()
Return whether this constraint is a logical constraint only; i.e.
|
boolean |
isPrimaryKeyAutoAssigned()
Whether the primary key columns of this key are auto-incrementing, or
whether they themselves are members of a foreign key who's primary key
is auto-incrementing (recursing to arbitrary depth).
|
void |
join(Column local,
Column toPK)
Join a local column to a primary key column of another table.
|
void |
joinConstant(Column col,
Object val)
Join a constant value to a local column of this table.
|
void |
joinConstant(Object val,
Column toPK)
Join a constant value to a primary key column of another table.
|
DBIdentifier |
loadIdentifierFromDB(DBDictionary dbdict,
Connection conn) |
String |
loadNameFromDB(DBDictionary dbdict,
Connection conn)
Deprecated.
|
void |
ref() |
void |
refColumns()
Ref all columns in this key.
|
boolean |
removeJoin(Column col)
Remove any joins inolving the given column.
|
void |
setConstantJoins(Column[] cols,
Object[] consts)
Set the foreign key's constant joins.
|
void |
setConstantJoins(Object[] consts,
Column[] pkCols)
Set the foreign key's constant joins.
|
void |
setDeleteAction(int action)
Set the delete action for the key.
|
void |
setJoins(Column[] cols,
Column[] pkCols)
Set the foreign key's joins.
|
void |
setKeySequence(int seq)
The sequence of this join in the foreign key.
|
void |
setPrimaryKeyColumnIdentifier(DBIdentifier pkColumnName) |
void |
setPrimaryKeyColumnName(String pkColumnName)
Deprecated.
|
void |
setPrimaryKeySchemaIdentifier(DBIdentifier pkSchemaName) |
void |
setPrimaryKeySchemaName(String pkSchemaName)
Deprecated.
|
void |
setPrimaryKeyTableIdentifier(DBIdentifier pkTableName) |
void |
setPrimaryKeyTableName(String pkTableName)
Deprecated.
|
void |
setUpdateAction(int action)
Set the update action for the key.
|
getColumnIdentifier, getColumnName, getFullIdentifier, getFullName, getIdentifier, getName, getQualifiedPath, getSchemaIdentifier, getSchemaName, getTable, getTableIdentifier, getTableName, isDeferred, setColumnIdentifier, setColumnName, setDeferred, setIdentifier, setName, setSchemaIdentifier, setSchemaName, setTableIdentifier, setTableName, toString
public static final int ACTION_NONE
public static final int ACTION_RESTRICT
public static final int ACTION_CASCADE
public static final int ACTION_NULL
public static final int ACTION_DEFAULT
public ForeignKey()
@Deprecated public ForeignKey(String name, Table table)
name
- the foreign key name, if anytable
- the local table of the foreign keypublic ForeignKey(DBIdentifier name, Table table)
public static int getAction(String name)
public static String getActionName(int action)
public boolean isLogical()
Constraint
isLogical
in class Constraint
public boolean isPrimaryKeyAutoAssigned()
@Deprecated public String getPrimaryKeyTableName()
public DBIdentifier getPrimaryKeyTableIdentifier()
@Deprecated public void setPrimaryKeyTableName(String pkTableName)
public void setPrimaryKeyTableIdentifier(DBIdentifier pkTableName)
@Deprecated public String getPrimaryKeySchemaName()
public DBIdentifier getPrimaryKeySchemaIdentifier()
@Deprecated public void setPrimaryKeySchemaName(String pkSchemaName)
public void setPrimaryKeySchemaIdentifier(DBIdentifier pkSchemaName)
@Deprecated public String getPrimaryKeyColumnName()
public DBIdentifier getPrimaryKeyColumnIdentifier()
@Deprecated public void setPrimaryKeyColumnName(String pkColumnName)
public void setPrimaryKeyColumnIdentifier(DBIdentifier pkColumnName)
public int getKeySequence()
public void setKeySequence(int seq)
public int getDeleteAction()
ACTION_NONE
, ACTION_RESTRICT
,
ACTION_CASCADE
, ACTION_NULL
, ACTION_DEFAULT
.public void setDeleteAction(int action)
ACTION_NONE
, ACTION_RESTRICT
,
ACTION_CASCADE
, ACTION_NULL
, ACTION_DEFAULT
.public int getUpdateAction()
ACTION_NONE
, ACTION_RESTRICT
,
ACTION_CASCADE
, ACTION_NULL
, ACTION_DEFAULT
.public void setUpdateAction(int action)
ACTION_NONE
, ACTION_RESTRICT
,
ACTION_CASCADE
, ACTION_NULL
, ACTION_DEFAULT
.public int getIndex()
public Column getPrimaryKeyColumn(Column local)
public Column getColumn(Column pk)
public Object getConstant(Column local)
public Object getPrimaryKeyConstant(Column pk)
public Column[] getColumns()
public Object[] getConstants()
getConstantColumns()
.public Object[] getPrimaryKeyConstants()
getConstantPrimaryKeyColumns()
.public boolean containsColumn(Column col)
public boolean containsPrimaryKeyColumn(Column col)
public boolean containsConstantColumn(Column col)
public boolean containsConstantPrimaryKeyColumn(Column col)
public Column[] getPrimaryKeyColumns()
getColumns()
.public Column[] getConstantColumns()
public Column[] getConstantPrimaryKeyColumns()
public void setConstantJoins(Object[] consts, Column[] pkCols)
public void setConstantJoins(Column[] cols, Object[] consts)
public void join(Column local, Column toPK)
public void joinConstant(Object val, Column toPK)
public void joinConstant(Column col, Object val)
public boolean removeJoin(Column col)
public Table getPrimaryKeyTable()
public void refColumns()
public void derefColumns()
public boolean equalsForeignKey(ForeignKey fk)
Constraint
and they have the same local and primary key
columns and action.public boolean columnsMatch(Column[] fkCols, Column[] fkPKCols)
public boolean hasNotNullColumns()
@Deprecated public String loadNameFromDB(DBDictionary dbdict, Connection conn)
public DBIdentifier loadIdentifierFromDB(DBDictionary dbdict, Connection conn)
public void addColumn(ForeignKey fk)
fk
- public int getRefCount()
public void ref()
public void deref()
Copyright © 2006–2020 Apache Software Foundation. All rights reserved.