org.datanucleus.metadata
Class ForeignKeyMetaData

java.lang.Object
  extended by org.datanucleus.metadata.MetaData
      extended by org.datanucleus.metadata.AbstractConstraintMetaData
          extended by org.datanucleus.metadata.ForeignKeyMetaData
All Implemented Interfaces:
java.io.Serializable, ColumnMetaDataContainer

public class ForeignKeyMetaData
extends AbstractConstraintMetaData
implements ColumnMetaDataContainer

Foreign keys in metadata serve two quite different purposes. First, when generating schema, the foreign key element identifies foreign keys to be generated. Second, when using the database, foreign key elements identify foreign keys that are assumed to exist in the database. This is important for the runtime to properly order insert, update, and delete statements to avoid constraint violations. A foreign-key element can be contained by a field, element, key, value, or join element, if all of the columns mapped are to be part of the same foreign key. A foreign-key element can be contained within a class element. In this case, the column elements are mapped elsewhere, and the column elements contained in the foreign-key element have only the column name.

See Also:
Serialized Form

Field Summary
protected  boolean deferred
          The deferred attribute specifies whether the foreign key constraint is defined to be checked only at commit time.
protected  ForeignKeyAction deleteAction
          Foreign keys represent a consistency constraint in the database that must be maintained.
protected  boolean unique
          The unique attribute specifies whether the foreign key constraint is defined to be a unique constraint as well.
protected  ForeignKeyAction updateAction
          Foreign keys represent a consistency constraint in the database that must be maintained.
 
Fields inherited from class org.datanucleus.metadata.AbstractConstraintMetaData
columnMetaData, columns, memberMetaData, members, name, table
 
Fields inherited from class org.datanucleus.metadata.MetaData
extensions, LOCALISER, METADATA_CREATED_STATE, METADATA_INITIALISED_STATE, METADATA_POPULATED_STATE, METADATA_USED_STATE, metaDataState, parent, VENDOR_NAME, VENDOR_NAME_OLD
 
Constructor Summary
ForeignKeyMetaData()
          Default constructor.
ForeignKeyMetaData(ForeignKeyMetaData fkmd)
          Constructor to create a copy of the passed metadata using the provided parent.
 
Method Summary
 ForeignKeyAction getDeleteAction()
           
 java.lang.String getName()
           
 java.lang.String getTable()
           
 ForeignKeyAction getUpdateAction()
           
 boolean isDeferred()
           
 boolean isUnique()
           
 ForeignKeyMetaData setDeferred(boolean deferred)
           
 ForeignKeyMetaData setDeferred(java.lang.String deferred)
           
 void setDeleteAction(ForeignKeyAction deleteAction)
           
 void setName(java.lang.String name)
           
 void setTable(java.lang.String table)
           
 ForeignKeyMetaData setUnique(boolean unique)
           
 ForeignKeyMetaData setUnique(java.lang.String unique)
           
 ForeignKeyMetaData setUpdateAction(ForeignKeyAction updateAction)
           
 java.lang.String toString(java.lang.String prefix, java.lang.String indent)
          Returns a string representation of the object using a prefix This can be used as part of a facility to output a MetaData file.
 
Methods inherited from class org.datanucleus.metadata.AbstractConstraintMetaData
addColumn, addMember, getColumnMetaData, getMemberMetaData, getNumberOfColumns, getNumberOfMembers, initialise, newColumnMetaData, newFieldMetaData, newPropertyMetaData
 
Methods inherited from class org.datanucleus.metadata.MetaData
addExtension, addExtension, assertIfInitialised, getExtensions, getNoOfExtensions, getParent, getValueForExtension, getValuesForExtension, hasExtension, isInitialised, isPopulated, isUsed, newExtensionMetaData, removeExtension, setParent, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.datanucleus.metadata.ColumnMetaDataContainer
addColumn, getColumnMetaData
 

Field Detail

unique

protected boolean unique
The unique attribute specifies whether the foreign key constraint is defined to be a unique constraint as well. This is most often used with one-to-one mappings.


deferred

protected boolean deferred
The deferred attribute specifies whether the foreign key constraint is defined to be checked only at commit time.


deleteAction

protected ForeignKeyAction deleteAction
Foreign keys represent a consistency constraint in the database that must be maintained. The user can specify by the value of the delete-action attribute what happens if the target row of a foreign key is deleted.


updateAction

protected ForeignKeyAction updateAction
Foreign keys represent a consistency constraint in the database that must be maintained. The user can specify by the update-action attribute what happens if the target row of a foreign key is updated.

Constructor Detail

ForeignKeyMetaData

public ForeignKeyMetaData(ForeignKeyMetaData fkmd)
Constructor to create a copy of the passed metadata using the provided parent.

Parameters:
fkmd - The metadata to copy

ForeignKeyMetaData

public ForeignKeyMetaData()
Default constructor. Set fields using setters, before populate().

Method Detail

getName

public final java.lang.String getName()

setName

public void setName(java.lang.String name)

getTable

public final java.lang.String getTable()

setTable

public void setTable(java.lang.String table)

isDeferred

public final boolean isDeferred()

setDeferred

public ForeignKeyMetaData setDeferred(boolean deferred)

setDeferred

public ForeignKeyMetaData setDeferred(java.lang.String deferred)

getDeleteAction

public final ForeignKeyAction getDeleteAction()

setDeleteAction

public void setDeleteAction(ForeignKeyAction deleteAction)

isUnique

public final boolean isUnique()

setUnique

public ForeignKeyMetaData setUnique(boolean unique)

setUnique

public ForeignKeyMetaData setUnique(java.lang.String unique)

getUpdateAction

public final ForeignKeyAction getUpdateAction()

setUpdateAction

public ForeignKeyMetaData setUpdateAction(ForeignKeyAction updateAction)

toString

public java.lang.String toString(java.lang.String prefix,
                                 java.lang.String indent)
Returns a string representation of the object using a prefix This can be used as part of a facility to output a MetaData file.

Overrides:
toString in class MetaData
Parameters:
prefix - prefix string
indent - indent string
Returns:
a string representation of the object.


Copyright © 2011. All Rights Reserved.