Package org.datanucleus.metadata
Class ForeignKeyMetaData
- java.lang.Object
-
- org.datanucleus.metadata.MetaData
-
- org.datanucleus.metadata.ConstraintMetaData
-
- org.datanucleus.metadata.ForeignKeyMetaData
-
- All Implemented Interfaces:
Serializable
public class ForeignKeyMetaData extends ConstraintMetaData
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
Fields Modifier and Type Field Description protected List<ColumnMetaData>
columns
The columns for this foreign key.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 String
fkDefinition
Alternative method of specifying FK where we just supply the string defining it (JPA crap).protected boolean
fkDefinitionApplies
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.ConstraintMetaData
columnNames, memberNames, name, table
-
Fields inherited from class org.datanucleus.metadata.MetaData
EXTENSION_CLASS_CREATETIMESTAMP, EXTENSION_CLASS_CREATETIMESTAMP_COLUMN_NAME, EXTENSION_CLASS_CREATEUSER, EXTENSION_CLASS_CREATEUSER_COLUMN_LENGTH, EXTENSION_CLASS_CREATEUSER_COLUMN_NAME, EXTENSION_CLASS_MULTITENANCY_COLUMN_LENGTH, EXTENSION_CLASS_MULTITENANCY_COLUMN_NAME, EXTENSION_CLASS_MULTITENANCY_DISABLE, EXTENSION_CLASS_MULTITENANCY_JDBC_TYPE, EXTENSION_CLASS_READ_ONLY, EXTENSION_CLASS_SOFTDELETE, EXTENSION_CLASS_SOFTDELETE_COLUMN_NAME, EXTENSION_CLASS_UPDATETIMESTAMP, EXTENSION_CLASS_UPDATETIMESTAMP_COLUMN_NAME, EXTENSION_CLASS_UPDATEUSER, EXTENSION_CLASS_UPDATEUSER_COLUMN_LENGTH, EXTENSION_CLASS_UPDATEUSER_COLUMN_NAME, EXTENSION_CLASS_VERSION_FIELD_NAME, EXTENSION_CLASS_VIEW_DEFINITION, EXTENSION_CLASS_VIEW_IMPORTS, EXTENSION_MEMBER_CACHEABLE, EXTENSION_MEMBER_CALENDAR_ONE_COLUMN, EXTENSION_MEMBER_CASCADE_DETACH, EXTENSION_MEMBER_CASCADE_PERSIST, EXTENSION_MEMBER_CASCADE_REFRESH, EXTENSION_MEMBER_CASCADE_UPDATE, EXTENSION_MEMBER_COMPARATOR_NAME, EXTENSION_MEMBER_CONTAINER_ALLOW_NULLS, EXTENSION_MEMBER_ENUM_GETTER_BY_VALUE, EXTENSION_MEMBER_ENUM_VALUE_GETTER, EXTENSION_MEMBER_FETCH_FK_ONLY, EXTENSION_MEMBER_IMPLEMENTATION_CLASSES, EXTENSION_MEMBER_INSERTABLE, EXTENSION_MEMBER_KEY_IMPLEMENTATION_CLASSES, EXTENSION_MEMBER_LIST_ORDERING, EXTENSION_MEMBER_RELATION_DISCRIM_COLUMN, EXTENSION_MEMBER_RELATION_DISCRIM_PK, EXTENSION_MEMBER_RELATION_DISCRIM_VALUE, EXTENSION_MEMBER_STRATEGY_WHEN_NOTNULL, EXTENSION_MEMBER_TYPE_CONVERTER_DISABLED, EXTENSION_MEMBER_TYPE_CONVERTER_NAME, EXTENSION_MEMBER_UPDATEABLE, EXTENSION_MEMBER_VALUE_IMPLEMENTATION_CLASSES, EXTENSION_VERSION_NUMBER_INITIAL_VALUE, extensions, METADATA_CREATED_STATE, METADATA_INITIALISED_STATE, METADATA_POPULATED_STATE, METADATA_USED_STATE, metaDataState, parent, VENDOR_NAME
-
-
Constructor Summary
Constructors Constructor Description ForeignKeyMetaData()
ForeignKeyMetaData(ForeignKeyMetaData fkmd)
Copy constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addColumn(ColumnMetaData colmd)
ColumnMetaData[]
getColumnMetaData()
ForeignKeyAction
getDeleteAction()
String
getFkDefinition()
boolean
getFkDefinitionApplies()
ForeignKeyAction
getUpdateAction()
boolean
isDeferred()
boolean
isUnique()
ColumnMetaData
newColumnMetaData()
Method to create a new column, add it, and return it.ForeignKeyMetaData
setDeferred(boolean deferred)
ForeignKeyMetaData
setDeferred(String deferred)
void
setDeleteAction(ForeignKeyAction deleteAction)
void
setFkDefinition(String def)
void
setFkDefinitionApplies(boolean flag)
ForeignKeyMetaData
setUnique(boolean unique)
ForeignKeyMetaData
setUnique(String unique)
ForeignKeyMetaData
setUpdateAction(ForeignKeyAction updateAction)
-
Methods inherited from class org.datanucleus.metadata.ConstraintMetaData
addColumn, addMember, getColumnNames, getMemberNames, getName, getNumberOfColumns, getNumberOfMembers, getTable, setName, setTable
-
Methods inherited from class org.datanucleus.metadata.MetaData
addExtension, addExtensions, getExtensions, getMetaDataManager, getNoOfExtensions, getParent, getValueForExtension, getValuesForExtension, hasExtension, initialise, isInitialised, isPopulated, isUsed, removeExtension, setExtensions, setParent
-
-
-
-
Field Detail
-
columns
protected List<ColumnMetaData> columns
The columns for this foreign key. Note that we don't use the "columnNames" in the superclass since the user can define the column target name also for a foreign-key.
-
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.
-
fkDefinition
protected String fkDefinition
Alternative method of specifying FK where we just supply the string defining it (JPA crap).
-
fkDefinitionApplies
protected boolean fkDefinitionApplies
-
-
Constructor Detail
-
ForeignKeyMetaData
public ForeignKeyMetaData()
-
ForeignKeyMetaData
public ForeignKeyMetaData(ForeignKeyMetaData fkmd)
Copy constructor.- Parameters:
fkmd
- The metadata to copy
-
-
Method Detail
-
addColumn
public void addColumn(ColumnMetaData colmd)
-
newColumnMetaData
public ColumnMetaData newColumnMetaData()
Method to create a new column, add it, and return it.- Returns:
- The column metadata
-
getColumnMetaData
public final ColumnMetaData[] getColumnMetaData()
-
isDeferred
public final boolean isDeferred()
-
setDeferred
public ForeignKeyMetaData setDeferred(boolean deferred)
-
setDeferred
public ForeignKeyMetaData setDeferred(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(String unique)
-
getUpdateAction
public final ForeignKeyAction getUpdateAction()
-
setUpdateAction
public ForeignKeyMetaData setUpdateAction(ForeignKeyAction updateAction)
-
setFkDefinition
public void setFkDefinition(String def)
-
getFkDefinition
public String getFkDefinition()
-
setFkDefinitionApplies
public void setFkDefinitionApplies(boolean flag)
-
getFkDefinitionApplies
public boolean getFkDefinitionApplies()
-
-