Top Description Methods
org.eclipse.persistence.mappings.foundation

public Interface MapKeyMapping

extends MapComponentMapping
Known Direct Implementers
org.eclipse.persistence.mappings.AggregateObjectMapping, org.eclipse.persistence.mappings.OneToOneMapping, org.eclipse.persistence.mappings.foundation.AbstractDirectMapping
Imports
java.util.List, .Map, .Set, org.eclipse.persistence.descriptors.ClassDescriptor, org.eclipse.persistence.exceptions.DescriptorException, org.eclipse.persistence.expressions.Expression, org.eclipse.persistence.internal.descriptors.DescriptorIterator, org.eclipse.persistence.internal.helper.DatabaseField, .DatabaseTable, org.eclipse.persistence.internal.identitymaps.CacheKey, org.eclipse.persistence.internal.queries.ContainerPolicy, .JoinedAttributeManager, .MappedKeyMapContainerPolicy, org.eclipse.persistence.internal.sessions.AbstractRecord, .AbstractSession, .MergeManager, .UnitOfWorkImpl, org.eclipse.persistence.mappings.querykeys.QueryKey, org.eclipse.persistence.queries.ObjectBuildingQuery, .ObjectLevelReadQuery, .ReadQuery

MapKeyMapping is implemented by DatabaseMappings that can be used to map the key in a map that uses a MappedKeyMapContainerPolicy. This interface provides the facilities to retreive data for the key from the database, to get data from the object to put in the database, and to appropriately initialize the mappings.
Author
tware
See Also
MappedKeyMapContainerPolicy, AbstractDirectMapping, org.eclipse.persistence.mappings.AggregateObjectMapping, org.eclipse.persistence.mappings.OneToOneMapping

Method Summary

Modifier and TypeMethod and Description
public void
addAdditionalFieldsToQuery(ReadQuery selectionQuery, Expression baseExpression)

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

public 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 query

public void
addKeyToDeletedObjectsList(Object object, Map<K, V> deletedObjects)

INTERNAL: For mappings used as MapKeys in MappedKeyContainerPolicy.

public Object
buildElementClone(Object element, Object parent, CacheKey cacheKey, Integer refreshCascade, AbstractSession cloningSession, boolean isExisting, boolean isFromSharedCache)

Build a clone of the given element in a unitOfWork

public ReadQuery
buildSelectionQueryForDirectCollectionKeyMapping(ContainerPolicy containerPolicy)

INTERNAL: Depending on the MapKeyMapping, a different selection query may be required to retrieve the map when the map is based on a DirectCollectionMapping

public void
cascadeDiscoverAndPersistUnregisteredNewObjects(Object object, Map<K, V> newObjects, Map<K, V> unregisteredExistingObjects, Map<K, V> visitedObjects, UnitOfWorkImpl uow, boolean getAttributeValueFromObject, Set<E> cascadeErrors)

INTERNAL: Cascade discover and persist new objects during commit to the map key

public void
cascadePerformRemoveIfRequired(Object object, UnitOfWorkImpl uow, Map<K, V> visitedObjects, boolean getAttributeValueFromObject)

INTERNAL: Cascade perform delete through mappings that require the cascade

public void
cascadeRegisterNewIfRequired(Object object, UnitOfWorkImpl uow, Map<K, V> visitedObjects, boolean getAttributeValueFromObject)

INTERNAL: Cascade registerNew for Create through mappings that require the cascade

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 and a join query is used.

public List<Object>
createMapComponentsFromSerializableKeyInfo(Object[] keyInfo, AbstractSession session)

INTERNAL: Create an instance of the Key object from the key information extracted from the map.

public QueryKey
createQueryKeyForMapKey()

INTERNAL: Create a query key that links to the map key

public Object
createSerializableMapKeyInfo(Object key, AbstractSession session)

INTERNAL: Creates the Array of simple types used to recreate this map.

public Object
createStubbedMapComponentFromSerializableKeyInfo(Object keyInfo, AbstractSession session)

INTERNAL: Create an instance of the Key object from the key information extracted from the map.

public void
deleteMapKey(Object objectDeleted, AbstractSession session)

INTERNAL: For mappings used as MapKeys in MappedKeyContainerPolicy, Delete the passed object if necessary.

public Map<K, V>
extractIdentityFieldsForQuery(Object key, AbstractSession session)

INTERNAL: Extract the fields for the Map key from the object to use in a query

public Expression
getAdditionalSelectionCriteriaForMapKey()

INTERNAL: Return the selection criteria necessary to select the target object

public List<DatabaseTable>
getAdditionalTablesForJoinQuery()

INTERNAL: Return any tables that will be required when this mapping is used as part of a join query

public List<DatabaseField>
getAllFieldsForMapKey()

INTERNAL: Get all the fields for the map key

public Map<DatabaseField, DatabaseField>
getForeignKeyFieldsForMapKey()

INTERNAL: Return a Map of any foreign keys defined within the the MapKey

public List<DatabaseField>
getIdentityFieldsForMapKey()

INTERNAL: Return the fields that make up the identity of the mapped object.

public Object
getMapKeyTargetType()

INTERNAL: Return the class this key mapping maps or the descriptor for it

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

public ClassDescriptor
getReferenceDescriptor()

INTERNAL: Get the descriptor for the Map Key

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

public void
iterateOnMapKey(DescriptorIterator iterator, Object element)

INTERNAL: Called when iterating through descriptors to handle iteration on this mapping when it is used as a MapKey

public void
postInitializeMapKey(MappedKeyMapContainerPolicy policy)

INTERNAL: Making any mapping changes necessary to use a the mapping as a map key after initializing the mapping

public void
preinitializeMapKey(DatabaseTable table)

INTERNAL: Making any mapping changes necessary to use a the mapping as a map key prior to initializing the mapping

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.

public Object
unwrapKey(Object key, AbstractSession session)

INTERNAL: Allow the key mapping to unwrap the object

public Object
wrapKey(Object key, AbstractSession session)

INTERNAL: Allow the key mapping to wrap the object

Inherited from org.eclipse.persistence.mappings.foundation.MapComponentMapping:
clonecreateMapComponentFromRow

Method Detail

addAdditionalFieldsToQueryback to summary
public void addAdditionalFieldsToQuery(ReadQuery selectionQuery, Expression baseExpression)

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

addFieldsForMapKeyback to summary
public 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 query

addKeyToDeletedObjectsListback to summary
public void addKeyToDeletedObjectsList(Object object, Map<K, V> deletedObjects)

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

buildElementCloneback to summary
public Object buildElementClone(Object element, Object parent, CacheKey cacheKey, Integer refreshCascade, AbstractSession cloningSession, boolean isExisting, boolean isFromSharedCache)

Build a clone of the given element in a unitOfWork

buildSelectionQueryForDirectCollectionKeyMappingback to summary
public ReadQuery buildSelectionQueryForDirectCollectionKeyMapping(ContainerPolicy containerPolicy)

INTERNAL: Depending on the MapKeyMapping, a different selection query may be required to retrieve the map when the map is based on a DirectCollectionMapping

cascadeDiscoverAndPersistUnregisteredNewObjectsback to summary
public void cascadeDiscoverAndPersistUnregisteredNewObjects(Object object, Map<K, V> newObjects, Map<K, V> unregisteredExistingObjects, Map<K, V> visitedObjects, UnitOfWorkImpl uow, boolean getAttributeValueFromObject, Set<E> cascadeErrors)

INTERNAL: Cascade discover and persist new objects during commit to the map key

cascadePerformRemoveIfRequiredback to summary
public void cascadePerformRemoveIfRequired(Object object, UnitOfWorkImpl uow, Map<K, V> visitedObjects, boolean getAttributeValueFromObject)

INTERNAL: Cascade perform delete through mappings that require the cascade

cascadeRegisterNewIfRequiredback to summary
public void cascadeRegisterNewIfRequired(Object object, UnitOfWorkImpl uow, Map<K, V> visitedObjects, boolean getAttributeValueFromObject)

INTERNAL: Cascade registerNew for Create through mappings that require the cascade

createMapComponentFromJoinedRowback to summary
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 and a join query is used. Returns the key.

createMapComponentsFromSerializableKeyInfoback to summary
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.

createQueryKeyForMapKeyback to summary
public QueryKey createQueryKeyForMapKey()

INTERNAL: Create a query key that links to the map key

createSerializableMapKeyInfoback to summary
public Object createSerializableMapKeyInfo(Object key, AbstractSession session)

INTERNAL: Creates the Array of simple types used to recreate this map.

createStubbedMapComponentFromSerializableKeyInfoback to summary
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.

deleteMapKeyback to summary
public void deleteMapKey(Object objectDeleted, AbstractSession session)

INTERNAL: For mappings used as MapKeys in MappedKeyContainerPolicy, Delete the passed object if necessary. This method is used for removal of private owned relationships

extractIdentityFieldsForQueryback to summary
public Map<K, V> extractIdentityFieldsForQuery(Object key, AbstractSession session)

INTERNAL: Extract the fields for the Map key from the object to use in a query

getAdditionalSelectionCriteriaForMapKeyback to summary
public Expression getAdditionalSelectionCriteriaForMapKey()

INTERNAL: Return the selection criteria necessary to select the target object

getAdditionalTablesForJoinQueryback to summary
public List<DatabaseTable> getAdditionalTablesForJoinQuery()

INTERNAL: Return any tables that will be required when this mapping is used as part of a join query

getAllFieldsForMapKeyback to summary
public List<DatabaseField> getAllFieldsForMapKey()

INTERNAL: Get all the fields for the map key

getForeignKeyFieldsForMapKeyback to summary
public Map<DatabaseField, DatabaseField> getForeignKeyFieldsForMapKey()

INTERNAL: Return a Map of any foreign keys defined within the the MapKey

getIdentityFieldsForMapKeyback to summary
public List<DatabaseField> 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

getMapKeyTargetTypeback to summary
public Object getMapKeyTargetType()

INTERNAL: Return the class this key mapping maps or the descriptor for it

getNestedJoinQueryback to summary
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

getReferenceDescriptorback to summary
public ClassDescriptor getReferenceDescriptor()

INTERNAL: Get the descriptor for the Map Key

getTargetVersionOfSourceObjectback to summary
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

iterateOnMapKeyback to summary
public void iterateOnMapKey(DescriptorIterator iterator, Object element)

INTERNAL: Called when iterating through descriptors to handle iteration on this mapping when it is used as a MapKey

postInitializeMapKeyback to summary
public void postInitializeMapKey(MappedKeyMapContainerPolicy policy) throws DescriptorException

INTERNAL: Making any mapping changes necessary to use a the mapping as a map key after initializing the mapping

preinitializeMapKeyback to summary
public void preinitializeMapKey(DatabaseTable table) throws DescriptorException

INTERNAL: Making any mapping changes necessary to use a the mapping as a map key prior to initializing the mapping

requiresDataModificationEventsForMapKeyback to summary
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.

unwrapKeyback to summary
public Object unwrapKey(Object key, AbstractSession session)

INTERNAL: Allow the key mapping to unwrap the object

wrapKeyback to summary
public Object wrapKey(Object key, AbstractSession session)

INTERNAL: Allow the key mapping to wrap the object