Module org.eclipse.persistence.core
Class OrderedListContainerPolicy
- java.lang.Object
-
- org.eclipse.persistence.internal.queries.ContainerPolicy
-
- org.eclipse.persistence.internal.queries.InterfaceContainerPolicy
-
- org.eclipse.persistence.internal.queries.CollectionContainerPolicy
-
- org.eclipse.persistence.internal.queries.ListContainerPolicy
-
- org.eclipse.persistence.internal.queries.OrderedListContainerPolicy
-
- All Implemented Interfaces:
Serializable,Cloneable,CoreContainerPolicy<AbstractSession>
public class OrderedListContainerPolicy extends ListContainerPolicy
Purpose: A OrderedListContainerPolicy is ContainerPolicy whose container class implements the List interface and is ordered by an @OrderBy.
Responsibilities: Provide the functionality to operate on an instance of a List.
-
-
Field Summary
Fields Modifier and Type Field Description protected DatabaseFieldlistOrderFieldprotected static StringNOT_SETprotected OrderCorrectionTypeorderCorrectionType-
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 OrderedListContainerPolicy()INTERNAL: Construct a new policy.OrderedListContainerPolicy(Class<?> containerClass)INTERNAL: Construct a new policy for the specified class.OrderedListContainerPolicy(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 voidaddAdditionalFieldsToQuery(ReadQuery selectionQuery, Expression baseExpression)INTERNAL: Add the index field to the query.booleanaddAll(List elements, Object container, AbstractSession session, List<AbstractRecord> dbRows, DataReadQuery query, CacheKey parentCacheKey, boolean isTargetProtected)INTERNAL: Add a list of elements to container.booleanaddAll(List elements, Object container, AbstractSession session, List<AbstractRecord> dbRows, ObjectBuildingQuery query, CacheKey parentCacheKey, boolean isTargetProtected)INTERNAL: Add a list of elements to container.protected booleanaddAll(List elements, Object container, AbstractSession session, List<AbstractRecord> dbRows, ReadQuery query, CacheKey parentCacheKey)protected voidaddIntoAtIndex(Integer index, Object object, Object container, AbstractSession session)INTERNAL: Add element into a container which implements the List interface.voidcompareCollectionsForChange(Object oldList, Object newList, CollectionChangeRecord changeRecord, AbstractSession session, ClassDescriptor referenceDescriptor)INTERNAL: This method is used to calculate the differences between two collections.ListcorrectOrderList(List<IndexedObject> indexedObjects)PUBLIC: Correct object's order in the list.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.IteratorgetChangeValuesFrom(Map map)INTERNAL: Used to create an iterator on a the Map object passed to CollectionChangeRecord.addRemoveChange() to access the values to be removed.DatabaseFieldgetListOrderField()OrderCorrectionTypegetOrderCorrectionType()booleanisOrderedListPolicy()ObjectiteratorFor(Object container)INTERNAL: Return an list iterator for the given container.protected voidmergeChanges(CollectionChangeRecord changeRecord, Object valueOfTarget, boolean shouldMergeCascadeParts, MergeManager mergeManager, AbstractSession targetSession)INTERNAL: Merge changes from the source to the target object.voidmergeChanges(CollectionChangeRecord changeRecord, Object valueOfTarget, boolean shouldMergeCascadeParts, MergeManager mergeManager, AbstractSession targetSession, boolean isSynchronizeOnMerge)INTERNAL: Merge changes from the source to the target object.voidrecordAddToCollectionInChangeRecord(ObjectChangeSet changeSetToAdd, 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.voidrecordRemoveFromCollectionInChangeRecord(ObjectChangeSet changeSetToRemove, 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.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.protected voidregisterRemoveNewObjectIfRequired(ObjectChangeSet objectChanges, MergeManager mergeManager)INTERNAL:protected voidremoveFromAtIndex(int index, Object container)INTERNAL: Remove the element at the specified index.voidsetListOrderField(DatabaseField field)voidsetOrderCorrectionType(OrderCorrectionType orderCorrectionType)booleanshouldAddAll()INTERNAL: Indicates whether addAll method should be called to add entire collection, or it's possible to call addInto multiple times instead.voidupdateChangeRecordForSelfMerge(ChangeRecord changeRecord, Object source, Object target, ForeignReferenceMapping mapping, UnitOfWorkChangeSet parentUOWChangeSet, UnitOfWorkImpl unitOfWork)INTERNAL: Update a ChangeRecord to replace the ChangeSet for the old entity with the changeSet for the new Entity.intupdateJoinedMappingIndexesForMapKey(Map<DatabaseMapping,Object> indexList, int index)INTERNAL: Add the index field count.-
Methods inherited from class org.eclipse.persistence.internal.queries.ListContainerPolicy
get, hasOrder, indexOf, isListPolicy, isValidContainer, valueFromPKList
-
Methods inherited from class org.eclipse.persistence.internal.queries.CollectionContainerPolicy
addInto, buildContainerFromVector, clear, cloneFor, contains, getInterfaceType, isCollectionPolicy, removeFrom, sizeFor
-
Methods inherited from class org.eclipse.persistence.internal.queries.InterfaceContainerPolicy
convertClassNamesToClasses, createChangeEvent, createQueryKeyForMapKey, equals, getCloneMethod, getCloneMethod, getContainerClass, getContainerClassName, getDirectKeyField, hashCode, hasNext, invokeCloneMethodOn, isMapKeyAttribute, isValidContainerType, next, setCloneMethod, setContainerClass, setContainerClassName, toStringInfo
-
Methods inherited from class org.eclipse.persistence.internal.queries.ContainerPolicy
addFieldsForMapKey, addInto, addInto, addInto, addNestedJoinsQueriesForMapKey, addNextValueFromIteratorInto, buildChangeSetForNewObjectInCollection, buildCloneForKey, buildCollectionEntry, buildDefaultPolicy, buildKey, buildKeyFromJoinedRow, buildPolicyFor, buildPolicyFor, buildReferencesPKList, buildSelectionQueryForDirectCollectionMapping, cascadeDiscoverAndPersistUnregisteredNewObjects, cascadePerformRemoveIfRequired, cascadeRegisterNewIfRequired, clone, clone, collectObjectForNewCollection, compareKeys, concatenateContainers, containerInstance, containerInstance, contains, copyMapDataToRow, createChangeSetForKeys, createWrappedObjectFromExistingWrappedObject, deleteWrappedObject, execute, getCloneDataFromChangeSet, getConstructor, getDefaultContainerClass, getDescriptorForMapKey, getElementDescriptor, getIdentityFieldsForMapKey, getKeyMappingDataForWriteQuery, getKeySelectionCriteria, getKeyType, hasElementDescriptor, initialize, initializeConstructor, isCursoredStreamPolicy, isCursorPolicy, isDirectMapPolicy, isEmpty, isMapKeyObject, isMappedKeyMapPolicy, isMapPolicy, isScrollableCursorPolicy, iterateOnMapKey, keyFrom, keyFromEntry, keyFromIterator, mergeCascadeParts, next, nextEntry, nextEntry, overridesRead, postCalculateChanges, postCalculateChanges, postInitialize, prepare, prepareForExecution, processAdditionalWritableMapKeyFields, propagatesEventsToCollection, propogatePostDelete, propogatePostInsert, propogatePostUpdate, propogatePreDelete, propogatePreInsert, propogatePreUpdate, recordPrivateOwnedRemovals, remoteExecute, removeFrom, removeFrom, requiresDataModificationEvents, setConstructor, setDefaultContainerClass, setElementDescriptor, setKeyName, setKeyName, shouldIncludeKeyInDeleteEvent, shouldUpdateForeignKeysPostInsert, toString, unwrapElement, unwrapIteratorResult, vectorFor
-
-
-
-
Field Detail
-
NOT_SET
protected static final String NOT_SET
- See Also:
- Constant Field Values
-
listOrderField
protected DatabaseField listOrderField
-
orderCorrectionType
protected OrderCorrectionType orderCorrectionType
-
-
Constructor Detail
-
OrderedListContainerPolicy
public OrderedListContainerPolicy()
INTERNAL: Construct a new policy.
-
OrderedListContainerPolicy
public OrderedListContainerPolicy(Class<?> containerClass)
INTERNAL: Construct a new policy for the specified class.
-
OrderedListContainerPolicy
public OrderedListContainerPolicy(String containerClassName)
INTERNAL: Construct a new policy for the specified class name.
-
-
Method Detail
-
addAll
public boolean addAll(List elements, Object container, AbstractSession session, List<AbstractRecord> dbRows, ObjectBuildingQuery query, CacheKey parentCacheKey, boolean isTargetProtected)
INTERNAL: Add a list of elements to container. This is used to add to a collection independent of JDK 1.1 and 1.2. The session may be required to wrap for the wrapper policy. The row may be required by subclasses Return whether the container changed- Overrides:
addAllin classContainerPolicy
-
addAll
public boolean addAll(List elements, Object container, AbstractSession session, List<AbstractRecord> dbRows, DataReadQuery query, CacheKey parentCacheKey, boolean isTargetProtected)
INTERNAL: Add a list of elements to container. This is used to add to a collection independent of JDK 1.1 and 1.2. The session may be required to wrap for the wrapper policy. The row may be required by subclasses Return whether the container changed- Overrides:
addAllin classContainerPolicy
-
addAll
protected boolean addAll(List elements, Object container, AbstractSession session, List<AbstractRecord> dbRows, ReadQuery query, CacheKey parentCacheKey)
-
addIntoAtIndex
protected void addIntoAtIndex(Integer index, Object object, Object container, AbstractSession session)
INTERNAL: Add element into a container which implements the List interface. Add at a particular index.
-
compareCollectionsForChange
public void compareCollectionsForChange(Object oldList, Object newList, CollectionChangeRecord changeRecord, AbstractSession session, ClassDescriptor referenceDescriptor)
INTERNAL: This method is used to calculate the differences between two collections. This algorithm is a work in progress. It works great and all, but like anything, you can always make it better.- Overrides:
compareCollectionsForChangein classContainerPolicy
-
correctOrderList
public List correctOrderList(List<IndexedObject> indexedObjects)
PUBLIC: Correct object's order in the list. The method is called only in one case - when the list of order indexes read from db is invalid (contains nulls, duplicates, negative values, values greater/equal list size). Each element of the indexedObjects is a pair of the order index and the corresponding object. The goal of the method is to return back the list of objects (not indexed objects!) in the correct order. The objects should not be altered. The default implementation of the method sorts indexedObjects according to their indexes (null less than any non-null). For example: indexedObjects = {{2, objectA}, {5, ObjectB}} returns {objectA, objectB}; indexedObjects = {{2, objectA}, {-1, ObjectB}} returns {objectB, objectA}; indexedObjects = {{2, objectA}, {null, ObjectB}} returns {objectB, objectA}; This method could be overridden by the user.
-
getChangeValuesFrom
public Iterator getChangeValuesFrom(Map map)
INTERNAL: Used to create an iterator on a the Map object passed to CollectionChangeRecord.addRemoveChange() to access the values to be removed. In the case of some container policies the values will actually be the keys.- Overrides:
getChangeValuesFromin classContainerPolicy
-
getListOrderField
public DatabaseField getListOrderField()
-
setListOrderField
public void setListOrderField(DatabaseField field)
-
getOrderCorrectionType
public OrderCorrectionType getOrderCorrectionType()
-
setOrderCorrectionType
public void setOrderCorrectionType(OrderCorrectionType orderCorrectionType)
-
iteratorFor
public Object iteratorFor(Object container)
INTERNAL: Return an list iterator for the given container.- Specified by:
iteratorForin interfaceCoreContainerPolicy<AbstractSession>- Overrides:
iteratorForin classCollectionContainerPolicy- Parameters:
container- java.lang.Object- Returns:
- java.util.Enumeration/java.util.Iterator
- See Also:
ContainerPolicy.hasNext(java.lang.Object),ContainerPolicy.next(java.lang.Object)
-
isOrderedListPolicy
public boolean isOrderedListPolicy()
- Overrides:
isOrderedListPolicyin classContainerPolicy
-
mergeChanges
public void mergeChanges(CollectionChangeRecord changeRecord, Object valueOfTarget, boolean shouldMergeCascadeParts, MergeManager mergeManager, AbstractSession targetSession, boolean isSynchronizeOnMerge)
INTERNAL: Merge changes from the source to the target object. Because this is a collection mapping, values are added to or removed from the collection based on the change set. Synchronize if system property is specified. If not, default to clone the target collection. No need to synchronize if the collection is new.- Overrides:
mergeChangesin classContainerPolicy
-
mergeChanges
protected void mergeChanges(CollectionChangeRecord changeRecord, Object valueOfTarget, boolean shouldMergeCascadeParts, MergeManager mergeManager, AbstractSession targetSession)
INTERNAL: Merge changes from the source to the target object. Because this is a collection mapping, values are added to or removed from the collection based on the change set.- Overrides:
mergeChangesin classContainerPolicy
-
registerRemoveNewObjectIfRequired
protected void registerRemoveNewObjectIfRequired(ObjectChangeSet objectChanges, MergeManager mergeManager)
INTERNAL:
-
removeFromAtIndex
protected void removeFromAtIndex(int index, Object container)INTERNAL: Remove the element at the specified index.
-
recordAddToCollectionInChangeRecord
public void recordAddToCollectionInChangeRecord(ObjectChangeSet changeSetToAdd, 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:
recordAddToCollectionInChangeRecordin classListContainerPolicy
-
recordRemoveFromCollectionInChangeRecord
public void recordRemoveFromCollectionInChangeRecord(ObjectChangeSet changeSetToRemove, CollectionChangeRecord collectionChangeRecord)
Description copied from class:ListContainerPolicyThis 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:
recordRemoveFromCollectionInChangeRecordin classListContainerPolicy
-
recordUpdateToCollectionInChangeRecord
public void recordUpdateToCollectionInChangeRecord(CollectionChangeEvent event, ObjectChangeSet changeSet, CollectionChangeRecord collectionChangeRecord)
Description copied from class:ContainerPolicyThis 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
-
shouldAddAll
public boolean shouldAddAll()
INTERNAL: Indicates whether addAll method should be called to add entire collection, or it's possible to call addInto multiple times instead.- Overrides:
shouldAddAllin classContainerPolicy
-
getAdditionalFieldsForJoin
public List<DatabaseField> getAdditionalFieldsForJoin(CollectionMapping baseMapping)
INTERNAL: Return any additional fields required by the policy for a fetch join.- Overrides:
getAdditionalFieldsForJoinin classContainerPolicy
-
updateJoinedMappingIndexesForMapKey
public int updateJoinedMappingIndexesForMapKey(Map<DatabaseMapping,Object> indexList, int index)
INTERNAL: Add the index field count.- Overrides:
updateJoinedMappingIndexesForMapKeyin classContainerPolicy
-
updateChangeRecordForSelfMerge
public void updateChangeRecordForSelfMerge(ChangeRecord changeRecord, Object source, Object target, ForeignReferenceMapping mapping, UnitOfWorkChangeSet parentUOWChangeSet, UnitOfWorkImpl unitOfWork)
INTERNAL: Update a ChangeRecord to replace the ChangeSet for the old entity with the changeSet for the new Entity. This is used when an Entity is merged into itself and the Entity reference new or detached entities.- Overrides:
updateChangeRecordForSelfMergein classListContainerPolicy
-
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:
getAdditionalTablesForJoinQueryin classContainerPolicy
-
addAdditionalFieldsToQuery
public void addAdditionalFieldsToQuery(ReadQuery selectionQuery, Expression baseExpression)
INTERNAL: Add the index field to the query.- Overrides:
addAdditionalFieldsToQueryin classContainerPolicy- See Also:
MappedKeyMapContainerPolicy
-
-