Class MappedKeyMapContainerPolicy
- java.lang.Object
-
- org.eclipse.persistence.internal.queries.ContainerPolicy
-
- org.eclipse.persistence.internal.queries.InterfaceContainerPolicy
-
- org.eclipse.persistence.internal.queries.MapContainerPolicy
-
- org.eclipse.persistence.internal.queries.MappedKeyMapContainerPolicy
-
- All Implemented Interfaces:
Serializable
,Cloneable
,CoreContainerPolicy<AbstractSession>
,CoreMappedKeyMapContainerPolicy<AbstractSession>
public class MappedKeyMapContainerPolicy extends MapContainerPolicy implements CoreMappedKeyMapContainerPolicy<AbstractSession>
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
, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.persistence.internal.queries.MapContainerPolicy
MapContainerPolicy.MapContainerPolicyIterator
-
-
Field Summary
Fields Modifier and Type Field Description protected MapKeyMapping
keyMapping
DatabaseQuery
keyQuery
protected MapComponentMapping
valueMapping
-
Fields inherited from class org.eclipse.persistence.internal.queries.MapContainerPolicy
elementClass, elementClassName, keyField, keyMethod, keyName
-
Fields inherited from class org.eclipse.persistence.internal.queries.InterfaceContainerPolicy
cloneMethod, containerClass, containerClassName
-
Fields inherited from class org.eclipse.persistence.internal.queries.ContainerPolicy
constructor, defaultContainerClass, elementDescriptor
-
-
Constructor Summary
Constructors Constructor Description MappedKeyMapContainerPolicy()
INTERNAL: Construct a new policy.MappedKeyMapContainerPolicy(Class containerClass)
INTERNAL: Construct a new policy for the specified class.MappedKeyMapContainerPolicy(String containerClassName)
INTERNAL: Construct a new policy for the specified class name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAdditionalFieldsToQuery(ReadQuery selectionQuery, Expression baseExpression)
INTERNAL: Called when the selection query is being initialize to add the fields for the key to the queryvoid
addFieldsForMapKey(AbstractRecord joinRow)
INTERNAL: Called when the insert query is being initialized to ensure the fields for the key are in the insert queryboolean
addInto(Object element, Object container, AbstractSession session)
INTERNAL: Add element into container which implements the Map interface.boolean
addInto(Object element, Object container, AbstractSession session, AbstractRecord row, DataReadQuery query, CacheKey parentCacheKey, boolean isTargetProtected)
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.boolean
addInto(Object element, Object container, AbstractSession session, AbstractRecord dbRow, ObjectBuildingQuery query, CacheKey parentCacheKey, boolean isTargetProtected)
INTERNAL: Add element to that implements the Map interface use the row to compute the keyvoid
addNestedJoinsQueriesForMapKey(JoinedAttributeManager joinManager, ObjectLevelReadQuery query, AbstractSession session)
INTERNAL: Used for joining.Object
buildCloneForKey(Object key, Object parent, CacheKey parentCacheKey, Integer refreshCascade, AbstractSession cloningSession, boolean isExisting, boolean isCacheCheckComplete)
Build a clone for the key of a Map represented by this container policy.Object
buildKey(AbstractRecord row, ObjectBuildingQuery query, CacheKey parentCacheKey, AbstractSession session, boolean isTargetProtected)
Extract the key for the map from the provided row.Object
buildKeyFromJoinedRow(AbstractRecord row, JoinedAttributeManager joinManager, ObjectBuildingQuery query, CacheKey parentCacheKey, AbstractSession session, boolean isTargetProtected)
Extract the key for the map from the provided row.Object[]
buildReferencesPKList(Object container, AbstractSession session)
INTERNAL: This method will access the target relationship and create a list of information to rebuild the collection.ReadQuery
buildSelectionQueryForDirectCollectionMapping()
INTERNAL: Certain key mappings favor different types of selection query.void
cascadeDiscoverAndPersistUnregisteredNewObjects(Object object, Map newObjects, Map unregisteredExistingObjects, Map visitedObjects, UnitOfWorkImpl uow, Set cascadeErrors)
INTERNAL: Cascade discover and persist new objects during commit to the map keyvoid
cascadePerformRemoveIfRequired(Object object, UnitOfWorkImpl uow, Map visitedObjects)
INTERNAL: Cascade registerNew to any mappings managed by the container policy.void
cascadeRegisterNewIfRequired(Object object, UnitOfWorkImpl uow, Map visitedObjects)
INTERNAL: Cascade registerNew to any mappings managed by the container policy.Object
clone()
INTERNAL: The mapping clones itself to create deep copy.boolean
compareContainers(Object firstObjectMap, Object secondObjectMap)
INTERNAL: Return true if keys are the same.boolean
compareKeys(Object sourceValue, AbstractSession session)
INTERNAL: Return true if keys are the same in the source as the backup.void
convertClassNamesToClasses(ClassLoader classLoader)
INTERNAL: Convert all the class-name-based settings in this ContainerPolicy to actual class-based settingsprotected void
createChangeSetForKeys(Map originalKeyValues, CollectionChangeRecord changeRecord, AbstractSession session, ClassDescriptor referenceDescriptor)
INTERNAL: Create change sets that contain map keys.QueryKey
createQueryKeyForMapKey()
INTERNAL: Create a query key that links to the map key.Object
createWrappedObjectFromExistingWrappedObject(Object wrappedObject, Object parent, ClassDescriptor referenceDescriptor, MergeManager mergeManager, AbstractSession targetSession)
INTERNAL: This method will actually potentially wrap an object in two ways.void
deleteWrappedObject(Object objectDeleted, AbstractSession session)
INTERNAL: Delete the key and value of the passed association passed object.List<DatabaseField>
getAdditionalFieldsForJoin(CollectionMapping baseMapping)
INTERNAL: Return any additional fields required by the policy for a fetch join.List<DatabaseTable>
getAdditionalTablesForJoinQuery()
INTERNAL: Return any tables that will be required when this mapping is used as part of a join query.Object
getCloneDataFromChangeSet(ObjectChangeSet changeSet)
INTERNAL: Used when objects are added or removed during an update.ClassDescriptor
getDescriptorForMapKey()
INTERNAL: Return the reference descriptor for the map key if it exists.DatabaseField
getDirectKeyField(CollectionMapping baseMapping)
INTERNAL: Return the DatabaseField that represents the key in a DirectMapMapping.Map<DatabaseField,DatabaseField>
getForeignKeyFieldsForMapKey()
INTERNAL: Return a Map of any foreign keys defined within the the MapKey.List<DatabaseField>
getIdentityFieldsForMapKey()
INTERNAL: Return the fields that make up the identity of the mapped object.Converter
getKeyConverter()
INTERNAL: Get the Converter for the key of this mapping if one exists.MapKeyMapping
getKeyMapping()
Map
getKeyMappingDataForWriteQuery(Object object, AbstractSession session)
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.DatabaseQuery
getKeyQuery()
INTERNAL: Some map keys must be obtained from the database.Expression
getKeySelectionCriteria()
INTERNAL: Get the selection criteria for the map key.Object
getKeyType()
INTERNAL: Return the type of the map key, this will be overridden by container policies that allow maps.MapComponentMapping
getValueMapping()
void
initialize(AbstractSession session, DatabaseTable keyTable)
INTERNAL: Initialize the key mappingprotected boolean
isKeyAvailableFromElement()
CollectionTableMapContainerPolicy is for mappings where the key is stored in a table separately from the map element.boolean
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.boolean
isMapKeyObject()
INTERNAL: Return if the map key this container policy represents is a OneToOne.boolean
isMappedKeyMapPolicy()
void
iterateOnMapKey(DescriptorIterator iterator, Object element)
INTERNAL: Used in Descriptor Iteration to iterate on map keys.Object
keyFrom(Object element, AbstractSession session)
INTERNAL: Return the key for the specified element.void
postCalculateChanges(Object key, Object value, ClassDescriptor referenceDescriptor, DatabaseMapping mapping, UnitOfWorkImpl uow)
INTERNAL: Add the provided object to the deleted objects list on the commit manager.void
postCalculateChanges(ObjectChangeSet ocs, ClassDescriptor referenceDescriptor, DatabaseMapping mapping, UnitOfWorkImpl uow)
INTERNAL: Add the provided object to the deleted objects list on the commit manager.void
postInitialize(AbstractSession session)
INTERNAL: Some subclasses need to post initialize mappings associated with them.void
processAdditionalWritableMapKeyFields(AbstractSession session)
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.boolean
propagatesEventsToCollection()
INTERNAL: Returns true if the key mapping is an AggregateObjectMapping.void
propogatePostDelete(DeleteObjectQuery query, Object object)
INTERNAL: Propagate the postDeleteEvent to any additional objects the query is aware ofvoid
propogatePostInsert(WriteObjectQuery query, Object object)
INTERNAL: Propagate the postDeleteEvent to any additional objects the query is aware ofvoid
propogatePostUpdate(WriteObjectQuery query, Object object)
INTERNAL: Propagate the postDeleteEvent to any additional objects the query is aware ofvoid
propogatePreDelete(DeleteObjectQuery query, Object object)
INTERNAL: Propagate the postDeleteEvent to any additional objects the query is aware ofvoid
propogatePreInsert(WriteObjectQuery query, Object object)
INTERNAL: Propagate the postDeleteEvent to any additional objects the query is aware ofvoid
propogatePreUpdate(WriteObjectQuery query, Object object)
INTERNAL: Propagate the postDeleteEvent to any additional objects the query is aware ofvoid
recordPrivateOwnedRemovals(Object object, ClassDescriptor referenceDescriptor, UnitOfWorkImpl uow)
INTERNAL: Add the key and value from provided association to the deleted objects list on the commit manager.boolean
requiresDataModificationEvents()
INTERNAL: Returns whether this ContainerPolicy requires data modification events when objects are added or deleted during update.void
setDescriptorForKeyMapping(ClassDescriptor descriptor)
INTERNAL: Used during initialization of DirectMapMapping.void
setKeyConverter(Converter keyConverter, DirectMapMapping mapping)
INTERNAL: Set a converter on the KeyField of a DirectCollectionMapping.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.void
setKeyField(DatabaseField keyField, ClassDescriptor descriptor)
INTERNAL: Set the DatabaseField that will represent the key in a DirectMapMapping.void
setKeyMapping(MapKeyMapping mapping)
void
setKeyQuery(DatabaseQuery keyQuery)
INTERNAL: Some map keys must be obtained from the database.void
setValueMapping(MapComponentMapping mapping)
boolean
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.boolean
shouldUpdateForeignKeysPostInsert()
INTERNAL: Certain types of container policies require an extra update statement after a relationship is inserted.Object
unwrapKey(Object key, AbstractSession session)
INTERNAL: Allow the key to be unwrapped.int
updateJoinedMappingIndexesForMapKey(Map<DatabaseMapping,Object> indexList, int index)
INTERNAL: Update the joined mapping indices Adds the key mapping and it's index to the list of joined mappings.Object
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.MapContainerPolicy
addInto, addNextValueFromIteratorInto, buildChangeSetForNewObjectInCollection, buildCloneForValue, buildCollectionEntry, clear, cloneFor, concatenateContainers, contains, createChangeEvent, getElementClass, getElementClassName, getInterfaceType, getKeyName, hasNext, initializeKey, isMapPolicy, isValidContainer, iteratorFor, keyFromEntry, keyFromIterator, next, nextEntry, nextEntry, prepare, recordUpdateToCollectionInChangeRecord, removeFrom, setElementClass, setKeyMethod, setKeyMethod, setKeyMethodName, setKeyName, setKeyName, setKeyName, sizeFor, unwrapElement, unwrapIteratorResult
-
Methods inherited from class org.eclipse.persistence.internal.queries.InterfaceContainerPolicy
buildContainerFromVector, equals, getCloneMethod, getCloneMethod, getContainerClass, getContainerClassName, hashCode, invokeCloneMethodOn, isValidContainerType, setCloneMethod, setContainerClass, setContainerClassName, toStringInfo
-
Methods inherited from class org.eclipse.persistence.internal.queries.ContainerPolicy
addAll, addAll, buildDefaultPolicy, buildPolicyFor, buildPolicyFor, clone, collectObjectForNewCollection, compareCollectionsForChange, containerInstance, containerInstance, contains, copyMapDataToRow, execute, getChangeValuesFrom, getConstructor, getDefaultContainerClass, getElementDescriptor, hasElementDescriptor, hasOrder, initializeConstructor, isCollectionPolicy, isCursoredStreamPolicy, isCursorPolicy, isDirectMapPolicy, isEmpty, isListPolicy, isOrderedListPolicy, isScrollableCursorPolicy, mergeCascadeParts, mergeChanges, mergeChanges, next, overridesRead, prepareForExecution, recordAddToCollectionInChangeRecord, recordRemoveFromCollectionInChangeRecord, remoteExecute, removeFrom, removeFrom, setConstructor, setDefaultContainerClass, setElementDescriptor, shouldAddAll, toString, updateChangeRecordForSelfMerge, vectorFor
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.persistence.internal.core.queries.CoreContainerPolicy
addInto, clear, containerInstance, containerInstance, contains, hasNext, isEmpty, isListPolicy, iteratorFor, next, nextEntry, nextEntry, removeFrom, setContainerClass, sizeFor, vectorFor
-
-
-
-
Field Detail
-
keyMapping
protected MapKeyMapping keyMapping
-
valueMapping
protected MapComponentMapping valueMapping
-
keyQuery
public DatabaseQuery keyQuery
-
-
Constructor Detail
-
MappedKeyMapContainerPolicy
public MappedKeyMapContainerPolicy()
INTERNAL: Construct a new policy.
-
MappedKeyMapContainerPolicy
public MappedKeyMapContainerPolicy(Class containerClass)
INTERNAL: Construct a new policy for the specified class.
-
MappedKeyMapContainerPolicy
public MappedKeyMapContainerPolicy(String containerClassName)
INTERNAL: Construct a new policy for the specified class name.
-
-
Method Detail
-
addAdditionalFieldsToQuery
public void addAdditionalFieldsToQuery(ReadQuery selectionQuery, Expression baseExpression)
INTERNAL: Called when the selection query is being initialize to add the fields for the key to the query- Overrides:
addAdditionalFieldsToQuery
in classContainerPolicy
- See Also:
MappedKeyMapContainerPolicy
-
getKeyMappingDataForWriteQuery
public Map getKeyMappingDataForWriteQuery(Object object, AbstractSession session)
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.- Overrides:
getKeyMappingDataForWriteQuery
in classContainerPolicy
-
getKeyType
public Object getKeyType()
INTERNAL: Return the type of the map key, this will be overridden by container policies that allow maps.- Overrides:
getKeyType
in classMapContainerPolicy
-
addFieldsForMapKey
public void addFieldsForMapKey(AbstractRecord joinRow)
INTERNAL: Called when the insert query is being initialized to ensure the fields for the key are in the insert query- Overrides:
addFieldsForMapKey
in classContainerPolicy
- See Also:
MappedKeyMapContainerPolicy
-
addInto
public boolean addInto(Object element, Object container, AbstractSession session)
INTERNAL: Add element into container which implements the Map interface. The may be used by merging/cloning passing a Map.Entry.- Specified by:
addInto
in interfaceCoreContainerPolicy<AbstractSession>
- Overrides:
addInto
in classMapContainerPolicy
-
addInto
public boolean addInto(Object element, Object container, AbstractSession session, AbstractRecord row, DataReadQuery query, CacheKey parentCacheKey, boolean isTargetProtected)
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. This is currently only used by OrderListContainerPolicy, so this is just a stub. The passing of the query is to allow future compatibility with Maps (ordered Map).- Overrides:
addInto
in classContainerPolicy
-
addInto
public boolean addInto(Object element, Object container, AbstractSession session, AbstractRecord dbRow, ObjectBuildingQuery query, CacheKey parentCacheKey, boolean isTargetProtected)
INTERNAL: Add element to that implements the Map interface use the row to compute the key- Overrides:
addInto
in classContainerPolicy
-
addNestedJoinsQueriesForMapKey
public void addNestedJoinsQueriesForMapKey(JoinedAttributeManager joinManager, ObjectLevelReadQuery query, AbstractSession session)
INTERNAL: Used for joining. Add any queries necessary for joining to the join manager- Overrides:
addNestedJoinsQueriesForMapKey
in classContainerPolicy
-
buildCloneForKey
public Object buildCloneForKey(Object key, Object parent, CacheKey parentCacheKey, Integer refreshCascade, AbstractSession cloningSession, boolean isExisting, boolean isCacheCheckComplete)
Build a clone for the key of a Map represented by this container policy.- Overrides:
buildCloneForKey
in classContainerPolicy
- Returns:
-
buildSelectionQueryForDirectCollectionMapping
public ReadQuery buildSelectionQueryForDirectCollectionMapping()
INTERNAL: Certain key mappings favor different types of selection query. Return the appropriate type of selectionQuery.- Overrides:
buildSelectionQueryForDirectCollectionMapping
in classContainerPolicy
- Returns:
-
buildKey
public Object buildKey(AbstractRecord row, ObjectBuildingQuery query, CacheKey parentCacheKey, AbstractSession session, boolean isTargetProtected)
Extract the key for the map from the provided row.- Overrides:
buildKey
in classContainerPolicy
- Returns:
-
buildKeyFromJoinedRow
public Object buildKeyFromJoinedRow(AbstractRecord row, JoinedAttributeManager joinManager, ObjectBuildingQuery query, CacheKey parentCacheKey, AbstractSession session, boolean isTargetProtected)
Extract the key for the map from the provided row.- Overrides:
buildKeyFromJoinedRow
in classContainerPolicy
- Returns:
-
buildReferencesPKList
public Object[] buildReferencesPKList(Object container, AbstractSession session)
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.
-
cascadeDiscoverAndPersistUnregisteredNewObjects
public void cascadeDiscoverAndPersistUnregisteredNewObjects(Object object, Map newObjects, Map unregisteredExistingObjects, Map visitedObjects, UnitOfWorkImpl uow, Set cascadeErrors)
INTERNAL: Cascade discover and persist new objects during commit to the map key- Overrides:
cascadeDiscoverAndPersistUnregisteredNewObjects
in classContainerPolicy
-
cascadePerformRemoveIfRequired
public void cascadePerformRemoveIfRequired(Object object, UnitOfWorkImpl uow, Map visitedObjects)
INTERNAL: Cascade registerNew to any mappings managed by the container policy. This will cascade the register to the key mapping.- Overrides:
cascadePerformRemoveIfRequired
in classContainerPolicy
-
cascadeRegisterNewIfRequired
public void cascadeRegisterNewIfRequired(Object object, UnitOfWorkImpl uow, Map visitedObjects)
INTERNAL: Cascade registerNew to any mappings managed by the container policy. This will cascade the register to the key mapping.- Overrides:
cascadeRegisterNewIfRequired
in classContainerPolicy
-
clone
public Object clone()
INTERNAL: The mapping clones itself to create deep copy.- Overrides:
clone
in classContainerPolicy
-
compareContainers
public boolean compareContainers(Object firstObjectMap, Object secondObjectMap)
INTERNAL: Return true if keys are the same. False otherwise
-
compareKeys
public boolean compareKeys(Object sourceValue, AbstractSession session)
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:
compareKeys
in classMapContainerPolicy
-
createChangeSetForKeys
protected void createChangeSetForKeys(Map originalKeyValues, CollectionChangeRecord changeRecord, AbstractSession session, ClassDescriptor referenceDescriptor)
INTERNAL: Create change sets that contain map keys.- Overrides:
createChangeSetForKeys
in classContainerPolicy
-
createQueryKeyForMapKey
public QueryKey createQueryKeyForMapKey()
INTERNAL: Create a query key that links to the map key.- Overrides:
createQueryKeyForMapKey
in classMapContainerPolicy
-
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:
createWrappedObjectFromExistingWrappedObject
in classMapContainerPolicy
parent
- if this is an aggregate, the owner of the aggregate- Returns:
- See Also:
MappedKeyMapContainerPolicy
-
convertClassNamesToClasses
public void convertClassNamesToClasses(ClassLoader classLoader)
INTERNAL: Convert all the class-name-based settings in this ContainerPolicy to actual class-based settings- Overrides:
convertClassNamesToClasses
in classMapContainerPolicy
- Parameters:
classLoader
-
-
deleteWrappedObject
public void deleteWrappedObject(Object objectDeleted, AbstractSession session)
INTERNAL: Delete the key and value of the passed association passed object.- Overrides:
deleteWrappedObject
in classContainerPolicy
- See Also:
MappedKeyMapContainerPolicy
-
getAdditionalTablesForJoinQuery
public List<DatabaseTable> getAdditionalTablesForJoinQuery()
INTERNAL: Return any tables that will be required when this mapping is used as part of a join query.- Overrides:
getAdditionalTablesForJoinQuery
in classContainerPolicy
-
getAdditionalFieldsForJoin
public List<DatabaseField> getAdditionalFieldsForJoin(CollectionMapping baseMapping)
INTERNAL: Return any additional fields required by the policy for a fetch join.- Overrides:
getAdditionalFieldsForJoin
in classContainerPolicy
-
getForeignKeyFieldsForMapKey
public Map<DatabaseField,DatabaseField> getForeignKeyFieldsForMapKey()
INTERNAL: Return a Map of any foreign keys defined within the the MapKey.
-
getDescriptorForMapKey
public ClassDescriptor getDescriptorForMapKey()
INTERNAL: Return the reference descriptor for the map key if it exists.- Overrides:
getDescriptorForMapKey
in classContainerPolicy
-
getCloneDataFromChangeSet
public Object getCloneDataFromChangeSet(ObjectChangeSet changeSet)
INTERNAL: Used when objects are added or removed during an update. This method returns either the clone from the ChangeSet or a packaged version of it that contains things like map keys.- Overrides:
getCloneDataFromChangeSet
in classContainerPolicy
-
getDirectKeyField
public DatabaseField getDirectKeyField(CollectionMapping baseMapping)
INTERNAL: Return the DatabaseField that represents the key in a DirectMapMapping. If the keyMapping is not a DirectMapping, this will return null.- Overrides:
getDirectKeyField
in classMapContainerPolicy
-
getIdentityFieldsForMapKey
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.- Overrides:
getIdentityFieldsForMapKey
in classContainerPolicy
-
getKeyConverter
public Converter getKeyConverter()
INTERNAL: Get the Converter for the key of this mapping if one exists.
-
getKeyMapping
public MapKeyMapping getKeyMapping()
-
getKeyQuery
public DatabaseQuery getKeyQuery()
INTERNAL: Some map keys must be obtained from the database. This query is used to obtain the key.
-
getKeySelectionCriteria
public Expression getKeySelectionCriteria()
INTERNAL: Get the selection criteria for the map key.- Overrides:
getKeySelectionCriteria
in classContainerPolicy
-
getValueMapping
public MapComponentMapping getValueMapping()
-
initialize
public void initialize(AbstractSession session, DatabaseTable keyTable)
INTERNAL: Initialize the key mapping- Overrides:
initialize
in classContainerPolicy
-
isKeyAvailableFromElement
protected boolean isKeyAvailableFromElement()
CollectionTableMapContainerPolicy is for mappings where the key is stored in a table separately from the map element.- Overrides:
isKeyAvailableFromElement
in classMapContainerPolicy
-
isMappedKeyMapPolicy
public boolean isMappedKeyMapPolicy()
- Overrides:
isMappedKeyMapPolicy
in classContainerPolicy
-
isMapKeyAttribute
public boolean 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.- Overrides:
isMapKeyAttribute
in classMapContainerPolicy
-
isMapKeyObject
public boolean isMapKeyObject()
INTERNAL: Return if the map key this container policy represents is a OneToOne.- Overrides:
isMapKeyObject
in classContainerPolicy
-
iterateOnMapKey
public void iterateOnMapKey(DescriptorIterator iterator, Object element)
INTERNAL: Used in Descriptor Iteration to iterate on map keys.- Overrides:
iterateOnMapKey
in classContainerPolicy
-
postCalculateChanges
public void postCalculateChanges(ObjectChangeSet ocs, ClassDescriptor referenceDescriptor, DatabaseMapping mapping, UnitOfWorkImpl uow)
INTERNAL: Add the provided object to the deleted objects list on the commit manager. This may be overridden by subclasses to process a composite object.- Overrides:
postCalculateChanges
in classContainerPolicy
- See Also:
MappedKeyMapContainerPolicy
-
postCalculateChanges
public void postCalculateChanges(Object key, Object value, ClassDescriptor referenceDescriptor, DatabaseMapping mapping, UnitOfWorkImpl uow)
INTERNAL: Add the provided object to the deleted objects list on the commit manager. This may be overridden by subclasses to process a composite object.- Overrides:
postCalculateChanges
in classContainerPolicy
-
processAdditionalWritableMapKeyFields
public void processAdditionalWritableMapKeyFields(AbstractSession session)
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. There are two possibilities: 1. The conflicting mapping has already been processed. In that case, we add MultipleWritableMappings exception to the integrity checker right away 2. There are no conflicting mappings. In that case, we store the list of fields that this mapping has processed on the descriptor for the target so they can be checked as the descriptor initializes.- Overrides:
processAdditionalWritableMapKeyFields
in classContainerPolicy
-
recordPrivateOwnedRemovals
public void recordPrivateOwnedRemovals(Object object, ClassDescriptor referenceDescriptor, UnitOfWorkImpl uow)
INTERNAL: Add the key and value from provided association to the deleted objects list on the commit manager.- Overrides:
recordPrivateOwnedRemovals
in classContainerPolicy
-
requiresDataModificationEvents
public boolean requiresDataModificationEvents()
INTERNAL: Returns whether this ContainerPolicy requires data modification events when objects are added or deleted during update.- Overrides:
requiresDataModificationEvents
in classContainerPolicy
- Returns:
-
keyFrom
public Object keyFrom(Object element, AbstractSession session)
INTERNAL: Return the key for the specified element.- Overrides:
keyFrom
in classMapContainerPolicy
-
postInitialize
public void postInitialize(AbstractSession session)
INTERNAL: Some subclasses need to post initialize mappings associated with them.- Overrides:
postInitialize
in classContainerPolicy
-
propogatePostDelete
public void propogatePostDelete(DeleteObjectQuery query, Object object)
INTERNAL: Propagate the postDeleteEvent to any additional objects the query is aware of- Overrides:
propogatePostDelete
in classContainerPolicy
-
propogatePostInsert
public void propogatePostInsert(WriteObjectQuery query, Object object)
INTERNAL: Propagate the postDeleteEvent to any additional objects the query is aware of- Overrides:
propogatePostInsert
in classContainerPolicy
-
propogatePostUpdate
public void propogatePostUpdate(WriteObjectQuery query, Object object)
INTERNAL: Propagate the postDeleteEvent to any additional objects the query is aware of- Overrides:
propogatePostUpdate
in classContainerPolicy
-
propogatePreDelete
public void propogatePreDelete(DeleteObjectQuery query, Object object)
INTERNAL: Propagate the postDeleteEvent to any additional objects the query is aware of- Overrides:
propogatePreDelete
in classContainerPolicy
-
propogatePreInsert
public void propogatePreInsert(WriteObjectQuery query, Object object)
INTERNAL: Propagate the postDeleteEvent to any additional objects the query is aware of- Overrides:
propogatePreInsert
in classContainerPolicy
-
propogatePreUpdate
public void propogatePreUpdate(WriteObjectQuery query, Object object)
INTERNAL: Propagate the postDeleteEvent to any additional objects the query is aware of- Overrides:
propogatePreUpdate
in classContainerPolicy
-
propagatesEventsToCollection
public boolean propagatesEventsToCollection()
INTERNAL: Returns true if the key mapping is an AggregateObjectMapping. Aggregates need events propagated to them because they are not explicitly deleted, updated or inserted- Overrides:
propagatesEventsToCollection
in classContainerPolicy
-
setKeyField
public void setKeyField(DatabaseField keyField, ClassDescriptor descriptor)
INTERNAL: Set the DatabaseField that will represent the key in a DirectMapMapping.
-
setDescriptorForKeyMapping
public void setDescriptorForKeyMapping(ClassDescriptor descriptor)
INTERNAL: Used during initialization of DirectMapMapping. Sets the descriptor associated with the key.
-
setKeyConverter
public void setKeyConverter(Converter keyConverter, DirectMapMapping mapping)
INTERNAL: Set a converter on the KeyField of a DirectCollectionMapping.
-
setKeyConverterClassName
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.
-
setKeyMapping
public void setKeyMapping(MapKeyMapping mapping)
-
setKeyQuery
public void setKeyQuery(DatabaseQuery keyQuery)
INTERNAL: Some map keys must be obtained from the database. This query is used to obtain the key- Parameters:
keyQuery
-
-
setValueMapping
public void setValueMapping(MapComponentMapping mapping)
-
shouldIncludeKeyInDeleteEvent
public boolean 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.- Overrides:
shouldIncludeKeyInDeleteEvent
in classContainerPolicy
-
shouldUpdateForeignKeysPostInsert
public boolean shouldUpdateForeignKeysPostInsert()
INTERNAL: Certain types of container policies require an extra update statement after a relationship is inserted. Return whether this update statement is required.- Overrides:
shouldUpdateForeignKeysPostInsert
in classContainerPolicy
-
updateJoinedMappingIndexesForMapKey
public int updateJoinedMappingIndexesForMapKey(Map<DatabaseMapping,Object> indexList, int index)
INTERNAL: Update the joined mapping indices Adds the key mapping and it's index to the list of joined mappings.- Overrides:
updateJoinedMappingIndexesForMapKey
in classContainerPolicy
-
unwrapKey
public Object unwrapKey(Object key, AbstractSession session)
INTERNAL: Allow the key to be unwrapped. This will be overridden by container policies that allow keys that are entities.- Overrides:
unwrapKey
in classMapContainerPolicy
-
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:
valueFromPKList
in classMapContainerPolicy
-
-