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.
DatabaseMapping.WriteType
INNER_JOIN, NONE, OUTER_JOIN, QUERY_BATCH_PARAMETER
Constructor and Description |
---|
OneToManyMapping()
PUBLIC:
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
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.
|
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.
|
void |
collectQueryParameters(java.util.Set<org.eclipse.persistence.internal.helper.DatabaseField> cacheFields)
INTERNAL:
This method is used to store the FK fields that can be cached that correspond to noncacheable mappings
the FK field values will be used to re-issue the query when cloning the shared cache entity
|
java.lang.Object |
createMapComponentFromRow(org.eclipse.persistence.internal.sessions.AbstractRecord dbRow,
ObjectBuildingQuery query,
org.eclipse.persistence.internal.identitymaps.CacheKey parentCacheKey,
org.eclipse.persistence.internal.sessions.AbstractSession session,
boolean isTargetProtected)
INTERNAL
Called when a DatabaseMapping is used to map the key in a collection.
|
java.util.Collection |
getFieldsForTranslationInAggregate()
INTERNAL:
Return source key fields for translation by an AggregateObjectMapping
|
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.
|
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:
|
void |
performDataModificationEvent(java.lang.Object[] event,
org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL:
Perform the commit event.
|
void |
postInitializeSourceAndTargetExpressions()
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 |
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.
|
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.
|
addAggregateOrderBy, addAscendingOrdering, addDescendingOrdering, addOrderBy, buildBackupCloneForPartObject, buildChangeRecord, buildCloneForPartObject, buildContainerClone, buildCopy, buildElementClone, buildElementUnitOfWorkClone, buildExpression, buildReferencesPKList, calculateDeferredChanges, cascadeDiscoverAndPersistUnregisteredNewObjects, cascadePerformRemoveIfRequired, cascadePerformRemovePrivateOwnedObjectFromChangeSetIfRequired, cascadeRegisterNewIfRequired, compareCollectionsForChange, compareForChange, compareObjects, convertClassNamesToClasses, extractResultFromBatchQuery, fixRealObjectReferences, getContainerPolicy, getJoinCriteria, getListOrderField, getObjectCorrespondingTo, getOrderByQueryKeyExpressions, getOrderCorrectionType, getRealCollectionAttributeValueFromObject, hasOrderBy, isAttributeValueInstantiatedOrChanged, isChangeTrackingSupported, isCollectionMapping, isListOrderFieldSupported, isMapKeyObjectRelationship, iterateOnElement, iterateOnRealAttributeValue, load, loadAll, mergeChangesIntoObject, mergeIntoObject, mustDeleteReferenceObjectsOneByOne, postCalculateChanges, postDelete, postInitialize, preInsert, preUpdate, recordPrivateOwnedRemovals, replaceValueHoldersIn, setChangeListener, setContainerPolicy, setCustomDeleteAllQuery, setDeleteAllCall, setListOrderField, setListOrderFieldName, setMustDeleteReferenceObjectsOneByOne, setOrderCorrectionType, setUseLazyInstantiationForIndirectCollection, shouldUseLazyInstantiationForIndirectCollection, shouldUseListOrderFieldTableExpression, simpleAddToCollectionChangeRecord, simpleRemoveFromCollectionChangeRecord, updateChangeRecord, updateChangeRecordForSelfMerge, updateCollectionChangeRecord, useCollectionClass, useCollectionClassName, useListClassName, useMapClass, useMapClass, useMapClassName, useSortedSetClass, useSortedSetClassName, useSortedSetClassName, useTransparentCollection, useTransparentList, useTransparentMap, useTransparentSet, validateBeforeInitialization, valueFromPKList, writeChanges
addForeignKeyField, buildBackupClone, buildClone, buildCloneFromRow, createCloneValueHolder, dontUseBatchReading, dontUseIndirection, extendPessimisticLockScopeInSourceQuery, fixObjectReferences, getAttributeValueFromObject, getAttributeValueWithClonedValueHolders, getBatchFetchType, getIndirectionPolicy, getJoinFetch, getMappedBy, getOrderByNormalizedExpressions, getPartitioningPolicy, getPartitioningPolicyName, getRealAttributeValueFromAttribute, getReferenceClass, getReferenceClassName, getReferenceDescriptor, getRelationshipPartner, getRelationshipPartnerAttributeName, getSelectionCriteria, getSelectionQuery, getValueFromRemoteValueHolder, hasCustomSelectionQuery, hasDependency, hasNestedIdentityReference, instantiateAttribute, isAttributeValueFromObjectInstantiated, isAttributeValueFullyBuilt, isAttributeValueInstantiated, isCascadeDetach, isCascadeMerge, isCascadeOnDeleteSetOnDatabase, isCascadePersist, isCascadeRefresh, isCascadeRemove, isForeignReferenceMapping, isInnerJoinFetched, isJoinFetched, isLazy, isLockableMapping, isOuterJoinFetched, isPrivateOwned, iterate, mergeRemoteValueHolder, preInitialize, prepareNestedBatchQuery, prepareNestedJoins, privateOwnedRelationship, readFromRowIntoObject, remoteInitialization, requiresTransientWeavedFields, setBatchFetchType, setCascadeAll, setCascadeDetach, setCascadeMerge, setCascadePersist, setCascadeRefresh, setCascadeRemove, setCustomSelectionQuery, setForceInitializationOfSelectionCriteria, setIndirectionPolicy, setIsCacheable, setIsCascadeOnDeleteSetOnDatabase, setIsPrivateOwned, setJoinFetch, setMappedBy, setPartitioningPolicy, setPartitioningPolicyName, setRealAttributeValueInObject, setReferenceClass, setReferenceClassName, setRelationshipPartner, setRelationshipPartnerAttributeName, setRequiresTransientWeavedFields, setSelectionCall, setSelectionCriteria, setSelectionSQLString, setShouldExtendPessimisticLockScope, setUsesBatchReading, setUsesIndirection, shouldExtendPessimisticLockScope, shouldExtendPessimisticLockScopeInDedicatedQuery, shouldExtendPessimisticLockScopeInSourceQuery, shouldExtendPessimisticLockScopeInTargetQuery, shouldMergeCascadeParts, shouldRefreshCascadeParts, shouldUseBatchReading, trimRowForJoin, trimRowForJoin, useBasicIndirection, useBatchReading, useContainerIndirection, useInnerJoinFetch, useOuterJoinFetch, usesIndirection, useWeavedIndirection, valueFromRow
addUnconvertedProperty, buildObjectJoinExpression, buildObjectJoinExpression, buildShallowOriginalFromRow, derivesId, earlyPreDelete, getAttributeAccessor, getAttributeClassification, getAttributeName, getDerivedIdMapping, getDescriptor, getField, getFieldClassification, getFields, getGetMethodName, getMapsIdValue, getProperties, getProperty, getRealAttributeValueFromObject, getSelectFields, getSelectTables, getSetMethodName, getUnconvertedProperties, getWeight, hasConstraintDependency, hasMapsIdValue, 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, isStructureMapping, isTransformationMapping, isUnidirectionalOneToManyMapping, isUsingMethodAccess, isVariableOneToOneMapping, isWriteOnly, isXMLMapping, postCalculateChangesOnDeleted, readFromResultSetIntoObject, readOnly, readWrite, rehashFieldDependancies, setAttributeAccessor, setAttributeName, setAttributeValueInObject, setDerivedIdMapping, setDerivesId, setDescriptor, setGetMethodName, setIsInAndOutSopObject, setIsInSopObject, setIsJPAId, setIsLazy, setIsMapKeyMapping, setIsOptional, setIsOutSopObject, setIsPrimaryKeyMapping, setIsReadOnly, setMapsIdValue, setProperties, setProperty, setSetMethodName, setWeight, toString, validateAfterInitialization, valueFromObject, valueFromResultSet, valueFromRow, writeFromAttributeIntoRow, writeFromObjectIntoRow, writeFromObjectIntoRowForShallowInsert, writeFromObjectIntoRowForShallowInsertWithChangeRecord, writeFromObjectIntoRowForUpdate, writeFromObjectIntoRowForUpdateAfterShallowInsert, writeFromObjectIntoRowForUpdateBeforeShallowDelete, writeFromObjectIntoRowForWhereClause, writeFromObjectIntoRowWithChangeRecord, writeInsertFieldsIntoRow, writeUpdateFieldsIntoRow
public boolean isRelationalMapping()
isRelationalMapping
in class DatabaseMapping
public void addTargetForeignKeyField(org.eclipse.persistence.internal.helper.DatabaseField targetForeignKeyField, org.eclipse.persistence.internal.helper.DatabaseField sourceKeyField)
addTargetForeignKeyField
in class ForeignReferenceMapping
public void addTargetForeignKeyFieldName(java.lang.String targetForeignKeyFieldName, java.lang.String sourceKeyFieldName)
public Expression buildSelectionCriteria()
public void collectQueryParameters(java.util.Set<org.eclipse.persistence.internal.helper.DatabaseField> cacheFields)
collectQueryParameters
in class CollectionMapping
public java.lang.Object clone()
clone
in interface MapComponentMapping
clone
in class CollectionMapping
public java.lang.Object createMapComponentFromRow(org.eclipse.persistence.internal.sessions.AbstractRecord dbRow, ObjectBuildingQuery query, org.eclipse.persistence.internal.identitymaps.CacheKey parentCacheKey, org.eclipse.persistence.internal.sessions.AbstractSession session, boolean isTargetProtected)
createMapComponentFromRow
in interface MapComponentMapping
public java.util.Collection getFieldsForTranslationInAggregate()
getFieldsForTranslationInAggregate
in class ForeignReferenceMapping
public java.util.Vector getSourceKeyFieldNames()
public java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> getSourceKeyFields()
public java.util.Map<org.eclipse.persistence.internal.helper.DatabaseField,org.eclipse.persistence.internal.helper.DatabaseField> getSourceKeysToTargetForeignKeys()
public java.util.List<org.eclipse.persistence.internal.helper.DatabaseField> getTargetPrimaryKeyFields()
getTargetPrimaryKeyFields
in class CollectionMapping
public java.util.Vector getTargetForeignKeyFieldNames()
public java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> getTargetForeignKeyFields()
public java.util.Map<org.eclipse.persistence.internal.helper.DatabaseField,org.eclipse.persistence.internal.helper.DatabaseField> getTargetForeignKeysToSourceKeys()
public java.util.Map getTargetForeignKeyToSourceKeys()
public boolean hasInverseConstraintDependency()
hasInverseConstraintDependency
in class DatabaseMapping
public void initialize(org.eclipse.persistence.internal.sessions.AbstractSession session) throws DescriptorException
initialize
in class CollectionMapping
DescriptorException
public boolean isOneToManyMapping()
isOneToManyMapping
in class DatabaseMapping
public void performDataModificationEvent(java.lang.Object[] event, org.eclipse.persistence.internal.sessions.AbstractSession session) throws DatabaseException, DescriptorException
performDataModificationEvent
in class DatabaseMapping
DatabaseException
DescriptorException
public void postInsert(WriteObjectQuery query) throws DatabaseException, OptimisticLockException
postInsert
in class CollectionMapping
DatabaseException
OptimisticLockException
public void postInitializeSourceAndTargetExpressions()
public void postUpdate(WriteObjectQuery query) throws DatabaseException, OptimisticLockException
postUpdate
in class DatabaseMapping
DatabaseException
OptimisticLockException
public void preDelete(DeleteObjectQuery query) throws DatabaseException, OptimisticLockException
preDelete
in class DatabaseMapping
DatabaseException
OptimisticLockException
public void prepareCascadeLockingPolicy()
prepareCascadeLockingPolicy
in class DatabaseMapping
public boolean requiresDataModificationEvents()
UnidirectionalOneToManyMapping
public void setCustomAddTargetQuery(DataModifyQuery query)
public void setAddTargetSQLString(java.lang.String sqlString)
public void setCustomRemoveTargetQuery(DataModifyQuery query)
public void setCustomRemoveAllTargetsQuery(DataModifyQuery query)
public void setDeleteAllSQLString(java.lang.String sqlString)
Example: "delete from PHONE where OWNER_ID = #EMPLOYEE_ID"
setDeleteAllSQLString
in class CollectionMapping
public void setSessionName(java.lang.String name)
setSessionName
in class CollectionMapping
public void setSourceKeyFieldNames(java.util.Vector fieldNames)
public void setSourceKeyFields(java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> sourceKeyFields)
public void setTargetForeignKeyFieldName(java.lang.String targetForeignKeyFieldName)
public void setTargetForeignKeyFieldNames(java.lang.String[] targetForeignKeyFieldNames, java.lang.String[] sourceKeyFieldNames)
public void setTargetForeignKeyFieldNames(java.util.Vector fieldNames)
public void setTargetForeignKeyFields(java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> targetForeignKeyFields)
public boolean isCascadedLockingSupported()
isCascadedLockingSupported
in class DatabaseMapping
public boolean isJoiningSupported()
isJoiningSupported
in class ForeignReferenceMapping
public void updateTargetRowPostInsertSource(WriteObjectQuery query) throws DatabaseException
DatabaseException
public void updateTargetForeignKeyPostUpdateSource_ObjectAdded(ObjectLevelModifyQuery query, java.lang.Object objectAdded, java.util.Map extraData) throws DatabaseException
- 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.
DatabaseException
public void updateTargetForeignKeyPostUpdateSource_ObjectRemoved(ObjectLevelModifyQuery query, java.lang.Object objectRemoved) throws DatabaseException
- 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.
DatabaseException
public void updateTargetRowPreDeleteSource(ObjectLevelModifyQuery query) throws DatabaseException
- 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.
DatabaseException
public boolean verifyDelete(java.lang.Object object, org.eclipse.persistence.internal.sessions.AbstractSession session) throws DatabaseException
verifyDelete
in class CollectionMapping
DatabaseException