Class ManyToManyMapping
- All Implemented Interfaces:
Serializable,Cloneable,ContainerMapping,MapComponentMapping,RelationalMapping
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.
- See Also:
- Author:
- Sati
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.persistence.mappings.DatabaseMapping
DatabaseMapping.WriteType -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected HistoryPolicyprotected boolean266912: Since: EclipseLink 2.0 for the Metamodel API For 1:1 and m:m mappings - track the original externally defined mapping if different Note: This field will provide differentiation for the following external to internal representations for mapping types
- A OneToManyMapping will be represented by a ManyToManyMapping if unidirectional
- A ManyToOneMapping will be represented by a OneToOneMapping (without a FK constraint)protected RelationTableMechanismMechanism holds relationTable and all fields and queries associated with it.protected static final Stringprotected static final Stringprotected static final StringUsed for data modification events.Fields inherited from class org.eclipse.persistence.mappings.CollectionMapping
changeOrderTargetQuery, containerPolicy, deleteAllQuery, hasCustomDeleteAllQuery, hasOrderBy, isListOrderFieldSupported, isSynchronizeOnMerge, listOrderField, mustDeleteReferenceObjectsOneByOne, orderCorrectionTypeFields inherited from class org.eclipse.persistence.mappings.ForeignReferenceMapping
batchFetchType, cascadeDetach, cascadeMerge, cascadePersist, cascadeRefresh, cascadeRemove, forceInitializationOfSelectionCriteria, hasCustomSelectionQuery, indirectionPolicy, INNER_JOIN, isCascadeOnDeleteSetOnDatabase, isPrivateOwned, joinFetch, mappedBy, NONE, OUTER_JOIN, partitioningPolicy, partitioningPolicyName, QUERY_BATCH_PARAMETER, referenceClass, referenceClassName, referenceDescriptor, relationshipPartner, relationshipPartnerAttributeName, requiresTransientWeavedFields, selectionQuery, tempInitSessionFields inherited from class org.eclipse.persistence.mappings.DatabaseMapping
attributeAccessor, attributeName, derivedIdMapping, derivesId, descriptor, fields, isCacheable, isInSopObject, isJPAId, isLazy, isMapKeyMapping, isOptional, isPrimaryKeyMapping, isReadOnly, isRemotelyInitialized, mapsIdValue, NO_FIELDS, NO_WEIGHT, properties, unconvertedProperties, weight, WEIGHT_AGGREGATE, WEIGHT_DIRECT, WEIGHT_TO_ONE, WEIGHT_TRANSFORM -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSourceRelationKeyField(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.voidaddSourceRelationKeyFieldName(String sourceRelationKeyFieldName, String sourcePrimaryKeyFieldName) PUBLIC: Add the fields in the intermediate table that corresponds to the primary key in the source table.voidaddTargetRelationKeyField(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.voidaddTargetRelationKeyFieldName(String targetRelationKeyFieldName, String targetPrimaryKeyFieldName) PUBLIC: Add the fields in the intermediate table that corresponds to the primary key in the target table.protected ExpressionbuildBatchCriteria(ExpressionBuilder builder, ObjectLevelReadQuery query) INTERNAL: Return the selection criteria used to IN batch fetching.protected voidINTERNAL: Verifies listOrderField's table: it must be relation table.clone()INTERNAL: The mapping clones itself to create deep copy.voidcollectQueryParameters(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 entitycreateMapComponentFromRow(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.voidearlyPreDelete(DeleteObjectQuery query, Object object) INTERNAL: Delete join tables before the start of the deletion process to avoid constraint errors.voidINTERNAL: Called only if both shouldExtendPessimisticLockScope and shouldExtendPessimisticLockScopeInSourceQuery are true.protected voidextendPessimisticLockScopeInTargetQuery(ObjectLevelReadQuery targetQuery, ObjectBuildingQuery sourceQuery) INTERNAL: Adds locking clause to the target query to extend pessimistic lock scope.protected ObjectextractBatchKeyFromRow(org.eclipse.persistence.internal.sessions.AbstractRecord row, org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Extract the primary key value from the source row.protected ObjectextractKeyFromTargetRow(org.eclipse.persistence.internal.sessions.AbstractRecord row, org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Extract the source primary key value from the relation row.protected ExpressionINTERNAL: Return the base expression to use for adding fields to the query.protected DataModifyQueryprotected ReadQuerygetExtendPessimisticLockScopeDedicatedQuery(org.eclipse.persistence.internal.sessions.AbstractSession session, short lockMode) INTERNAL: Should be overridden by subclass that allows setting extendPessimisticLockScope to DEDICATED_QUERY.INTERNAL: Return source key fields for translation by an AggregateObjectMappingPUBLIC: Allows history tracking on the m-m join table.protected DataModifyQuerygetJoinCriteria(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.DatabaseTableINTERNAL: Return the relation table associated with the mapping.PUBLIC: Returns RelationTableMechanism that may be owned by the mapping.PUBLIC: Return the relation table name associated with the mapping.PUBLIC: Return the relation table qualified name associated with the mapping.PUBLIC: Return the source key field names associated with the mapping.Vector<org.eclipse.persistence.internal.helper.DatabaseField>INTERNAL: Return all the source key fields associated with the mapping.PUBLIC: Return the source relation key field names associated with the mapping.Vector<org.eclipse.persistence.internal.helper.DatabaseField>INTERNAL: Return all the source relation key fields associated with the mapping.PUBLIC: Return the target key field names associated with the mapping.Vector<org.eclipse.persistence.internal.helper.DatabaseField>INTERNAL: Return all the target keys associated with the mapping.PUBLIC: Return the target relation key field names associated with the mapping.Vector<org.eclipse.persistence.internal.helper.DatabaseField>INTERNAL: Return all the target relation key fields associated with the mapping.protected booleanprotected booleanbooleanINTERNAL: The join table is a dependency if not read-only.voidinitialize(org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Initialize mappingsprotected voidinitializeChangeOrderTargetQuery(org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Initialize changeOrderTargetQuery.protected voidinitializeDeleteAllQuery(org.eclipse.persistence.internal.sessions.AbstractSession session) Initialize delete all query.protected voidinitializeListOrderFieldTable(org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Initializes listOrderField's table.protected voidinitializeSelectionCriteriaAndAddFieldsToQuery(Expression startCriteria) INTERNAL: Selection criteria is created to read target records from the table.protected voidinsertAddedObjectEntry(ObjectLevelModifyQuery query, Object objectAdded, Map extraData) INTERNAL: An object was added to the collection during an update, insert it.voidINTERNAL: Insert into relation table.voidINTERNAL: Write the target objects if the cascade policy requires them to be written first.booleanINTERNAL: Return whether this mapping was originally defined as a OneToMany.booleanINTERNAL: Return if this mapping support joining.booleanINTERNAL: Related mapping should implement this method to return true.booleanisOwned()INTERNAL:booleanINTERNAL:protected voidobjectAddedDuringUpdate(ObjectLevelModifyQuery query, Object objectAdded, org.eclipse.persistence.internal.sessions.ObjectChangeSet changeSet, Map extraData) INTERNAL: An object was added to the collection during an update, insert it if private.protected voidobjectOrderChangedDuringUpdate(WriteObjectQuery query, Object orderChangedObject, int orderIndex) protected voidobjectRemovedDuringUpdate(ObjectLevelModifyQuery query, Object objectDeleted, Map extraData) INTERNAL: An object was removed to the collection during an update, delete it if private.voidperformDataModificationEvent(Object[] event, org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Perform the commit event.voidpostInitialize(org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Ensure the container policy is post initializedvoidpostInsert(WriteObjectQuery query) INTERNAL: Insert into relation table.protected voidpostPrepareNestedBatchQuery(ReadQuery batchQuery, ObjectLevelReadQuery query) INTERNAL: Add additional fields and check for history.voidpostUpdate(WriteObjectQuery query) INTERNAL: Update the relation table with the entries related to this mapping.voidpreDelete(DeleteObjectQuery query) INTERNAL: Delete entries related to this mapping from the relation table.protected ReadQueryprepareHistoricalQuery(ReadQuery targetQuery, ObjectBuildingQuery sourceQuery, org.eclipse.persistence.internal.sessions.AbstractSession executionSession) INTERNAL: Append the temporal selection to the query selection criteria.protected voidprepareTranslationRow(org.eclipse.persistence.internal.sessions.AbstractRecord translationRow, Object object, ClassDescriptor descriptor, org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: The translation row may require additional fields than the primary key if the mapping in not on the primary key.voidPUBLIC: The default delete query for mapping can be overridden by specifying the new query.voidPUBLIC: The default insert query for mapping can be overridden by specifying the new query.voidsetDefinedAsOneToManyMapping(boolean isDefinedAsOneToManyMapping) INTERNAL: Set whether this mapping was originally defined as a OneToManyvoidsetDeleteCall(Call call) PUBLIC: Set the receiver's delete Call.protected voidsetDeleteQuery(DataModifyQuery deleteQuery) voidsetDeleteSQLString(String sqlString) PUBLIC: Set the receiver's delete SQL string.voidsetHistoryPolicy(HistoryPolicy policy) PUBLIC: Enable history tracking on the m-m join table.voidsetInsertCall(Call call) PUBLIC: Set the receiver's insert Call.protected voidsetInsertQuery(DataModifyQuery insertQuery) voidsetInsertSQLString(String sqlString) PUBLIC: Set the receiver's insert SQL string.voidsetRelationTable(org.eclipse.persistence.internal.helper.DatabaseTable relationTable) PUBLIC: Set the relational table.voidsetRelationTableName(String tableName) PUBLIC: Set the name of the relational table.voidsetSessionName(String name) PUBLIC: Set the name of the session to execute the mapping's queries under.voidsetSourceKeyFieldNames(Vector fieldNames) PUBLIC: Set the source key field names associated with the mapping.voidsetSourceKeyFields(Vector<org.eclipse.persistence.internal.helper.DatabaseField> sourceKeyFields) INTERNAL: Set the source fields.voidsetSourceRelationKeyFieldName(String sourceRelationKeyFieldName) PUBLIC: Set the source key field in the relation table.voidsetSourceRelationKeyFieldNames(Vector fieldNames) PUBLIC: Set the source relation key field names associated with the mapping.voidsetSourceRelationKeyFields(Vector<org.eclipse.persistence.internal.helper.DatabaseField> sourceRelationKeyFields) INTERNAL: Set the source fields.voidsetTargetKeyFieldNames(Vector fieldNames) INTERNAL: Set the target key field names associated with the mapping.voidsetTargetKeyFields(Vector<org.eclipse.persistence.internal.helper.DatabaseField> targetKeyFields) INTERNAL: Set the target fields.voidsetTargetRelationKeyFieldName(String targetRelationKeyFieldName) PUBLIC: Set the target key field in the relation table.voidsetTargetRelationKeyFieldNames(Vector fieldNames) INTERNAL: Set the target relation key field names associated with the mapping.voidsetTargetRelationKeyFields(Vector<org.eclipse.persistence.internal.helper.DatabaseField> targetRelationKeyFields) INTERNAL: Set the target fields.booleanINTERNAL: Indicates whether getListOrderFieldExpression method should create field expression on table expression.Methods inherited from class org.eclipse.persistence.mappings.CollectionMapping
addAggregateOrderBy, addAscendingOrdering, addDescendingOrdering, addOrderBy, buildBackupCloneForPartObject, buildChangeRecord, buildCloneForPartObject, buildContainerClone, buildCopy, buildElementClone, buildElementUnitOfWorkClone, buildExpression, buildReferencesPKList, calculateDeferredChanges, cascadeDiscoverAndPersistUnregisteredNewObjects, cascadePerformRemoveIfRequired, cascadePerformRemovePrivateOwnedObjectFromChangeSetIfRequired, cascadeRegisterNewIfRequired, compareCollectionsForChange, compareForChange, compareLists, compareListsAndWrite, compareObjects, compareObjectsAndWrite, compareObjectsWithoutPrivateOwned, compareObjectsWithPrivateOwned, convertClassNamesToClasses, copyElement, executeBatchQuery, extractResultFromBatchQuery, fixRealObjectReferences, getContainerPolicy, getDeleteAllQuery, getListOrderField, getObjectCorrespondingTo, getOrderByQueryKeyExpressions, getOrderCorrectionType, getRealCollectionAttributeValueFromObject, getSelectionQueryContainerPolicy, getTargetPrimaryKeyFields, hasCustomDeleteAllQuery, hasOrderBy, initializeListOrderField, isAttributeValueInstantiatedOrChanged, isChangeTrackingSupported, isCollectionMapping, isListOrderFieldSupported, isMapKeyObjectRelationship, iterateOnElement, iterateOnRealAttributeValue, load, loadAll, mergeChangesIntoObject, mergeIntoObject, mustDeleteReferenceObjectsOneByOne, objectUnchangedDuringUpdate, objectUnchangedDuringUpdate, postCalculateChanges, postDelete, preInsert, preUpdate, readPrivateOwnedForObject, recordPrivateOwnedRemovals, replaceValueHoldersIn, setChangeListener, setContainerPolicy, setCustomDeleteAllQuery, setDeleteAllCall, setDeleteAllQuery, setDeleteAllSQLString, setHasCustomDeleteAllQuery, setListOrderField, setListOrderFieldName, setMustDeleteReferenceObjectsOneByOne, setOrderCorrectionType, setSelectionQueryContainerPolicy, setUseLazyInstantiationForIndirectCollection, shouldUseLazyInstantiationForIndirectCollection, simpleAddToCollectionChangeRecord, simpleRemoveFromCollectionChangeRecord, updateChangeRecord, updateChangeRecordForSelfMerge, updateCollectionChangeRecord, useCollectionClass, useCollectionClassName, useListClassName, useMapClass, useMapClass, useMapClassName, useSortedSetClass, useSortedSetClassName, useSortedSetClassName, useTransparentCollection, useTransparentList, useTransparentMap, useTransparentSet, validateBeforeInitialization, valueFromPKList, valueFromRowInternalWithJoin, verifyDelete, writeChangesMethods inherited from class org.eclipse.persistence.mappings.ForeignReferenceMapping
addForeignKeyField, addTargetForeignKeyField, batchedValueFromRow, buildBackupClone, buildClone, buildCloneFromRow, checkCacheForBatchKey, createCloneValueHolder, dontDoMerge, dontUseBatchReading, dontUseIndirection, fixObjectReferences, getAttributeValueFromObject, getAttributeValueWithClonedValueHolders, getBatchFetchType, getIndirectionPolicy, getJoinFetch, getMappedBy, getOrderByNormalizedExpressions, getPartitioningPolicy, getPartitioningPolicyName, getRealAttributeValueFromAttribute, getReferenceClass, getReferenceClassName, getReferenceDescriptor, getRelationshipPartner, getRelationshipPartnerAttributeName, getSelectionCriteria, getSelectionQuery, getTempSession, getValueFromRemoteValueHolder, hasCustomSelectionQuery, hasNestedIdentityReference, initializeReferenceDescriptor, initializeSelectionQuery, instantiateAttribute, isAttributeValueFromObjectInstantiated, isAttributeValueFullyBuilt, isAttributeValueInstantiated, isCascadeDetach, isCascadeMerge, isCascadeOnDeleteSetOnDatabase, isCascadePersist, isCascadeRefresh, isCascadeRemove, isExtendingPessimisticLockScope, isForeignReferenceMapping, isInnerJoinFetched, isJoinFetched, isLazy, isLockableMapping, isOuterJoinFetched, isPrivateOwned, iterate, mergeRemoteValueHolder, preInitialize, prepareNestedBatchQuery, prepareNestedJoinQueryClone, prepareNestedJoins, privateOwnedRelationship, readFromRowIntoObject, remoteInitialization, requiresTransientWeavedFields, setBatchFetchType, setCascadeAll, setCascadeDetach, setCascadeMerge, setCascadePersist, setCascadeRefresh, setCascadeRemove, setCustomSelectionQuery, setForceInitializationOfSelectionCriteria, setHasCustomSelectionQuery, setIndirectionPolicy, setIsCacheable, setIsCascadeOnDeleteSetOnDatabase, setIsPrivateOwned, setJoinFetch, setMappedBy, setPartitioningPolicy, setPartitioningPolicyName, setRealAttributeValueInObject, setReferenceClass, setReferenceClassName, setReferenceDescriptor, setRelationshipPartner, setRelationshipPartnerAttributeName, setRequiresTransientWeavedFields, setSelectionCall, setSelectionCriteria, setSelectionQuery, setSelectionSQLString, setShouldExtendPessimisticLockScope, setTempSession, setUsesBatchReading, setUsesIndirection, shouldExtendPessimisticLockScope, shouldExtendPessimisticLockScopeInDedicatedQuery, shouldExtendPessimisticLockScopeInSourceQuery, shouldExtendPessimisticLockScopeInTargetQuery, shouldForceInitializationOfSelectionCriteria, shouldInitializeSelectionCriteria, shouldMergeCascadeParts, shouldMergeCascadeReference, shouldObjectModifyCascadeToParts, shouldRefreshCascadeParts, shouldUseBatchReading, shouldUseValueFromRowWithJoin, trimRowForJoin, trimRowForJoin, useBasicIndirection, useBatchReading, useContainerIndirection, useInnerJoinFetch, useOuterJoinFetch, usesIndirection, useWeavedIndirection, valueFromRow, valueFromRowInternal, valueFromRowInternalMethods inherited from class org.eclipse.persistence.mappings.DatabaseMapping
addUnconvertedProperty, buildObjectJoinExpression, buildObjectJoinExpression, buildShallowOriginalFromRow, cloneFields, collectFields, convertConverterClassNamesToClasses, derivesId, extractNestedExpressions, extractNestedNonAggregateExpressions, getAttributeAccessor, getAttributeClassification, getAttributeName, getDerivedIdMapping, getDescriptor, getField, getFieldClassification, getFields, getGetMethodName, getMapsIdValue, getProperties, getProperty, getRealAttributeValueFromObject, getSelectFields, getSelectTables, getSetMethodName, getUnconvertedProperties, getWeight, hasConstraintDependency, hasInverseConstraintDependency, hasMapsIdValue, hasRootExpressionThatShouldUseOuterJoin, 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, isRemotelyInitialized, isStructureMapping, isTransformationMapping, isUnidirectionalOneToManyMapping, isUsingMethodAccess, isVariableOneToOneMapping, isWriteOnly, isXMLMapping, postCalculateChangesOnDeleted, postInitializeSourceAndTargetExpressions, prepareCascadeLockingPolicy, readFromResultSetIntoObject, readOnly, readWrite, rehashFieldDependancies, remotelyInitialized, setAttributeAccessor, setAttributeName, setAttributeValueInObject, setDerivedIdMapping, setDerivesId, setDescriptor, setFields, 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
-
Field Details
-
PostInsert
Used for data modification events.- See Also:
-
ObjectRemoved
- See Also:
-
ObjectAdded
- See Also:
-
mechanism
Mechanism holds relationTable and all fields and queries associated with it. -
historyPolicy
-
isDefinedAsOneToManyMapping
protected boolean isDefinedAsOneToManyMapping266912: Since: EclipseLink 2.0 for the Metamodel API For 1:1 and m:m mappings - track the original externally defined mapping if different Note: This field will provide differentiation for the following external to internal representations for mapping types
- A OneToManyMapping will be represented by a ManyToManyMapping if unidirectional
- A ManyToOneMapping will be represented by a OneToOneMapping (without a FK constraint)
-
-
Constructor Details
-
ManyToManyMapping
public ManyToManyMapping()PUBLIC: Default constructor.
-
-
Method Details
-
isOwned
public boolean isOwned()INTERNAL:- Overrides:
isOwnedin classDatabaseMapping
-
isRelationalMapping
public boolean isRelationalMapping()INTERNAL:- Overrides:
isRelationalMappingin classDatabaseMapping
-
addSourceRelationKeyField
public 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. This method is used if the keys are composite. -
addSourceRelationKeyFieldName
public void addSourceRelationKeyFieldName(String sourceRelationKeyFieldName, String sourcePrimaryKeyFieldName) PUBLIC: Add the fields in the intermediate table that corresponds to the primary key in the source table. This method is used if the keys are composite. -
addTargetRelationKeyField
public 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. This method is used if the keys are composite. -
addTargetRelationKeyFieldName
public void addTargetRelationKeyFieldName(String targetRelationKeyFieldName, String targetPrimaryKeyFieldName) PUBLIC: Add the fields in the intermediate table that corresponds to the primary key in the target table. This method is used if the keys are composite. -
collectQueryParameters
public void collectQueryParameters(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- Overrides:
collectQueryParametersin classCollectionMapping
-
clone
INTERNAL: The mapping clones itself to create deep copy.- Specified by:
clonein interfaceMapComponentMapping- Overrides:
clonein classCollectionMapping
-
earlyPreDelete
INTERNAL: Delete join tables before the start of the deletion process to avoid constraint errors.- Overrides:
earlyPreDeletein classDatabaseMapping
-
createMapComponentFromRow
public 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. Returns the key.- Specified by:
createMapComponentFromRowin interfaceMapComponentMapping
-
extendPessimisticLockScopeInTargetQuery
protected void extendPessimisticLockScopeInTargetQuery(ObjectLevelReadQuery targetQuery, ObjectBuildingQuery sourceQuery) INTERNAL: Adds locking clause to the target query to extend pessimistic lock scope.- Overrides:
extendPessimisticLockScopeInTargetQueryin classForeignReferenceMapping
-
extendPessimisticLockScopeInSourceQuery
INTERNAL: Called only if both shouldExtendPessimisticLockScope and shouldExtendPessimisticLockScopeInSourceQuery are true. Adds fields to be locked to the where clause of the source query. Note that the sourceQuery must be ObjectLevelReadQuery so that it has ExpressionBuilder. This method must be implemented in subclasses that allow setting shouldExtendPessimisticLockScopeInSourceQuery to true.- Overrides:
extendPessimisticLockScopeInSourceQueryin classForeignReferenceMapping
-
extractKeyFromTargetRow
protected Object extractKeyFromTargetRow(org.eclipse.persistence.internal.sessions.AbstractRecord row, org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Extract the source primary key value from the relation row. Used for batch reading, most following same order and fields as in the mapping.- Overrides:
extractKeyFromTargetRowin classCollectionMapping
-
extractBatchKeyFromRow
protected Object extractBatchKeyFromRow(org.eclipse.persistence.internal.sessions.AbstractRecord row, org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Extract the primary key value from the source row. Used for batch reading, most following same order and fields as in the mapping.- Overrides:
extractBatchKeyFromRowin classForeignReferenceMapping
-
buildBatchCriteria
INTERNAL: Return the selection criteria used to IN batch fetching.- Overrides:
buildBatchCriteriain classForeignReferenceMapping
-
postPrepareNestedBatchQuery
INTERNAL: Add additional fields and check for history.- Overrides:
postPrepareNestedBatchQueryin classCollectionMapping
-
getAdditionalFieldsBaseExpression
INTERNAL: Return the base expression to use for adding fields to the query. Normally this is the query's builder, but may be the join table for m-m.- Overrides:
getAdditionalFieldsBaseExpressionin classCollectionMapping
-
getDeleteQuery
-
getExtendPessimisticLockScopeDedicatedQuery
protected ReadQuery getExtendPessimisticLockScopeDedicatedQuery(org.eclipse.persistence.internal.sessions.AbstractSession session, short lockMode) INTERNAL: Should be overridden by subclass that allows setting extendPessimisticLockScope to DEDICATED_QUERY.- Overrides:
getExtendPessimisticLockScopeDedicatedQueryin classForeignReferenceMapping
-
getFieldsForTranslationInAggregate
INTERNAL: Return source key fields for translation by an AggregateObjectMapping- Overrides:
getFieldsForTranslationInAggregatein classForeignReferenceMapping
-
getInsertQuery
-
getJoinCriteria
public Expression getJoinCriteria(org.eclipse.persistence.internal.expressions.ObjectExpression context, Expression base) INTERNAL: Returns the join criteria stored in the mapping selection query. This criteria is used to read reference objects across the tables from the database.- Overrides:
getJoinCriteriain classCollectionMapping
-
getHistoryPolicy
PUBLIC: Allows history tracking on the m-m join table. -
getRelationTableMechanism
PUBLIC: Returns RelationTableMechanism that may be owned by the mapping. Note that all RelationTableMechanism methods are accessible through the mapping directly. The only reason this method is provided is to allow a uniform approach to RelationTableMechanism in both ManyToManyMapping and OneToOneMapping that uses RelationTableMechanism. -
getRelationTable
public org.eclipse.persistence.internal.helper.DatabaseTable getRelationTable()INTERNAL: Return the relation table associated with the mapping. -
getRelationTableName
PUBLIC: Return the relation table name associated with the mapping. -
getRelationTableQualifiedName
PUBLIC: Return the relation table qualified name associated with the mapping. -
getSourceKeyFieldNames
PUBLIC: Return the source key field names associated with the mapping. These are in-order with the sourceRelationKeyFieldNames. -
getSourceKeyFields
INTERNAL: Return all the source key fields associated with the mapping. -
getSourceRelationKeyFieldNames
PUBLIC: Return the source relation key field names associated with the mapping. These are in-order with the sourceKeyFieldNames. -
getSourceRelationKeyFields
INTERNAL: Return all the source relation key fields associated with the mapping. -
getTargetKeyFieldNames
PUBLIC: Return the target key field names associated with the mapping. These are in-order with the targetRelationKeyFieldNames. -
getTargetKeyFields
INTERNAL: Return all the target keys associated with the mapping. -
getTargetRelationKeyFieldNames
PUBLIC: Return the target relation key field names associated with the mapping. These are in-order with the targetKeyFieldNames. -
getTargetRelationKeyFields
INTERNAL: Return all the target relation key fields associated with the mapping. -
hasCustomDeleteQuery
protected boolean hasCustomDeleteQuery() -
hasCustomInsertQuery
protected boolean hasCustomInsertQuery() -
hasDependency
public boolean hasDependency()INTERNAL: The join table is a dependency if not read-only.- Overrides:
hasDependencyin classForeignReferenceMapping
-
initialize
public void initialize(org.eclipse.persistence.internal.sessions.AbstractSession session) throws DescriptorException INTERNAL: Initialize mappings- Overrides:
initializein classCollectionMapping- Throws:
DescriptorException
-
buildListOrderField
protected void buildListOrderField()INTERNAL: Verifies listOrderField's table: it must be relation table. Precondition: listOrderField != null.- Overrides:
buildListOrderFieldin classCollectionMapping
-
shouldUseListOrderFieldTableExpression
public boolean shouldUseListOrderFieldTableExpression()INTERNAL: Indicates whether getListOrderFieldExpression method should create field expression on table expression.- Overrides:
shouldUseListOrderFieldTableExpressionin classCollectionMapping
-
initializeChangeOrderTargetQuery
protected void initializeChangeOrderTargetQuery(org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Initialize changeOrderTargetQuery.- Overrides:
initializeChangeOrderTargetQueryin classCollectionMapping
-
initializeDeleteAllQuery
protected void initializeDeleteAllQuery(org.eclipse.persistence.internal.sessions.AbstractSession session) Initialize delete all query. This query is used to all relevant rows from the relation table. -
initializeListOrderFieldTable
protected void initializeListOrderFieldTable(org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Initializes listOrderField's table. Precondition: listOrderField != null.- Overrides:
initializeListOrderFieldTablein classCollectionMapping
-
initializeSelectionCriteriaAndAddFieldsToQuery
INTERNAL: Selection criteria is created to read target records from the table. -
insertAddedObjectEntry
protected void insertAddedObjectEntry(ObjectLevelModifyQuery query, Object objectAdded, Map extraData) throws DatabaseException, OptimisticLockException INTERNAL: An object was added to the collection during an update, insert it. -
insertIntoRelationTable
INTERNAL: Insert into relation table. This follows following steps.- 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.
- Throws:
DatabaseException
-
insertTargetObjects
public void insertTargetObjects(WriteObjectQuery query) throws DatabaseException, OptimisticLockException INTERNAL: Write the target objects if the cascade policy requires them to be written first. They must be written within a unit of work to ensure that they exist. -
isDefinedAsOneToManyMapping
public boolean isDefinedAsOneToManyMapping()INTERNAL: Return whether this mapping was originally defined as a OneToMany. -
isJoiningSupported
public boolean isJoiningSupported()INTERNAL: Return if this mapping support joining.- Overrides:
isJoiningSupportedin classForeignReferenceMapping
-
isManyToManyMapping
public boolean isManyToManyMapping()Description copied from class:DatabaseMappingINTERNAL: Related mapping should implement this method to return true.- Overrides:
isManyToManyMappingin classDatabaseMapping
-
postInitialize
public void postInitialize(org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Ensure the container policy is post initialized- Overrides:
postInitializein classCollectionMapping
-
objectAddedDuringUpdate
protected void objectAddedDuringUpdate(ObjectLevelModifyQuery query, Object objectAdded, org.eclipse.persistence.internal.sessions.ObjectChangeSet changeSet, Map extraData) throws DatabaseException, OptimisticLockException INTERNAL: An object was added to the collection during an update, insert it if private.- Overrides:
objectAddedDuringUpdatein classCollectionMapping- Throws:
DatabaseExceptionOptimisticLockException
-
objectRemovedDuringUpdate
protected void objectRemovedDuringUpdate(ObjectLevelModifyQuery query, Object objectDeleted, Map extraData) throws DatabaseException, OptimisticLockException INTERNAL: An object was removed to the collection during an update, delete it if private.- Overrides:
objectRemovedDuringUpdatein classCollectionMapping- Throws:
DatabaseExceptionOptimisticLockException
-
objectOrderChangedDuringUpdate
protected void objectOrderChangedDuringUpdate(WriteObjectQuery query, Object orderChangedObject, int orderIndex) - Overrides:
objectOrderChangedDuringUpdatein classCollectionMapping
-
performDataModificationEvent
public void performDataModificationEvent(Object[] event, org.eclipse.persistence.internal.sessions.AbstractSession session) throws DatabaseException, DescriptorException INTERNAL: Perform the commit event. This is used in the uow to delay data modifications.- Overrides:
performDataModificationEventin classDatabaseMapping- Throws:
DatabaseExceptionDescriptorException
-
postInsert
INTERNAL: Insert into relation table. This follows following steps.- 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.
- Overrides:
postInsertin classCollectionMapping- Throws:
DatabaseException
-
postUpdate
INTERNAL: Update the relation table with the entries related to this mapping. Delete entries removed, insert entries added. If private also insert/delete/update target objects.- Overrides:
postUpdatein classDatabaseMapping- Throws:
DatabaseException
-
preDelete
INTERNAL: Delete entries related to this mapping from the relation table.- Overrides:
preDeletein classDatabaseMapping- Throws:
DatabaseException
-
prepareTranslationRow
protected void prepareTranslationRow(org.eclipse.persistence.internal.sessions.AbstractRecord translationRow, Object object, ClassDescriptor descriptor, org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: The translation row may require additional fields than the primary key if the mapping in not on the primary key.- Overrides:
prepareTranslationRowin classCollectionMapping
-
setCustomDeleteQuery
PUBLIC: The default delete query for mapping can be overridden by specifying the new query. This query must delete the row from the M-M join table. -
setCustomInsertQuery
PUBLIC: The default insert query for mapping can be overridden by specifying the new query. This query must insert the row into the M-M join table. -
setDeleteQuery
-
setDeleteSQLString
PUBLIC: Set the receiver's delete SQL string. This allows the user to override the SQL generated by TOPLink, with there own SQL or procedure call. The arguments are translated from the fields of the source row, through replacing the field names marked by '#' with the values for those fields. This is used to delete a single entry from the M-M join table. Example, 'delete from PROJ_EMP where PROJ_ID = #PROJ_ID AND EMP_ID = #EMP_ID'. -
setDefinedAsOneToManyMapping
public void setDefinedAsOneToManyMapping(boolean isDefinedAsOneToManyMapping) INTERNAL: Set whether this mapping was originally defined as a OneToMany- Parameters:
isDefinedAsOneToManyMapping-
-
setDeleteCall
PUBLIC: Set the receiver's delete Call. This allows the user to override the SQL generated by TOPLink, with there own SQL or procedure call. The arguments are translated from the fields of the source row. This is used to delete a single entry from the M-M join table. Example, 'new SQLCall("delete from PROJ_EMP where PROJ_ID = #PROJ_ID AND EMP_ID = #EMP_ID")'. -
setInsertQuery
-
setInsertSQLString
PUBLIC: Set the receiver's insert SQL string. This allows the user to override the SQL generated by TOPLink, with there own SQL or procedure call. The arguments are translated from the fields of the source row, through replacing the field names marked by '#' with the values for those fields. This is used to insert an entry into the M-M join table. Example, 'insert into PROJ_EMP (EMP_ID, PROJ_ID) values (#EMP_ID, #PROJ_ID)'. -
setInsertCall
PUBLIC: Set the receiver's insert Call. This allows the user to override the SQL generated by TOPLink, with there own SQL or procedure call. The arguments are translated from the fields of the source row. This is used to insert an entry into the M-M join table. Example, 'new SQLCall("insert into PROJ_EMP (EMP_ID, PROJ_ID) values (#EMP_ID, #PROJ_ID)")'. -
setRelationTable
public void setRelationTable(org.eclipse.persistence.internal.helper.DatabaseTable relationTable) PUBLIC: Set the relational table. This is the join table that store both the source and target primary keys. -
setHistoryPolicy
PUBLIC: Enable history tracking on the m-m join table. -
setRelationTableName
PUBLIC: Set the name of the relational table. This is the join table that store both the source and target primary keys. -
setSessionName
PUBLIC: Set the name of the session to execute the mapping's queries under. This can be used by the session broker to override the default session to be used for the target class.- Overrides:
setSessionNamein classCollectionMapping
-
setSourceKeyFieldNames
PUBLIC: Set the source key field names associated with the mapping. These must be in-order with the sourceRelationKeyFieldNames. -
setSourceKeyFields
public void setSourceKeyFields(Vector<org.eclipse.persistence.internal.helper.DatabaseField> sourceKeyFields) INTERNAL: Set the source fields. -
setSourceRelationKeyFieldName
PUBLIC: Set the source key field in the relation table. This is the name of the foreign key in the relation table to the source's primary key field. This method is used if the source primary key is a singleton only. -
setSourceRelationKeyFieldNames
PUBLIC: Set the source relation key field names associated with the mapping. These must be in-order with the sourceKeyFieldNames. -
setSourceRelationKeyFields
public void setSourceRelationKeyFields(Vector<org.eclipse.persistence.internal.helper.DatabaseField> sourceRelationKeyFields) INTERNAL: Set the source fields. -
setTargetKeyFieldNames
INTERNAL: Set the target key field names associated with the mapping. These must be in-order with the targetRelationKeyFieldNames. -
setTargetKeyFields
public void setTargetKeyFields(Vector<org.eclipse.persistence.internal.helper.DatabaseField> targetKeyFields) INTERNAL: Set the target fields. -
setTargetRelationKeyFieldName
PUBLIC: Set the target key field in the relation table. This is the name of the foreign key in the relation table to the target's primary key field. This method is used if the target's primary key is a singleton only. -
setTargetRelationKeyFieldNames
INTERNAL: Set the target relation key field names associated with the mapping. These must be in-order with the targetKeyFieldNames. -
setTargetRelationKeyFields
public void setTargetRelationKeyFields(Vector<org.eclipse.persistence.internal.helper.DatabaseField> targetRelationKeyFields) INTERNAL: Set the target fields. -
prepareHistoricalQuery
protected ReadQuery prepareHistoricalQuery(ReadQuery targetQuery, ObjectBuildingQuery sourceQuery, org.eclipse.persistence.internal.sessions.AbstractSession executionSession) INTERNAL: Append the temporal selection to the query selection criteria.- Overrides:
prepareHistoricalQueryin classForeignReferenceMapping
-