Class ToManyHolder<E>

java.lang.Object
org.apache.cayenne.access.ToManyHolder<E>
Direct Known Subclasses:
ToManyList, ToManySet

public abstract class ToManyHolder<E> extends Object
An abstract superclass of lazily faulted to-many relationship collections. Tracks additions and removals made while the relationship is still unresolved, and merges them into the fetched result on resolution.
Since:
5.0
  • Field Details

    • relationshipOwner

      protected Persistent relationshipOwner
    • relationshipName

      protected String relationshipName
    • addedToUnresolved

      protected Set<E> addedToUnresolved
    • removedFromUnresolved

      protected Set<E> removedFromUnresolved
  • Constructor Details

    • ToManyHolder

      protected ToManyHolder()
    • ToManyHolder

      protected ToManyHolder(Persistent relationshipOwner, String relationshipName)
  • Method Details

    • isFault

      public abstract boolean isFault()
      Returns whether this collection is not yet resolved and requires a fetch.
    • invalidate

      public abstract void invalidate()
      Turns this collection into a fault, thus forcing a refresh on the next access.
    • resolveWith

      public abstract void resolveWith(Collection<E> objects)
      Resolves this collection with the given objects without fetching them from the database. Used to inject prefetched results.
    • isTransientParent

      protected boolean isTransientParent()
    • isUncommittedParent

      protected boolean isUncommittedParent()
    • resolveRelationship

      protected List<E> resolveRelationship()
      Resolves related objects via the DataChannel stack of the owner's context, merging in any local changes made while the relationship was unresolved. Subclasses invoke this method whenever they need to resolve a fault.
    • addLocal

      protected void addLocal(E object)
      Records an addition made while the relationship is unresolved.
    • removeLocal

      protected void removeLocal(E object)
      Records a removal made while the relationship is unresolved.
    • mergeLocalChanges

      protected void mergeLocalChanges(List<E> fetched)
      Applies additions and removals recorded while unresolved to a freshly fetched list, then discards them.