public class OneToManyMapping extends CollectionMapping implements RelationalMapping
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.
Modifier and Type | Field and Description |
---|---|
protected java.util.Vector<DatabaseField> |
sourceKeyFields
The (typically primary) source key fields that are referenced by the targetForeignKeyFields.
|
protected java.util.Map<DatabaseField,DatabaseField> |
sourceKeysToTargetForeignKeys
This maps the (primary) source key fields to the corresponding target foreign key fields.
|
protected java.util.Vector<DatabaseField> |
targetForeignKeyFields
The target foreign key fields that reference the sourceKeyFields.
|
protected java.util.Map<DatabaseField,DatabaseField> |
targetForeignKeysToSourceKeys
This maps the target foreign key fields to the corresponding (primary) source key fields.
|
containerPolicy, deleteAllQuery, hasCustomDeleteAllQuery, hasOrderBy
cascadeMerge, cascadePersist, cascadeRefresh, cascadeRemove, hasCustomSelectionQuery, indirectionPolicy, isPrivateOwned, referenceClass, referenceClassName, referenceDescriptor, relationshipPartner, relationshipPartnerAttributeName, selectionQuery, tempInitSession
attributeAccessor, descriptor, fields, isOptional, isReadOnly, isRemotelyInitialized, NO_FIELDS, NO_WEIGHT, primaryKeyMapping, properties, weight, WEIGHT_1
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.
|
protected Expression |
buildDefaultSelectionCriteria()
The selection criteria are created with target foreign keys and source "primary" 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.
|
protected void |
deleteAll(WriteObjectQuery query)
Delete all the reference objects with a single query.
|
protected void |
deleteReferenceObjectsLeftOnDatabase(WriteObjectQuery query)
This method will make sure that all the records privately owned by this mapping are
actually removed.
|
protected java.util.Vector |
extractForeignKeyFromReferenceObject(java.lang.Object object,
AbstractSession session)
Extract the foreign key value from the reference object.
|
protected java.util.Vector |
extractKeyFromRow(AbstractRecord row,
AbstractSession session)
Extract the key field values from the specified row.
|
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.
|
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.
|
protected void |
initializeDeleteAllQuery()
Initialize the delete all query.
|
protected void |
initializeTargetForeignKeysToSourceKeys()
Verify, munge, and hash the target foreign keys and source keys.
|
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 boolean |
mustDeleteReferenceObjectsOneByOne()
Return whether the reference objects must be deleted
one by one, as opposed to with a single DELETE statement.
|
void |
postInsert(WriteObjectQuery query)
INTERNAL:
Insert the referenced objects.
|
void |
postUpdate(WriteObjectQuery query)
INTERNAL:
Update the reference objects.
|
void |
preDelete(WriteObjectQuery query)
INTERNAL:
Delete the referenced objects.
|
void |
setDeleteAllSQLString(java.lang.String sqlString)
PUBLIC:
Set the SQL string used by the mapping to delete the target objects.
|
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.
|
protected void |
setTargetForeignKeysToSourceKeys(java.util.Map<DatabaseField,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.
|
boolean |
verifyDelete(java.lang.Object object,
AbstractSession session)
INTERNAL:
Used to verify whether the specified object is deleted or not.
|
addAggregateOrderBy, addAscendingOrdering, addDescendingOrdering, addOrderBy, addToCollectionChangeRecord, buildBackupCloneForPartObject, buildChangeRecord, buildCloneForPartObject, buildCopy, buildElementClone, calculateDeferredChanges, cascadeMerge, cascadePerformRemoveIfRequired, cascadeRegisterNewIfRequired, compareCollectionsForChange, compareForChange, compareObjects, compareObjectsAndWrite, compareObjectsWithoutPrivateOwned, compareObjectsWithPrivateOwned, convertClassNamesToClasses, getContainerPolicy, getDeleteAllQuery, getRealAttributeValueFromObject, getRealCollectionAttributeValueFromObject, hasCustomDeleteAllQuery, hasOrderBy, isChangeTrackingSupported, isCollectionMapping, iterateOnElement, iterateOnRealAttributeValue, mergeChangesIntoObject, mergeIntoObject, objectAddedDuringUpdate, objectRemovedDuringUpdate, objectUnchangedDuringUpdate, objectUnchangedDuringUpdate, prepareTranslationRow, readPrivateOwnedForObject, removeFromCollectionChangeRecord, setContainerPolicy, setCustomDeleteAllQuery, setDeleteAllCall, setDeleteAllQuery, setHasCustomDeleteAllQuery, setSessionName, shouldUseValueFromRowWithJoin, simpleAddToCollectionChangeRecord, simpleRemoveFromCollectionChangeRecord, updateChangeRecord, useCollectionClass, useMapClass, useMapClass, useSortedSetClass, useTransparentCollection, useTransparentList, useTransparentMap, useTransparentSet, validateBeforeInitialization, valueFromRowInternalWithJoin
buildBackupClone, buildClone, buildCloneFromRow, createUnitOfWorkValueHolder, dontDoMerge, dontUseIndirection, getAttributeValueFromObject, getAttributeValueWithClonedValueHolders, getIndirectionPolicy, getJoinCriteria, getReferenceClass, getReferenceClassName, getReferenceDescriptor, getRelationshipPartner, getRelationshipPartnerAttributeName, getSelectionCriteria, getSelectionQuery, getTempSession, hasCustomSelectionQuery, initializeReferenceDescriptor, initializeSelectionQuery, isAttributeValueInstantiated, isCascadeMerge, isCascadePersist, isCascadeRefresh, isCascadeRemove, isForeignReferenceMapping, isPrivateOwned, iterate, prepareHistoricalQuery, prepareNestedJoins, privateOwnedRelationship, setCascadeAll, setCascadeMerge, setCascadePersist, setCascadeRefresh, setCascadeRemove, setCustomSelectionQuery, setHasCustomSelectionQuery, setIndirectionPolicy, setIsPrivateOwned, setRealAttributeValueInObject, setReferenceClass, setReferenceClassName, setReferenceDescriptor, setRelationshipPartner, setRelationshipPartnerAttributeName, setSelectionCall, setSelectionCriteria, setSelectionQuery, setSelectionSQLString, setTempSession, setUsesIndirection, shouldInitializeSelectionCriteria, shouldMergeCascadeParts, shouldMergeCascadeReference, shouldObjectModifyCascadeToPartsForPreDelete, trimRowForJoin, trimRowForJoin, useBasicIndirection, usesIndirection, useWeavedIndirection, valueFromRow, valueFromRowInternal
buildObjectJoinExpression, buildObjectJoinExpression, buildShallowOriginalFromRow, cloneFields, collectFields, extractNestedExpressions, getAttributeAccessor, getAttributeClassification, getAttributeName, getDescriptor, getField, getFieldClassification, getFields, getGetMethodName, getProperties, getProperty, getReferenceClassDescriptor, getSetMethodName, getWeight, hasConstraintDependency, hasDependency, isAbstractCompositeCollectionMapping, isAbstractCompositeDirectCollectionMapping, isAbstractCompositeObjectMapping, isAbstractDirectMapping, isAggregateCollectionMapping, isAggregateMapping, isAggregateObjectMapping, isCloningRequired, isDatabaseMapping, isDirectCollectionMapping, isDirectMapMapping, isDirectToFieldMapping, isDirectToXMLTypeMapping, isEISMapping, isManyToManyMapping, isNestedTableMapping, isObjectReferenceMapping, isObjectTypeMapping, isOneToOneMapping, isOptional, isPrimaryKeyMapping, isReadOnly, isReferenceMapping, isRemotelyInitialized, isSerializedObjectMapping, isStructureMapping, isTransformationMapping, isTypeConversionMapping, isUsingMethodAccess, isVariableOneToOneMapping, isWriteOnly, isXMLMapping, performDataModificationEvent, postDelete, postInitialize, preInitialize, preInsert, prepareCascadeLockingPolicy, preUpdate, readFromRowIntoObject, readFromRowIntoObject, readOnly, readWrite, rehashFieldDependancies, setAttributeAccessor, setAttributeName, setAttributeValueInObject, setDescriptor, setFields, setGetMethodName, setIsOptional, setIsPrimaryKeyMapping, setIsReadOnly, setProperties, setProperty, setSetMethodName, setWeight, toString, validateAfterInitialization, valueFromObject, valueFromRow, writeFromAttributeIntoRow, writeFromObjectIntoRow, writeFromObjectIntoRowForShallowDelete, writeFromObjectIntoRowForShallowInsert, writeFromObjectIntoRowForShallowInsertWithChangeRecord, writeFromObjectIntoRowForUpdate, writeFromObjectIntoRowForWhereClause, writeFromObjectIntoRowWithChangeRecord, writeInsertFieldsIntoRow, writeUpdateFieldsIntoRow
protected transient java.util.Vector<DatabaseField> targetForeignKeyFields
protected transient java.util.Vector<DatabaseField> sourceKeyFields
protected transient java.util.Map<DatabaseField,DatabaseField> targetForeignKeysToSourceKeys
protected transient java.util.Map<DatabaseField,DatabaseField> sourceKeysToTargetForeignKeys
public boolean isRelationalMapping()
isRelationalMapping
in class DatabaseMapping
public void addTargetForeignKeyField(DatabaseField targetForeignKeyField, DatabaseField sourceKeyField)
public void addTargetForeignKeyFieldName(java.lang.String targetForeignKeyFieldName, java.lang.String sourceKeyFieldName)
protected Expression buildDefaultSelectionCriteria()
public Expression buildSelectionCriteria()
public java.lang.Object clone()
clone
in class ForeignReferenceMapping
protected void deleteAll(WriteObjectQuery query) throws DatabaseException
DatabaseException
protected void deleteReferenceObjectsLeftOnDatabase(WriteObjectQuery query) throws DatabaseException, OptimisticLockException
protected java.util.Vector extractForeignKeyFromReferenceObject(java.lang.Object object, AbstractSession session)
protected java.util.Vector extractKeyFromRow(AbstractRecord row, AbstractSession session)
public java.util.Vector getSourceKeyFieldNames()
public java.util.Vector<DatabaseField> getSourceKeyFields()
public java.util.Map<DatabaseField,DatabaseField> getSourceKeysToTargetForeignKeys()
public 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 DatabaseMapping
public void initialize(AbstractSession session) throws DescriptorException
initialize
in class CollectionMapping
DescriptorException
protected void initializeDeleteAllQuery()
protected void initializeTargetForeignKeysToSourceKeys() throws DescriptorException
DescriptorException
public boolean isOneToManyMapping()
isOneToManyMapping
in class DatabaseMapping
protected boolean isSourceKeySpecified()
protected boolean mustDeleteReferenceObjectsOneByOne()
public void postInsert(WriteObjectQuery query) throws DatabaseException, OptimisticLockException
postInsert
in class DatabaseMapping
DatabaseException
OptimisticLockException
public void postUpdate(WriteObjectQuery query) throws DatabaseException, OptimisticLockException
postUpdate
in class DatabaseMapping
DatabaseException
OptimisticLockException
public void preDelete(WriteObjectQuery query) throws DatabaseException, OptimisticLockException
preDelete
in class DatabaseMapping
DatabaseException
OptimisticLockException
public void setDeleteAllSQLString(java.lang.String sqlString)
Example: "delete from PHONE where OWNER_ID = #EMPLOYEE_ID"
setDeleteAllSQLString
in class CollectionMapping
public 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)
protected void setTargetForeignKeysToSourceKeys(java.util.Map<DatabaseField,DatabaseField> targetForeignKeysToSourceKeys)
protected boolean shouldObjectModifyCascadeToParts(ObjectLevelModifyQuery query)
shouldObjectModifyCascadeToParts
in class ForeignReferenceMapping
public boolean isCascadedLockingSupported()
isCascadedLockingSupported
in class DatabaseMapping
public boolean isJoiningSupported()
isJoiningSupported
in class DatabaseMapping
public boolean verifyDelete(java.lang.Object object, AbstractSession session) throws DatabaseException
verifyDelete
in class CollectionMapping
DatabaseException