Top Description Fields Constructors Methods
org.eclipse.persistence.internal.queries

public Class MappedKeyMapContainerPolicy

extends MapContainerPolicy
implements CoreMappedKeyMapContainerPolicy<AbstractSession>
Class Inheritance
All Implemented Interfaces
org.eclipse.persistence.internal.core.queries.CoreMappedKeyMapContainerPolicy, org.eclipse.persistence.internal.core.queries.CoreContainerPolicy
Imports
java.util.ArrayList, .Arrays, .Collection, .Iterator, .List, .Map, .Map.Entry, .Set, org.eclipse.persistence.annotations.CacheKeyType, org.eclipse.persistence.descriptors.ClassDescriptor, org.eclipse.persistence.exceptions.DescriptorException, .QueryException, .ValidationException, org.eclipse.persistence.expressions.Expression, org.eclipse.persistence.internal.core.queries.CoreMappedKeyMapContainerPolicy, org.eclipse.persistence.internal.descriptors.DescriptorIterator, org.eclipse.persistence.internal.helper.DatabaseField, .DatabaseTable, org.eclipse.persistence.internal.identitymaps.CacheId, .CacheKey, org.eclipse.persistence.internal.sessions.AbstractRecord, .AbstractSession, .CollectionChangeRecord, .MergeManager, .ObjectChangeSet, .UnitOfWorkChangeSet, .UnitOfWorkImpl, org.eclipse.persistence.mappings.AggregateObjectMapping, .Association, .CollectionMapping, .DatabaseMapping, .DirectMapMapping, .DirectToFieldMapping, .ForeignReferenceMapping, .ObjectReferenceMapping, org.eclipse.persistence.mappings.converters.Converter, org.eclipse.persistence.mappings.foundation.AbstractDirectMapping, .MapComponentMapping, .MapKeyMapping, org.eclipse.persistence.mappings.querykeys.QueryKey, org.eclipse.persistence.queries.DataReadQuery, .DatabaseQuery, .DeleteObjectQuery, .ObjectBuildingQuery, .ObjectLevelReadQuery, .ReadAllQuery, .ReadQuery, .WriteObjectQuery

A MappedKeyMapContainerPolicy should be used for mappings to implementers of Map. It differs from MapContainerPolicy by allowing the MapKey to be an otherwise unmapped column in a table rather than a mapped element of the value in the map. This container policy holds a reference to a KeyMapping that will be used to construct the key from the database and a reference to its owner which creates the value for the map. The key of the map can be any implementer of MapKeyMapping and the data representing the key can either be stored in the target table of the value mapping, or in a collection table that associates the source to the target. The data can either be everything necessary to compose the key, or foreign keys that allow the key to be retrieved
Author
tware
See Also
MapContainerPolicy, MapKeyMapping, MapComponentMapping

Field Summary

Modifier and TypeField and Description
protected MapKeyMapping
public DatabaseQuery
protected MapComponentMapping
Inherited from org.eclipse.persistence.internal.queries.MapContainerPolicy:
elementClasselementClassNamekeyFieldkeyMethodkeyName

Constructor Summary

AccessConstructor and Description
public
MappedKeyMapContainerPolicy()

INTERNAL: Construct a new policy.

public
MappedKeyMapContainerPolicy(Class<?> containerClass)

INTERNAL: Construct a new policy for the specified class.

public
MappedKeyMapContainerPolicy(String containerClassName)

INTERNAL: Construct a new policy for the specified class name.

Method Summary

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

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.addAdditionalFieldsToQuery.

INTERNAL: Called when the selection query is being initialize to add the fields for the key to the query
public void
addFieldsForMapKey(AbstractRecord joinRow)

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.addFieldsForMapKey.

INTERNAL: Called when the insert query is being initialized to ensure the fields for the key are in the insert query
public boolean
addInto(Object element, Object container, AbstractSession session)

Overrides org.eclipse.persistence.internal.queries.MapContainerPolicy.addInto.

Implements org.eclipse.persistence.internal.core.queries.CoreContainerPolicy.addInto.

INTERNAL: Add element into container which implements the Map interface.
public boolean
addInto(Object element, Object container, AbstractSession session, AbstractRecord row, DataReadQuery query, CacheKey parentCacheKey, boolean isTargetProtected)

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.addInto.

INTERNAL: This is used for ordered List containers to add all of the elements to the collection in the order of the index field in the row.
public boolean
addInto(Object element, Object container, AbstractSession session, AbstractRecord dbRow, ObjectBuildingQuery query, CacheKey parentCacheKey, boolean isTargetProtected)

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.addInto.

INTERNAL: Add element to that implements the Map interface use the row to compute the key
public void
public Object
buildCloneForKey(Object key, Object parent, CacheKey parentCacheKey, Integer refreshCascade, AbstractSession cloningSession, boolean isExisting, boolean isCacheCheckComplete)

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.buildCloneForKey.

Build a clone for the key of a Map represented by this container policy.
public Object
buildKey(AbstractRecord row, ObjectBuildingQuery query, CacheKey parentCacheKey, AbstractSession session, boolean isTargetProtected)

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.buildKey.

Extract the key for the map from the provided row.
public Object
buildKeyFromJoinedRow(AbstractRecord row, JoinedAttributeManager joinManager, ObjectBuildingQuery query, CacheKey parentCacheKey, AbstractSession session, boolean isTargetProtected)

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.buildKeyFromJoinedRow.

Extract the key for the map from the provided row.
public Object[]
buildReferencesPKList(Object container, AbstractSession session)

Overrides org.eclipse.persistence.internal.queries.MapContainerPolicy.buildReferencesPKList.

INTERNAL: This method will access the target relationship and create a list of information to rebuild the collection.
public ReadQuery
public void
cascadeDiscoverAndPersistUnregisteredNewObjects(Object object, Map<K, V> newObjects, Map<K, V> unregisteredExistingObjects, Map<K, V> visitedObjects, UnitOfWorkImpl uow, Set<E> cascadeErrors)

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.cascadeDiscoverAndPersistUnregisteredNewObjects.

INTERNAL: Cascade discover and persist new objects during commit to the map key
public void
cascadePerformRemoveIfRequired(Object object, UnitOfWorkImpl uow, Map<K, V> visitedObjects)

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.cascadePerformRemoveIfRequired.

INTERNAL: Cascade registerNew to any mappings managed by the container policy.
public void
cascadeRegisterNewIfRequired(Object object, UnitOfWorkImpl uow, Map<K, V> visitedObjects)

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.cascadeRegisterNewIfRequired.

INTERNAL: Cascade registerNew to any mappings managed by the container policy.
public Object
clone()

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.clone.

INTERNAL: The mapping clones itself to create deep copy.
public boolean
compareContainers(Object firstObjectMap, Object secondObjectMap)

INTERNAL: Return true if keys are the same.

public boolean
compareKeys(Object sourceValue, AbstractSession session)

Overrides org.eclipse.persistence.internal.queries.MapContainerPolicy.compareKeys.

INTERNAL: Return true if keys are the same in the source as the backup.
public void
convertClassNamesToClasses(ClassLoader classLoader)

Overrides org.eclipse.persistence.internal.queries.MapContainerPolicy.convertClassNamesToClasses.

INTERNAL: Convert all the class-name-based settings in this ContainerPolicy to actual class-based settings
protected void
createChangeSetForKeys(Map<K, V> originalKeyValues, CollectionChangeRecord changeRecord, AbstractSession session, ClassDescriptor referenceDescriptor)

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.createChangeSetForKeys.

INTERNAL: Create change sets that contain map keys.
public QueryKey
public Object
createWrappedObjectFromExistingWrappedObject(Object wrappedObject, Object
if this is an aggregate, the owner of the aggregate
parent
,
ClassDescriptor referenceDescriptor, MergeManager mergeManager, AbstractSession targetSession)

Overrides org.eclipse.persistence.internal.queries.MapContainerPolicy.createWrappedObjectFromExistingWrappedObject.

INTERNAL: This method will actually potentially wrap an object in two ways.
public void
deleteWrappedObject(Object objectDeleted, AbstractSession session)

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.deleteWrappedObject.

INTERNAL: Delete the key and value of the passed association passed object.
public List<DatabaseField>
getAdditionalFieldsForJoin(CollectionMapping baseMapping)

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.getAdditionalFieldsForJoin.

INTERNAL: Return any additional fields required by the policy for a fetch join.
public List<DatabaseTable>
getAdditionalTablesForJoinQuery()

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.getAdditionalTablesForJoinQuery.

INTERNAL: Return any tables that will be required when this mapping is used as part of a join query.
public Object
getCloneDataFromChangeSet(ObjectChangeSet changeSet)

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.getCloneDataFromChangeSet.

INTERNAL: Used when objects are added or removed during an update.
public ClassDescriptor
getDescriptorForMapKey()

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.getDescriptorForMapKey.

INTERNAL: Return the reference descriptor for the map key if it exists.
public DatabaseField
getDirectKeyField(CollectionMapping baseMapping)

Overrides org.eclipse.persistence.internal.queries.MapContainerPolicy.getDirectKeyField.

INTERNAL: Return the DatabaseField that represents the key in a DirectMapMapping.
public Map<DatabaseField, DatabaseField>
getForeignKeyFieldsForMapKey()

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

public List<DatabaseField>
getIdentityFieldsForMapKey()

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.getIdentityFieldsForMapKey.

INTERNAL: Return the fields that make up the identity of the mapped object.
public Converter
getKeyConverter()

INTERNAL: Get the Converter for the key of this mapping if one exists.

public MapKeyMapping
public Map<K, V>
getKeyMappingDataForWriteQuery(Object object, AbstractSession session)

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.getKeyMappingDataForWriteQuery.

INTERNAL: Add any non-Foreign-key data from an Object describe by a MapKeyMapping to a database row This is typically used in write queries to ensure all the data stored in the collection table is included in the query.
public DatabaseQuery
getKeyQuery()

INTERNAL: Some map keys must be obtained from the database.

public Expression
public Object
getKeyType()

Overrides org.eclipse.persistence.internal.queries.MapContainerPolicy.getKeyType.

INTERNAL: Return the type of the map key, this will be overridden by container policies that allow maps.
public MapComponentMapping
public void
initialize(AbstractSession session, DatabaseTable keyTable)

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.initialize.

INTERNAL: Initialize the key mapping
protected boolean
isKeyAvailableFromElement()

Overrides org.eclipse.persistence.internal.queries.MapContainerPolicy.isKeyAvailableFromElement.

CollectionTableMapContainerPolicy is for mappings where the key is stored in a table separately from the map element.
public boolean
isMapKeyAttribute()

Overrides org.eclipse.persistence.internal.queries.MapContainerPolicy.isMapKeyAttribute.

INTERNAL: Return whether a map key this container policy represents is an attribute By default this method will return false since only subclasses actually represent maps.
public boolean
isMapKeyObject()

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.isMapKeyObject.

INTERNAL: Return if the map key this container policy represents is a OneToOne.
public boolean
public void
iterateOnMapKey(DescriptorIterator iterator, Object element)

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.iterateOnMapKey.

INTERNAL: Used in Descriptor Iteration to iterate on map keys.
public Object
keyFrom(Object element, AbstractSession session)

Overrides org.eclipse.persistence.internal.queries.MapContainerPolicy.keyFrom.

INTERNAL: Return the key for the specified element.
public void
postCalculateChanges(ObjectChangeSet ocs, ClassDescriptor referenceDescriptor, DatabaseMapping mapping, UnitOfWorkImpl uow)

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.postCalculateChanges.

INTERNAL: Add the provided object to the deleted objects list on the commit manager.
public void
postCalculateChanges(Object key, Object value, ClassDescriptor referenceDescriptor, DatabaseMapping mapping, UnitOfWorkImpl uow)

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.postCalculateChanges.

INTERNAL: Add the provided object to the deleted objects list on the commit manager.
public void
postInitialize(AbstractSession session)

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.postInitialize.

INTERNAL: Some subclasses need to post initialize mappings associated with them.
public void
processAdditionalWritableMapKeyFields(AbstractSession session)

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.processAdditionalWritableMapKeyFields.

INTERNAL: This method is used to check the key mapping to ensure that it does not write to a field that is written by another mapping.
public boolean
propagatesEventsToCollection()

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.propagatesEventsToCollection.

INTERNAL: Returns true if the key mapping is an AggregateObjectMapping.
public void
propogatePostDelete(DeleteObjectQuery query, Object object)

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.propogatePostDelete.

INTERNAL: Propagate the postDeleteEvent to any additional objects the query is aware of
public void
propogatePostInsert(WriteObjectQuery query, Object object)

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.propogatePostInsert.

INTERNAL: Propagate the postDeleteEvent to any additional objects the query is aware of
public void
propogatePostUpdate(WriteObjectQuery query, Object object)

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.propogatePostUpdate.

INTERNAL: Propagate the postDeleteEvent to any additional objects the query is aware of
public void
propogatePreDelete(DeleteObjectQuery query, Object object)

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.propogatePreDelete.

INTERNAL: Propagate the postDeleteEvent to any additional objects the query is aware of
public void
propogatePreInsert(WriteObjectQuery query, Object object)

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.propogatePreInsert.

INTERNAL: Propagate the postDeleteEvent to any additional objects the query is aware of
public void
propogatePreUpdate(WriteObjectQuery query, Object object)

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.propogatePreUpdate.

INTERNAL: Propagate the postDeleteEvent to any additional objects the query is aware of
public void
recordPrivateOwnedRemovals(Object object, ClassDescriptor referenceDescriptor, UnitOfWorkImpl uow)

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.recordPrivateOwnedRemovals.

INTERNAL: Add the key and value from provided association to the deleted objects list on the commit manager.
public boolean
requiresDataModificationEvents()

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.requiresDataModificationEvents.

INTERNAL: Returns whether this ContainerPolicy requires data modification events when objects are added or deleted during update.
public void
setDescriptorForKeyMapping(ClassDescriptor descriptor)

INTERNAL: Used during initialization of DirectMapMapping.

public void
setKeyConverter(Converter keyConverter, DirectMapMapping mapping)

INTERNAL: Set a converter on the KeyField of a DirectCollectionMapping.

public void
setKeyConverterClassName(String keyConverterClassName, DirectMapMapping mapping)

INTERNAL: Set the name of the class to be used as a converter for the key of a DirectMapMaping.

public void
setKeyField(DatabaseField keyField, ClassDescriptor descriptor)

INTERNAL: Set the DatabaseField that will represent the key in a DirectMapMapping.

public void
public void
setKeyQuery(DatabaseQuery keyQuery)

INTERNAL: Some map keys must be obtained from the database.

public void
public boolean
shouldIncludeKeyInDeleteEvent()

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.shouldIncludeKeyInDeleteEvent.

INTERNAL: Return whether data for a map key must be included on a Delete datamodification event If the keyMapping is privateOwned, that data should be.
public boolean
shouldUpdateForeignKeysPostInsert()

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.shouldUpdateForeignKeysPostInsert.

INTERNAL: Certain types of container policies require an extra update statement after a relationship is inserted.
public Object
unwrapKey(Object key, AbstractSession session)

Overrides org.eclipse.persistence.internal.queries.MapContainerPolicy.unwrapKey.

INTERNAL: Allow the key to be unwrapped.
public int
updateJoinedMappingIndexesForMapKey(Map<DatabaseMapping, Object> indexList, int index)

Overrides org.eclipse.persistence.internal.queries.ContainerPolicy.updateJoinedMappingIndexesForMapKey.

INTERNAL: Update the joined mapping indices Adds the key mapping and it's index to the list of joined mappings.
public Object
valueFromPKList(Object[] pks, AbstractRecord foreignKeys, ForeignReferenceMapping mapping, AbstractSession session)

Overrides org.eclipse.persistence.internal.queries.MapContainerPolicy.valueFromPKList.

INTERNAL: This method is used to load a relationship from a list of PKs.
Inherited from org.eclipse.persistence.internal.queries.MapContainerPolicy:
addIntoaddNextValueFromIteratorIntobuildChangeSetForNewObjectInCollectionbuildCloneForValuebuildCollectionEntryclearcloneForconcatenateContainerscontainscreateChangeEventgetElementClassgetElementClassNamegetInterfaceTypegetKeyNamehasNextinitializeKeyisMapPolicyisValidContaineriteratorForkeyFromEntrykeyFromIteratornextnextEntrynextEntrypreparerecordUpdateToCollectionInChangeRecordremoveFromsetElementClasssetKeyMethodsetKeyMethodsetKeyMethodNamesetKeyNamesetKeyNamesetKeyNamesizeForunwrapElementunwrapIteratorResult