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 class
ForeignKey.FKAction
Enum 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 void
addColumn(Column col)
Class to add a column to the keyvoid
addColumn(Column col, Column refCol)
Method to add a Column.protected void
assertSameDatastoreObject(Column col)
Utility to assert if the column is for a different table.boolean
equals(Object obj)
Equality operator.String
getColumnList()
Accessor for the column liststatic String
getColumnList(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.String
getName()
Accessor for the key name.int
getNumberOfColumns()
Accessor for the number of columns.String
getRefColumnList()
DatastoreClass
getRefTable()
Table
getTable()
Accessor for the tableint
hashCode()
Hashcode operator.boolean
isEqual(ForeignKey fk)
void
setColumn(int seq, Column col)
Sets a column in a specified positionseq
for this index.void
setColumn(int seq, Column col, Column refCol)
Set the column for the specified positionseq
void
setDeleteAction(ForeignKey.FKAction deleteAction)
Mutator for deleteAction.void
setForMetaData(org.datanucleus.metadata.ForeignKeyMetaData fkmd)
Convenience mutator for setting the specification based on MetaDataprotected static void
setListMinimumSize(List list, int size)
void
setName(String name)
Mutator for the key name.void
setUpdateAction(ForeignKey.FKAction updateAction)
Mutator for updateAction.String
toString()
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 positionseq
for this index.- Parameters:
seq
- the specified position for thecol
col
- 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)
-
-