- All Implemented Interfaces:
Serializable
,Cloneable
,ContainerMapping
,MapComponentMapping
,RelationalMapping
- Direct Known Subclasses:
UnidirectionalOneToManyMapping
Purpose: This mapping is used to represent the typical RDBMS relationship between a single source object and collection of target objects; where, on the database, the target objects have references (foreign keys) to the source object.
- Since:
- TOPLink/Java 1.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.persistence.mappings.DatabaseMapping
DatabaseMapping.WriteType
-
Field Summary
Modifier and TypeFieldDescriptionprotected DataModifyQuery
Query used to update a single target row setting its foreign key to point to the source.protected boolean
protected boolean
protected boolean
protected static final String
protected static final String
protected static final String
Used for data modification events.protected DataModifyQuery
Query used to update all target rows changing target foreign key value from the one pointing to the source to null.protected DataModifyQuery
Query used to update a single target row changing its foreign key value from the one pointing to the source to null.protected Boolean
protected List
<Expression> Keep a reference to the source and target expressions to post initialize when building a selection criteria early.protected Vector
<DatabaseField> The (typically primary) source key fields that are referenced by the targetForeignKeyFields.protected Map
<DatabaseField, DatabaseField> This maps the (primary) source key fields to the corresponding target foreign key fields.protected List
<Expression> protected Vector
<DatabaseField> The target foreign key fields that reference the sourceKeyFields.protected Map
<DatabaseField, DatabaseField> This maps the target foreign key fields to the corresponding (primary) source key fields.protected DatabaseTable
All targetForeignKeyFields should have the same table.protected List
<DatabaseField> Primary keys of targetForeignKeyTable: the same as referenceDescriptor().getPrimaryKeyFields() in case the table is default table of reference descriptor; otherwise contains secondary table's primary key fields in the same order as default table primary keys mapped to them.Fields inherited from class org.eclipse.persistence.mappings.CollectionMapping
changeOrderTargetQuery, containerPolicy, deleteAllQuery, hasCustomDeleteAllQuery, hasOrderBy, isListOrderFieldSupported, isSynchronizeOnMerge, listOrderField, mustDeleteReferenceObjectsOneByOne, orderCorrectionType
Fields 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, tempInitSession
Fields 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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addTargetForeignKeyField
(DatabaseField targetForeignKeyField, DatabaseField sourceKeyField) INTERNAL: Add the associated fields to the appropriate collections.void
addTargetForeignKeyFieldName
(String targetForeignKeyFieldName, String sourceKeyFieldName) PUBLIC: Define the target foreign key relationship in the one-to-many mapping.protected Expression
buildBatchCriteria
(ExpressionBuilder builder, ObjectLevelReadQuery query) INTERNAL: Return the selection criteria used to IN batch fetching.protected Expression
The selection criteria are created with target foreign keys and source "primary" keys.protected AbstractRecord
protected void
INTERNAL: Verifies listOrderField's table: it must be the same table that contains all target foreign keys.This method would allow customers to get the potential selection criteria for a mapping prior to initialization.clone()
INTERNAL: Clone the appropriate attributes.void
collectQueryParameters
(Set<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
(AbstractRecord dbRow, ObjectBuildingQuery query, CacheKey parentCacheKey, AbstractSession session, boolean isTargetProtected) INTERNAL Called when a DatabaseMapping is used to map the key in a collection.protected AbstractRecord
INTERNAL:protected void
deleteAll
(DeleteObjectQuery query, AbstractSession session) Delete all the reference objects with a single query.protected void
This method will make sure that all the records privately owned by this mapping are actually removed.protected Object
extractBatchKeyFromRow
(AbstractRecord row, AbstractSession session) Extract the key field values from the specified row.protected Object
extractKeyFromTargetRow
(AbstractRecord row, AbstractSession session) INTERNAL: Extract the source primary key value from the target row.protected ModifyQuery
Overrides CollectionMappig because this mapping requires a DeleteAllQuery instead of a ModifyQuery.INTERNAL: Return source key fields for translation by an AggregateObjectMappingprotected InsertObjectQuery
getInsertObjectQuery
(AbstractSession session, ClassDescriptor desc) INTERNAL: Returns a clone of InsertObjectQuery from the ClassDescriptor's DescriptorQueryManager or a new onePUBLIC: Return the source key field names associated with the mapping.INTERNAL: Return the source key fields.INTERNAL: Return the source/target key fields.INTERNAL: Return the target foreign key field names associated with the mapping.INTERNAL: Return the target foreign key fields.INTERNAL: Return the target/source key fields.INTERNAL: Primary keys of targetForeignKeyTable.boolean
INTERNAL: Return whether the mapping has any inverse constraint dependencies, such as foreign keys and join tables.void
initialize
(AbstractSession session) INTERNAL: Initialize the mapping.protected void
initializeAddTargetQuery
(AbstractSession session) INTERNAL: Initialize addTargetQuery.protected void
INTERNAL: Initialize changeOrderTargetQuery.protected void
initializeDeleteAllQuery
(AbstractSession session) Initialize the delete all query.protected void
Initialize and set the descriptor for the referenced class in this mapping.protected void
INTERNAL: Initialize removeAllTargetsQuery.protected void
INTERNAL: Initialize removeTargetQuery.protected void
Verify, munge, and hash the target foreign keys and source keys.protected void
INTERNAL: Initialize targetForeignKeyTable and initializeTargetPrimaryKeyFields.boolean
INTERNAL Return true if this mapping supports cascaded version optimistic locking.boolean
INTERNAL: Return if this mapping support joining.boolean
INTERNAL:boolean
INTERNAL:protected boolean
Return whether the source key is specified.protected void
objectAddedDuringUpdate
(ObjectLevelModifyQuery query, Object objectAdded, ObjectChangeSet changeSet, Map extraData) INTERNAL: An object was added to the collection during an update, insert it if private.protected void
objectRemovedDuringUpdate
(ObjectLevelModifyQuery query, Object objectDeleted, Map extraData) INTERNAL: An object was removed to the collection during an update, delete it if private.void
performDataModificationEvent
(Object[] event, AbstractSession session) INTERNAL: Perform the commit event.void
INTERNAL: Post-initialize source and target expression fields created when a mapping's selectionCriteria is created early with only partly initialized fields.void
postInsert
(WriteObjectQuery query) INTERNAL: Insert the reference objects.void
postUpdate
(WriteObjectQuery query) INTERNAL: Update the reference objects.void
preDelete
(DeleteObjectQuery query) INTERNAL: Delete the reference objects.void
Prepare a cascade locking policy.boolean
INTERNAL: Returns whether this mapping uses data modification events to complete its writesvoid
setAddTargetSQLString
(String sqlString) PUBLIC:void
PUBLIC: The default add target query for mapping can be overridden by specifying the new query.void
PUBLIC: The default remove all targets query for mapping can be overridden by specifying the new query.void
PUBLIC: The default remove target query for mapping can be overridden by specifying the new query.void
setDeleteAllSQLString
(String sqlString) PUBLIC: Set the SQL string used by the mapping to delete the target objects.void
setSessionName
(String name) PUBLIC: Set the name of the session to execute the mapping's queries under.void
setShouldDeferInsert
(boolean defer) void
setSourceKeyFieldNames
(Vector fieldNames) INTERNAL: Set the source key field names associated with the mapping.void
setSourceKeyFields
(Vector<DatabaseField> sourceKeyFields) INTERNAL: Set the source key fields.void
setTargetForeignKeyFieldName
(String targetForeignKeyFieldName) PUBLIC: Define the target foreign key relationship in the one-to-many mapping.void
setTargetForeignKeyFieldNames
(String[] targetForeignKeyFieldNames, String[] sourceKeyFieldNames) PUBLIC: Define the target foreign key relationship in the one-to-many mapping.void
setTargetForeignKeyFieldNames
(Vector fieldNames) INTERNAL: Set the target key field names associated with the mapping.void
setTargetForeignKeyFields
(Vector<DatabaseField> targetForeignKeyFields) INTERNAL: Set the target fields.protected void
setTargetForeignKeysToSourceKeys
(Map<DatabaseField, DatabaseField> targetForeignKeysToSourceKeys) INTERNAL: Set the target fields.boolean
protected boolean
Return whether any process leading to object modification should also affect its parts.protected boolean
INTERNAL If it's not a map then target foreign key has been already modified (set to null).void
updateTargetForeignKeyPostUpdateSource_ObjectAdded
(ObjectLevelModifyQuery query, Object objectAdded, Map extraData) INTERNAL: Update target foreign key after a target object was added to the source.void
updateTargetForeignKeyPostUpdateSource_ObjectRemoved
(ObjectLevelModifyQuery query, Object objectRemoved) INTERNAL: Update target foreign key after a target object was removed from the source.void
INTERNAL: Update target foreign keys after a new source was inserted.void
INTERNAL: Update target foreign key after a target object was removed from the source.boolean
verifyDelete
(Object object, AbstractSession session) INTERNAL: Used to verify whether the specified object is deleted or not.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, getAdditionalFieldsBaseExpression, getContainerPolicy, getJoinCriteria, getListOrderField, getObjectCorrespondingTo, getOrderByQueryKeyExpressions, getOrderCorrectionType, getRealCollectionAttributeValueFromObject, getSelectionQueryContainerPolicy, hasCustomDeleteAllQuery, hasOrderBy, initializeListOrderField, initializeListOrderFieldTable, isAttributeValueInstantiatedOrChanged, isChangeTrackingSupported, isCollectionMapping, isListOrderFieldSupported, isMapKeyObjectRelationship, iterateOnElement, iterateOnRealAttributeValue, load, loadAll, mergeChangesIntoObject, mergeIntoObject, mustDeleteReferenceObjectsOneByOne, objectOrderChangedDuringUpdate, objectUnchangedDuringUpdate, objectUnchangedDuringUpdate, postCalculateChanges, postDelete, postInitialize, postPrepareNestedBatchQuery, preInsert, prepareTranslationRow, preUpdate, readPrivateOwnedForObject, recordPrivateOwnedRemovals, replaceValueHoldersIn, setChangeListener, setContainerPolicy, setCustomDeleteAllQuery, setDeleteAllCall, setDeleteAllQuery, setHasCustomDeleteAllQuery, setListOrderField, setListOrderFieldName, setMustDeleteReferenceObjectsOneByOne, setOrderCorrectionType, setSelectionQueryContainerPolicy, setUseLazyInstantiationForIndirectCollection, shouldUseLazyInstantiationForIndirectCollection, shouldUseListOrderFieldTableExpression, simpleAddToCollectionChangeRecord, simpleRemoveFromCollectionChangeRecord, updateChangeRecord, updateChangeRecordForSelfMerge, updateCollectionChangeRecord, useCollectionClass, useCollectionClassName, useListClassName, useMapClass, useMapClass, useMapClassName, useSortedSetClass, useSortedSetClassName, useSortedSetClassName, useTransparentCollection, useTransparentList, useTransparentMap, useTransparentSet, validateBeforeInitialization, valueFromPKList, valueFromRowInternalWithJoin, writeChanges
Methods inherited from class org.eclipse.persistence.mappings.ForeignReferenceMapping
addForeignKeyField, batchedValueFromRow, buildBackupClone, buildClone, buildCloneFromRow, checkCacheForBatchKey, createCloneValueHolder, dontDoMerge, dontUseBatchReading, dontUseIndirection, extendPessimisticLockScopeInSourceQuery, extendPessimisticLockScopeInTargetQuery, fixObjectReferences, getAttributeValueFromObject, getAttributeValueWithClonedValueHolders, getBatchFetchType, getExtendPessimisticLockScopeDedicatedQuery, getIndirectionPolicy, getJoinFetch, getMappedBy, getOrderByNormalizedExpressions, getPartitioningPolicy, getPartitioningPolicyName, getRealAttributeValueFromAttribute, getReferenceClass, getReferenceClassName, getReferenceDescriptor, getRelationshipPartner, getRelationshipPartnerAttributeName, getSelectionCriteria, getSelectionQuery, getTempSession, getValueFromRemoteValueHolder, hasCustomSelectionQuery, hasDependency, hasNestedIdentityReference, initializeSelectionQuery, instantiateAttribute, isAttributeValueFromObjectInstantiated, isAttributeValueFullyBuilt, isAttributeValueInstantiated, isCascadeDetach, isCascadeMerge, isCascadeOnDeleteSetOnDatabase, isCascadePersist, isCascadeRefresh, isCascadeRemove, isExtendingPessimisticLockScope, isForeignReferenceMapping, isInnerJoinFetched, isJoinFetched, isLazy, isLockableMapping, isOuterJoinFetched, isPrivateOwned, iterate, mergeRemoteValueHolder, preInitialize, prepareHistoricalQuery, 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, shouldRefreshCascadeParts, shouldUseBatchReading, shouldUseValueFromRowWithJoin, trimRowForJoin, trimRowForJoin, useBasicIndirection, useBatchReading, useContainerIndirection, useInnerJoinFetch, useOuterJoinFetch, usesIndirection, useWeavedIndirection, valueFromRow, valueFromRowInternal, valueFromRowInternal
Methods inherited from class org.eclipse.persistence.mappings.DatabaseMapping
addUnconvertedProperty, buildObjectJoinExpression, buildObjectJoinExpression, buildShallowOriginalFromRow, cloneFields, collectFields, convertConverterClassNamesToClasses, derivesId, earlyPreDelete, extractNestedExpressions, extractNestedNonAggregateExpressions, getAttributeAccessor, getAttributeClassification, getAttributeName, getDerivedIdMapping, getDescriptor, getField, getFieldClassification, getFields, getGetMethodName, getMapsIdValue, getProperties, getProperty, getRealAttributeValueFromObject, getSelectFields, getSelectTables, getSetMethodName, getUnconvertedProperties, getWeight, hasConstraintDependency, hasMapsIdValue, hasRootExpressionThatShouldUseOuterJoin, hasUnconvertedProperties, isAbstractColumnMapping, isAbstractCompositeCollectionMapping, isAbstractCompositeDirectCollectionMapping, isAbstractCompositeObjectMapping, isAbstractDirectMapping, isAggregateCollectionMapping, isAggregateMapping, isAggregateObjectMapping, isCacheable, isCandidateForPrivateOwnedRemoval, isCloningRequired, isDatabaseMapping, isDirectCollectionMapping, isDirectMapMapping, isDirectToFieldMapping, isDirectToXMLTypeMapping, isEISMapping, isElementCollectionMapping, isInAndOutSopObject, isInOnlySopObject, isInSopObject, isJPAId, isManyToManyMapping, isManyToOneMapping, isMapKeyMapping, isMultitenantPrimaryKeyMapping, isNestedTableMapping, isObjectReferenceMapping, isOneToOneMapping, isOptional, isOutOnlySopObject, isOutSopObject, isOwned, isPrimaryKeyMapping, isReadOnly, isReferenceMapping, isRemotelyInitialized, isStructureMapping, isTransformationMapping, isUnidirectionalOneToManyMapping, isUsingMethodAccess, isVariableOneToOneMapping, isWriteOnly, isXMLMapping, postCalculateChangesOnDeleted, 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:
-
targetForeignKeyFields
The target foreign key fields that reference the sourceKeyFields. -
sourceKeyFields
The (typically primary) source key fields that are referenced by the targetForeignKeyFields. -
targetForeignKeysToSourceKeys
This maps the target foreign key fields to the corresponding (primary) source key fields. -
sourceKeysToTargetForeignKeys
This maps the (primary) source key fields to the corresponding target foreign key fields. -
targetForeignKeyTable
All targetForeignKeyFields should have the same table. Used only in case data modification events required. -
targetPrimaryKeyFields
Primary keys of targetForeignKeyTable: the same as referenceDescriptor().getPrimaryKeyFields() in case the table is default table of reference descriptor; otherwise contains secondary table's primary key fields in the same order as default table primary keys mapped to them. Used only in case data modification events required. -
sourceExpressionsToPostInitialize
Keep a reference to the source and target expressions to post initialize when building a selection criteria early. -
targetExpressionsToPostInitialize
-
addTargetQuery
Query used to update a single target row setting its foreign key to point to the source. Run once for each target added to the source. Example: for Employee with managedEmployees attribute mapped with UnidirectionalOneToMany the query looks like: UPDATE EMPLOYEE SET MANAGER_ID = 1 WHERE (EMP_ID = 2) where 1 is id of the source, and 2 is the id of the target to be added. Used only in case data modification events required. -
hasCustomAddTargetQuery
protected boolean hasCustomAddTargetQuery -
shouldDeferInserts
-
removeTargetQuery
Query used to update a single target row changing its foreign key value from the one pointing to the source to null. Run once for each target removed from the source. Example: for Employee with managedEmployees attribute mapped with UnidirectionalOneToMany the query looks like: UPDATE EMPLOYEE SET MANAGER_ID = null WHERE ((MANAGER_ID = 1) AND (EMP_ID = 2)) where 1 is id of the source, and 2 is the id of the target to be removed. Used only in case data modification events required. -
hasCustomRemoveTargetQuery
protected boolean hasCustomRemoveTargetQuery -
removeAllTargetsQuery
Query used to update all target rows changing target foreign key value from the one pointing to the source to null. Run before the source object is deleted. Example: for Employee with managedEmployees attribute mapped with UnidirectionalOneToMany the query looks like: UPDATE EMPLOYEE SET MANAGER_ID = null WHERE (MANAGER_ID = 1) where 1 is id of the source to be deleted. Used only in case data modification events required. -
hasCustomRemoveAllTargetsQuery
protected boolean hasCustomRemoveAllTargetsQuery
-
-
Constructor Details
-
OneToManyMapping
public OneToManyMapping()PUBLIC: Default constructor.
-
-
Method Details
-
isRelationalMapping
public boolean isRelationalMapping()INTERNAL:- Overrides:
isRelationalMapping
in classDatabaseMapping
-
addTargetForeignKeyField
public void addTargetForeignKeyField(DatabaseField targetForeignKeyField, DatabaseField sourceKeyField) INTERNAL: Add the associated fields to the appropriate collections.- Overrides:
addTargetForeignKeyField
in classForeignReferenceMapping
-
addTargetForeignKeyFieldName
public void addTargetForeignKeyFieldName(String targetForeignKeyFieldName, String sourceKeyFieldName) PUBLIC: Define the target foreign key relationship in the one-to-many mapping. This method is used for composite target foreign key relationships. That is, the target object's table has multiple foreign key fields that are references to the source object's (typically primary) key fields. Both the target foreign key field name and the corresponding source primary key field name must be specified. Because the target object's table must store a foreign key to the source table, the target object must map that foreign key, this is normally done through a one-to-one mapping back-reference. Other options include:- use a DirectToFieldMapping and maintain the foreign key fields directly in the target
- use a ManyToManyMapping
- use an AggregateCollectionMapping
- See Also:
-
buildListOrderField
protected void buildListOrderField()INTERNAL: Verifies listOrderField's table: it must be the same table that contains all target foreign keys. Precondition: listOrderField != null.- Overrides:
buildListOrderField
in classCollectionMapping
-
buildDefaultSelectionCriteriaAndAddFieldsToQuery
The selection criteria are created with target foreign keys and source "primary" keys. These criteria are then used to read the target records from the table. These criteria are also used as the default "delete all" criteria. CR#3922 - This method is almost the same as buildSelectionCriteria() the difference is that TargetForeignKeysToSourceKeys contains more information after login then SourceKeyFields contains before login. -
buildSelectionCriteria
This method would allow customers to get the potential selection criteria for a mapping prior to initialization. This would allow them to more easily create an amendment method that would amend the SQL for the join. CR#3922 - This method is almost the same as buildDefaultSelectionCriteria() the difference is that TargetForeignKeysToSourceKeys contains more information after login then SourceKeyFields contains before login. -
collectQueryParameters
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:
collectQueryParameters
in classCollectionMapping
- Parameters:
cacheFields
- TODO
-
clone
INTERNAL: Clone the appropriate attributes.- Specified by:
clone
in interfaceMapComponentMapping
- Overrides:
clone
in classCollectionMapping
- Returns:
- new instance of itself
-
createMapComponentFromRow
public Object createMapComponentFromRow(AbstractRecord dbRow, ObjectBuildingQuery query, CacheKey parentCacheKey, AbstractSession session, boolean isTargetProtected) INTERNAL Called when a DatabaseMapping is used to map the key in a collection. Returns the key.- Specified by:
createMapComponentFromRow
in interfaceMapComponentMapping
-
deleteAll
Delete all the reference objects with a single query.- Throws:
DatabaseException
-
deleteReferenceObjectsLeftOnDatabase
protected void deleteReferenceObjectsLeftOnDatabase(DeleteObjectQuery query) throws DatabaseException, OptimisticLockException This method will make sure that all the records privately owned by this mapping are actually removed. If such records are found then those are all read and removed one by one along with their privately owned parts. -
extractKeyFromTargetRow
INTERNAL: Extract the source primary key value from the target row. Used for batch reading, most following same order and fields as in the mapping.- Overrides:
extractKeyFromTargetRow
in classCollectionMapping
-
extractBatchKeyFromRow
Extract the key field values from the specified row. Used for batch reading. Keep the fields in the same order as in the targetForeignKeysToSourceKeys map.- Overrides:
extractBatchKeyFromRow
in classForeignReferenceMapping
-
getDeleteAllQuery
Overrides CollectionMappig because this mapping requires a DeleteAllQuery instead of a ModifyQuery.- Overrides:
getDeleteAllQuery
in classCollectionMapping
-
getFieldsForTranslationInAggregate
INTERNAL: Return source key fields for translation by an AggregateObjectMapping- Overrides:
getFieldsForTranslationInAggregate
in classForeignReferenceMapping
-
getSourceKeyFieldNames
PUBLIC: Return the source key field names associated with the mapping. These are in-order with the targetForeignKeyFieldNames. -
getSourceKeyFields
INTERNAL: Return the source key fields. -
getSourceKeysToTargetForeignKeys
INTERNAL: Return the source/target key fields. -
getTargetPrimaryKeyFields
INTERNAL: Primary keys of targetForeignKeyTable.- Overrides:
getTargetPrimaryKeyFields
in classCollectionMapping
-
getTargetForeignKeyFieldNames
INTERNAL: Return the target foreign key field names associated with the mapping. These are in-order with the targetForeignKeyFieldNames. -
getTargetForeignKeyFields
INTERNAL: Return the target foreign key fields. -
getTargetForeignKeysToSourceKeys
INTERNAL: Return the target/source key fields. -
hasInverseConstraintDependency
public boolean hasInverseConstraintDependency()INTERNAL: Return whether the mapping has any inverse constraint dependencies, such as foreign keys and join tables.- Overrides:
hasInverseConstraintDependency
in classDatabaseMapping
-
initialize
INTERNAL: Initialize the mapping.- Overrides:
initialize
in classCollectionMapping
- Throws:
DescriptorException
-
initializeAddTargetQuery
INTERNAL: Initialize addTargetQuery. -
createModifyRowForAddTargetQuery
INTERNAL: -
initializeChangeOrderTargetQuery
INTERNAL: Initialize changeOrderTargetQuery.- Overrides:
initializeChangeOrderTargetQuery
in classCollectionMapping
-
initializeDeleteAllQuery
Initialize the delete all query. This query is used to delete the collection of objects from the database. -
initializeTargetPrimaryKeyFields
protected void initializeTargetPrimaryKeyFields()INTERNAL: Initialize targetForeignKeyTable and initializeTargetPrimaryKeyFields. This method should be called after initializeTargetForeignKeysToSourceKeys method, which creates targetForeignKeyFields (guaranteed to be not empty in case requiresDataModificationEvents method returns true - the only case for the method to be called). -
initializeRemoveTargetQuery
INTERNAL: Initialize removeTargetQuery. -
initializeReferenceDescriptor
Initialize and set the descriptor for the referenced class in this mapping. Added here initialization of target foreign keys and target primary keys so that they are ready when CollectionMapping.initialize initializes listOrderField.- Overrides:
initializeReferenceDescriptor
in classForeignReferenceMapping
- Throws:
DescriptorException
-
initializeRemoveAllTargetsQuery
INTERNAL: Initialize removeAllTargetsQuery. -
initializeTargetForeignKeysToSourceKeys
Verify, munge, and hash the target foreign keys and source keys.- Throws:
DescriptorException
-
isOneToManyMapping
public boolean isOneToManyMapping()INTERNAL:- Overrides:
isOneToManyMapping
in classDatabaseMapping
-
isSourceKeySpecified
protected boolean isSourceKeySpecified()Return whether the source key is specified. It will be empty when #setTargetForeignKeyFieldName(String) is used. -
objectAddedDuringUpdate
protected void objectAddedDuringUpdate(ObjectLevelModifyQuery query, Object objectAdded, ObjectChangeSet changeSet, Map extraData) throws DatabaseException, OptimisticLockException INTERNAL: An object was added to the collection during an update, insert it if private.- Overrides:
objectAddedDuringUpdate
in classCollectionMapping
- Throws:
DatabaseException
OptimisticLockException
-
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:
objectRemovedDuringUpdate
in classCollectionMapping
- Throws:
DatabaseException
OptimisticLockException
-
performDataModificationEvent
public void performDataModificationEvent(Object[] event, AbstractSession session) throws DatabaseException, DescriptorException INTERNAL: Perform the commit event. This is used in the uow to delay data modifications.- Overrides:
performDataModificationEvent
in classDatabaseMapping
- Throws:
DatabaseException
DescriptorException
-
postInsert
INTERNAL: Insert the reference objects.- Overrides:
postInsert
in classCollectionMapping
- Throws:
DatabaseException
OptimisticLockException
-
postInitializeSourceAndTargetExpressions
public void postInitializeSourceAndTargetExpressions()INTERNAL: Post-initialize source and target expression fields created when a mapping's selectionCriteria is created early with only partly initialized fields.- Overrides:
postInitializeSourceAndTargetExpressions
in classDatabaseMapping
- See Also:
-
postUpdate
INTERNAL: Update the reference objects.- Overrides:
postUpdate
in classDatabaseMapping
- Throws:
DatabaseException
OptimisticLockException
-
buildBatchCriteria
INTERNAL: Return the selection criteria used to IN batch fetching.- Overrides:
buildBatchCriteria
in classForeignReferenceMapping
-
preDelete
INTERNAL: Delete the reference objects.- Overrides:
preDelete
in classDatabaseMapping
- Throws:
DatabaseException
OptimisticLockException
-
prepareCascadeLockingPolicy
public void prepareCascadeLockingPolicy()Prepare a cascade locking policy.- Overrides:
prepareCascadeLockingPolicy
in classDatabaseMapping
-
requiresDataModificationEvents
public boolean requiresDataModificationEvents()INTERNAL: Returns whether this mapping uses data modification events to complete its writes- See Also:
-
setCustomAddTargetQuery
PUBLIC: The default add target query for mapping can be overridden by specifying the new query. This query must set new value to target foreign key. -
setAddTargetSQLString
PUBLIC: -
setCustomRemoveTargetQuery
PUBLIC: The default remove target query for mapping can be overridden by specifying the new query. In case target foreign key references the source, this query must set target foreign key to null. -
setCustomRemoveAllTargetsQuery
PUBLIC: The default remove all targets query for mapping can be overridden by specifying the new query. This query must set all target foreign keys that reference the source to null. -
setDeleteAllSQLString
PUBLIC: Set the SQL string used by the mapping to delete the target objects. This allows the developer to override the SQL generated by TopLink with a custom SQL statement or procedure call. The arguments are translated from the fields of the source row, by replacing the field names marked by '#' with the values for those fields at execution time. A one-to-many mapping will only use this delete all optimization if the target objects can be deleted in a single SQL call. This is possible when the target objects are in a single table, do not using locking, do not contain other privately-owned parts, do not read subclasses, etc.Example: "delete from PHONE where OWNER_ID = #EMPLOYEE_ID"
- Overrides:
setDeleteAllSQLString
in classCollectionMapping
-
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:
setSessionName
in classCollectionMapping
-
setSourceKeyFieldNames
INTERNAL: Set the source key field names associated with the mapping. These must be in-order with the targetForeignKeyFieldNames. -
setSourceKeyFields
INTERNAL: Set the source key fields. -
setTargetForeignKeyFieldName
PUBLIC: Define the target foreign key relationship in the one-to-many mapping. This method can be used when the foreign and primary keys have only a single field each. (Use #addTargetForeignKeyFieldName(String, String) for "composite" keys.) Only the target foreign key field name is specified and the source (primary) key field is assumed to be the primary key of the source object. Because the target object's table must store a foreign key to the source table, the target object must map that foreign key, this is normally done through a one-to-one mapping back-reference. Other options include:- use a DirectToFieldMapping and maintain the foreign key fields directly in the target
- use a ManyToManyMapping
- use an AggregateCollectionMapping
- See Also:
-
setTargetForeignKeyFieldNames
public void setTargetForeignKeyFieldNames(String[] targetForeignKeyFieldNames, String[] sourceKeyFieldNames) PUBLIC: Define the target foreign key relationship in the one-to-many mapping. This method is used for composite target foreign key relationships. That is, the target object's table has multiple foreign key fields to the source object's (typically primary) key fields. Both the target foreign key field names and the corresponding source primary key field names must be specified. -
setTargetForeignKeyFieldNames
INTERNAL: Set the target key field names associated with the mapping. These must be in-order with the sourceKeyFieldNames. -
setTargetForeignKeyFields
INTERNAL: Set the target fields. -
setTargetForeignKeysToSourceKeys
protected void setTargetForeignKeysToSourceKeys(Map<DatabaseField, DatabaseField> targetForeignKeysToSourceKeys) INTERNAL: Set the target fields. -
shouldObjectModifyCascadeToParts
Return whether any process leading to object modification should also affect its parts. Used by write, insert, update, and delete.- Overrides:
shouldObjectModifyCascadeToParts
in classForeignReferenceMapping
-
shouldRemoveTargetQueryModifyTargetForeignKey
protected boolean shouldRemoveTargetQueryModifyTargetForeignKey()INTERNAL If it's not a map then target foreign key has been already modified (set to null). -
isCascadedLockingSupported
public boolean isCascadedLockingSupported()INTERNAL Return true if this mapping supports cascaded version optimistic locking.- Overrides:
isCascadedLockingSupported
in classDatabaseMapping
-
isJoiningSupported
public boolean isJoiningSupported()INTERNAL: Return if this mapping support joining.- Overrides:
isJoiningSupported
in classForeignReferenceMapping
-
updateTargetRowPostInsertSource
INTERNAL: Update target foreign keys after a new source was inserted. This follows following steps.- Throws:
DatabaseException
-
buildKeyRowForTargetUpdate
-
updateTargetForeignKeyPostUpdateSource_ObjectAdded
public void updateTargetForeignKeyPostUpdateSource_ObjectAdded(ObjectLevelModifyQuery query, Object objectAdded, Map extraData) throws DatabaseException INTERNAL: Update target foreign key after a target object was added to the source. 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 an update statement with above fields and values for target table.
- execute the statement.
- Throws:
DatabaseException
-
updateTargetForeignKeyPostUpdateSource_ObjectRemoved
public void updateTargetForeignKeyPostUpdateSource_ObjectRemoved(ObjectLevelModifyQuery query, Object objectRemoved) throws DatabaseException INTERNAL: Update target foreign key after a target object was removed from the source. 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 an update statement with above fields and values for target table.
- execute the statement.
- Throws:
DatabaseException
-
updateTargetRowPreDeleteSource
INTERNAL: Update target foreign key after a target object was removed from the source. 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 an update statement with above fields and values for target table.
- execute the statement.
- Throws:
DatabaseException
-
verifyDelete
INTERNAL: Used to verify whether the specified object is deleted or not.- Overrides:
verifyDelete
in classCollectionMapping
- Throws:
DatabaseException
-
shouldDeferInsert
public boolean shouldDeferInsert() -
setShouldDeferInsert
public void setShouldDeferInsert(boolean defer) -
getInsertObjectQuery
INTERNAL: Returns a clone of InsertObjectQuery from the ClassDescriptor's DescriptorQueryManager or a new one
-