EclipseLink 2.1.2, build 'v20101206-r8635' API Reference

org.eclipse.persistence.mappings
Class OneToManyMapping

java.lang.Object
  extended by org.eclipse.persistence.mappings.DatabaseMapping
      extended by org.eclipse.persistence.mappings.ForeignReferenceMapping
          extended by org.eclipse.persistence.mappings.CollectionMapping
              extended by org.eclipse.persistence.mappings.OneToManyMapping
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, ContainerMapping, MapComponentMapping, RelationalMapping
Direct Known Subclasses:
UnidirectionalOneToManyMapping

public class OneToManyMapping
extends CollectionMapping
implements RelationalMapping, MapComponentMapping

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.

See Also:
Serialized Form
Author:
Sati
Since:
TOPLink/Java 1.0

Nested Class Summary
 
Nested classes/interfaces inherited from class org.eclipse.persistence.mappings.DatabaseMapping
DatabaseMapping.WriteType
 
Field Summary
protected  DataModifyQuery addTargetQuery
          Query used to update a single target row setting its foreign key to point to the source.
protected  boolean hasCustomAddTargetQuery
           
protected  boolean hasCustomRemoveAllTargetsQuery
           
protected  boolean hasCustomRemoveTargetQuery
           
protected static java.lang.String ObjectAdded
           
protected static java.lang.String ObjectRemoved
           
protected static java.lang.String PostInsert
          Used for data modification events.
protected  DataModifyQuery removeAllTargetsQuery
          Query used to update all target rows changing target foreign key value from the one pointing to the source to null.
protected  DataModifyQuery removeTargetQuery
          Query used to update a single target row changing its foreign key value from the one pointing to the source to null.
protected  java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> sourceKeyFields
          The (typically primary) source key fields that are referenced by the targetForeignKeyFields.
protected  java.util.Map<org.eclipse.persistence.internal.helper.DatabaseField,org.eclipse.persistence.internal.helper.DatabaseField> sourceKeysToTargetForeignKeys
          This maps the (primary) source key fields to the corresponding target foreign key fields.
protected  java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> targetForeignKeyFields
          The target foreign key fields that reference the sourceKeyFields.
protected  java.util.Map<org.eclipse.persistence.internal.helper.DatabaseField,org.eclipse.persistence.internal.helper.DatabaseField> targetForeignKeysToSourceKeys
          This maps the target foreign key fields to the corresponding (primary) source key fields.
protected  org.eclipse.persistence.internal.helper.DatabaseTable targetForeignKeyTable
          All targetForeignKeyFields should have the same table.
protected  java.util.List<org.eclipse.persistence.internal.helper.DatabaseField> 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.
 
Fields inherited from class org.eclipse.persistence.mappings.CollectionMapping
changeOrderTargetQuery, containerPolicy, deleteAllQuery, hasCustomDeleteAllQuery, hasOrderBy, isListOrderFieldSupported, listOrderField, orderCorrectionType
 
Fields inherited from class org.eclipse.persistence.mappings.ForeignReferenceMapping
batchFetchType, cascadeDetach, cascadeMerge, cascadePersist, cascadeRefresh, cascadeRemove, forceInitializationOfSelectionCriteria, hasCustomSelectionQuery, indirectionPolicy, INNER_JOIN, isPrivateOwned, joinFetch, NONE, OUTER_JOIN, 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, isJPAId, isLazy, isMapKeyMapping, isOptional, isPrimaryKeyMapping, isReadOnly, isRemotelyInitialized, mapsIdValue, NO_FIELDS, NO_WEIGHT, properties, weight, WEIGHT_1
 
Constructor Summary
OneToManyMapping()
          PUBLIC: Default constructor.
 
Method Summary
 void addTargetForeignKeyField(org.eclipse.persistence.internal.helper.DatabaseField targetForeignKeyField, org.eclipse.persistence.internal.helper.DatabaseField sourceKeyField)
          INTERNAL: Add the associated fields to the appropriate collections.
 void addTargetForeignKeyFieldName(java.lang.String targetForeignKeyFieldName, java.lang.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 buildDefaultSelectionCriteriaAndAddFieldsToQuery()
          The selection criteria are created with target foreign keys and source "primary" keys.
protected  org.eclipse.persistence.internal.sessions.AbstractRecord buildKeyRowForTargetUpdate(ObjectLevelModifyQuery query)
           
protected  void buildListOrderField()
          INTERNAL: Verifies listOrderField's table: it must be the same table that contains all target foreign keys.
 Expression buildSelectionCriteria()
          This method would allow customers to get the potential selection criteria for a mapping prior to initialization.
 java.lang.Object clone()
          INTERNAL: Clone the appropriate attributes.
 java.lang.Object createMapComponentFromRow(org.eclipse.persistence.internal.sessions.AbstractRecord dbRow, ObjectBuildingQuery query, org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL Called when a DatabaseMapping is used to map the key in a collection.
protected  org.eclipse.persistence.internal.sessions.AbstractRecord createModifyRowForAddTargetQuery()
          INTERNAL:
protected  void deleteAll(DeleteObjectQuery query)
          Delete all the reference objects with a single query.
protected  void deleteReferenceObjectsLeftOnDatabase(DeleteObjectQuery query)
          This method will make sure that all the records privately owned by this mapping are actually removed.
protected  java.lang.Object extractBatchKeyFromRow(org.eclipse.persistence.internal.sessions.AbstractRecord row, org.eclipse.persistence.internal.sessions.AbstractSession session)
          Extract the key field values from the specified row.
protected  java.lang.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 target row.
 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 the source key fields.
 java.util.Map<org.eclipse.persistence.internal.helper.DatabaseField,org.eclipse.persistence.internal.helper.DatabaseField> getSourceKeysToTargetForeignKeys()
          INTERNAL: Return the source/target key fields.
 java.util.Vector getTargetForeignKeyFieldNames()
          INTERNAL: Return the target foreign key field names associated with the mapping.
 java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> getTargetForeignKeyFields()
          INTERNAL: Return the target foreign key fields.
 java.util.Map<org.eclipse.persistence.internal.helper.DatabaseField,org.eclipse.persistence.internal.helper.DatabaseField> getTargetForeignKeysToSourceKeys()
          INTERNAL: Return the target/source key fields.
 java.util.Map getTargetForeignKeyToSourceKeys()
          INTERNAL: Maintain for backward compatibility.
 java.util.List<org.eclipse.persistence.internal.helper.DatabaseField> getTargetPrimaryKeyFields()
          INTERNAL: Primary keys of targetForeignKeyTable.
 boolean hasInverseConstraintDependency()
          INTERNAL: Return whether the mapping has any inverse constraint dependencies, such as foreign keys and join tables.
 void initialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL: Initialize the mapping.
protected  void initializeAddTargetQuery(org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL: Initialize addTargetQuery.
protected  void initializeChangeOrderTargetQuery(org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL: Initialize changeOrderTargetQuery.
protected  void initializeDeleteAllQuery()
          Initialize the delete all query.
protected  void initializeReferenceDescriptor(org.eclipse.persistence.internal.sessions.AbstractSession session)
          Initialize and set the descriptor for the referenced class in this mapping.
protected  void initializeRemoveAllTargetsQuery(org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL: Initialize removeAllTargetsQuery.
protected  void initializeRemoveTargetQuery(org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL: Initialize removeTargetQuery.
protected  void initializeTargetForeignKeysToSourceKeys()
          Verify, munge, and hash the target foreign keys and source keys.
protected  void initializeTargetPrimaryKeyFields()
          INTERNAL: Initialize targetForeignKeyTable and initializeTargetPrimaryKeyFields.
 boolean isCascadedLockingSupported()
          INTERNAL Return true if this mapping supports cascaded version optimistic locking.
 boolean isJoiningSupported()
          INTERNAL: Return if this mapping support joining.
 boolean isOneToManyMapping()
          INTERNAL:
 boolean isRelationalMapping()
          INTERNAL:
protected  boolean isSourceKeySpecified()
          Return whether the source key is specified.
protected  void objectAddedDuringUpdate(ObjectLevelModifyQuery query, java.lang.Object objectAdded, org.eclipse.persistence.internal.sessions.ObjectChangeSet changeSet, java.util.Map extraData)
          INTERNAL: An object was added to the collection during an update, insert it if private.
protected  void objectRemovedDuringUpdate(ObjectLevelModifyQuery query, java.lang.Object objectDeleted, java.util.Map extraData)
          INTERNAL: An object was removed to the collection during an update, delete it if private.
 void performDataModificationEvent(java.lang.Object[] event, org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL: Perform the commit event.
 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 prepareCascadeLockingPolicy()
          Prepare a cascade locking policy.
 boolean requiresDataModificationEvents()
          INTERNAL: Returns whether this mapping uses data modification events to complete its writes
 void setAddTargetSQLString(java.lang.String sqlString)
          PUBLIC:
 void setCustomAddTargetQuery(DataModifyQuery query)
          PUBLIC: The default add target query for mapping can be overridden by specifying the new query.
 void setCustomRemoveAllTargetsQuery(DataModifyQuery query)
          PUBLIC: The default remove all targets query for mapping can be overridden by specifying the new query.
 void setCustomRemoveTargetQuery(DataModifyQuery query)
          PUBLIC: The default remove target query for mapping can be overridden by specifying the new query.
 void setDeleteAllSQLString(java.lang.String sqlString)
          PUBLIC: Set the SQL string used by the mapping to delete the target objects.
 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)
          INTERNAL: 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 key fields.
 void setTargetForeignKeyFieldName(java.lang.String targetForeignKeyFieldName)
          PUBLIC: Define the target foreign key relationship in the one-to-many mapping.
 void setTargetForeignKeyFieldNames(java.lang.String[] targetForeignKeyFieldNames, java.lang.String[] sourceKeyFieldNames)
          PUBLIC: Define the target foreign key relationship in the one-to-many mapping.
 void setTargetForeignKeyFieldNames(java.util.Vector fieldNames)
          INTERNAL: Set the target key field names associated with the mapping.
 void setTargetForeignKeyFields(java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> targetForeignKeyFields)
          INTERNAL: Set the target fields.
protected  void setTargetForeignKeysToSourceKeys(java.util.Map<org.eclipse.persistence.internal.helper.DatabaseField,org.eclipse.persistence.internal.helper.DatabaseField> targetForeignKeysToSourceKeys)
          INTERNAL: Set the target fields.
protected  boolean shouldObjectModifyCascadeToParts(ObjectLevelModifyQuery query)
          Return whether any process leading to object modification should also affect its parts.
protected  boolean shouldRemoveTargetQueryModifyTargetForeignKey()
          INTERNAL If it's not a map then target foreign key has been already modified (set to null).
 void updateTargetForeignKeyPostUpdateSource_ObjectAdded(ObjectLevelModifyQuery query, java.lang.Object objectAdded, java.util.Map extraData)
          INTERNAL: Update target foreign key after a target object was added to the source.
 void updateTargetForeignKeyPostUpdateSource_ObjectRemoved(ObjectLevelModifyQuery query, java.lang.Object objectRemoved)
          INTERNAL: Update target foreign key after a target object was removed from the source.
 void updateTargetRowPostInsertSource(WriteObjectQuery query)
          INTERNAL: Update target foreign keys after a new source was inserted.
 void updateTargetRowPreDeleteSource(ObjectLevelModifyQuery query)
          INTERNAL: Update target foreign key after a target object was removed from the source.
 boolean verifyDelete(java.lang.Object object, org.eclipse.persistence.internal.sessions.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, buildCopy, buildElementClone, buildReferencesPKList, calculateDeferredChanges, cascadeDiscoverAndPersistUnregisteredNewObjects, cascadeMerge, cascadePerformRemoveIfRequired, cascadePerformRemovePrivateOwnedObjectFromChangeSetIfRequired, cascadeRegisterNewIfRequired, compareCollectionsForChange, compareForChange, compareLists, compareListsAndWrite, compareObjects, compareObjectsAndWrite, compareObjectsWithoutPrivateOwned, compareObjectsWithPrivateOwned, convertClassNamesToClasses, executeBatchQuery, extractResultFromBatchQuery, fixRealObjectReferences, getAdditionalFieldsBaseExpression, getContainerPolicy, getDeleteAllQuery, getJoinCriteria, getListOrderField, getObjectCorrespondingTo, getOrderByQueryKeyExpressions, getOrderCorrectionType, getRealCollectionAttributeValueFromObject, getSelectionQueryContainerPolicy, hasCustomDeleteAllQuery, hasOrderBy, initializeListOrderField, initializeListOrderFieldTable, isAttributeValueInstantiatedOrChanged, isChangeTrackingSupported, isCollectionMapping, isListOrderFieldSupported, isMapKeyObjectRelationship, iterateOnElement, iterateOnRealAttributeValue, mergeChangesIntoObject, mergeIntoObject, mustDeleteReferenceObjectsOneByOne, objectOrderChangedDuringUpdate, objectUnchangedDuringUpdate, objectUnchangedDuringUpdate, postCalculateChanges, postDelete, postInitialize, postPrepareNestedBatchQuery, preInsert, prepareTranslationRow, preUpdate, readPrivateOwnedForObject, recordPrivateOwnedRemovals, replaceValueHoldersIn, setChangeListener, setContainerPolicy, setCustomDeleteAllQuery, setDeleteAllCall, setDeleteAllQuery, setHasCustomDeleteAllQuery, setListOrderField, setListOrderFieldName, setOrderCorrectionType, setSelectionQueryContainerPolicy, shouldUseListOrderFieldTableExpression, simpleAddToCollectionChangeRecord, simpleRemoveFromCollectionChangeRecord, updateChangeRecord, updateCollectionChangeRecord, useCollectionClass, useCollectionClassName, useListClassName, useMapClass, useMapClass, useMapClassName, useSortedSetClass, useSortedSetClassName, useSortedSetClassName, useTransparentCollection, useTransparentList, useTransparentMap, useTransparentSet, validateBeforeInitialization, valueFromPKList, valueFromRowInternalWithJoin
 
Methods inherited from class org.eclipse.persistence.mappings.ForeignReferenceMapping
batchedValueFromRow, buildBackupClone, buildClone, buildCloneFromRow, checkCacheForBatchKey, createUnitOfWorkValueHolder, dontDoMerge, dontUseBatchReading, dontUseIndirection, extendPessimisticLockScopeInSourceQuery, extendPessimisticLockScopeInTargetQuery, fixObjectReferences, getAttributeValueFromObject, getAttributeValueWithClonedValueHolders, getBatchFetchType, getExtendPessimisticLockScopeDedicatedQuery, getIndirectionPolicy, getJoinFetch, getRealAttributeValueFromAttribute, getReferenceClass, getReferenceClassName, getReferenceDescriptor, getRelationshipPartner, getRelationshipPartnerAttributeName, getSelectionCriteria, getSelectionQuery, getTempSession, getValueFromRemoteValueHolder, hasCustomSelectionQuery, initializeSelectionQuery, instantiateAttribute, isAttributeValueInstantiated, isCascadeDetach, isCascadeMerge, isCascadePersist, isCascadeRefresh, isCascadeRemove, isExtendingPessimisticLockScope, isForeignReferenceMapping, isInnerJoinFetched, isJoinFetched, isLazy, isLockableMapping, isOuterJoinFetched, isPrivateOwned, iterate, mergeRemoteValueHolder, preInitialize, prepareHistoricalQuery, prepareNestedBatchQuery, prepareNestedJoinQueryClone, prepareNestedJoins, privateOwnedRelationship, remoteInitialization, requiresTransientWeavedFields, setBatchFetchType, setCascadeAll, setCascadeDetach, setCascadeMerge, setCascadePersist, setCascadeRefresh, setCascadeRemove, setCustomSelectionQuery, setForceInitializationOfSelectionCriteria, setHasCustomSelectionQuery, setIndirectionPolicy, setIsPrivateOwned, setJoinFetch, setRealAttributeValueInObject, setReferenceClass, setReferenceClassName, setReferenceDescriptor, setRelationshipPartner, setRelationshipPartnerAttributeName, setRequiresTransientWeavedFields, setSelectionCall, setSelectionCriteria, setSelectionQuery, setSelectionSQLString, setShouldExtendPessimisticLockScope, setTempSession, setUsesBatchReading, setUsesIndirection, shouldExtendPessimisticLockScope, shouldExtendPessimisticLockScopeInDedicatedQuery, shouldExtendPessimisticLockScopeInSourceQuery, shouldExtendPessimisticLockScopeInTargetQuery, shouldForceInitializationOfSelectionCriteria, shouldInitializeSelectionCriteria, shouldMergeCascadeParts, shouldMergeCascadeReference, shouldUseBatchReading, shouldUseValueFromRowWithJoin, trimRowForJoin, trimRowForJoin, useBasicIndirection, useBatchReading, useContainerIndirection, useInnerJoinFetch, useOuterJoinFetch, usesIndirection, useWeavedIndirection, valueFromRow, valueFromRowInternal
 
Methods inherited from class org.eclipse.persistence.mappings.DatabaseMapping
buildExpression, buildObjectJoinExpression, buildObjectJoinExpression, buildShallowOriginalFromRow, cloneFields, collectFields, derivesId, earlyPreDelete, extractNestedExpressions, getAttributeAccessor, getAttributeClassification, getAttributeName, getDerivedIdMapping, getDescriptor, getField, getFieldClassification, getFields, getGetMethodName, getMapsIdValue, getProperties, getProperty, getRealAttributeValueFromObject, getSelectFields, getSelectTables, getSetMethodName, getWeight, hasConstraintDependency, hasDependency, hasMapsIdValue, hasRootExpressionThatShouldUseOuterJoin, isAbstractCompositeCollectionMapping, isAbstractCompositeDirectCollectionMapping, isAbstractCompositeObjectMapping, isAbstractDirectMapping, isAggregateCollectionMapping, isAggregateMapping, isAggregateObjectMapping, isCandidateForPrivateOwnedRemoval, isCloningRequired, isDatabaseMapping, isDirectCollectionMapping, isDirectMapMapping, isDirectToFieldMapping, isDirectToXMLTypeMapping, isEISMapping, isJPAId, isManyToManyMapping, isManyToOneMapping, isMapKeyMapping, isNestedTableMapping, isObjectReferenceMapping, isOneToOneMapping, isOptional, isOwned, isPrimaryKeyMapping, isReadOnly, isReferenceMapping, isRemotelyInitialized, isStructureMapping, isTransformationMapping, isUnidirectionalOneToManyMapping, isUsingMethodAccess, isVariableOneToOneMapping, isWriteOnly, isXMLMapping, postCalculateChangesOnDeleted, readFromResultSetIntoObject, readFromRowIntoObject, readOnly, readWrite, rehashFieldDependancies, remotelyInitialized, setAttributeAccessor, setAttributeName, setAttributeValueInObject, setDerivedIdMapping, setDerivesId, setDescriptor, setFields, setGetMethodName, setIsJPAId, setIsLazy, setIsMapKeyMapping, setIsOptional, setIsPrimaryKeyMapping, setIsReadOnly, setMapsIdValue, setProperties, setProperty, setSetMethodName, setWeight, toString, validateAfterInitialization, valueFromObject, valueFromResultSet, valueFromRow, writeFromAttributeIntoRow, writeFromObjectIntoRow, writeFromObjectIntoRowForShallowInsert, writeFromObjectIntoRowForShallowInsertWithChangeRecord, writeFromObjectIntoRowForUpdate, writeFromObjectIntoRowForWhereClause, writeFromObjectIntoRowWithChangeRecord, writeInsertFieldsIntoRow, writeUpdateFieldsIntoRow
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PostInsert

protected static final java.lang.String PostInsert
Used for data modification events.

See Also:
Constant Field Values

ObjectRemoved

protected static final java.lang.String ObjectRemoved
See Also:
Constant Field Values

ObjectAdded

protected static final java.lang.String ObjectAdded
See Also:
Constant Field Values

targetForeignKeyFields

protected transient java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> targetForeignKeyFields
The target foreign key fields that reference the sourceKeyFields.


sourceKeyFields

protected transient java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> sourceKeyFields
The (typically primary) source key fields that are referenced by the targetForeignKeyFields.


targetForeignKeysToSourceKeys

protected transient java.util.Map<org.eclipse.persistence.internal.helper.DatabaseField,org.eclipse.persistence.internal.helper.DatabaseField> targetForeignKeysToSourceKeys
This maps the target foreign key fields to the corresponding (primary) source key fields.


sourceKeysToTargetForeignKeys

protected transient java.util.Map<org.eclipse.persistence.internal.helper.DatabaseField,org.eclipse.persistence.internal.helper.DatabaseField> sourceKeysToTargetForeignKeys
This maps the (primary) source key fields to the corresponding target foreign key fields.


targetForeignKeyTable

protected transient org.eclipse.persistence.internal.helper.DatabaseTable targetForeignKeyTable
All targetForeignKeyFields should have the same table. Used only in case data modification events required.


targetPrimaryKeyFields

protected transient java.util.List<org.eclipse.persistence.internal.helper.DatabaseField> 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.


addTargetQuery

protected transient DataModifyQuery 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 transient boolean hasCustomAddTargetQuery

removeTargetQuery

protected transient DataModifyQuery 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 transient boolean hasCustomRemoveTargetQuery

removeAllTargetsQuery

protected transient DataModifyQuery 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 transient boolean hasCustomRemoveAllTargetsQuery
Constructor Detail

OneToManyMapping

public OneToManyMapping()
PUBLIC: Default constructor.

Method Detail

isRelationalMapping

public boolean isRelationalMapping()
INTERNAL:

Overrides:
isRelationalMapping in class DatabaseMapping

addTargetForeignKeyField

public void addTargetForeignKeyField(org.eclipse.persistence.internal.helper.DatabaseField targetForeignKeyField,
                                     org.eclipse.persistence.internal.helper.DatabaseField sourceKeyField)
INTERNAL: Add the associated fields to the appropriate collections.


addTargetForeignKeyFieldName

public void addTargetForeignKeyFieldName(java.lang.String targetForeignKeyFieldName,
                                         java.lang.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:

See Also:
DirectToFieldMapping, ManyToManyMapping, AggregateCollectionMapping

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 class CollectionMapping

buildDefaultSelectionCriteriaAndAddFieldsToQuery

protected Expression 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

public Expression 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.


clone

public java.lang.Object clone()
INTERNAL: Clone the appropriate attributes.

Overrides:
clone in class CollectionMapping

createMapComponentFromRow

public java.lang.Object createMapComponentFromRow(org.eclipse.persistence.internal.sessions.AbstractRecord dbRow,
                                                  ObjectBuildingQuery query,
                                                  org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL Called when a DatabaseMapping is used to map the key in a collection. Returns the key.

Specified by:
createMapComponentFromRow in interface MapComponentMapping

deleteAll

protected void deleteAll(DeleteObjectQuery query)
                  throws DatabaseException
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.

Throws:
DatabaseException
OptimisticLockException

extractKeyFromTargetRow

protected java.lang.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 target row. Used for batch reading, most following same order and fields as in the mapping.

Overrides:
extractKeyFromTargetRow in class CollectionMapping

extractBatchKeyFromRow

protected java.lang.Object extractBatchKeyFromRow(org.eclipse.persistence.internal.sessions.AbstractRecord row,
                                                  org.eclipse.persistence.internal.sessions.AbstractSession session)
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 class ForeignReferenceMapping

getSourceKeyFieldNames

public java.util.Vector getSourceKeyFieldNames()
PUBLIC: Return the source key field names associated with the mapping. These are in-order with the targetForeignKeyFieldNames.


getSourceKeyFields

public java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> getSourceKeyFields()
INTERNAL: Return the source key fields.


getSourceKeysToTargetForeignKeys

public java.util.Map<org.eclipse.persistence.internal.helper.DatabaseField,org.eclipse.persistence.internal.helper.DatabaseField> getSourceKeysToTargetForeignKeys()
INTERNAL: Return the source/target key fields.


getTargetPrimaryKeyFields

public java.util.List<org.eclipse.persistence.internal.helper.DatabaseField> getTargetPrimaryKeyFields()
INTERNAL: Primary keys of targetForeignKeyTable.

Overrides:
getTargetPrimaryKeyFields in class CollectionMapping

getTargetForeignKeyFieldNames

public java.util.Vector getTargetForeignKeyFieldNames()
INTERNAL: Return the target foreign key field names associated with the mapping. These are in-order with the targetForeignKeyFieldNames.


getTargetForeignKeyFields

public java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> getTargetForeignKeyFields()
INTERNAL: Return the target foreign key fields.


getTargetForeignKeysToSourceKeys

public java.util.Map<org.eclipse.persistence.internal.helper.DatabaseField,org.eclipse.persistence.internal.helper.DatabaseField> getTargetForeignKeysToSourceKeys()
INTERNAL: Return the target/source key fields.


getTargetForeignKeyToSourceKeys

public java.util.Map getTargetForeignKeyToSourceKeys()
INTERNAL: Maintain for backward compatibility. This is 'public' so StoredProcedureGenerator does not have to use the custom query expressions.


hasInverseConstraintDependency

public boolean hasInverseConstraintDependency()
INTERNAL: Return whether the mapping has any inverse constraint dependencies, such as foreign keys and join tables.

Overrides:
hasInverseConstraintDependency in class DatabaseMapping

initialize

public void initialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
                throws DescriptorException
INTERNAL: Initialize the mapping.

Overrides:
initialize in class CollectionMapping
Throws:
DescriptorException

initializeAddTargetQuery

protected void initializeAddTargetQuery(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: Initialize addTargetQuery.


createModifyRowForAddTargetQuery

protected org.eclipse.persistence.internal.sessions.AbstractRecord createModifyRowForAddTargetQuery()
INTERNAL:


initializeChangeOrderTargetQuery

protected void initializeChangeOrderTargetQuery(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: Initialize changeOrderTargetQuery.

Overrides:
initializeChangeOrderTargetQuery in class CollectionMapping

initializeDeleteAllQuery

protected void 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

protected void initializeRemoveTargetQuery(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: Initialize removeTargetQuery.


initializeReferenceDescriptor

protected void initializeReferenceDescriptor(org.eclipse.persistence.internal.sessions.AbstractSession session)
                                      throws DescriptorException
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 class ForeignReferenceMapping
Throws:
DescriptorException

initializeRemoveAllTargetsQuery

protected void initializeRemoveAllTargetsQuery(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: Initialize removeAllTargetsQuery.


initializeTargetForeignKeysToSourceKeys

protected void initializeTargetForeignKeysToSourceKeys()
                                                throws DescriptorException
Verify, munge, and hash the target foreign keys and source keys.

Throws:
DescriptorException

isOneToManyMapping

public boolean isOneToManyMapping()
INTERNAL:

Overrides:
isOneToManyMapping in class DatabaseMapping

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,
                                       java.lang.Object objectAdded,
                                       org.eclipse.persistence.internal.sessions.ObjectChangeSet changeSet,
                                       java.util.Map extraData)
                                throws DatabaseException,
                                       OptimisticLockException
INTERNAL: An object was added to the collection during an update, insert it if private.

Overrides:
objectAddedDuringUpdate in class CollectionMapping
Throws:
DatabaseException
OptimisticLockException

objectRemovedDuringUpdate

protected void objectRemovedDuringUpdate(ObjectLevelModifyQuery query,
                                         java.lang.Object objectDeleted,
                                         java.util.Map extraData)
                                  throws DatabaseException,
                                         OptimisticLockException
INTERNAL: An object was removed to the collection during an update, delete it if private.

Overrides:
objectRemovedDuringUpdate in class CollectionMapping
Throws:
DatabaseException
OptimisticLockException

performDataModificationEvent

public void performDataModificationEvent(java.lang.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:
performDataModificationEvent in class DatabaseMapping
Throws:
DatabaseException
DescriptorException

postInsert

public void postInsert(WriteObjectQuery query)
                throws DatabaseException,
                       OptimisticLockException
INTERNAL: Insert the reference objects.

Overrides:
postInsert in class CollectionMapping
Throws:
DatabaseException
OptimisticLockException

postUpdate

public void postUpdate(WriteObjectQuery query)
                throws DatabaseException,
                       OptimisticLockException
INTERNAL: Update the reference objects.

Overrides:
postUpdate in class DatabaseMapping
Throws:
DatabaseException
OptimisticLockException

buildBatchCriteria

protected Expression buildBatchCriteria(ExpressionBuilder builder,
                                        ObjectLevelReadQuery query)
INTERNAL: Return the selection criteria used to IN batch fetching.

Overrides:
buildBatchCriteria in class ForeignReferenceMapping

preDelete

public void preDelete(DeleteObjectQuery query)
               throws DatabaseException,
                      OptimisticLockException
INTERNAL: Delete the reference objects.

Overrides:
preDelete in class DatabaseMapping
Throws:
DatabaseException
OptimisticLockException

prepareCascadeLockingPolicy

public void prepareCascadeLockingPolicy()
Prepare a cascade locking policy.

Overrides:
prepareCascadeLockingPolicy in class DatabaseMapping

requiresDataModificationEvents

public boolean requiresDataModificationEvents()
INTERNAL: Returns whether this mapping uses data modification events to complete its writes

Returns:
See Also:
UnidirectionalOneToManyMapping

setCustomAddTargetQuery

public void setCustomAddTargetQuery(DataModifyQuery query)
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 void setAddTargetSQLString(java.lang.String sqlString)
PUBLIC:


setCustomRemoveTargetQuery

public void setCustomRemoveTargetQuery(DataModifyQuery query)
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 void setCustomRemoveAllTargetsQuery(DataModifyQuery query)
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 void setDeleteAllSQLString(java.lang.String sqlString)
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 class CollectionMapping

setSessionName

public void setSessionName(java.lang.String name)
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 class CollectionMapping

setSourceKeyFieldNames

public void setSourceKeyFieldNames(java.util.Vector fieldNames)
INTERNAL: Set the source key field names associated with the mapping. These must be in-order with the targetForeignKeyFieldNames.


setSourceKeyFields

public void setSourceKeyFields(java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> sourceKeyFields)
INTERNAL: Set the source key fields.


setTargetForeignKeyFieldName

public void setTargetForeignKeyFieldName(java.lang.String targetForeignKeyFieldName)
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:

See Also:
DirectToFieldMapping, ManyToManyMapping, AggregateCollectionMapping

setTargetForeignKeyFieldNames

public void setTargetForeignKeyFieldNames(java.lang.String[] targetForeignKeyFieldNames,
                                          java.lang.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

public void setTargetForeignKeyFieldNames(java.util.Vector fieldNames)
INTERNAL: Set the target key field names associated with the mapping. These must be in-order with the sourceKeyFieldNames.


setTargetForeignKeyFields

public void setTargetForeignKeyFields(java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> targetForeignKeyFields)
INTERNAL: Set the target fields.


setTargetForeignKeysToSourceKeys

protected void setTargetForeignKeysToSourceKeys(java.util.Map<org.eclipse.persistence.internal.helper.DatabaseField,org.eclipse.persistence.internal.helper.DatabaseField> targetForeignKeysToSourceKeys)
INTERNAL: Set the target fields.


shouldObjectModifyCascadeToParts

protected boolean shouldObjectModifyCascadeToParts(ObjectLevelModifyQuery query)
Return whether any process leading to object modification should also affect its parts. Used by write, insert, update, and delete.

Overrides:
shouldObjectModifyCascadeToParts in class ForeignReferenceMapping

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 class DatabaseMapping

isJoiningSupported

public boolean isJoiningSupported()
INTERNAL: Return if this mapping support joining.

Overrides:
isJoiningSupported in class ForeignReferenceMapping

updateTargetRowPostInsertSource

public void updateTargetRowPostInsertSource(WriteObjectQuery query)
                                     throws DatabaseException
INTERNAL: Update target foreign keys after a new source was inserted. This follows following steps.

Throws:
DatabaseException

buildKeyRowForTargetUpdate

protected org.eclipse.persistence.internal.sessions.AbstractRecord buildKeyRowForTargetUpdate(ObjectLevelModifyQuery query)

updateTargetForeignKeyPostUpdateSource_ObjectAdded

public void updateTargetForeignKeyPostUpdateSource_ObjectAdded(ObjectLevelModifyQuery query,
                                                               java.lang.Object objectAdded,
                                                               java.util.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,
                                                                 java.lang.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

public void updateTargetRowPreDeleteSource(ObjectLevelModifyQuery query)
                                    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

verifyDelete

public boolean verifyDelete(java.lang.Object object,
                            org.eclipse.persistence.internal.sessions.AbstractSession session)
                     throws DatabaseException
INTERNAL: Used to verify whether the specified object is deleted or not.

Overrides:
verifyDelete in class CollectionMapping
Throws:
DatabaseException

EclipseLink 2.1.2, build 'v20101206-r8635' API Reference