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

public Class OrderedListContainerPolicy

extends ListContainerPolicy
Class Inheritance
Imports
java.util.ArrayList, .HashMap, .Iterator, .List, .Map, .Collections, .IdentityHashMap, .ListIterator, org.eclipse.persistence.exceptions.QueryException, .ValidationException, org.eclipse.persistence.expressions.Expression, org.eclipse.persistence.internal.descriptors.ObjectBuilder, org.eclipse.persistence.internal.expressions.SQLSelectStatement, org.eclipse.persistence.internal.helper.ConversionManager, .DatabaseField, .DatabaseTable, .IndexedObject, org.eclipse.persistence.internal.identitymaps.CacheKey, org.eclipse.persistence.internal.sessions.AbstractRecord, .ChangeRecord, .MergeManager, .ObjectChangeSet, .OrderedChangeObject, .UnitOfWorkChangeSet, .CollectionChangeRecord, .AbstractSession, .UnitOfWorkImpl, org.eclipse.persistence.annotations.OrderCorrectionType, org.eclipse.persistence.descriptors.ClassDescriptor, org.eclipse.persistence.descriptors.changetracking.CollectionChangeEvent, org.eclipse.persistence.indirection.IndirectCollection, .IndirectList, org.eclipse.persistence.mappings.CollectionMapping, .DatabaseMapping, .ForeignReferenceMapping, org.eclipse.persistence.queries.DataReadQuery, .ObjectBuildingQuery, .ObjectLevelReadQuery, .ReadQuery

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.

See Also
ContainerPolicy, CollectionContainerPolicy, ListContainerPolicy

Field Summary

Modifier and TypeField and Description
protected DatabaseField
protected static final String
protected OrderCorrectionType

Constructor Summary

AccessConstructor and Description
public
OrderedListContainerPolicy()

INTERNAL: Construct a new policy.

public
OrderedListContainerPolicy(Class<?> containerClass)

INTERNAL: Construct a new policy for the specified class.

public
OrderedListContainerPolicy(String containerClassName)

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

Method Summary

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

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

INTERNAL: Add the index field to the query.
public boolean
addAll(List<E> elements, Object container, AbstractSession session, List<AbstractRecord> dbRows, ObjectBuildingQuery query, CacheKey parentCacheKey, boolean isTargetProtected)

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

INTERNAL: Add a list of elements to container.
public boolean
addAll(List<E> elements, Object container, AbstractSession session, List<AbstractRecord> dbRows, DataReadQuery query, CacheKey parentCacheKey, boolean isTargetProtected)

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

INTERNAL: Add a list of elements to container.
protected boolean
addAll(List<E> 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.

public void
compareCollectionsForChange(Object oldList, Object newList, CollectionChangeRecord changeRecord, AbstractSession session, ClassDescriptor referenceDescriptor)

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

INTERNAL: This method is used to calculate the differences between two collections.
public List<E>
correctOrderList(List<IndexedObject> indexedObjects)

PUBLIC: Correct object's order in the list.

public List<DatabaseField>
getAdditionalFieldsForJoin(CollectionMapping baseMapping)

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

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

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

INTERNAL: Return any tables that will be required when this mapping is used as part of a join query.
public Iterator<E>
getChangeValuesFrom(Map<K, V> map)

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

INTERNAL: Used to create an iterator on a the Map object passed to CollectionChangeRecord.addRemoveChange() to access the values to be removed.
public DatabaseField
public OrderCorrectionType
public boolean
public Object
public void
mergeChanges(CollectionChangeRecord changeRecord, Object valueOfTarget, boolean shouldMergeCascadeParts, MergeManager mergeManager, AbstractSession targetSession, boolean isSynchronizeOnMerge)

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

INTERNAL: Merge changes from the source to the target object.
protected void
mergeChanges(CollectionChangeRecord changeRecord, Object valueOfTarget, boolean shouldMergeCascadeParts, MergeManager mergeManager, AbstractSession targetSession)

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

INTERNAL: Merge changes from the source to the target object.
public void
recordAddToCollectionInChangeRecord(ObjectChangeSet changeSetToAdd, CollectionChangeRecord collectionChangeRecord)

Overrides org.eclipse.persistence.internal.queries.ListContainerPolicy.recordAddToCollectionInChangeRecord.

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.
public void
recordRemoveFromCollectionInChangeRecord(ObjectChangeSet changeSetToRemove, CollectionChangeRecord collectionChangeRecord)

Overrides org.eclipse.persistence.internal.queries.ListContainerPolicy.recordRemoveFromCollectionInChangeRecord.

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.
public void
recordUpdateToCollectionInChangeRecord(CollectionChangeEvent event, ObjectChangeSet changeSet, CollectionChangeRecord collectionChangeRecord)

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

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.

public void
public void
public boolean
shouldAddAll()

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

INTERNAL: Indicates whether addAll method should be called to add entire collection, or it's possible to call addInto multiple times instead.
public void
updateChangeRecordForSelfMerge(ChangeRecord changeRecord, Object source, Object target, ForeignReferenceMapping mapping, UnitOfWorkChangeSet parentUOWChangeSet, UnitOfWorkImpl unitOfWork)

Overrides org.eclipse.persistence.internal.queries.ListContainerPolicy.updateChangeRecordForSelfMerge.

INTERNAL: Update a ChangeRecord to replace the ChangeSet for the old entity with the changeSet for the new Entity.
public int
Inherited from org.eclipse.persistence.internal.queries.ListContainerPolicy:
gethasOrderindexOfisListPolicyisValidContainervalueFromPKList

Field Detail

listOrderFieldback to summary
protected DatabaseField listOrderField
NOT_SETback to summary
protected static final String NOT_SET
orderCorrectionTypeback to summary
protected OrderCorrectionType orderCorrectionType

Constructor Detail

OrderedListContainerPolicyback to summary
public OrderedListContainerPolicy()

INTERNAL: Construct a new policy.

OrderedListContainerPolicyback to summary
public OrderedListContainerPolicy(Class<?> containerClass)

INTERNAL: Construct a new policy for the specified class.

OrderedListContainerPolicyback to summary
public OrderedListContainerPolicy(String containerClassName)

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

Method Detail

addAdditionalFieldsToQueryback to summary
public void addAdditionalFieldsToQuery(ReadQuery selectionQuery, Expression baseExpression)

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

INTERNAL: Add the index field to the query.

Annotations
@Override
addAllback to summary
public boolean addAll(List<E> elements, Object container, AbstractSession session, List<AbstractRecord> dbRows, ObjectBuildingQuery query, CacheKey parentCacheKey, boolean isTargetProtected)

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

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

Annotations
@Override
addAllback to summary
public boolean addAll(List<E> elements, Object container, AbstractSession session, List<AbstractRecord> dbRows, DataReadQuery query, CacheKey parentCacheKey, boolean isTargetProtected)

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

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

Annotations
@Override
addAllback to summary
protected boolean addAll(List<E> elements, Object container, AbstractSession session, List<AbstractRecord> dbRows, ReadQuery query, CacheKey parentCacheKey)
addIntoAtIndexback to summary
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.

compareCollectionsForChangeback to summary
public void compareCollectionsForChange(Object oldList, Object newList, CollectionChangeRecord changeRecord, AbstractSession session, ClassDescriptor referenceDescriptor)

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

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.

Annotations
@Override
correctOrderListback to summary
public List<E> 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.

getAdditionalFieldsForJoinback to summary
public List<DatabaseField> getAdditionalFieldsForJoin(CollectionMapping baseMapping)

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

INTERNAL: Return any additional fields required by the policy for a fetch join.

Annotations
@Override
getAdditionalTablesForJoinQueryback to summary
public List<DatabaseTable> getAdditionalTablesForJoinQuery()

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

INTERNAL: Return any tables that will be required when this mapping is used as part of a join query.

Annotations
@Override
getChangeValuesFromback to summary
public Iterator<E> getChangeValuesFrom(Map<K, V> map)

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

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.

Annotations
@Override
getListOrderFieldback to summary
public DatabaseField getListOrderField()
getOrderCorrectionTypeback to summary
public OrderCorrectionType getOrderCorrectionType()
isOrderedListPolicyback to summary
public boolean isOrderedListPolicy()

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

Annotations
@Override
iteratorForback to summary
public Object iteratorFor(Object container)

Overrides org.eclipse.persistence.internal.queries.CollectionContainerPolicy.iteratorFor.

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

INTERNAL: Return an list iterator for the given container.

Parameters
container:Object

Doc from org.eclipse.persistence.internal.queries.CollectionContainerPolicy.iteratorFor.

java.lang.Object

Returns:Object

Doc from org.eclipse.persistence.internal.queries.CollectionContainerPolicy.iteratorFor.

java.util.Enumeration/java.util.Iterator

Annotations
@Override
mergeChangesback to summary
public void mergeChanges(CollectionChangeRecord changeRecord, Object valueOfTarget, boolean shouldMergeCascadeParts, MergeManager mergeManager, AbstractSession targetSession, boolean isSynchronizeOnMerge)

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

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.

Annotations
@Override
mergeChangesback to summary
protected void mergeChanges(CollectionChangeRecord changeRecord, Object valueOfTarget, boolean shouldMergeCascadeParts, MergeManager mergeManager, AbstractSession targetSession)

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

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.

Annotations
@Override
recordAddToCollectionInChangeRecordback to summary
public void recordAddToCollectionInChangeRecord(ObjectChangeSet changeSetToAdd, CollectionChangeRecord collectionChangeRecord)

Overrides org.eclipse.persistence.internal.queries.ListContainerPolicy.recordAddToCollectionInChangeRecord.

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

Annotations
@Override
recordRemoveFromCollectionInChangeRecordback to summary
public void recordRemoveFromCollectionInChangeRecord(ObjectChangeSet changeSetToRemove, CollectionChangeRecord collectionChangeRecord)

Overrides org.eclipse.persistence.internal.queries.ListContainerPolicy.recordRemoveFromCollectionInChangeRecord.

Doc from org.eclipse.persistence.internal.queries.ListContainerPolicy.recordRemoveFromCollectionInChangeRecord.

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

Annotations
@Override
recordUpdateToCollectionInChangeRecordback to summary
public void recordUpdateToCollectionInChangeRecord(CollectionChangeEvent event, ObjectChangeSet changeSet, CollectionChangeRecord collectionChangeRecord)

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

Doc from org.eclipse.persistence.internal.queries.ContainerPolicy.recordUpdateToCollectionInChangeRecord.

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

Annotations
@Override
registerRemoveNewObjectIfRequiredback to summary
protected void registerRemoveNewObjectIfRequired(ObjectChangeSet objectChanges, MergeManager mergeManager)

INTERNAL:

removeFromAtIndexback to summary
protected void removeFromAtIndex(int index, Object container)

INTERNAL: Remove the element at the specified index.

setListOrderFieldback to summary
public void setListOrderField(DatabaseField field)
setOrderCorrectionTypeback to summary
public void setOrderCorrectionType(OrderCorrectionType orderCorrectionType)
shouldAddAllback to summary
public boolean shouldAddAll()

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

INTERNAL: Indicates whether addAll method should be called to add entire collection, or it's possible to call addInto multiple times instead.

Annotations
@Override
updateChangeRecordForSelfMergeback to summary
public void updateChangeRecordForSelfMerge(ChangeRecord changeRecord, Object source, Object target, ForeignReferenceMapping mapping, UnitOfWorkChangeSet parentUOWChangeSet, UnitOfWorkImpl unitOfWork)

Overrides org.eclipse.persistence.internal.queries.ListContainerPolicy.updateChangeRecordForSelfMerge.

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.

Annotations
@Override
updateJoinedMappingIndexesForMapKeyback to summary
public int updateJoinedMappingIndexesForMapKey(Map<DatabaseMapping, Object> indexList, int index)

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

INTERNAL: Add the index field count.

Annotations
@Override