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.WriteTypeINNER_JOIN, NONE, OUTER_JOIN, QUERY_BATCH_PARAMETER| Constructor and Description |
|---|
OneToManyMapping()
PUBLIC:
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addTargetForeignKeyField(DatabaseField targetForeignKeyField,
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<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(AbstractRecord dbRow,
ObjectBuildingQuery query,
CacheKey parentCacheKey,
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<DatabaseField> |
getSourceKeyFields()
INTERNAL:
Return the source key fields.
|
java.util.Map<DatabaseField,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<DatabaseField> |
getTargetForeignKeyFields()
INTERNAL:
Return the target foreign key fields.
|
java.util.Map<DatabaseField,DatabaseField> |
getTargetForeignKeysToSourceKeys()
INTERNAL:
Return the target/source key fields.
|
java.util.Map |
getTargetForeignKeyToSourceKeys()
INTERNAL:
Maintain for backward compatibility.
|
java.util.List<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(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,
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<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<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,
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, writeChangesaddForeignKeyField, 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, valueFromRowaddUnconvertedProperty, 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, writeUpdateFieldsIntoRowpublic boolean isRelationalMapping()
isRelationalMapping in class DatabaseMappingpublic void addTargetForeignKeyField(DatabaseField targetForeignKeyField, DatabaseField sourceKeyField)
addTargetForeignKeyField in class ForeignReferenceMappingpublic void addTargetForeignKeyFieldName(java.lang.String targetForeignKeyFieldName,
java.lang.String sourceKeyFieldName)
public Expression buildSelectionCriteria()
public void collectQueryParameters(java.util.Set<DatabaseField> cacheFields)
collectQueryParameters in class CollectionMappingpublic java.lang.Object clone()
clone in interface MapComponentMappingclone in class CollectionMappingpublic java.lang.Object createMapComponentFromRow(AbstractRecord dbRow, ObjectBuildingQuery query, CacheKey parentCacheKey, AbstractSession session, boolean isTargetProtected)
createMapComponentFromRow in interface MapComponentMappingpublic java.util.Collection getFieldsForTranslationInAggregate()
getFieldsForTranslationInAggregate in class ForeignReferenceMappingpublic java.util.Vector getSourceKeyFieldNames()
public java.util.Vector<DatabaseField> getSourceKeyFields()
public java.util.Map<DatabaseField,DatabaseField> getSourceKeysToTargetForeignKeys()
public java.util.List<DatabaseField> getTargetPrimaryKeyFields()
getTargetPrimaryKeyFields in class CollectionMappingpublic java.util.Vector getTargetForeignKeyFieldNames()
public java.util.Vector<DatabaseField> getTargetForeignKeyFields()
public java.util.Map<DatabaseField,DatabaseField> getTargetForeignKeysToSourceKeys()
public java.util.Map getTargetForeignKeyToSourceKeys()
public boolean hasInverseConstraintDependency()
hasInverseConstraintDependency in class DatabaseMappingpublic void initialize(AbstractSession session) throws DescriptorException
initialize in class CollectionMappingDescriptorExceptionpublic boolean isOneToManyMapping()
isOneToManyMapping in class DatabaseMappingpublic void performDataModificationEvent(java.lang.Object[] event,
AbstractSession session)
throws DatabaseException,
DescriptorException
performDataModificationEvent in class DatabaseMappingDatabaseExceptionDescriptorExceptionpublic void postInsert(WriteObjectQuery query) throws DatabaseException, OptimisticLockException
postInsert in class CollectionMappingDatabaseExceptionOptimisticLockExceptionpublic void postInitializeSourceAndTargetExpressions()
public void postUpdate(WriteObjectQuery query) throws DatabaseException, OptimisticLockException
postUpdate in class DatabaseMappingDatabaseExceptionOptimisticLockExceptionpublic void preDelete(DeleteObjectQuery query) throws DatabaseException, OptimisticLockException
preDelete in class DatabaseMappingDatabaseExceptionOptimisticLockExceptionpublic void prepareCascadeLockingPolicy()
prepareCascadeLockingPolicy in class DatabaseMappingpublic boolean requiresDataModificationEvents()
UnidirectionalOneToManyMappingpublic 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 CollectionMappingpublic void setSessionName(java.lang.String name)
setSessionName in class CollectionMappingpublic void setSourceKeyFieldNames(java.util.Vector fieldNames)
public void setSourceKeyFields(java.util.Vector<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<DatabaseField> targetForeignKeyFields)
public boolean isCascadedLockingSupported()
isCascadedLockingSupported in class DatabaseMappingpublic boolean isJoiningSupported()
isJoiningSupported in class ForeignReferenceMappingpublic void updateTargetRowPostInsertSource(WriteObjectQuery query) throws DatabaseException
DatabaseExceptionpublic 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.
DatabaseExceptionpublic 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.
DatabaseExceptionpublic 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.
DatabaseExceptionpublic boolean verifyDelete(java.lang.Object object,
AbstractSession session)
throws DatabaseException
verifyDelete in class CollectionMappingDatabaseExceptionEclipseLink 2.6.3, "build v20160428-59c81c5" API Reference