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 DatabaseField
listOrderField
protected static String
NOT_SET
protected OrderCorrectionType
orderCorrectionType
-
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 void
addAdditionalFieldsToQuery(ReadQuery selectionQuery, Expression baseExpression)
INTERNAL: Add the index field to the query.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.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.protected boolean
addAll(List elements, Object container, AbstractSession session, List<AbstractRecord> dbRows, ReadQuery query, CacheKey parentCacheKey)
protected void
addIntoAtIndex(Integer index, Object object, Object container, AbstractSession session)
INTERNAL: Add element into a container which implements the List interface.void
compareCollectionsForChange(Object oldList, Object newList, CollectionChangeRecord changeRecord, AbstractSession session, ClassDescriptor referenceDescriptor)
INTERNAL: This method is used to calculate the differences between two collections.List
correctOrderList(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.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.DatabaseField
getListOrderField()
OrderCorrectionType
getOrderCorrectionType()
boolean
isOrderedListPolicy()
Object
iteratorFor(Object container)
INTERNAL: Return an list iterator for the given container.protected void
mergeChanges(CollectionChangeRecord changeRecord, Object valueOfTarget, boolean shouldMergeCascadeParts, MergeManager mergeManager, AbstractSession targetSession)
INTERNAL: Merge changes from the source to the target object.void
mergeChanges(CollectionChangeRecord changeRecord, Object valueOfTarget, boolean shouldMergeCascadeParts, MergeManager mergeManager, AbstractSession targetSession, boolean isSynchronizeOnMerge)
INTERNAL: Merge changes from the source to the target object.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.void
recordRemoveFromCollectionInChangeRecord(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.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.protected void
registerRemoveNewObjectIfRequired(ObjectChangeSet objectChanges, MergeManager mergeManager)
INTERNAL:protected void
removeFromAtIndex(int index, Object container)
INTERNAL: Remove the element at the specified index.void
setListOrderField(DatabaseField field)
void
setOrderCorrectionType(OrderCorrectionType orderCorrectionType)
boolean
shouldAddAll()
INTERNAL: Indicates whether addAll method should be called to add entire collection, or it's possible to call addInto multiple times instead.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.int
updateJoinedMappingIndexesForMapKey(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:
addAll
in 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:
addAll
in 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:
compareCollectionsForChange
in 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:
getChangeValuesFrom
in 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:
iteratorFor
in interfaceCoreContainerPolicy<AbstractSession>
- Overrides:
iteratorFor
in 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:
isOrderedListPolicy
in 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:
mergeChanges
in 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:
mergeChanges
in 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:
recordAddToCollectionInChangeRecord
in classListContainerPolicy
-
recordRemoveFromCollectionInChangeRecord
public void recordRemoveFromCollectionInChangeRecord(ObjectChangeSet changeSetToRemove, CollectionChangeRecord collectionChangeRecord)
Description copied from class:ListContainerPolicy
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:
recordRemoveFromCollectionInChangeRecord
in classListContainerPolicy
-
recordUpdateToCollectionInChangeRecord
public void recordUpdateToCollectionInChangeRecord(CollectionChangeEvent event, ObjectChangeSet changeSet, CollectionChangeRecord collectionChangeRecord)
Description copied from class:ContainerPolicy
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:
recordUpdateToCollectionInChangeRecord
in 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:
shouldAddAll
in classContainerPolicy
- Returns:
-
getAdditionalFieldsForJoin
public List<DatabaseField> getAdditionalFieldsForJoin(CollectionMapping baseMapping)
INTERNAL: Return any additional fields required by the policy for a fetch join.- Overrides:
getAdditionalFieldsForJoin
in classContainerPolicy
-
updateJoinedMappingIndexesForMapKey
public int updateJoinedMappingIndexesForMapKey(Map<DatabaseMapping,Object> indexList, int index)
INTERNAL: Add the index field count.- Overrides:
updateJoinedMappingIndexesForMapKey
in 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:
updateChangeRecordForSelfMerge
in 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:
getAdditionalTablesForJoinQuery
in classContainerPolicy
-
addAdditionalFieldsToQuery
public void addAdditionalFieldsToQuery(ReadQuery selectionQuery, Expression baseExpression)
INTERNAL: Add the index field to the query.- Overrides:
addAdditionalFieldsToQuery
in classContainerPolicy
- See Also:
MappedKeyMapContainerPolicy
-
-