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
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List
<ColumnMetaData> The columns for this foreign key.protected boolean
The deferred attribute specifies whether the foreign key constraint is defined to be checked only at commit time.protected ForeignKeyAction
Foreign keys represent a consistency constraint in the database that must be maintained.protected String
Alternative method of specifying FK where we just supply the string defining it (JPA crap).protected boolean
private static final long
protected boolean
The unique attribute specifies whether the foreign key constraint is defined to be a unique constraint as well.protected ForeignKeyAction
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_JDBC_TYPE, EXTENSION_CLASS_MULTITENANT, 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_INDEX_COLUMN_ORDERING, EXTENSION_MEMBER_CACHEABLE, EXTENSION_MEMBER_CALENDAR_ONE_COLUMN, EXTENSION_MEMBER_CASCADE_ATTACH, EXTENSION_MEMBER_CASCADE_DETACH, EXTENSION_MEMBER_CASCADE_PERSIST, EXTENSION_MEMBER_CASCADE_REFRESH, EXTENSION_MEMBER_COMPARATOR_NAME, EXTENSION_MEMBER_CONTAINER_ALLOW_NULLS, EXTENSION_MEMBER_CREATE_TIMESTAMP, EXTENSION_MEMBER_CREATE_USER, EXTENSION_MEMBER_ENUM_VALUE_GETTER, 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_UPDATE_TIMESTAMP, EXTENSION_MEMBER_UPDATE_USER, EXTENSION_MEMBER_UPDATEABLE, EXTENSION_MEMBER_VALUE_IMPLEMENTATION_CLASSES, EXTENSION_VERSION_NUMBER_INITIAL_VALUE, extensions, metaDataState, parent, VENDOR_NAME
-
Constructor Summary
ConstructorsConstructorDescriptionCopy constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addColumn
(ColumnMetaData colmd) final ColumnMetaData[]
final ForeignKeyAction
boolean
final ForeignKeyAction
final boolean
final boolean
isUnique()
Method to create a new column, add it, and return it.setDeferred
(boolean deferred) setDeferred
(String deferred) void
setDeleteAction
(ForeignKeyAction deleteAction) void
setFkDefinition
(String def) void
setFkDefinitionApplies
(boolean flag) setUnique
(boolean unique) 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, setInitialised, setParent, setPopulated, setUsed
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
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 uniqueThe 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 deferredThe deferred attribute specifies whether the foreign key constraint is defined to be checked only at commit time. -
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
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
Alternative method of specifying FK where we just supply the string defining it (JPA crap). -
fkDefinitionApplies
protected boolean fkDefinitionApplies
-
-
Constructor Details
-
ForeignKeyMetaData
public ForeignKeyMetaData() -
ForeignKeyMetaData
Copy constructor.- Parameters:
fkmd
- The metadata to copy
-
-
Method Details
-
addColumn
-
newColumnMetaData
Method to create a new column, add it, and return it.- Returns:
- The column metadata
-
getColumnMetaData
-
isDeferred
public final boolean isDeferred() -
setDeferred
-
setDeferred
-
getDeleteAction
-
setDeleteAction
-
isUnique
public final boolean isUnique() -
setUnique
-
setUnique
-
getUpdateAction
-
setUpdateAction
-
setFkDefinition
-
getFkDefinition
-
setFkDefinitionApplies
public void setFkDefinitionApplies(boolean flag) -
getFkDefinitionApplies
public boolean getFkDefinitionApplies()
-