Top Description Fields Constructors Methods
org.eclipse.persistence.mappings

public Class OneToManyMapping

extends CollectionMapping
implements RelationalMapping, MapComponentMapping
Class Inheritance
All Implemented Interfaces
org.eclipse.persistence.mappings.foundation.MapComponentMapping, org.eclipse.persistence.mappings.RelationalMapping
Known Direct Subclasses
org.eclipse.persistence.mappings.UnidirectionalOneToManyMapping
Imports
java.util.ArrayList, .Collection, .Enumeration, .HashMap, .HashSet, .Iterator, .List, .Map, .Set, .Vector, java.util.concurrent.CopyOnWriteArrayList, org.eclipse.persistence.descriptors.ClassDescriptor, org.eclipse.persistence.exceptions.ConversionException, .DatabaseException, .DescriptorException, .OptimisticLockException, org.eclipse.persistence.expressions.Expression, .ExpressionBuilder, org.eclipse.persistence.internal.descriptors.CascadeLockingPolicy, .ObjectBuilder, org.eclipse.persistence.internal.expressions.FieldExpression, .ParameterExpression, .SQLUpdateStatement, org.eclipse.persistence.internal.helper.ConversionManager, .DatabaseField, .DatabaseTable, org.eclipse.persistence.internal.identitymaps.CacheId, .CacheKey, org.eclipse.persistence.internal.queries.ContainerPolicy, org.eclipse.persistence.internal.sessions.AbstractRecord, .AbstractSession, .ObjectChangeSet, .UnitOfWorkImpl, org.eclipse.persistence.mappings.foundation.MapComponentMapping, org.eclipse.persistence.queries.DataModifyQuery, .DeleteAllQuery, .DeleteObjectQuery, .InsertObjectQuery, .ModifyQuery, .ObjectBuildingQuery, .ObjectLevelModifyQuery, .ObjectLevelReadQuery, .WriteObjectQuery, org.eclipse.persistence.sessions.DatabaseRecord

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.

Author
Sati
Since
TOPLink/Java 1.0

Field Summary

Modifier and TypeField and Description
protected DataModifyQuery
addTargetQuery

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
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 Boolean
protected transient List<Expression>
sourceExpressionsToPostInitialize

Keep a reference to the source and target expressions to post initialize when building a selection criteria early.

protected Vector<DatabaseField>
sourceKeyFields

The (typically primary) source key fields that are referenced by the targetForeignKeyFields.

protected transient Map<DatabaseField, DatabaseField>
sourceKeysToTargetForeignKeys

This maps the (primary) source key fields to the corresponding target foreign key fields.

protected transient List<Expression>
protected Vector<DatabaseField>
targetForeignKeyFields

The target foreign key fields that reference the sourceKeyFields.

protected transient Map<DatabaseField, DatabaseField>
targetForeignKeysToSourceKeys

This maps the target foreign key fields to the corresponding (primary) source key fields.

protected transient DatabaseTable
targetForeignKeyTable

All targetForeignKeyFields should have the same table.

protected transient List<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.

Inherited from org.eclipse.persistence.mappings.CollectionMapping:
changeOrderTargetQuerycontainerPolicydeleteAllQueryhasCustomDeleteAllQueryhasOrderByisListOrderFieldSupportedisSynchronizeOnMergelistOrderFieldmustDeleteReferenceObjectsOneByOneorderCorrectionType

Constructor Summary

AccessConstructor and Description
public
OneToManyMapping()

PUBLIC: Default constructor.

Method Summary

Modifier and TypeMethod and Description
public void
addTargetForeignKeyField(DatabaseField targetForeignKeyField, DatabaseField sourceKeyField)

Overrides org.eclipse.persistence.mappings.ForeignReferenceMapping.addTargetForeignKeyField.

INTERNAL: Add the associated fields to the appropriate collections.
public 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)

Overrides org.eclipse.persistence.mappings.ForeignReferenceMapping.buildBatchCriteria.

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 AbstractRecord
protected void
buildListOrderField()

Overrides org.eclipse.persistence.mappings.CollectionMapping.buildListOrderField.

INTERNAL: Verifies listOrderField's table: it must be the same table that contains all target foreign keys.
public Expression
buildSelectionCriteria()

This method would allow customers to get the potential selection criteria for a mapping prior to initialization.

public Object
private Vector<DatabaseField>
private Map<DatabaseField, DatabaseField>
public void
collectQueryParameters(Set<DatabaseField>
TODO
cacheFields
)

Overrides org.eclipse.persistence.mappings.CollectionMapping.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
public Object
createMapComponentFromRow(AbstractRecord dbRow, ObjectBuildingQuery query, CacheKey parentCacheKey, AbstractSession session, boolean isTargetProtected)

Implements org.eclipse.persistence.mappings.foundation.MapComponentMapping.createMapComponentFromRow.

INTERNAL Called when a DatabaseMapping is used to map the key in a collection.
protected AbstractRecord
protected void
deleteAll(DeleteObjectQuery query, AbstractSession session)

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 Object
protected Object
extractKeyFromTargetRow(AbstractRecord row, AbstractSession session)

Overrides org.eclipse.persistence.mappings.CollectionMapping.extractKeyFromTargetRow.

INTERNAL: Extract the source primary key value from the target row.
protected ModifyQuery
getDeleteAllQuery()

Overrides org.eclipse.persistence.mappings.CollectionMapping.getDeleteAllQuery.

Overrides CollectionMappig because this mapping requires a DeleteAllQuery instead of a ModifyQuery.
public Collection<E>
getFieldsForTranslationInAggregate()

Overrides org.eclipse.persistence.mappings.ForeignReferenceMapping.getFieldsForTranslationInAggregate.

INTERNAL: Return source key fields for translation by an AggregateObjectMapping
protected InsertObjectQuery
getInsertObjectQuery(AbstractSession session, ClassDescriptor desc)

INTERNAL: Returns a clone of InsertObjectQuery from the ClassDescriptor's DescriptorQueryManager or a new one

public Vector<E>
getSourceKeyFieldNames()

PUBLIC: Return the source key field names associated with the mapping.

public Vector<DatabaseField>
getSourceKeyFields()

INTERNAL: Return the source key fields.

public Map<DatabaseField, DatabaseField>
getSourceKeysToTargetForeignKeys()

INTERNAL: Return the source/target key fields.

public Vector<E>
getTargetForeignKeyFieldNames()

INTERNAL: Return the target foreign key field names associated with the mapping.

public Vector<DatabaseField>
getTargetForeignKeyFields()

INTERNAL: Return the target foreign key fields.

public Map<DatabaseField, DatabaseField>
getTargetForeignKeysToSourceKeys()

INTERNAL: Return the target/source key fields.

public List<DatabaseField>
public boolean
hasInverseConstraintDependency()

Overrides org.eclipse.persistence.mappings.DatabaseMapping.hasInverseConstraintDependency.

INTERNAL: Return whether the mapping has any inverse constraint dependencies, such as foreign keys and join tables.
public void
protected void
initializeAddTargetQuery(AbstractSession session)

INTERNAL: Initialize addTargetQuery.

protected void
protected void
initializeDeleteAllQuery(AbstractSession session)

Initialize the delete all query.

protected void
initializeReferenceDescriptor(AbstractSession session)

Overrides org.eclipse.persistence.mappings.ForeignReferenceMapping.initializeReferenceDescriptor.

Initialize and set the descriptor for the referenced class in this mapping.
protected void
initializeRemoveAllTargetsQuery(AbstractSession session)

INTERNAL: Initialize removeAllTargetsQuery.

protected void
initializeRemoveTargetQuery(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.

public boolean
isCascadedLockingSupported()

Overrides org.eclipse.persistence.mappings.DatabaseMapping.isCascadedLockingSupported.

INTERNAL Return true if this mapping supports cascaded version optimistic locking.
public boolean
isJoiningSupported()

Overrides org.eclipse.persistence.mappings.ForeignReferenceMapping.isJoiningSupported.

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

Return whether the source key is specified.

protected void
objectAddedDuringUpdate(ObjectLevelModifyQuery query, Object objectAdded, ObjectChangeSet changeSet, Map<K, V> extraData)

Overrides org.eclipse.persistence.mappings.CollectionMapping.objectAddedDuringUpdate.

INTERNAL: An object was added to the collection during an update, insert it if private.
protected void
objectRemovedDuringUpdate(ObjectLevelModifyQuery query, Object objectDeleted, Map<K, V> extraData)

Overrides org.eclipse.persistence.mappings.CollectionMapping.objectRemovedDuringUpdate.

INTERNAL: An object was removed to the collection during an update, delete it if private.
public void
public void
postInitializeSourceAndTargetExpressions()

Overrides org.eclipse.persistence.mappings.DatabaseMapping.postInitializeSourceAndTargetExpressions.

INTERNAL: Post-initialize source and target expression fields created when a mapping's selectionCriteria is created early with only partly initialized fields.
public void
postInsert(WriteObjectQuery query)

Overrides org.eclipse.persistence.mappings.CollectionMapping.postInsert.

INTERNAL: Insert the reference objects.
public void
postUpdate(WriteObjectQuery query)

Overrides org.eclipse.persistence.mappings.DatabaseMapping.postUpdate.

INTERNAL: Update the reference objects.
public void
preDelete(DeleteObjectQuery query)

Overrides org.eclipse.persistence.mappings.DatabaseMapping.preDelete.

INTERNAL: Delete the reference objects.
public void
public boolean
requiresDataModificationEvents()

INTERNAL: Returns whether this mapping uses data modification events to complete its writes

public void
setAddTargetSQLString(String sqlString)

PUBLIC:

public void
setCustomAddTargetQuery(DataModifyQuery query)

PUBLIC: The default add target query for mapping can be overridden by specifying the new query.

public void
setCustomRemoveAllTargetsQuery(DataModifyQuery query)

PUBLIC: The default remove all targets query for mapping can be overridden by specifying the new query.

public void
setCustomRemoveTargetQuery(DataModifyQuery query)

PUBLIC: The default remove target query for mapping can be overridden by specifying the new query.

public void
setDeleteAllSQLString(String sqlString)

Overrides org.eclipse.persistence.mappings.CollectionMapping.setDeleteAllSQLString.

PUBLIC: Set the SQL string used by the mapping to delete the target objects.
public void
setSessionName(String name)

Overrides org.eclipse.persistence.mappings.CollectionMapping.setSessionName.

PUBLIC: Set the name of the session to execute the mapping's queries under.
public void
setShouldDeferInsert(boolean defer)

public void
setSourceKeyFieldNames(Vector<E> fieldNames)

INTERNAL: Set the source key field names associated with the mapping.

public void
setSourceKeyFields(Vector<DatabaseField> sourceKeyFields)

INTERNAL: Set the source key fields.

public void
setTargetForeignKeyFieldName(String targetForeignKeyFieldName)

PUBLIC: Define the target foreign key relationship in the one-to-many mapping.

public void
setTargetForeignKeyFieldNames(String[] targetForeignKeyFieldNames, String[] sourceKeyFieldNames)

PUBLIC: Define the target foreign key relationship in the one-to-many mapping.

public void
setTargetForeignKeyFieldNames(Vector<E> fieldNames)

INTERNAL: Set the target key field names associated with the mapping.

public void
setTargetForeignKeyFields(Vector<DatabaseField> targetForeignKeyFields)

INTERNAL: Set the target fields.

protected void
setTargetForeignKeysToSourceKeys(Map<DatabaseField, DatabaseField> targetForeignKeysToSourceKeys)

INTERNAL: Set the target fields.

public boolean
protected boolean
shouldObjectModifyCascadeToParts(ObjectLevelModifyQuery query)

Overrides org.eclipse.persistence.mappings.ForeignReferenceMapping.shouldObjectModifyCascadeToParts.

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).

public void
updateTargetForeignKeyPostUpdateSource_ObjectAdded(ObjectLevelModifyQuery query, Object objectAdded, Map<K, V> extraData)

INTERNAL: Update target foreign key after a target object was added to the source.

public void
updateTargetForeignKeyPostUpdateSource_ObjectRemoved(ObjectLevelModifyQuery query, Object objectRemoved)

INTERNAL: Update target foreign key after a target object was removed from the source.

public void
updateTargetRowPostInsertSource(WriteObjectQuery query)

INTERNAL: Update target foreign keys after a new source was inserted.

public void
updateTargetRowPreDeleteSource(ObjectLevelModifyQuery query)

INTERNAL: Update target foreign key after a target object was removed from the source.

public boolean
verifyDelete(Object object, AbstractSession session)

Overrides org.eclipse.persistence.mappings.CollectionMapping.verifyDelete.

INTERNAL: Used to verify whether the specified object is deleted or not.
Inherited from org.eclipse.persistence.mappings.CollectionMapping:
addAggregateOrderByaddAscendingOrderingaddDescendingOrderingaddOrderBybuildBackupCloneForPartObjectbuildChangeRecordbuildCloneForPartObjectbuildContainerClonebuildCopybuildElementClonebuildElementUnitOfWorkClonebuildExpressionbuildReferencesPKListcalculateDeferredChangescascadeDiscoverAndPersistUnregisteredNewObjectscascadePerformRemoveIfRequiredcascadePerformRemovePrivateOwnedObjectFromChangeSetIfRequiredcascadeRegisterNewIfRequiredcompareCollectionsForChangecompareForChangecompareListscompareListsAndWritecompareObjectscompareObjectsAndWritecompareObjectsWithoutPrivateOwnedcompareObjectsWithPrivateOwnedconvertClassNamesToClassescopyElementexecuteBatchQueryextractResultFromBatchQueryfixRealObjectReferencesgetAdditionalFieldsBaseExpressiongetContainerPolicygetJoinCriteriagetListOrderFieldgetObjectCorrespondingTogetOrderByQueryKeyExpressionsgetOrderCorrectionTypegetRealCollectionAttributeValueFromObjectgetSelectionQueryContainerPolicyhasCustomDeleteAllQueryhasOrderByinitializeListOrderFieldinitializeListOrderFieldTableisAttributeValueInstantiatedOrChangedisChangeTrackingSupportedisCollectionMappingisListOrderFieldSupportedisMapKeyObjectRelationshipiterateOnElementiterateOnRealAttributeValueloadloadAllmergeChangesIntoObjectmergeIntoObjectmustDeleteReferenceObjectsOneByOneobjectOrderChangedDuringUpdateobjectUnchangedDuringUpdateobjectUnchangedDuringUpdatepostCalculateChangespostDeletepostInitializepostPrepareNestedBatchQuerypreInsertprepareTranslationRowpreUpdatereadPrivateOwnedForObjectrecordPrivateOwnedRemovalsreplaceValueHoldersInsetChangeListenersetContainerPolicysetCustomDeleteAllQuerysetDeleteAllCallsetDeleteAllQuerysetHasCustomDeleteAllQuerysetListOrderFieldsetListOrderFieldNamesetMustDeleteReferenceObjectsOneByOnesetOrderCorrectionTypesetSelectionQueryContainerPolicysetUseLazyInstantiationForIndirectCollectionshouldUseLazyInstantiationForIndirectCollectionshouldUseListOrderFieldTableExpressionsimpleAddToCollectionChangeRecordsimpleRemoveFromCollectionChangeRecordupdateChangeRecordupdateChangeRecordForSelfMergeupdateCollectionChangeRecorduseCollectionClassuseCollectionClassNameuseListClassNameuseMapClassuseMapClassuseMapClassNameuseSortedSetClassuseSortedSetClassNameuseSortedSetClassNameuseTransparentCollectionuseTransparentListuseTransparentMapuseTransparentSetvalidateBeforeInitializationvalueFromPKListvalueFromRowInternalWithJoinwriteChanges