Package org.datanucleus.store.rdbms.key
Class ForeignKey
- java.lang.Object
-
- org.datanucleus.store.rdbms.key.ForeignKey
-
public class ForeignKey extends Object
Representation of a foreign key to another table.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classForeignKey.FKActionEnum representing an action on the FK.
-
Constructor Summary
Constructors Constructor Description ForeignKey(DatastoreAdapter dba, boolean initiallyDeferred)Constructor.ForeignKey(JavaTypeMapping mapping, DatastoreAdapter dba, DatastoreClass refTable, boolean initiallyDeferred)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddColumn(Column col)Class to add a column to the keyvoidaddColumn(Column col, Column refCol)Method to add a Column.protected voidassertSameDatastoreObject(Column col)Utility to assert if the column is for a different table.booleanequals(Object obj)Equality operator.StringgetColumnList()Accessor for the column liststatic StringgetColumnList(List<Column> cols)Method to return the list of columns which the key applies to.List<Column>getColumns()Accessor for the columns that the key relates to.StringgetName()Accessor for the key name.intgetNumberOfColumns()Accessor for the number of columns.StringgetRefColumnList()DatastoreClassgetRefTable()TablegetTable()Accessor for the tableinthashCode()Hashcode operator.booleanisEqual(ForeignKey fk)voidsetColumn(int seq, Column col)Sets a column in a specified positionseqfor this index.voidsetColumn(int seq, Column col, Column refCol)Set the column for the specified positionseqvoidsetDeleteAction(ForeignKey.FKAction deleteAction)Mutator for deleteAction.voidsetForMetaData(org.datanucleus.metadata.ForeignKeyMetaData fkmd)Convenience mutator for setting the specification based on MetaDataprotected static voidsetListMinimumSize(List list, int size)voidsetName(String name)Mutator for the key name.voidsetUpdateAction(ForeignKey.FKAction updateAction)Mutator for updateAction.StringtoString()Stringify method.
-
-
-
Constructor Detail
-
ForeignKey
public ForeignKey(DatastoreAdapter dba, boolean initiallyDeferred)
Constructor.- Parameters:
dba- Datastore adapterinitiallyDeferred- Whether the constraints are deferred
-
ForeignKey
public ForeignKey(JavaTypeMapping mapping, DatastoreAdapter dba, DatastoreClass refTable, boolean initiallyDeferred)
Constructor.- Parameters:
mapping- The type mapping for this Foreign-key fielddba- Datastore adapterrefTable- Referred to tableinitiallyDeferred- Whether they are deferred
-
-
Method Detail
-
setForMetaData
public void setForMetaData(org.datanucleus.metadata.ForeignKeyMetaData fkmd)
Convenience mutator for setting the specification based on MetaData- Parameters:
fkmd- ForeignKey MetaData definition
-
setDeleteAction
public void setDeleteAction(ForeignKey.FKAction deleteAction)
Mutator for deleteAction.- Parameters:
deleteAction- The deleteAction to set.
-
setUpdateAction
public void setUpdateAction(ForeignKey.FKAction updateAction)
Mutator for updateAction.- Parameters:
updateAction- The updateAction to set.
-
addColumn
public void addColumn(Column col, Column refCol)
Method to add a Column.- Parameters:
col- The column to addrefCol- The column to reference
-
getRefTable
public DatastoreClass getRefTable()
-
getRefColumnList
public String getRefColumnList()
-
setColumn
public void setColumn(int seq, Column col, Column refCol)Set the column for the specified positionseq- Parameters:
seq- the specified positioncol- the columnrefCol- the foreign (refered) column
-
hashCode
public int hashCode()
Hashcode operator.- Returns:
- The hashcode
-
equals
public boolean equals(Object obj)
Equality operator.- Parameters:
obj- Object to compare against- Returns:
- Whether they are equal.
-
isEqual
public boolean isEqual(ForeignKey fk)
-
toString
public String toString()
Stringify method. Generates the foreign key statement ready for use in an SQL call.
-
setName
public void setName(String name)
Mutator for the key name.- Parameters:
name- The key name
-
getName
public String getName()
Accessor for the key name.- Returns:
- Key name
-
getTable
public Table getTable()
Accessor for the table- Returns:
- table
-
getColumns
public List<Column> getColumns()
Accessor for the columns that the key relates to.- Returns:
- the List of columns.
-
getColumnList
public String getColumnList()
Accessor for the column list- Returns:
- The column list
-
getNumberOfColumns
public int getNumberOfColumns()
Accessor for the number of columns.- Returns:
- The number of columns.
-
addColumn
public void addColumn(Column col)
Class to add a column to the key- Parameters:
col- The column to add
-
setColumn
public void setColumn(int seq, Column col)Sets a column in a specified positionseqfor this index.- Parameters:
seq- the specified position for thecolcol- the Column
-
assertSameDatastoreObject
protected void assertSameDatastoreObject(Column col)
Utility to assert if the column is for a different table.- Parameters:
col- The column to compare with
-
setListMinimumSize
protected static void setListMinimumSize(List list, int size)
-
-