java.lang.Object
org.eclipse.persistence.core.mappings.CoreMapping<AttributeAccessor,AbstractSession,ContainerPolicy,ClassDescriptor,DatabaseField>
org.eclipse.persistence.mappings.DatabaseMapping
org.eclipse.persistence.mappings.ForeignReferenceMapping
org.eclipse.persistence.mappings.ObjectReferenceMapping
org.eclipse.persistence.mappings.OneToOneMapping
- All Implemented Interfaces:
Serializable
,Cloneable
,MapComponentMapping
,MapKeyMapping
,RelationalMapping
- Direct Known Subclasses:
ManyToOneMapping
public class OneToOneMapping
extends ObjectReferenceMapping
implements RelationalMapping, MapKeyMapping
Purpose: One to one mappings are used to represent a pointer references between two java objects. This mappings is usually represented by a single pointer (stored in an instance variable) between the source and target objects. In the relational database tables, these mappings are normally implemented using foreign keys.
- Since:
- TOPLink/Java 1.0
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static enum
Mode for writeFromObjectIntoRowInternal methodNested classes/interfaces inherited from class org.eclipse.persistence.mappings.DatabaseMapping
DatabaseMapping.WriteType
-
Field Summary
Modifier and TypeFieldDescriptionprotected HashSet
<DatabaseField> Keep track of which fields are insertable and updatable.protected boolean
Defines if this mapping was built using primary key join columns.protected boolean
Define if this mapping is really for a OneToOne relationship.protected RelationTableMechanism
Mechanism holds relationTable and all fields and queries associated with it.protected Expression
protected static final String
protected boolean
These are used for non-unit of work modification to check if the value of the 1-1 was changed and a deletion is required.protected List
<Expression> Keep a reference to the source and target expressions to post initialize when building a selection criteria early.protected Map
<DatabaseField, DatabaseField> Maps the source foreign/primary key fields to the target primary/foreign key fields.protected List
<Expression> protected Map
<DatabaseField, DatabaseField> Maps the target primary/foreign key fields to the source foreign/primary key fields.protected HashSet
<DatabaseField> Fields inherited from class org.eclipse.persistence.mappings.ObjectReferenceMapping
foreignKeyFields, isForeignKeyRelationship
Fields inherited from class org.eclipse.persistence.mappings.ForeignReferenceMapping
batchFetchType, cascadeDetach, cascadeMerge, cascadePersist, cascadeRefresh, cascadeRemove, forceInitializationOfSelectionCriteria, hasCustomSelectionQuery, indirectionPolicy, INNER_JOIN, isCascadeOnDeleteSetOnDatabase, isPrivateOwned, joinFetch, mappedBy, NONE, OUTER_JOIN, partitioningPolicy, partitioningPolicyName, 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, isCacheable, isInSopObject, isJPAId, isLazy, isMapKeyMapping, isOptional, isPrimaryKeyMapping, isReadOnly, isRemotelyInitialized, mapsIdValue, NO_FIELDS, NO_WEIGHT, properties, unconvertedProperties, weight, WEIGHT_AGGREGATE, WEIGHT_DIRECT, WEIGHT_TO_ONE, WEIGHT_TRANSFORM
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAdditionalFieldsToQuery
(ReadQuery selectionQuery, Expression baseExpression) INTERNAL: Used when initializing queries for mappings that use a Map.void
addFieldsForMapKey
(AbstractRecord joinRow) INTERNAL: Used when initializing queries for mappings that use a Map Called when the insert query is being initialized to ensure the fields for the map key are in the insert queryvoid
addForeignKeyField
(DatabaseField sourceForeignKeyField, DatabaseField targetPrimaryKeyField) PUBLIC: Define the foreign key relationship in the 1-1 mapping.void
addForeignKeyFieldName
(String sourceForeignKeyFieldName, String targetPrimaryKeyFieldName) PUBLIC: Define the foreign key relationship in the 1-1 mapping.void
addKeyToDeletedObjectsList
(Object object, Map deletedObjects) INTERNAL: For mappings used as MapKeys in MappedKeyContainerPolicy.void
addTargetForeignKeyField
(DatabaseField targetForeignKeyField, DatabaseField sourcePrimaryKeyField) PUBLIC: Define the target foreign key relationship in the 1-1 mapping.void
addTargetForeignKeyFieldName
(String targetForeignKeyFieldName, String sourcePrimaryKeyFieldName) PUBLIC: Define the target foreign key relationship in the 1-1 mapping.protected Expression
buildBatchCriteria
(ExpressionBuilder builder, ObjectLevelReadQuery query) INTERNAL: Return the selection criteria used to IN batch fetching.buildElementClone
(Object attributeValue, Object parent, CacheKey cacheKey, Integer refreshCascade, AbstractSession cloningSession, boolean isExisting, boolean isFromSharedCache) Build a clone of the given element in a unitOfWork.buildObjectJoinExpression
(Expression expression, Object value, AbstractSession session) INTERNAL: Used to allow object level comparisons.buildObjectJoinExpression
(Expression expression, Expression argument, AbstractSession session) INTERNAL: Used to allow object level comparisons.This method would allow customers to get the potential selection criteria for a mapping prior to initialization.buildSelectionCriteria
(boolean useParameter, boolean usePreviousSelectionCriteria) INTERNAL: Build the selection criteria for this mapping.buildSelectionQueryForDirectCollectionKeyMapping
(ContainerPolicy containerPolicy) INTERNAL: Certain key mappings favor different types of selection query.void
buildShallowOriginalFromRow
(AbstractRecord databaseRow, Object original, JoinedAttributeManager joinManager, ObjectBuildingQuery query, AbstractSession executionSession) INTERNAL: Builds a shallow original object.protected Object
checkCacheForBatchKey
(AbstractRecord sourceRow, Object foreignKey, Map batchObjects, ReadQuery batchQuery, ObjectLevelReadQuery originalQuery, AbstractSession session) INTERNAL: Check if the target object is in the cache if possible based on the target key value.clone()
INTERNAL: This methods clones all the fields and ensures that each collection refers to the same clones.protected Vector
<DatabaseField> INTERNAL: Return all the fields populated by this mapping, these are foreign keys only.void
collectQueryParameters
(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 entitycreateMapComponentFromJoinedRow
(AbstractRecord dbRow, JoinedAttributeManager joinManager, ObjectBuildingQuery query, CacheKey parentCacheKey, AbstractSession session, boolean isTargetProtected) INTERNAL Called when a DatabaseMapping is used to map the key in a collection.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.createMapComponentsFromSerializableKeyInfo
(Object[] keyInfo, AbstractSession session) INTERNAL: Create an instance of the Key object from the key information extracted from the map.INTERNAL: Create a query key that links to the map keycreateSerializableMapKeyInfo
(Object key, AbstractSession session) INTERNAL: Creates the Array of simple types used to recreate this map.createStubbedMapComponentFromSerializableKeyInfo
(Object keyInfo, AbstractSession session) INTERNAL: Create an instance of the Key object from the key information extracted from the map.void
deleteMapKey
(Object objectDeleted, AbstractSession session) INTERNAL: For mappings used as MapKeys in MappedKeyContainerPolicy, Delete the passed object if necessary.protected void
executeBatchQuery
(DatabaseQuery query, CacheKey parentCacheKey, Map referenceObjectsByKey, AbstractSession session, AbstractRecord translationRow) INTERNAL: Prepare and execute the batch query and store the results for each source object in a map keyed by the mappings source keys of the source objects.void
INTERNAL: Called only if both shouldExtendPessimisticLockScope and shouldExtendPessimisticLockScopeInSourceQuery are true.protected void
extendPessimisticLockScopeInTargetQuery
(ObjectLevelReadQuery targetQuery, ObjectBuildingQuery sourceQuery) INTERNAL: Adds locking clause to the target query to extend pessimistic lock scope.protected Object
extractBatchKeyFromRow
(AbstractRecord row, AbstractSession session) INTERNAL: Extract the foreign key value from the source row.extractIdentityFieldsForQuery
(Object object, AbstractSession session) INTERNAL: Extract the fields for the Map key from the object to use in a queryprotected Object
extractKeyFromReferenceObject
(Object object, AbstractSession session) INTERNAL: Extract the key value from the reference object.INTERNAL: Return the primary key for the reference object (i.e.INTERNAL: Return the selection criteria necessary to select the target object when this mapping is a map key.INTERNAL: Return any tables that will be required when this mapping is used as part of a join queryINTERNAL: Get all the fields for the map keyprotected ReadQuery
getExtendPessimisticLockScopeDedicatedQuery
(AbstractSession session, short lockMode) INTERNAL: Should be overridden by subclass that allows setting extendPessimisticLockScope to DEDICATED_QUERY.Class
<?> getFieldClassification
(DatabaseField fieldToClassify) INTERNAL: Return the classification for the field contained in the mapping.INTERNAL: Return source key fields for translation by an AggregateObjectMappingPUBLIC: Return the foreign key field names associated with the mapping.INTERNAL: Return a Map of any foreign keys defined within the the MapKeyprotected Map
Return the appropriate map that maps the "foreign keys" to the "primary keys".INTERNAL: Return the fields that make up the identity of the mapped object.Class
<?> INTERNAL: Return the class this key mapping maps or the descriptor for itgetNestedJoinQuery
(JoinedAttributeManager joinManager, ObjectLevelReadQuery query, AbstractSession session) INTERNAL: Return the query that is used when this mapping is part of a joined relationship This method is used when this mapping is used to map the key in a MapINTERNAL: Order by foreign key fields if a foreign key mapping (avoids joins).INTERNAL: Return a vector of the foreign key fields in the same order as the corresponding primary key fields are in their descriptor.protected ClassDescriptor
Return the descriptor for whichever side of the relation has the "primary key".INTERNAL: The private owned criteria is only used outside of the unit of work to compare the previous value of the reference.PUBLIC: Return RelationTable.PUBLIC: Returns RelationTableMechanism that may be owned by the mapping, that allows to configure the mapping to use relation table (just like ManyToManyMapping).INTERNAL: Return a collection of the source to target field value associations.INTERNAL: Returns the source keys to target keys fields association.INTERNAL: Returns the target keys to source keys fields association.getTargetVersionOfSourceObject
(Object object, Object parent, MergeManager mergeManager, AbstractSession targetSession) INTERNAL: If required, get the targetVersion of the source object from the merge manager Used with MapKeyContainerPolicy to abstract getting the target version of a source keyboolean
PUBLIC: Indicates whether the mapping has RelationTable.boolean
PUBLIC: Indicates whether the mapping has RelationTableMechanism.void
initialize
(AbstractSession session) INTERNAL: Initialize the mapping.protected void
initializeForeignKeys
(AbstractSession session) INTERNAL: The foreign keys primary keys are stored as database fields in the map.protected void
INTERNAL: The foreign keys primary keys are stored as database fields in the map.protected void
INTERNAL: Selection criteria is created with source foreign keys and target keys.boolean
INTERNAL Return true if this mapping supports cascaded version optimistic locking.boolean
INTERNAL: Return if this mapping support joining.boolean
INTERNAL:boolean
Return if this mapping is mapped using primary key join columns.boolean
Return if this mapping is really for a OneToOne relationship.boolean
isOwned()
INTERNAL:boolean
INTERNAL:void
iterateOnMapKey
(DescriptorIterator iterator, Object element) INTERNAL: Called when iterating through descriptors to handle iteration on this mapping when it is used as a MapKeyvoid
performDataModificationEvent
(Object[] event, AbstractSession session) INTERNAL: Perform the commit event.void
INTERNAL: Need to set the field type for the foreign key fields for a map key, as the fields are not contained in any descriptor.void
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 into relation table.protected void
postPrepareNestedBatchQuery
(ReadQuery batchQuery, ObjectLevelReadQuery query) INTERNAL: Allow the mapping the do any further batch preparation.void
postUpdate
(WriteObjectQuery query) INTERNAL: Update the relation table with the entries related to this mapping.void
preDelete
(DeleteObjectQuery query) INTERNAL: Delete privately owned partsvoid
preinitializeMapKey
(DatabaseTable table) INTERNAL: Making any mapping changes necessary to use a the mapping as a map key prior to initializing the mappingvoid
INTERNAL: Prepare a cascade locking policy.protected Object
readPrivateOwnedForObject
(ObjectLevelModifyQuery modifyQuery) INTERNAL: Reads the private owned object.void
rehashFieldDependancies
(AbstractSession session) INTERNAL: Rehash any map based on fields.boolean
INTERNAL: Return whether this mapping requires extra queries to update the rows if it is used as a key in a map.void
setForeignKeyFieldName
(String sourceForeignKeyFieldName) PUBLIC: Define the foreign key relationship in the 1-1 mapping.void
setForeignKeyFieldNames
(Vector fieldNames) PUBLIC: Return the foreign key field names associated with the mapping.void
setIsOneToOnePrimaryKeyRelationship
(boolean isOneToOnePrimaryKeyRelationship) Set if this mapping is defined using primary key join columns.void
setIsOneToOneRelationship
(boolean isOneToOneRelationship) Define if this mapping is really for a OneToOne relationship.protected void
setPrivateOwnedCriteria
(Expression expression) INTERNAL: Private owned criteria is used to verify the deletion of the target.void
setRelationTable
(DatabaseTable relationTable) PUBLIC: Set the relational table.void
setRelationTableMechanism
(RelationTableMechanism mechanism) PUBLIC: Set RelationTableMechanism into the mapping, that allows to configure the mapping to use relation table (just like ManyToManyMapping).void
setShouldVerifyDelete
(boolean shouldVerifyDelete) PUBLIC: Verify delete is used during delete and update on private 1:1's outside of a unit of work only.void
setSourceToTargetKeyFieldAssociations
(Vector sourceToTargetKeyFieldAssociations) INTERNAL: Set a collection of the source to target field associations.void
setSourceToTargetKeyFields
(Map<DatabaseField, DatabaseField> sourceToTargetKeyFields) INTERNAL: Set the source keys to target keys fields association.void
setTargetForeignKeyFieldName
(String targetForeignKeyFieldName) PUBLIC: Define the target foreign key relationship in the 1-1 mapping.void
setTargetToSourceKeyFields
(Map<DatabaseField, DatabaseField> targetToSourceKeyFields) INTERNAL: Set the target keys to source keys fields association.boolean
PUBLIC: Verify delete is used during delete and update outside of a unit of work only.protected boolean
shouldWriteField
(DatabaseField field, DatabaseMapping.WriteType writeType) INTERNAL: By default returns true.unwrapKey
(Object key, AbstractSession session) INTERNAL: Allow the key mapping to unwrap the object.protected void
INTERNAL: Add the field to the updatable and/or insertable list.valueFromObject
(Object object, DatabaseField field, AbstractSession session) INTERNAL: Get a value from the object and set that in the respective field of the row.protected Object
valueFromRowInternal
(AbstractRecord row, JoinedAttributeManager joinManager, ObjectBuildingQuery sourceQuery, AbstractSession executionSession, boolean shouldUseSopObject) INTERNAL: Return the value of the field from the row or a value holder on the query to obtain the object.protected Object
valueFromRowInternalWithJoin
(AbstractRecord row, JoinedAttributeManager joinManager, ObjectBuildingQuery sourceQuery, CacheKey parentCacheKey, AbstractSession executionSession, boolean isTargetProtected) INTERNAL: Return the value of the field from the row or a value holder on the query to obtain the object.wrapKey
(Object key, AbstractSession session) INTERNAL: Allow the key mapping to wrap the object.void
writeFromAttributeIntoRow
(Object attribute, AbstractRecord row, AbstractSession session) INTERNAL: A subclass should implement this method if it wants different behavior.void
writeFromObjectIntoRow
(Object object, AbstractRecord databaseRow, AbstractSession session, DatabaseMapping.WriteType writeType) INTERNAL: Get a value from the object and set that in the respective field of the row.void
writeFromObjectIntoRowForShallowInsert
(Object object, AbstractRecord databaseRow, AbstractSession session) INTERNAL: This row is built for shallow insert which happens in case of bidirectional inserts.void
writeFromObjectIntoRowForShallowInsertWithChangeRecord
(ChangeRecord ChangeRecord, AbstractRecord databaseRow, AbstractSession session) INTERNAL: This row is built for shallow insert which happens in case of bidirectional inserts.void
writeFromObjectIntoRowForUpdateAfterShallowInsert
(Object object, AbstractRecord databaseRow, AbstractSession session, DatabaseTable table) INTERNAL: This row is built for update after shallow insert which happens in case of bidirectional inserts.void
writeFromObjectIntoRowForUpdateBeforeShallowDelete
(Object object, AbstractRecord databaseRow, AbstractSession session, DatabaseTable table) INTERNAL: This row is built for update before shallow delete which happens in case of bidirectional inserts.protected void
writeFromObjectIntoRowInternal
(Object object, AbstractRecord databaseRow, AbstractSession session, OneToOneMapping.ShallowMode mode, DatabaseMapping.WriteType writeType) INTERNAL: Get a value from the object and set that in the respective field of the row.void
writeFromObjectIntoRowWithChangeRecord
(ChangeRecord changeRecord, AbstractRecord databaseRow, AbstractSession session, DatabaseMapping.WriteType writeType) INTERNAL: Get a value from the object and set that in the respective field of the row.void
writeInsertFieldsIntoRow
(AbstractRecord databaseRow, AbstractSession session) INTERNAL: Write fields needed for insert into the template for with null values.Methods inherited from class org.eclipse.persistence.mappings.ObjectReferenceMapping
buildBackupCloneForPartObject, buildChangeRecord, buildCloneForPartObject, buildCopy, buildExpression, buildReferencesPKList, buildTargetInterfaces, buildUnitofWorkCloneForPartObject, cascadeDiscoverAndPersistUnregisteredNewObjects, cascadeDiscoverAndPersistUnregisteredNewObjects, cascadePerformRemoveIfRequired, cascadePerformRemoveIfRequired, cascadePerformRemovePrivateOwnedObjectFromChangeSetIfRequired, cascadeRegisterNewIfRequired, cascadeRegisterNewIfRequired, compareForChange, compareObjectsWithoutPrivateOwned, compareObjectsWithPrivateOwned, createCloneValueHolder, earlyPreDelete, extractPrimaryKeyRowForSourceObject, extractPrimaryKeysForReferenceObject, extractPrimaryKeysFromRealReferenceObject, fixRealObjectReferences, getDescriptorForTarget, getForeignKeyFields, getPrimaryKeyForObject, getRealAttributeValueFromAttribute, hasConstraintDependency, insert, internalBuildChangeRecord, isChangeTrackingSupported, isForeignKeyRelationship, isObjectReferenceMapping, iterateOnRealAttributeValue, loadAll, mergeChangesIntoObject, mergeIntoObject, postCalculateChanges, postDelete, preInitialize, preInsert, preUpdate, recordPrivateOwnedRemovals, setForeignKeyFields, setIsForeignKeyRelationship, setNewValueInChangeRecord, update, updateChangeRecord, updateChangeRecordForSelfMerge, useProxyIndirection, useProxyIndirection, useProxyIndirection, valueFromPKList, verifyDelete, writeFromObjectIntoRowForUpdate, writeFromObjectIntoRowForWhereClause
Methods inherited from class org.eclipse.persistence.mappings.ForeignReferenceMapping
batchedValueFromRow, buildBackupClone, buildClone, buildCloneFromRow, compareObjects, convertClassNamesToClasses, dontDoMerge, dontUseBatchReading, dontUseIndirection, extractResultFromBatchQuery, fixObjectReferences, getAttributeValueFromObject, getAttributeValueWithClonedValueHolders, getBatchFetchType, getIndirectionPolicy, getJoinCriteria, getJoinFetch, getMappedBy, getObjectCorrespondingTo, getPartitioningPolicy, getPartitioningPolicyName, getReferenceClass, getReferenceClassName, getReferenceDescriptor, getRelationshipPartner, getRelationshipPartnerAttributeName, getSelectionCriteria, getSelectionQuery, getTempSession, getValueFromRemoteValueHolder, hasCustomSelectionQuery, hasDependency, hasNestedIdentityReference, initializeReferenceDescriptor, initializeSelectionQuery, instantiateAttribute, isAttributeValueFromObjectInstantiated, isAttributeValueFullyBuilt, isAttributeValueInstantiated, isCascadeDetach, isCascadeMerge, isCascadeOnDeleteSetOnDatabase, isCascadePersist, isCascadeRefresh, isCascadeRemove, isExtendingPessimisticLockScope, isForeignReferenceMapping, isInnerJoinFetched, isJoinFetched, isLazy, isLockableMapping, isOuterJoinFetched, isPrivateOwned, iterate, load, mergeRemoteValueHolder, prepareHistoricalQuery, prepareNestedBatchQuery, prepareNestedJoinQueryClone, prepareNestedJoins, privateOwnedRelationship, readFromRowIntoObject, remoteInitialization, replaceValueHoldersIn, requiresTransientWeavedFields, setBatchFetchType, setCascadeAll, setCascadeDetach, setCascadeMerge, setCascadePersist, setCascadeRefresh, setCascadeRemove, setCustomSelectionQuery, setForceInitializationOfSelectionCriteria, setHasCustomSelectionQuery, setIndirectionPolicy, setIsCacheable, setIsCascadeOnDeleteSetOnDatabase, setIsPrivateOwned, setJoinFetch, setMappedBy, setPartitioningPolicy, setPartitioningPolicyName, setRealAttributeValueInObject, setReferenceClass, setReferenceClassName, setReferenceDescriptor, setRelationshipPartner, setRelationshipPartnerAttributeName, setRequiresTransientWeavedFields, setSelectionCall, setSelectionCriteria, setSelectionQuery, setSelectionSQLString, setShouldExtendPessimisticLockScope, setTempSession, setUsesBatchReading, setUsesIndirection, shouldExtendPessimisticLockScope, shouldExtendPessimisticLockScopeInDedicatedQuery, shouldExtendPessimisticLockScopeInSourceQuery, shouldExtendPessimisticLockScopeInTargetQuery, shouldForceInitializationOfSelectionCriteria, shouldInitializeSelectionCriteria, shouldMergeCascadeParts, shouldMergeCascadeReference, shouldObjectModifyCascadeToParts, shouldRefreshCascadeParts, shouldUseBatchReading, shouldUseValueFromRowWithJoin, trimRowForJoin, trimRowForJoin, useBasicIndirection, useBatchReading, useContainerIndirection, useInnerJoinFetch, useOuterJoinFetch, usesIndirection, useWeavedIndirection, validateBeforeInitialization, valueFromRow, valueFromRowInternal
Methods inherited from class org.eclipse.persistence.mappings.DatabaseMapping
addUnconvertedProperty, buildContainerClone, calculateDeferredChanges, cloneFields, convertConverterClassNamesToClasses, derivesId, extractNestedExpressions, extractNestedNonAggregateExpressions, getAttributeAccessor, getAttributeClassification, getAttributeName, getContainerPolicy, getDerivedIdMapping, getDescriptor, getField, getFields, getGetMethodName, getMapsIdValue, getProperties, getProperty, getRealAttributeValueFromObject, getRealCollectionAttributeValueFromObject, getSelectFields, getSelectTables, getSetMethodName, getUnconvertedProperties, getWeight, hasInverseConstraintDependency, hasMapsIdValue, hasRootExpressionThatShouldUseOuterJoin, hasUnconvertedProperties, isAbstractColumnMapping, isAbstractCompositeCollectionMapping, isAbstractCompositeDirectCollectionMapping, isAbstractCompositeObjectMapping, isAbstractDirectMapping, isAggregateCollectionMapping, isAggregateMapping, isAggregateObjectMapping, isCacheable, isCandidateForPrivateOwnedRemoval, isCloningRequired, isCollectionMapping, isDatabaseMapping, isDirectCollectionMapping, isDirectMapMapping, isDirectToFieldMapping, isDirectToXMLTypeMapping, isEISMapping, isElementCollectionMapping, isInAndOutSopObject, isInOnlySopObject, isInSopObject, isJPAId, isManyToManyMapping, isManyToOneMapping, isMapKeyMapping, isMultitenantPrimaryKeyMapping, isNestedTableMapping, isOneToManyMapping, isOptional, isOutOnlySopObject, isOutSopObject, isPrimaryKeyMapping, isReadOnly, isReferenceMapping, isRemotelyInitialized, isStructureMapping, isTransformationMapping, isUnidirectionalOneToManyMapping, isUsingMethodAccess, isVariableOneToOneMapping, isWriteOnly, isXMLMapping, postCalculateChangesOnDeleted, postInitialize, readFromResultSetIntoObject, readOnly, readWrite, remotelyInitialized, setAttributeAccessor, setAttributeName, setAttributeValueInObject, setChangeListener, setDerivedIdMapping, setDerivesId, setDescriptor, setFields, setGetMethodName, setIsInAndOutSopObject, setIsInSopObject, setIsJPAId, setIsLazy, setIsMapKeyMapping, setIsOptional, setIsOutSopObject, setIsPrimaryKeyMapping, setIsReadOnly, setMapsIdValue, setProperties, setProperty, setSetMethodName, setWeight, simpleAddToCollectionChangeRecord, simpleRemoveFromCollectionChangeRecord, toString, updateCollectionChangeRecord, validateAfterInitialization, valueFromResultSet, valueFromRow, writeUpdateFieldsIntoRow
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.persistence.mappings.foundation.MapKeyMapping
cascadeDiscoverAndPersistUnregisteredNewObjects, cascadePerformRemoveIfRequired, cascadeRegisterNewIfRequired, getReferenceDescriptor
-
Field Details
-
sourceToTargetKeyFields
Maps the source foreign/primary key fields to the target primary/foreign key fields. -
targetToSourceKeyFields
Maps the target primary/foreign key fields to the source foreign/primary key fields. -
shouldVerifyDelete
protected boolean shouldVerifyDeleteThese are used for non-unit of work modification to check if the value of the 1-1 was changed and a deletion is required. -
privateOwnedCriteria
-
keyTableForMapKey
-
setObject
- See Also:
-
mechanism
Mechanism holds relationTable and all fields and queries associated with it. -
isOneToOneRelationship
protected boolean isOneToOneRelationshipDefine if this mapping is really for a OneToOne relationship. This is a backward compatibility issue, in that before the ManyToOneMapping was created OneToOneMapping was used for both. -
isOneToOnePrimaryKeyRelationship
protected boolean isOneToOnePrimaryKeyRelationshipDefines if this mapping was built using primary key join columns. -
insertableFields
Keep track of which fields are insertable and updatable. -
updatableFields
-
sourceExpressionsToPostInitialize
Keep a reference to the source and target expressions to post initialize when building a selection criteria early. -
targetExpressionsToPostInitialize
-
-
Constructor Details
-
OneToOneMapping
public OneToOneMapping()PUBLIC: Default constructor.
-
-
Method Details
-
isRelationalMapping
public boolean isRelationalMapping()INTERNAL:- Overrides:
isRelationalMapping
in classDatabaseMapping
-
addAdditionalFieldsToQuery
INTERNAL: Used when initializing queries for mappings that use a Map. Called when the selection query is being initialized to add the fields for the map key to the query.- Specified by:
addAdditionalFieldsToQuery
in interfaceMapKeyMapping
-
addFieldsForMapKey
INTERNAL: Used when initializing queries for mappings that use a Map Called when the insert query is being initialized to ensure the fields for the map key are in the insert query- Specified by:
addFieldsForMapKey
in interfaceMapKeyMapping
-
addForeignKeyField
public void addForeignKeyField(DatabaseField sourceForeignKeyField, DatabaseField targetPrimaryKeyField) PUBLIC: Define the foreign key relationship in the 1-1 mapping. This method is used for composite foreign key relationships, that is the source object's table has multiple foreign key fields to the target object's primary key fields. Both the source foreign key field and the target foreign key field must be specified. When a foreign key is specified TopLink will automatically populate the value for that field from the target object when the object is written to the database. If the foreign key is also mapped through a direct-to-field then the direct-to-field must be set read-only.- Overrides:
addForeignKeyField
in classForeignReferenceMapping
-
addForeignKeyFieldName
public void addForeignKeyFieldName(String sourceForeignKeyFieldName, String targetPrimaryKeyFieldName) PUBLIC: Define the foreign key relationship in the 1-1 mapping. This method is used for composite foreign key relationships, that is the source object's table has multiple foreign key fields to the target object's primary key fields. Both the source foreign key field name and the target foreign key field name must be specified. When a foreign key is specified TopLink will automatically populate the value for that field from the target object when the object is written to the database. If the foreign key is also mapped through a direct-to-field then the direct-to-field must be set read-only. -
addTargetForeignKeyField
public void addTargetForeignKeyField(DatabaseField targetForeignKeyField, DatabaseField sourcePrimaryKeyField) PUBLIC: Define the target foreign key relationship in the 1-1 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 primary key fields. Both the target foreign key field and the source primary key field must be specified. The distinction between a foreign key and target foreign key is that the 1-1 mapping will not populate the target foreign key value when written (because it is in the target table). Normally 1-1's are through foreign keys but in bi-directional 1-1's the back reference will be a target foreign key. In obscure composite legacy data models a 1-1 may consist of a foreign key part and a target foreign key part, in this case both method will be called with the correct parts.- Overrides:
addTargetForeignKeyField
in classForeignReferenceMapping
-
addTargetForeignKeyFieldName
public void addTargetForeignKeyFieldName(String targetForeignKeyFieldName, String sourcePrimaryKeyFieldName) PUBLIC: Define the target foreign key relationship in the 1-1 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 primary key fields. Both the target foreign key field name and the source primary key field name must be specified. The distinction between a foreign key and target foreign key is that the 1-1 mapping will not populate the target foreign key value when written (because it is in the target table). Normally 1-1's are through foreign keys but in bi-directional 1-1's the back reference will be a target foreign key. In obscure composite legacy data models a 1-1 may consist of a foreign key part and a target foreign key part, in this case both method will be called with the correct parts. -
addKeyToDeletedObjectsList
INTERNAL: For mappings used as MapKeys in MappedKeyContainerPolicy. Add the target of this mapping to the deleted objects list if necessary This method is used for removal of private owned relationships.- Specified by:
addKeyToDeletedObjectsList
in interfaceMapKeyMapping
-
buildElementClone
public Object buildElementClone(Object attributeValue, Object parent, CacheKey cacheKey, Integer refreshCascade, AbstractSession cloningSession, boolean isExisting, boolean isFromSharedCache) Build a clone of the given element in a unitOfWork.- Specified by:
buildElementClone
in interfaceMapKeyMapping
-
buildObjectJoinExpression
public Expression buildObjectJoinExpression(Expression expression, Object value, AbstractSession session) INTERNAL: Used to allow object level comparisons.- Overrides:
buildObjectJoinExpression
in classDatabaseMapping
- Parameters:
expression
- TODOvalue
- TODOsession
- TODO- Returns:
- TODO
-
buildObjectJoinExpression
public Expression buildObjectJoinExpression(Expression expression, Expression argument, AbstractSession session) INTERNAL: Used to allow object level comparisons.- Overrides:
buildObjectJoinExpression
in classDatabaseMapping
- Parameters:
expression
- TODOargument
- TODOsession
- TODO- Returns:
- TODO
-
buildSelectionQueryForDirectCollectionKeyMapping
INTERNAL: Certain key mappings favor different types of selection query. Return the appropriate type of selectionQuery- Specified by:
buildSelectionQueryForDirectCollectionKeyMapping
in interfaceMapKeyMapping
-
clone
INTERNAL: This methods clones all the fields and ensures that each collection refers to the same clones.- Specified by:
clone
in interfaceMapComponentMapping
- Overrides:
clone
in classForeignReferenceMapping
- Returns:
- new instance of itself
-
collectQueryParameters
Description copied from class:ObjectReferenceMapping
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- Overrides:
collectQueryParameters
in classObjectReferenceMapping
- Parameters:
cacheFields
- TODO
-
createMapComponentFromRow
public 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. Returns the key.- Specified by:
createMapComponentFromRow
in interfaceMapComponentMapping
-
createSerializableMapKeyInfo
INTERNAL: Creates the Array of simple types used to recreate this map.- Specified by:
createSerializableMapKeyInfo
in interfaceMapKeyMapping
-
createMapComponentsFromSerializableKeyInfo
public List<Object> createMapComponentsFromSerializableKeyInfo(Object[] keyInfo, AbstractSession session) INTERNAL: Create an instance of the Key object from the key information extracted from the map. This may return the value directly in case of a simple key or will be used as the FK to load a related entity.- Specified by:
createMapComponentsFromSerializableKeyInfo
in interfaceMapKeyMapping
-
createStubbedMapComponentFromSerializableKeyInfo
public Object createStubbedMapComponentFromSerializableKeyInfo(Object keyInfo, AbstractSession session) INTERNAL: Create an instance of the Key object from the key information extracted from the map. This key object may be a shallow stub of the actual object if the key is an Entity type.- Specified by:
createStubbedMapComponentFromSerializableKeyInfo
in interfaceMapKeyMapping
-
createMapComponentFromJoinedRow
public Object createMapComponentFromJoinedRow(AbstractRecord dbRow, JoinedAttributeManager joinManager, ObjectBuildingQuery query, CacheKey parentCacheKey, AbstractSession session, boolean isTargetProtected) INTERNAL Called when a DatabaseMapping is used to map the key in a collection. Returns the key.- Specified by:
createMapComponentFromJoinedRow
in interfaceMapKeyMapping
-
createQueryKeyForMapKey
INTERNAL: Create a query key that links to the map key- Specified by:
createQueryKeyForMapKey
in interfaceMapKeyMapping
-
deleteMapKey
INTERNAL: For mappings used as MapKeys in MappedKeyContainerPolicy, Delete the passed object if necessary. This method is used for removal of private owned relationships- Specified by:
deleteMapKey
in interfaceMapKeyMapping
-
extendPessimisticLockScopeInTargetQuery
protected void extendPessimisticLockScopeInTargetQuery(ObjectLevelReadQuery targetQuery, ObjectBuildingQuery sourceQuery) INTERNAL: Adds locking clause to the target query to extend pessimistic lock scope.- Overrides:
extendPessimisticLockScopeInTargetQuery
in classForeignReferenceMapping
-
extendPessimisticLockScopeInSourceQuery
INTERNAL: Called only if both shouldExtendPessimisticLockScope and shouldExtendPessimisticLockScopeInSourceQuery are true. Adds fields to be locked to the where clause of the source query. Note that the sourceQuery must be ObjectLevelReadQuery so that it has ExpressionBuilder. This method must be implemented in subclasses that allow setting shouldExtendPessimisticLockScopeInSourceQuery to true.- Overrides:
extendPessimisticLockScopeInSourceQuery
in classForeignReferenceMapping
-
extractBatchKeyFromRow
INTERNAL: Extract the foreign key value from the source row.- Overrides:
extractBatchKeyFromRow
in classForeignReferenceMapping
-
extractIdentityFieldsForQuery
INTERNAL: Extract the fields for the Map key from the object to use in a query- Specified by:
extractIdentityFieldsForQuery
in interfaceMapKeyMapping
-
extractKeyFromReferenceObject
INTERNAL: Extract the key value from the reference object. -
extractPrimaryKeysForReferenceObjectFromRow
INTERNAL: Return the primary key for the reference object (i.e. the object object referenced by domainObject and specified by mapping). This key will be used by a RemoteValueHolder.- Overrides:
extractPrimaryKeysForReferenceObjectFromRow
in classObjectReferenceMapping
-
postPrepareNestedBatchQuery
INTERNAL: Allow the mapping the do any further batch preparation.- Overrides:
postPrepareNestedBatchQuery
in classForeignReferenceMapping
-
buildBatchCriteria
INTERNAL: Return the selection criteria used to IN batch fetching.- Overrides:
buildBatchCriteria
in classForeignReferenceMapping
-
executeBatchQuery
protected void executeBatchQuery(DatabaseQuery query, CacheKey parentCacheKey, Map referenceObjectsByKey, AbstractSession session, AbstractRecord translationRow) INTERNAL: Prepare and execute the batch query and store the results for each source object in a map keyed by the mappings source keys of the source objects.- Overrides:
executeBatchQuery
in classForeignReferenceMapping
-
checkCacheForBatchKey
protected Object checkCacheForBatchKey(AbstractRecord sourceRow, Object foreignKey, Map batchObjects, ReadQuery batchQuery, ObjectLevelReadQuery originalQuery, AbstractSession session) INTERNAL: Check if the target object is in the cache if possible based on the target key value. Return null if the target key is not the primary key, or if the query is refreshing.- Overrides:
checkCacheForBatchKey
in classForeignReferenceMapping
-
getAdditionalSelectionCriteriaForMapKey
INTERNAL: Return the selection criteria necessary to select the target object when this mapping is a map key.- Specified by:
getAdditionalSelectionCriteriaForMapKey
in interfaceMapKeyMapping
-
getAdditionalTablesForJoinQuery
INTERNAL: Return any tables that will be required when this mapping is used as part of a join query- Specified by:
getAdditionalTablesForJoinQuery
in interfaceMapKeyMapping
-
getExtendPessimisticLockScopeDedicatedQuery
protected ReadQuery getExtendPessimisticLockScopeDedicatedQuery(AbstractSession session, short lockMode) INTERNAL: Should be overridden by subclass that allows setting extendPessimisticLockScope to DEDICATED_QUERY.- Overrides:
getExtendPessimisticLockScopeDedicatedQuery
in classForeignReferenceMapping
-
getFieldClassification
INTERNAL: Return the classification for the field contained in the mapping. This is used to convert the row value to a consistent java value.- Overrides:
getFieldClassification
in classDatabaseMapping
- Throws:
DescriptorException
-
getForeignKeyFieldNames
PUBLIC: Return the foreign key field names associated with the mapping. These are only the source fields that are writable. -
getFieldsForTranslationInAggregate
INTERNAL: Return source key fields for translation by an AggregateObjectMapping- Overrides:
getFieldsForTranslationInAggregate
in classForeignReferenceMapping
-
getForeignKeysToPrimaryKeys
Return the appropriate map that maps the "foreign keys" to the "primary keys". -
getForeignKeyFieldsForMapKey
INTERNAL: Return a Map of any foreign keys defined within the the MapKey- Specified by:
getForeignKeyFieldsForMapKey
in interfaceMapKeyMapping
-
getIdentityFieldsForMapKey
INTERNAL: Return the fields that make up the identity of the mapped object. For mappings with a primary key, it will be the set of fields in the primary key. For mappings without a primary key it will likely be all the fields- Specified by:
getIdentityFieldsForMapKey
in interfaceMapKeyMapping
-
getNestedJoinQuery
public ObjectLevelReadQuery getNestedJoinQuery(JoinedAttributeManager joinManager, ObjectLevelReadQuery query, AbstractSession session) INTERNAL: Return the query that is used when this mapping is part of a joined relationship This method is used when this mapping is used to map the key in a Map- Specified by:
getNestedJoinQuery
in interfaceMapKeyMapping
-
getAllFieldsForMapKey
INTERNAL: Get all the fields for the map key- Specified by:
getAllFieldsForMapKey
in interfaceMapKeyMapping
-
getOrderedForeignKeyFields
INTERNAL: Return a vector of the foreign key fields in the same order as the corresponding primary key fields are in their descriptor. -
getPrimaryKeyDescriptor
Return the descriptor for whichever side of the relation has the "primary key". -
getPrivateOwnedCriteria
INTERNAL: The private owned criteria is only used outside of the unit of work to compare the previous value of the reference. -
getSourceToTargetKeyFieldAssociations
INTERNAL: Return a collection of the source to target field value associations. -
getSourceToTargetKeyFields
INTERNAL: Returns the source keys to target keys fields association. -
getTargetToSourceKeyFields
INTERNAL: Returns the target keys to source keys fields association. -
getTargetVersionOfSourceObject
public Object getTargetVersionOfSourceObject(Object object, Object parent, MergeManager mergeManager, AbstractSession targetSession) INTERNAL: If required, get the targetVersion of the source object from the merge manager Used with MapKeyContainerPolicy to abstract getting the target version of a source key- Specified by:
getTargetVersionOfSourceObject
in interfaceMapKeyMapping
-
getMapKeyTargetType
INTERNAL: Return the class this key mapping maps or the descriptor for it- Specified by:
getMapKeyTargetType
in interfaceMapKeyMapping
-
initialize
INTERNAL: Initialize the mapping.- Overrides:
initialize
in classForeignReferenceMapping
- Throws:
DescriptorException
-
initializeForeignKeys
INTERNAL: The foreign keys primary keys are stored as database fields in the map. -
initializeForeignKeysWithDefaults
INTERNAL: The foreign keys primary keys are stored as database fields in the map. -
initializePrivateOwnedCriteria
protected void initializePrivateOwnedCriteria()INTERNAL: Selection criteria is created with source foreign keys and target keys. -
preinitializeMapKey
INTERNAL: Making any mapping changes necessary to use a the mapping as a map key prior to initializing the mapping- Specified by:
preinitializeMapKey
in interfaceMapKeyMapping
- Throws:
DescriptorException
-
postInitializeMapKey
INTERNAL: Need to set the field type for the foreign key fields for a map key, as the fields are not contained in any descriptor.- Specified by:
postInitializeMapKey
in interfaceMapKeyMapping
-
postInitializeSourceAndTargetExpressions
public void postInitializeSourceAndTargetExpressions()INTERNAL: Post-initialize source and target expression fields created when a mapping's selectionCriteria is created early with only partly initialized fields.- Overrides:
postInitializeSourceAndTargetExpressions
in classDatabaseMapping
- See Also:
-
prepareCascadeLockingPolicy
public void prepareCascadeLockingPolicy()INTERNAL: Prepare a cascade locking policy.- Overrides:
prepareCascadeLockingPolicy
in classDatabaseMapping
-
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. -
buildSelectionCriteria
public Expression buildSelectionCriteria(boolean useParameter, boolean usePreviousSelectionCriteria) INTERNAL: Build the selection criteria for this mapping. Allows several variations. Either a parameter can be used for the join or simply the database field The existing selection criteria can be built upon or a whole new criteria can be built. -
buildShallowOriginalFromRow
public void buildShallowOriginalFromRow(AbstractRecord databaseRow, Object original, JoinedAttributeManager joinManager, ObjectBuildingQuery query, AbstractSession executionSession) INTERNAL: Builds a shallow original object. Only direct attributes and primary keys are populated. In this way the minimum original required for instantiating a working copy clone can be built without placing it in the shared cache (no concern over cycles).- Overrides:
buildShallowOriginalFromRow
in classDatabaseMapping
- Parameters:
databaseRow
- TODOoriginal
- TODOjoinManager
- TODOquery
- TODOexecutionSession
- TODO
-
isOneToOneMapping
public boolean isOneToOneMapping()INTERNAL:- Overrides:
isOneToOneMapping
in classDatabaseMapping
-
isOwned
public boolean isOwned()INTERNAL:- Overrides:
isOwned
in classDatabaseMapping
-
readPrivateOwnedForObject
protected Object readPrivateOwnedForObject(ObjectLevelModifyQuery modifyQuery) throws DatabaseException INTERNAL: Reads the private owned object.- Overrides:
readPrivateOwnedForObject
in classObjectReferenceMapping
- Throws:
DatabaseException
-
rehashFieldDependancies
INTERNAL: Rehash any map based on fields. This is used to clone descriptors for aggregates, which hammer field names, it is probably better not to hammer the field name and this should be refactored.- Overrides:
rehashFieldDependancies
in classDatabaseMapping
-
requiresDataModificationEventsForMapKey
public boolean requiresDataModificationEventsForMapKey()INTERNAL: Return whether this mapping requires extra queries to update the rows if it is used as a key in a map. This will typically be true if there are any parts to this mapping that are not read-only.- Specified by:
requiresDataModificationEventsForMapKey
in interfaceMapKeyMapping
-
isOneToOneRelationship
public boolean isOneToOneRelationship()Return if this mapping is really for a OneToOne relationship. This is a backward compatibility issue, in that before the ManyToOneMapping was created OneToOneMapping was used for both. false means it may be a OneToOne or a ManyToOne (unknown). -
isOneToOnePrimaryKeyRelationship
public boolean isOneToOnePrimaryKeyRelationship()Return if this mapping is mapped using primary key join columns. -
setIsOneToOneRelationship
public void setIsOneToOneRelationship(boolean isOneToOneRelationship) Define if this mapping is really for a OneToOne relationship. This is a backward compatibility issue, in that before the ManyToOneMapping was created OneToOneMapping was used for both. -
setIsOneToOnePrimaryKeyRelationship
public void setIsOneToOnePrimaryKeyRelationship(boolean isOneToOnePrimaryKeyRelationship) Set if this mapping is defined using primary key join columns. -
setForeignKeyFieldName
PUBLIC: Define the foreign key relationship in the 1-1 mapping. This method is used for singleton foreign key relationships only, that is the source object's table has a foreign key field to the target object's primary key field. Only the source foreign key field name is specified. When a foreign key is specified TopLink will automatically populate the value for that field from the target object when the object is written to the database. If the foreign key is also mapped through a direct-to-field then the direct-to-field must be set read-only. -
setForeignKeyFieldNames
PUBLIC: Return the foreign key field names associated with the mapping. These are only the source fields that are writable. -
setPrivateOwnedCriteria
INTERNAL: Private owned criteria is used to verify the deletion of the target. It joins from the source table on the foreign key to the target table, with a parameterization of the primary key of the source object. -
setShouldVerifyDelete
public void setShouldVerifyDelete(boolean shouldVerifyDelete) PUBLIC: Verify delete is used during delete and update on private 1:1's outside of a unit of work only. It checks for the previous value of the target object through joining the source and target tables. By default it is always done, but may be disabled for performance on distributed database reasons. In the unit of work the previous value is obtained from the backup-clone so it is never used. -
setSourceToTargetKeyFieldAssociations
INTERNAL: Set a collection of the source to target field associations. -
setSourceToTargetKeyFields
INTERNAL: Set the source keys to target keys fields association. -
setTargetForeignKeyFieldName
PUBLIC: Define the target foreign key relationship in the 1-1 mapping. This method is used for singleton target foreign key relationships only, that is the target object's table has a foreign key field to the source object's primary key field. The target foreign key field name is specified. The distinction between a foreign key and target foreign key is that the 1-1 mapping will not populate the target foreign key value when written (because it is in the target table). Normally 1-1's are through foreign keys but in bi-directional 1-1's the back reference will be a target foreign key. -
setTargetToSourceKeyFields
INTERNAL: Set the target keys to source keys fields association. -
shouldVerifyDelete
public boolean shouldVerifyDelete()PUBLIC: Verify delete is used during delete and update outside of a unit of work only. It checks for the previous value of the target object through joining the source and target tables. -
shouldWriteField
INTERNAL: By default returns true. Will also return true if: 1 - WriteType is INSERT and the field is insertable. 2 - WriteType is UPDATE and the field is updatable. -
isCascadedLockingSupported
public boolean isCascadedLockingSupported()INTERNAL Return true if this mapping supports cascaded version optimistic locking.- Overrides:
isCascadedLockingSupported
in classDatabaseMapping
-
isJoiningSupported
public boolean isJoiningSupported()INTERNAL: Return if this mapping support joining.- Overrides:
isJoiningSupported
in classForeignReferenceMapping
-
iterateOnMapKey
INTERNAL: Called when iterating through descriptors to handle iteration on this mapping when it is used as a MapKey- Specified by:
iterateOnMapKey
in interfaceMapKeyMapping
-
unwrapKey
INTERNAL: Allow the key mapping to unwrap the object.- Specified by:
unwrapKey
in interfaceMapKeyMapping
-
updateInsertableAndUpdatableFields
INTERNAL: Add the field to the updatable and/or insertable list. Remove any previous field under the same name, otherwise shouldn't matter if we leave an old name (before translation) in the list as it should 'never' be used anyway. -
wrapKey
INTERNAL: Allow the key mapping to wrap the object.- Specified by:
wrapKey
in interfaceMapKeyMapping
-
writeFromAttributeIntoRow
public void writeFromAttributeIntoRow(Object attribute, AbstractRecord row, AbstractSession session) INTERNAL: A subclass should implement this method if it wants different behavior. Write the foreign key values from the attribute to the row.- Overrides:
writeFromAttributeIntoRow
in classDatabaseMapping
-
valueFromObject
INTERNAL: Get a value from the object and set that in the respective field of the row.- Overrides:
valueFromObject
in classDatabaseMapping
- Parameters:
object
- TODOfield
- TODOsession
- TODO- Returns:
- TODO
-
valueFromRowInternalWithJoin
protected Object valueFromRowInternalWithJoin(AbstractRecord row, JoinedAttributeManager joinManager, ObjectBuildingQuery sourceQuery, CacheKey parentCacheKey, AbstractSession executionSession, boolean isTargetProtected) throws DatabaseException INTERNAL: Return the value of the field from the row or a value holder on the query to obtain the object. Check for batch + aggregation reading.- Overrides:
valueFromRowInternalWithJoin
in classForeignReferenceMapping
- Throws:
DatabaseException
-
valueFromRowInternal
protected Object valueFromRowInternal(AbstractRecord row, JoinedAttributeManager joinManager, ObjectBuildingQuery sourceQuery, AbstractSession executionSession, boolean shouldUseSopObject) throws DatabaseException INTERNAL: Return the value of the field from the row or a value holder on the query to obtain the object. Check for batch + aggregation reading.- Overrides:
valueFromRowInternal
in classForeignReferenceMapping
- Parameters:
shouldUseSopObject
- indicates whether sopObject stored in the row should be used to extract the value (and fields/values stored in the row ignored).- Throws:
DatabaseException
-
writeFromObjectIntoRow
public void writeFromObjectIntoRow(Object object, AbstractRecord databaseRow, AbstractSession session, DatabaseMapping.WriteType writeType) INTERNAL: Get a value from the object and set that in the respective field of the row.- Overrides:
writeFromObjectIntoRow
in classDatabaseMapping
-
writeFromObjectIntoRowInternal
protected void writeFromObjectIntoRowInternal(Object object, AbstractRecord databaseRow, AbstractSession session, OneToOneMapping.ShallowMode mode, DatabaseMapping.WriteType writeType) INTERNAL: Get a value from the object and set that in the respective field of the row. The fields and the values added to the row depend on ShallowMode mode: null - all fields with their values from object; Insert - nullable fields added with value null, non nullable fields added with their values from object; UpdateAfterInsert - nullable fields added with with their non-null values from object, non nullable fields (and nullable with null values) are ignored; UpdateBeforeDelete - the same fields as for UpdateAfterShallowInsert - but all values are nulls. -
writeFromObjectIntoRowForShallowInsert
public void writeFromObjectIntoRowForShallowInsert(Object object, AbstractRecord databaseRow, AbstractSession session) INTERNAL: This row is built for shallow insert which happens in case of bidirectional inserts. The foreign keys must be set to null to avoid constraints.- Overrides:
writeFromObjectIntoRowForShallowInsert
in classDatabaseMapping
-
writeFromObjectIntoRowForUpdateAfterShallowInsert
public void writeFromObjectIntoRowForUpdateAfterShallowInsert(Object object, AbstractRecord databaseRow, AbstractSession session, DatabaseTable table) INTERNAL: This row is built for update after shallow insert which happens in case of bidirectional inserts. It contains the foreign keys with non null values that were set to null for shallow insert.- Overrides:
writeFromObjectIntoRowForUpdateAfterShallowInsert
in classDatabaseMapping
-
writeFromObjectIntoRowForUpdateBeforeShallowDelete
public void writeFromObjectIntoRowForUpdateBeforeShallowDelete(Object object, AbstractRecord databaseRow, AbstractSession session, DatabaseTable table) INTERNAL: This row is built for update before shallow delete which happens in case of bidirectional inserts. It contains the same fields as the row built by writeFromObjectIntoRowForUpdateAfterShallowInsert, but all the values are null.- Overrides:
writeFromObjectIntoRowForUpdateBeforeShallowDelete
in classDatabaseMapping
-
writeFromObjectIntoRowWithChangeRecord
public void writeFromObjectIntoRowWithChangeRecord(ChangeRecord changeRecord, AbstractRecord databaseRow, AbstractSession session, DatabaseMapping.WriteType writeType) INTERNAL: Get a value from the object and set that in the respective field of the row. Validation preventing primary key updates is implemented here.- Overrides:
writeFromObjectIntoRowWithChangeRecord
in classDatabaseMapping
-
writeFromObjectIntoRowForShallowInsertWithChangeRecord
public void writeFromObjectIntoRowForShallowInsertWithChangeRecord(ChangeRecord ChangeRecord, AbstractRecord databaseRow, AbstractSession session) INTERNAL: This row is built for shallow insert which happens in case of bidirectional inserts. The foreign keys must be set to null to avoid constraints.- Overrides:
writeFromObjectIntoRowForShallowInsertWithChangeRecord
in classDatabaseMapping
-
writeInsertFieldsIntoRow
INTERNAL: Write fields needed for insert into the template for with null values.- Overrides:
writeInsertFieldsIntoRow
in classDatabaseMapping
-
hasRelationTableMechanism
public boolean hasRelationTableMechanism()PUBLIC: Indicates whether the mapping has RelationTableMechanism.- Overrides:
hasRelationTableMechanism
in classObjectReferenceMapping
-
hasRelationTable
public boolean hasRelationTable()PUBLIC: Indicates whether the mapping has RelationTable. -
getRelationTableMechanism
PUBLIC: Returns RelationTableMechanism that may be owned by the mapping, that allows to configure the mapping to use relation table (just like ManyToManyMapping). By default its null, should be created and set into the mapping before use. -
setRelationTable
PUBLIC: Set the relational table. This is the join table that store both the source and target primary keys. -
setRelationTableMechanism
PUBLIC: Set RelationTableMechanism into the mapping, that allows to configure the mapping to use relation table (just like ManyToManyMapping). -
getRelationTable
PUBLIC: Return RelationTable. -
preDelete
INTERNAL: Delete privately owned parts- Overrides:
preDelete
in classObjectReferenceMapping
- Throws:
DatabaseException
OptimisticLockException
-
postInsert
INTERNAL: Insert into relation table. 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 a insert statement with above fields and values for relation table.
- execute the statement.
- Overrides:
postInsert
in classObjectReferenceMapping
- Throws:
DatabaseException
-
postUpdate
INTERNAL: Update the relation table with the entries related to this mapping. Delete entries removed, insert entries added. If private also insert/delete/update target objects.- Overrides:
postUpdate
in classObjectReferenceMapping
- Throws:
DatabaseException
-
performDataModificationEvent
public void performDataModificationEvent(Object[] event, AbstractSession session) throws DatabaseException, DescriptorException INTERNAL: Perform the commit event. This is used in the uow to delay data modifications.- Overrides:
performDataModificationEvent
in classDatabaseMapping
- Throws:
DatabaseException
DescriptorException
-
collectFields
INTERNAL: Return all the fields populated by this mapping, these are foreign keys only.- Overrides:
collectFields
in classObjectReferenceMapping
- Returns:
- TODO
-
getOrderByNormalizedExpressions
INTERNAL: Order by foreign key fields if a foreign key mapping (avoids joins).- Overrides:
getOrderByNormalizedExpressions
in classForeignReferenceMapping
-