public class ManyToManyMapping extends CollectionMapping implements RelationalMapping, MapComponentMapping
Purpose: Many to many mappings are used to represent the relationships between a collection of source objects and a collection of target objects. The mapping requires the creation of an intermediate table for managing the associations between the source and target records.
DatabaseMapping.WriteType
INNER_JOIN, NONE, OUTER_JOIN, QUERY_BATCH_PARAMETER
Constructor and Description |
---|
ManyToManyMapping()
PUBLIC: Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addSourceRelationKeyField(org.eclipse.persistence.internal.helper.DatabaseField sourceRelationKeyField, org.eclipse.persistence.internal.helper.DatabaseField sourcePrimaryKeyField)
PUBLIC: Add the fields in the intermediate table that corresponds to the primary key in the source table.
|
void |
addSourceRelationKeyFieldName(java.lang.String sourceRelationKeyFieldName, java.lang.String sourcePrimaryKeyFieldName)
PUBLIC: Add the fields in the intermediate table that corresponds to the primary key in the source table.
|
void |
addTargetRelationKeyField(org.eclipse.persistence.internal.helper.DatabaseField targetRelationKeyField, org.eclipse.persistence.internal.helper.DatabaseField targetPrimaryKeyField)
PUBLIC: Add the fields in the intermediate table that corresponds to the primary key in the target table.
|
void |
addTargetRelationKeyFieldName(java.lang.String targetRelationKeyFieldName, java.lang.String targetPrimaryKeyFieldName)
PUBLIC: Add the fields in the intermediate table that corresponds to the primary key in the target table.
|
java.lang.Object |
clone()
INTERNAL: The mapping clones itself to create deep copy.
|
void |
collectQueryParameters(java.util.Set<org.eclipse.persistence.internal.helper.DatabaseField> cacheFields)
INTERNAL: This method is used to store the FK fields that can be cached that correspond to noncacheable mappings the FK field values will be used to re-issue the query when cloning the shared cache entity
|
java.lang.Object |
createMapComponentFromRow(org.eclipse.persistence.internal.sessions.AbstractRecord dbRow, ObjectBuildingQuery query, org.eclipse.persistence.internal.identitymaps.CacheKey parentCacheKey, org.eclipse.persistence.internal.sessions.AbstractSession session, boolean isTargetProtected)
INTERNAL Called when a DatabaseMapping is used to map the key in a collection.
|
void |
earlyPreDelete(DeleteObjectQuery query, java.lang.Object object)
INTERNAL: Delete join tables before the start of the deletion process to avoid constraint errors.
|
void |
extendPessimisticLockScopeInSourceQuery(ObjectLevelReadQuery sourceQuery)
INTERNAL: Called only if both shouldExtendPessimisticLockScope and shouldExtendPessimisticLockScopeInSourceQuery are true.
|
java.util.Collection |
getFieldsForTranslationInAggregate()
INTERNAL: Return source key fields for translation by an AggregateObjectMapping
|
HistoryPolicy |
getHistoryPolicy()
PUBLIC: Allows history tracking on the m-m join table.
|
Expression |
getJoinCriteria(org.eclipse.persistence.internal.expressions.ObjectExpression context, Expression base)
INTERNAL: Returns the join criteria stored in the mapping selection query.
|
org.eclipse.persistence.internal.helper.DatabaseTable |
getRelationTable()
INTERNAL: Return the relation table associated with the mapping.
|
RelationTableMechanism |
getRelationTableMechanism()
PUBLIC: Returns RelationTableMechanism that may be owned by the mapping.
|
java.lang.String |
getRelationTableName()
PUBLIC: Return the relation table name associated with the mapping.
|
java.lang.String |
getRelationTableQualifiedName()
PUBLIC: Return the relation table qualified name associated with the mapping.
|
java.util.Vector |
getSourceKeyFieldNames()
PUBLIC: Return the source key field names associated with the mapping.
|
java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> |
getSourceKeyFields()
INTERNAL: Return all the source key fields associated with the mapping.
|
java.util.Vector |
getSourceRelationKeyFieldNames()
PUBLIC: Return the source relation key field names associated with the mapping.
|
java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> |
getSourceRelationKeyFields()
INTERNAL: Return all the source relation key fields associated with the mapping.
|
java.util.Vector |
getTargetKeyFieldNames()
PUBLIC: Return the target key field names associated with the mapping.
|
java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> |
getTargetKeyFields()
INTERNAL: Return all the target keys associated with the mapping.
|
java.util.Vector |
getTargetRelationKeyFieldNames()
PUBLIC: Return the target relation key field names associated with the mapping.
|
java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> |
getTargetRelationKeyFields()
INTERNAL: Return all the target relation key fields associated with the mapping.
|
boolean |
hasDependency()
INTERNAL: The join table is a dependency if not read-only.
|
void |
initialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: Initialize mappings
|
void |
insertIntoRelationTable(WriteObjectQuery query)
INTERNAL: Insert into relation table.
|
void |
insertTargetObjects(WriteObjectQuery query)
INTERNAL: Write the target objects if the cascade policy requires them to be written first.
|
boolean |
isDefinedAsOneToManyMapping()
INTERNAL: Return whether this mapping was originally defined as a OneToMany.
|
boolean |
isJoiningSupported()
INTERNAL: Return if this mapping support joining.
|
boolean |
isManyToManyMapping()
INTERNAL: Related mapping should implement this method to return true.
|
boolean |
isOwned()
INTERNAL:
|
boolean |
isRelationalMapping()
INTERNAL:
|
void |
performDataModificationEvent(java.lang.Object[] event, org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: Perform the commit event.
|
void |
postInitialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: Ensure the container policy is post initialized
|
void |
postInsert(WriteObjectQuery query)
INTERNAL: Insert into relation table.
|
void |
postUpdate(WriteObjectQuery query)
INTERNAL: Update the relation table with the entries related to this mapping.
|
void |
preDelete(DeleteObjectQuery query)
INTERNAL: Delete entries related to this mapping from the relation table.
|
void |
setCustomDeleteQuery(DataModifyQuery query)
PUBLIC: The default delete query for mapping can be overridden by specifying the new query.
|
void |
setCustomInsertQuery(DataModifyQuery query)
PUBLIC: The default insert query for mapping can be overridden by specifying the new query.
|
void |
setDefinedAsOneToManyMapping(boolean isDefinedAsOneToManyMapping)
INTERNAL: Set whether this mapping was originally defined as a OneToMany
|
void |
setDeleteCall(Call call)
PUBLIC: Set the receiver's delete Call.
|
void |
setDeleteSQLString(java.lang.String sqlString)
PUBLIC: Set the receiver's delete SQL string.
|
void |
setHistoryPolicy(HistoryPolicy policy)
PUBLIC: Enable history tracking on the m-m join table.
|
void |
setInsertCall(Call call)
PUBLIC: Set the receiver's insert Call.
|
void |
setInsertSQLString(java.lang.String sqlString)
PUBLIC: Set the receiver's insert SQL string.
|
void |
setRelationTable(org.eclipse.persistence.internal.helper.DatabaseTable relationTable)
PUBLIC: Set the relational table.
|
void |
setRelationTableName(java.lang.String tableName)
PUBLIC: Set the name of the relational table.
|
void |
setSessionName(java.lang.String name)
PUBLIC: Set the name of the session to execute the mapping's queries under.
|
void |
setSourceKeyFieldNames(java.util.Vector fieldNames)
PUBLIC: Set the source key field names associated with the mapping.
|
void |
setSourceKeyFields(java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> sourceKeyFields)
INTERNAL: Set the source fields.
|
void |
setSourceRelationKeyFieldName(java.lang.String sourceRelationKeyFieldName)
PUBLIC: Set the source key field in the relation table.
|
void |
setSourceRelationKeyFieldNames(java.util.Vector fieldNames)
PUBLIC: Set the source relation key field names associated with the mapping.
|
void |
setSourceRelationKeyFields(java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> sourceRelationKeyFields)
INTERNAL: Set the source fields.
|
void |
setTargetKeyFieldNames(java.util.Vector fieldNames)
INTERNAL: Set the target key field names associated with the mapping.
|
void |
setTargetKeyFields(java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> targetKeyFields)
INTERNAL: Set the target fields.
|
void |
setTargetRelationKeyFieldName(java.lang.String targetRelationKeyFieldName)
PUBLIC: Set the target key field in the relation table.
|
void |
setTargetRelationKeyFieldNames(java.util.Vector fieldNames)
INTERNAL: Set the target relation key field names associated with the mapping.
|
void |
setTargetRelationKeyFields(java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> targetRelationKeyFields)
INTERNAL: Set the target fields.
|
boolean |
shouldUseListOrderFieldTableExpression()
INTERNAL: Indicates whether getListOrderFieldExpression method should create field expression on table expression.
|
addAggregateOrderBy, addAscendingOrdering, addDescendingOrdering, addOrderBy, buildBackupCloneForPartObject, buildChangeRecord, buildCloneForPartObject, buildContainerClone, buildCopy, buildElementClone, buildElementUnitOfWorkClone, buildExpression, buildReferencesPKList, calculateDeferredChanges, cascadeDiscoverAndPersistUnregisteredNewObjects, cascadePerformRemoveIfRequired, cascadePerformRemovePrivateOwnedObjectFromChangeSetIfRequired, cascadeRegisterNewIfRequired, compareCollectionsForChange, compareForChange, compareObjects, convertClassNamesToClasses, extractResultFromBatchQuery, fixRealObjectReferences, getContainerPolicy, getListOrderField, getObjectCorrespondingTo, getOrderByQueryKeyExpressions, getOrderCorrectionType, getRealCollectionAttributeValueFromObject, getTargetPrimaryKeyFields, hasOrderBy, isAttributeValueInstantiatedOrChanged, isChangeTrackingSupported, isCollectionMapping, isListOrderFieldSupported, isMapKeyObjectRelationship, iterateOnElement, iterateOnRealAttributeValue, load, loadAll, mergeChangesIntoObject, mergeIntoObject, mustDeleteReferenceObjectsOneByOne, postCalculateChanges, postDelete, preInsert, preUpdate, recordPrivateOwnedRemovals, replaceValueHoldersIn, setChangeListener, setContainerPolicy, setCustomDeleteAllQuery, setDeleteAllCall, setDeleteAllSQLString, setListOrderField, setListOrderFieldName, setMustDeleteReferenceObjectsOneByOne, setOrderCorrectionType, setUseLazyInstantiationForIndirectCollection, shouldUseLazyInstantiationForIndirectCollection, simpleAddToCollectionChangeRecord, simpleRemoveFromCollectionChangeRecord, updateChangeRecord, updateChangeRecordForSelfMerge, updateCollectionChangeRecord, useCollectionClass, useCollectionClassName, useListClassName, useMapClass, useMapClass, useMapClassName, useSortedSetClass, useSortedSetClassName, useSortedSetClassName, useTransparentCollection, useTransparentList, useTransparentMap, useTransparentSet, validateBeforeInitialization, valueFromPKList, verifyDelete, writeChanges
addForeignKeyField, addTargetForeignKeyField, buildBackupClone, buildClone, buildCloneFromRow, createCloneValueHolder, dontUseBatchReading, dontUseIndirection, fixObjectReferences, getAttributeValueFromObject, getAttributeValueWithClonedValueHolders, getBatchFetchType, getIndirectionPolicy, getJoinFetch, getMappedBy, getOrderByNormalizedExpressions, getPartitioningPolicy, getPartitioningPolicyName, getRealAttributeValueFromAttribute, getReferenceClass, getReferenceClassName, getReferenceDescriptor, getRelationshipPartner, getRelationshipPartnerAttributeName, getSelectionCriteria, getSelectionQuery, getValueFromRemoteValueHolder, hasCustomSelectionQuery, hasNestedIdentityReference, instantiateAttribute, isAttributeValueFromObjectInstantiated, isAttributeValueFullyBuilt, isAttributeValueInstantiated, isCascadeDetach, isCascadeMerge, isCascadeOnDeleteSetOnDatabase, isCascadePersist, isCascadeRefresh, isCascadeRemove, isForeignReferenceMapping, isInnerJoinFetched, isJoinFetched, isLazy, isLockableMapping, isOuterJoinFetched, isPrivateOwned, iterate, mergeRemoteValueHolder, preInitialize, prepareNestedBatchQuery, prepareNestedJoins, privateOwnedRelationship, readFromRowIntoObject, remoteInitialization, requiresTransientWeavedFields, setBatchFetchType, setCascadeAll, setCascadeDetach, setCascadeMerge, setCascadePersist, setCascadeRefresh, setCascadeRemove, setCustomSelectionQuery, setForceInitializationOfSelectionCriteria, setIndirectionPolicy, setIsCacheable, setIsCascadeOnDeleteSetOnDatabase, setIsPrivateOwned, setJoinFetch, setMappedBy, setPartitioningPolicy, setPartitioningPolicyName, setRealAttributeValueInObject, setReferenceClass, setReferenceClassName, setRelationshipPartner, setRelationshipPartnerAttributeName, setRequiresTransientWeavedFields, setSelectionCall, setSelectionCriteria, setSelectionSQLString, setShouldExtendPessimisticLockScope, setUsesBatchReading, setUsesIndirection, shouldExtendPessimisticLockScope, shouldExtendPessimisticLockScopeInDedicatedQuery, shouldExtendPessimisticLockScopeInSourceQuery, shouldExtendPessimisticLockScopeInTargetQuery, shouldMergeCascadeParts, shouldRefreshCascadeParts, shouldUseBatchReading, trimRowForJoin, trimRowForJoin, useBasicIndirection, useBatchReading, useContainerIndirection, useInnerJoinFetch, useOuterJoinFetch, usesIndirection, useWeavedIndirection, valueFromRow
addUnconvertedProperty, buildObjectJoinExpression, buildObjectJoinExpression, buildShallowOriginalFromRow, derivesId, getAttributeAccessor, getAttributeClassification, getAttributeName, getDerivedIdMapping, getDescriptor, getField, getFieldClassification, getFields, getGetMethodName, getMapsIdValue, getProperties, getProperty, getRealAttributeValueFromObject, getSelectFields, getSelectTables, getSetMethodName, getUnconvertedProperties, getWeight, hasConstraintDependency, hasInverseConstraintDependency, hasMapsIdValue, hasUnconvertedProperties, isAbstractColumnMapping, isAbstractCompositeCollectionMapping, isAbstractCompositeDirectCollectionMapping, isAbstractCompositeObjectMapping, isAbstractDirectMapping, isAggregateCollectionMapping, isAggregateMapping, isAggregateObjectMapping, isCacheable, isCandidateForPrivateOwnedRemoval, isCascadedLockingSupported, isCloningRequired, isDatabaseMapping, isDirectCollectionMapping, isDirectMapMapping, isDirectToFieldMapping, isDirectToXMLTypeMapping, isEISMapping, isElementCollectionMapping, isInAndOutSopObject, isInOnlySopObject, isInSopObject, isJPAId, isManyToOneMapping, isMapKeyMapping, isMultitenantPrimaryKeyMapping, isNestedTableMapping, isObjectReferenceMapping, isOneToManyMapping, isOneToOneMapping, isOptional, isOutOnlySopObject, isOutSopObject, isPrimaryKeyMapping, isReadOnly, isReferenceMapping, isStructureMapping, isTransformationMapping, isUnidirectionalOneToManyMapping, isUsingMethodAccess, isVariableOneToOneMapping, isWriteOnly, isXMLMapping, postCalculateChangesOnDeleted, postInitializeSourceAndTargetExpressions, prepareCascadeLockingPolicy, readFromResultSetIntoObject, readOnly, readWrite, rehashFieldDependancies, setAttributeAccessor, setAttributeName, setAttributeValueInObject, setDerivedIdMapping, setDerivesId, setDescriptor, setGetMethodName, setIsInAndOutSopObject, setIsInSopObject, setIsJPAId, setIsLazy, setIsMapKeyMapping, setIsOptional, setIsOutSopObject, setIsPrimaryKeyMapping, setIsReadOnly, setMapsIdValue, setProperties, setProperty, setSetMethodName, setWeight, toString, validateAfterInitialization, valueFromObject, valueFromResultSet, valueFromRow, writeFromAttributeIntoRow, writeFromObjectIntoRow, writeFromObjectIntoRowForShallowInsert, writeFromObjectIntoRowForShallowInsertWithChangeRecord, writeFromObjectIntoRowForUpdate, writeFromObjectIntoRowForUpdateAfterShallowInsert, writeFromObjectIntoRowForUpdateBeforeShallowDelete, writeFromObjectIntoRowForWhereClause, writeFromObjectIntoRowWithChangeRecord, writeInsertFieldsIntoRow, writeUpdateFieldsIntoRow
public boolean isOwned()
isOwned
in class DatabaseMapping
public boolean isRelationalMapping()
isRelationalMapping
in class DatabaseMapping
public void addSourceRelationKeyField(org.eclipse.persistence.internal.helper.DatabaseField sourceRelationKeyField, org.eclipse.persistence.internal.helper.DatabaseField sourcePrimaryKeyField)
public void addSourceRelationKeyFieldName(java.lang.String sourceRelationKeyFieldName, java.lang.String sourcePrimaryKeyFieldName)
public void addTargetRelationKeyField(org.eclipse.persistence.internal.helper.DatabaseField targetRelationKeyField, org.eclipse.persistence.internal.helper.DatabaseField targetPrimaryKeyField)
public void addTargetRelationKeyFieldName(java.lang.String targetRelationKeyFieldName, java.lang.String targetPrimaryKeyFieldName)
public void collectQueryParameters(java.util.Set<org.eclipse.persistence.internal.helper.DatabaseField> cacheFields)
collectQueryParameters
in class CollectionMapping
public java.lang.Object clone()
clone
in interface MapComponentMapping
clone
in class CollectionMapping
public void earlyPreDelete(DeleteObjectQuery query, java.lang.Object object)
earlyPreDelete
in class DatabaseMapping
public java.lang.Object createMapComponentFromRow(org.eclipse.persistence.internal.sessions.AbstractRecord dbRow, ObjectBuildingQuery query, org.eclipse.persistence.internal.identitymaps.CacheKey parentCacheKey, org.eclipse.persistence.internal.sessions.AbstractSession session, boolean isTargetProtected)
createMapComponentFromRow
in interface MapComponentMapping
public void extendPessimisticLockScopeInSourceQuery(ObjectLevelReadQuery sourceQuery)
extendPessimisticLockScopeInSourceQuery
in class ForeignReferenceMapping
public java.util.Collection getFieldsForTranslationInAggregate()
getFieldsForTranslationInAggregate
in class ForeignReferenceMapping
public Expression getJoinCriteria(org.eclipse.persistence.internal.expressions.ObjectExpression context, Expression base)
getJoinCriteria
in class CollectionMapping
public HistoryPolicy getHistoryPolicy()
public RelationTableMechanism getRelationTableMechanism()
public org.eclipse.persistence.internal.helper.DatabaseTable getRelationTable()
public java.lang.String getRelationTableName()
public java.lang.String getRelationTableQualifiedName()
public java.util.Vector getSourceKeyFieldNames()
public java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> getSourceKeyFields()
public java.util.Vector getSourceRelationKeyFieldNames()
public java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> getSourceRelationKeyFields()
public java.util.Vector getTargetKeyFieldNames()
public java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> getTargetKeyFields()
public java.util.Vector getTargetRelationKeyFieldNames()
public java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> getTargetRelationKeyFields()
public boolean hasDependency()
hasDependency
in class ForeignReferenceMapping
public void initialize(org.eclipse.persistence.internal.sessions.AbstractSession session) throws DescriptorException
initialize
in class CollectionMapping
DescriptorException
public boolean shouldUseListOrderFieldTableExpression()
shouldUseListOrderFieldTableExpression
in class CollectionMapping
public void insertIntoRelationTable(WriteObjectQuery query) throws DatabaseException
- Extract primary key and its value from the source object.
- Extract target key and its value from the target object.
- Construct a insert statement with above fields and values for relation table.
- execute the statement.
- Repeat above three statements until all the target objects are done.
DatabaseException
public void insertTargetObjects(WriteObjectQuery query) throws DatabaseException, OptimisticLockException
public boolean isDefinedAsOneToManyMapping()
public boolean isJoiningSupported()
isJoiningSupported
in class ForeignReferenceMapping
public boolean isManyToManyMapping()
DatabaseMapping
isManyToManyMapping
in class DatabaseMapping
public void postInitialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
postInitialize
in class CollectionMapping
public void performDataModificationEvent(java.lang.Object[] event, org.eclipse.persistence.internal.sessions.AbstractSession session) throws DatabaseException, DescriptorException
performDataModificationEvent
in class DatabaseMapping
DatabaseException
DescriptorException
public void postInsert(WriteObjectQuery query) throws DatabaseException
- Extract primary key and its value from the source object.
- Extract target key and its value from the target object.
- Construct a insert statement with above fields and values for relation table.
- execute the statement.
- Repeat above three statements until all the target objects are done.
postInsert
in class CollectionMapping
DatabaseException
public void postUpdate(WriteObjectQuery query) throws DatabaseException
postUpdate
in class DatabaseMapping
DatabaseException
public void preDelete(DeleteObjectQuery query) throws DatabaseException
preDelete
in class DatabaseMapping
DatabaseException
public void setCustomDeleteQuery(DataModifyQuery query)
public void setCustomInsertQuery(DataModifyQuery query)
public void setDeleteSQLString(java.lang.String sqlString)
public void setDefinedAsOneToManyMapping(boolean isDefinedAsOneToManyMapping)
isDefinedAsOneToManyMapping
-public void setDeleteCall(Call call)
public void setInsertSQLString(java.lang.String sqlString)
public void setInsertCall(Call call)
public void setRelationTable(org.eclipse.persistence.internal.helper.DatabaseTable relationTable)
public void setHistoryPolicy(HistoryPolicy policy)
public void setRelationTableName(java.lang.String tableName)
public void setSessionName(java.lang.String name)
setSessionName
in class CollectionMapping
public void setSourceKeyFieldNames(java.util.Vector fieldNames)
public void setSourceKeyFields(java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> sourceKeyFields)
public void setSourceRelationKeyFieldName(java.lang.String sourceRelationKeyFieldName)
public void setSourceRelationKeyFieldNames(java.util.Vector fieldNames)
public void setSourceRelationKeyFields(java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> sourceRelationKeyFields)
public void setTargetKeyFieldNames(java.util.Vector fieldNames)
public void setTargetKeyFields(java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> targetKeyFields)
public void setTargetRelationKeyFieldName(java.lang.String targetRelationKeyFieldName)
public void setTargetRelationKeyFieldNames(java.util.Vector fieldNames)
public void setTargetRelationKeyFields(java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> targetRelationKeyFields)