Module org.eclipse.persistence.core
Class MapContainerPolicy
java.lang.Object
org.eclipse.persistence.internal.queries.ContainerPolicy
org.eclipse.persistence.internal.queries.InterfaceContainerPolicy
org.eclipse.persistence.internal.queries.MapContainerPolicy
- All Implemented Interfaces:
Serializable,Cloneable,CoreContainerPolicy<AbstractSession>
- Direct Known Subclasses:
MappedKeyMapContainerPolicy
Purpose: A MapContainerPolicy is ContainerPolicy whose container class implements the Map interface.
Responsibilities: Provide the functionality to operate on an instance of a Map.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classINTERNAL: This inner class is used to iterate through the Map.Entry s of a Map. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Class<?> protected Stringprotected Fieldprotected Methodprotected StringThe Method which is called on each value added to the Map and whose result is used as key to the value.Fields inherited from class org.eclipse.persistence.internal.queries.InterfaceContainerPolicy
cloneMethod, containerClass, containerClassNameFields inherited from class org.eclipse.persistence.internal.queries.ContainerPolicy
constructor, defaultContainerClass, elementDescriptor -
Constructor Summary
ConstructorsConstructorDescriptionINTERNAL: Construct a new policy.MapContainerPolicy(Class<?> containerClass) INTERNAL: Construct a new policy for the specified class.MapContainerPolicy(String containerClassName) INTERNAL: Construct a new policy for the specified class name. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddInto(Object key, Object element, Object container, AbstractSession session) INTERNAL: Add element into container which implements the Map interface.booleanaddInto(Object element, Object container, AbstractSession session) INTERNAL: Add element to container.voidaddNextValueFromIteratorInto(Object valuesIterator, Object parent, CacheKey parentCacheKey, Object toCollection, CollectionMapping mapping, Integer refreshCascade, AbstractSession cloningSession, boolean isExisting, boolean isFromSharedCache) INTERNAL: This method is used to add the next value from an iterator built using ContainerPolicy's iteratorFor() method into the toCollection.voidbuildChangeSetForNewObjectInCollection(Object object, ClassDescriptor referenceDescriptor, UnitOfWorkChangeSet uowChangeSet, AbstractSession session) INTERNAL: Ensure the new key is set for the change set for a new map objectprotected ObjectbuildCloneForValue(Object value, Object parent, CacheKey parentCacheKey, CollectionMapping mapping, Integer refreshCascade, AbstractSession cloningSession, boolean isExisting, boolean isFromSharedCache) Build a clone for the value in a mapping.buildCollectionEntry(Object objectAdded, ObjectChangeSet changeSet) INTERNAL: Return an object representing an entry in the collection represented by this container policy This method will returns an Association containing the key and the value for a MapObject[]buildReferencesPKList(Object container, AbstractSession session) INTERNAL: This method will access the target relationship and create a list of information to rebuild the collection.voidINTERNAL: Remove all the elements from container.INTERNAL: Return a clone of the specified container.booleancompareKeys(Object sourceValue, AbstractSession session) INTERNAL: Return true if keys are the same in the source as the backup.concatenateContainers(Object firstContainer, Object secondContainer, AbstractSession session) INTERNAL: Build a new container, add the contents of each of the specified containers to it, and return it.protected booleanINTERNAL: Return the true if element exists in container.voidconvertClassNamesToClasses(ClassLoader classLoader) INTERNAL: Convert all the class-name-based settings in this ContainerPolicy to actual class-based settings.createChangeEvent(Object collectionOwner, String propertyName, Object collectionChanged, Object elementChanged, int changeType, Integer index, boolean isChangeApplied) INTERNAL: Creates a CollectionChangeEvent for the containerINTERNAL: Create a query key that links to the map key.createWrappedObjectFromExistingWrappedObject(Object wrappedObject, Object parent, ClassDescriptor referenceDescriptor, MergeManager mergeManager, AbstractSession targetSession) INTERNAL: This method will actually potentially wrap an object in two ways.getDirectKeyField(CollectionMapping baseMapping) INTERNAL: Return the DatabaseField that represents the key in a DirectMapMapping.Class<?> INTERNAL: Returns the element class which defines the map key.INTERNAL: Returns the element class name which defines the map key.Class<?> INTERNAL:INTERNAL: Returns the key name which will return the value of the key to be used in the container.INTERNAL: Return the type of the map key, this will be overridden by container policies that allow maps.booleanINTERNAL: Return whether the iterator has more objects.protected voidINTERNAL: Set the keyMethod or keyField based on the keyName.protected booleanMapContainerPolicy is for mappings where the key is stored in actual element.booleanINTERNAL: Return whether a map key this container policy represents is an attribute.booleanINTERNAL Yes this is a MapPolicybooleanisValidContainer(Object container) INTERNAL: Validate the container type.iteratorFor(Object container) INTERNAL: Return an Iterator for the given container.keyFrom(Object element, AbstractSession session) INTERNAL: Return the key for the specified element.keyFromEntry(Object entry) Get the key from the passed in Map.Entry.keyFromIterator(Object iterator) protected ObjectINTERNAL: Return the next object on the queue.INTERNAL: Return the next object on the queue.nextEntry(Object iterator, AbstractSession session) INTERNAL: Return the next object on the queue.voidprepare(DatabaseQuery query, AbstractSession session) Prepare and validate.voidrecordUpdateToCollectionInChangeRecord(CollectionChangeEvent event, ObjectChangeSet changeSet, CollectionChangeRecord collectionChangeRecord) This method is used to bridge the behavior between Attribute Change Tracking and deferred change tracking with respect to adding the same instance multiple times.booleanremoveFrom(Object key, Object element, Object container, AbstractSession session) INTERNAL: Remove element from container which implements the Map interface.voidsetElementClass(Class<?> elementClass) INTERNAL: Sets the element class which defines the method.voidsetKeyMethod(String keyMethodName, Class<?> elementClass) INTERNAL: Sets the Method to be used to generate the key in a Map type container class.voidsetKeyMethod(String keyMethodName, String elementClassName) INTERNAL: Sets the Method to be used to generate the key in a Map type container class.voidsetKeyMethodName(String keyMethodName) INTERNAL: Sets the Method to be used to generate the key in a Map type container class.voidsetKeyName(String keyName) INTERNAL: Sets the key name to be used to generate the key in a Map type container class.voidsetKeyName(String keyName, Class<?> elementClass) INTERNAL: Sets the key name to be used to generate the key in a Map type container class.voidsetKeyName(String keyName, String elementClassName) INTERNAL: Sets the key name to be used to generate the key in a Map type container class.intINTERNAL: Return the size of container.unwrapElement(Object object) INTERNAL: MapContainerPolicy's iterator iterates on the Entries of a Map.unwrapIteratorResult(Object object) INTERNAL: MapContainerPolicy's iterator iterates on the Entries of a Map.unwrapKey(Object key, AbstractSession session) INTERNAL: Allow the key to be unwrapped.valueFromPKList(Object[] pks, AbstractRecord foreignKeys, ForeignReferenceMapping mapping, AbstractSession session) INTERNAL: This method is used to load a relationship from a list of PKs.Methods inherited from class org.eclipse.persistence.internal.queries.InterfaceContainerPolicy
buildContainerFromVector, equals, getCloneMethod, getCloneMethod, getContainerClass, getContainerClassName, hashCode, invokeCloneMethodOn, isValidContainerType, setCloneMethod, setContainerClass, setContainerClassName, toStringInfoMethods inherited from class org.eclipse.persistence.internal.queries.ContainerPolicy
addAdditionalFieldsToQuery, addAll, addAll, addFieldsForMapKey, addInto, addInto, addNestedJoinsQueriesForMapKey, buildCloneForKey, buildDefaultPolicy, buildKey, buildKeyFromJoinedRow, buildPolicyFor, buildPolicyFor, buildSelectionQueryForDirectCollectionMapping, cascadeDiscoverAndPersistUnregisteredNewObjects, cascadePerformRemoveIfRequired, cascadeRegisterNewIfRequired, clone, clone, collectObjectForNewCollection, compareCollectionsForChange, containerInstance, containerInstance, contains, copyMapDataToRow, createChangeSetForKeys, deleteWrappedObject, execute, getAdditionalFieldsForJoin, getAdditionalTablesForJoinQuery, getChangeValuesFrom, getCloneDataFromChangeSet, getConstructor, getDefaultContainerClass, getDescriptorForMapKey, getElementDescriptor, getIdentityFieldsForMapKey, getKeyMappingDataForWriteQuery, getKeySelectionCriteria, hasElementDescriptor, hasOrder, initialize, initializeConstructor, isCollectionPolicy, isCursoredStreamPolicy, isCursorPolicy, isDirectMapPolicy, isEmpty, isListPolicy, isMapKeyObject, isMappedKeyMapPolicy, isOrderedListPolicy, isScrollableCursorPolicy, iterateOnMapKey, mergeCascadeParts, mergeChanges, mergeChanges, next, overridesRead, postCalculateChanges, postCalculateChanges, postInitialize, prepareForExecution, processAdditionalWritableMapKeyFields, propagatesEventsToCollection, propogatePostDelete, propogatePostInsert, propogatePostUpdate, propogatePreDelete, propogatePreInsert, propogatePreUpdate, recordAddToCollectionInChangeRecord, recordPrivateOwnedRemovals, recordRemoveFromCollectionInChangeRecord, remoteExecute, removeFrom, removeFrom, requiresDataModificationEvents, setConstructor, setDefaultContainerClass, setElementDescriptor, shouldAddAll, shouldIncludeKeyInDeleteEvent, shouldUpdateForeignKeysPostInsert, toString, updateChangeRecordForSelfMerge, updateJoinedMappingIndexesForMapKey, vectorFor
-
Field Details
-
keyName
The Method which is called on each value added to the Map and whose result is used as key to the value. -
elementClassName
-
elementClass
-
keyField
-
keyMethod
-
-
Constructor Details
-
MapContainerPolicy
public MapContainerPolicy()INTERNAL: Construct a new policy. -
MapContainerPolicy
INTERNAL: Construct a new policy for the specified class. -
MapContainerPolicy
INTERNAL: Construct a new policy for the specified class name.
-
-
Method Details
-
prepare
Prepare and validate. Set the element class.- Overrides:
preparein classContainerPolicy- Throws:
QueryException
-
addInto
INTERNAL: Add element to container. This is used to add to a collection independent of the collection type. The session may be required to wrap for the wrapper policy. Return whether the container changed.- Specified by:
addIntoin interfaceCoreContainerPolicy<AbstractSession>- Overrides:
addIntoin classContainerPolicy
-
addInto
INTERNAL: Add element into container which implements the Map interface.- Specified by:
addIntoin interfaceCoreContainerPolicy<AbstractSession>- Overrides:
addIntoin classContainerPolicy
-
addNextValueFromIteratorInto
public void addNextValueFromIteratorInto(Object valuesIterator, Object parent, CacheKey parentCacheKey, Object toCollection, CollectionMapping mapping, Integer refreshCascade, AbstractSession cloningSession, boolean isExisting, boolean isFromSharedCache) INTERNAL: This method is used to add the next value from an iterator built using ContainerPolicy's iteratorFor() method into the toCollection. Since this ContainerPolicy represents a Map, the key and the value are extracted and added.- Overrides:
addNextValueFromIteratorIntoin classContainerPolicy- See Also:
-
buildCollectionEntry
INTERNAL: Return an object representing an entry in the collection represented by this container policy This method will returns an Association containing the key and the value for a Map- Overrides:
buildCollectionEntryin classContainerPolicy- See Also:
-
buildReferencesPKList
INTERNAL: This method will access the target relationship and create a list of information to rebuild the collection. For the MapContainerPolicy this return will consist of an array with serial Map entry key and value elements.- Overrides:
buildReferencesPKListin classContainerPolicy- See Also:
-
buildChangeSetForNewObjectInCollection
public void buildChangeSetForNewObjectInCollection(Object object, ClassDescriptor referenceDescriptor, UnitOfWorkChangeSet uowChangeSet, AbstractSession session) INTERNAL: Ensure the new key is set for the change set for a new map object- Overrides:
buildChangeSetForNewObjectInCollectionin classContainerPolicy
-
buildCloneForValue
protected Object buildCloneForValue(Object value, Object parent, CacheKey parentCacheKey, CollectionMapping mapping, Integer refreshCascade, AbstractSession cloningSession, boolean isExisting, boolean isFromSharedCache) Build a clone for the value in a mapping. -
clear
INTERNAL: Remove all the elements from container.- Specified by:
clearin interfaceCoreContainerPolicy<AbstractSession>- Overrides:
clearin classContainerPolicy
-
cloneFor
INTERNAL: Return a clone of the specified container.- Overrides:
cloneForin classInterfaceContainerPolicy
-
compareKeys
INTERNAL: Return true if keys are the same in the source as the backup. False otherwise in the case of read-only compare against the original- Overrides:
compareKeysin classContainerPolicy
-
concatenateContainers
public Object concatenateContainers(Object firstContainer, Object secondContainer, AbstractSession session) INTERNAL: Build a new container, add the contents of each of the specified containers to it, and return it. Both of the containers must use the same container policy (namely, this one).- Overrides:
concatenateContainersin classContainerPolicy
-
contains
INTERNAL: Return the true if element exists in container.- Overrides:
containsin classContainerPolicy- Returns:
- boolean true if container 'contains' element
-
convertClassNamesToClasses
INTERNAL: Convert all the class-name-based settings in this ContainerPolicy to actual class-based settings. This method is used when converting a project that has been built with class names to a project with classes.- Overrides:
convertClassNamesToClassesin classInterfaceContainerPolicy
-
createChangeEvent
public CollectionChangeEvent createChangeEvent(Object collectionOwner, String propertyName, Object collectionChanged, Object elementChanged, int changeType, Integer index, boolean isChangeApplied) INTERNAL: Creates a CollectionChangeEvent for the container- Overrides:
createChangeEventin classInterfaceContainerPolicy
-
createQueryKeyForMapKey
INTERNAL: Create a query key that links to the map key. MapContainerPolicy does not have a specific mapping for the key, so return null.- Overrides:
createQueryKeyForMapKeyin classInterfaceContainerPolicy
-
createWrappedObjectFromExistingWrappedObject
public Object createWrappedObjectFromExistingWrappedObject(Object wrappedObject, Object parent, ClassDescriptor referenceDescriptor, MergeManager mergeManager, AbstractSession targetSession) INTERNAL: This method will actually potentially wrap an object in two ways. It will first wrap the object based on the referenceDescriptor's wrapper policy. It will also potentially do some wrapping based on what is required by the container policy.- Overrides:
createWrappedObjectFromExistingWrappedObjectin classContainerPolicy- Parameters:
parent- if this is an aggregate, the owner of the aggregate- See Also:
-
getDirectKeyField
INTERNAL: Return the DatabaseField that represents the key in a DirectMapMapping. MapContainerPolicy gets it fields from the reference descriptor of the provided mappings. It uses its keyName to lookup the appropriate mapping and returns the field from that mapping.- Overrides:
getDirectKeyFieldin classInterfaceContainerPolicy
-
getElementClass
INTERNAL: Returns the element class which defines the map key. -
getElementClassName
INTERNAL: Returns the element class name which defines the map key. -
getInterfaceType
INTERNAL:- Specified by:
getInterfaceTypein classInterfaceContainerPolicy
-
getKeyName
INTERNAL: Returns the key name which will return the value of the key to be used in the container. -
getKeyType
INTERNAL: Return the type of the map key, this will be overridden by container policies that allow maps.- Overrides:
getKeyTypein classContainerPolicy
-
isMapPolicy
public boolean isMapPolicy()INTERNAL Yes this is a MapPolicy- Overrides:
isMapPolicyin classContainerPolicy
-
isKeyAvailableFromElement
protected boolean isKeyAvailableFromElement()MapContainerPolicy is for mappings where the key is stored in actual element. -
isMapKeyAttribute
public boolean isMapKeyAttribute()INTERNAL: Return whether a map key this container policy represents is an attribute.- Overrides:
isMapKeyAttributein classInterfaceContainerPolicy
-
hasNext
INTERNAL: Return whether the iterator has more objects. The iterator is the one returned from #iteratorFor().- Specified by:
hasNextin interfaceCoreContainerPolicy<AbstractSession>- Overrides:
hasNextin classInterfaceContainerPolicy- See Also:
-
initializeKey
protected void initializeKey()INTERNAL: Set the keyMethod or keyField based on the keyName. -
iteratorFor
INTERNAL: Return an Iterator for the given container.- Specified by:
iteratorForin interfaceCoreContainerPolicy<AbstractSession>- Specified by:
iteratorForin classContainerPolicy- See Also:
-
keyFrom
INTERNAL: Return the key for the specified element.- Overrides:
keyFromin classContainerPolicy
-
keyFromEntry
Get the key from the passed in Map.Entry.- Overrides:
keyFromEntryin classContainerPolicy
-
keyFromIterator
- Overrides:
keyFromIteratorin classContainerPolicy
-
next
INTERNAL: Return the next object on the queue. The iterator is the one returned from #iteratorFor().- Overrides:
nextin classInterfaceContainerPolicy- See Also:
-
nextEntry
INTERNAL: Return the next object on the queue. The iterator is the one returned from #iteratorFor(). This will return a MapEntry to allow use of the key- Specified by:
nextEntryin interfaceCoreContainerPolicy<AbstractSession>- Overrides:
nextEntryin classContainerPolicy- See Also:
-
nextEntry
INTERNAL: Return the next object on the queue. The iterator is the one returned from #iteratorFor(). This will return a MapEntry to allow use of the key- Specified by:
nextEntryin interfaceCoreContainerPolicy<AbstractSession>- Overrides:
nextEntryin classContainerPolicy- See Also:
-
unwrapElement
INTERNAL: MapContainerPolicy's iterator iterates on the Entries of a Map. This method returns the object from the iterator- Overrides:
unwrapElementin classContainerPolicy- See Also:
-
unwrapIteratorResult
INTERNAL: MapContainerPolicy's iterator iterates on the Entries of a Map. This method returns the object from the iterator- Overrides:
unwrapIteratorResultin classContainerPolicy- See Also:
-
unwrapKey
INTERNAL: Allow the key to be unwrapped. This will be overridden by container policies that allow keys that are entities. -
recordUpdateToCollectionInChangeRecord
public void recordUpdateToCollectionInChangeRecord(CollectionChangeEvent event, ObjectChangeSet changeSet, CollectionChangeRecord collectionChangeRecord) This method is used to bridge the behavior between Attribute Change Tracking and deferred change tracking with respect to adding the same instance multiple times. Each ContainerPolicy type will implement specific behavior for the collection type it is wrapping. These methods are only valid for collections containing object references- Overrides:
recordUpdateToCollectionInChangeRecordin classContainerPolicy
-
removeFrom
INTERNAL: Remove element from container which implements the Map interface.- Overrides:
removeFromin classContainerPolicy
-
setElementClass
INTERNAL: Sets the element class which defines the method. -
isValidContainer
INTERNAL: Validate the container type.- Overrides:
isValidContainerin classContainerPolicy- See Also:
-
setKeyName
INTERNAL: Sets the key name to be used to generate the key in a Map type container class. The key name, may be the name of a field or method.- Overrides:
setKeyNamein classContainerPolicy- See Also:
-
setKeyName
INTERNAL: Sets the key name to be used to generate the key in a Map type container class. The key name, may be the name of a field or method. An instance of the class is provided in the case when the descriptor is being built in code.- Overrides:
setKeyNamein classContainerPolicy
-
setKeyName
INTERNAL: Sets the key name to be used to generate the key in a Map type container class. The key name, maybe the name of a field or method. -
setKeyMethod
INTERNAL: Sets the Method to be used to generate the key in a Map type container class. -
setKeyMethod
INTERNAL: Sets the Method to be used to generate the key in a Map type container class. -
setKeyMethodName
INTERNAL: Sets the Method to be used to generate the key in a Map type container class. -
sizeFor
INTERNAL: Return the size of container.- Specified by:
sizeForin interfaceCoreContainerPolicy<AbstractSession>- Overrides:
sizeForin classContainerPolicy
-
valueFromPKList
public Object valueFromPKList(Object[] pks, AbstractRecord foreignKeys, ForeignReferenceMapping mapping, AbstractSession session) INTERNAL: This method is used to load a relationship from a list of PKs. This list may be available if the relationship has been cached.- Overrides:
valueFromPKListin classContainerPolicy
-