Package io.ebean.bean

Interface BeanCollection<E>

  • All Superinterfaces:
    Serializable
    All Known Implementing Classes:
    BeanList, BeanMap, BeanSet

    public interface BeanCollection<E>
    extends Serializable
    Lazy loading capable Maps, Lists and Sets.

    This also includes the ability to listen for additions and removals to or from the Map Set or List. The purpose of gathering the additions and removals is to support persisting ManyToMany objects. The additions and removals become inserts and deletes from the intersection table.

    Technically this is NOT an extension of java.util.Collection. The reason being that java.util.Map is not a Collection. I realise this makes this name confusing so I apologise for that.

    • Method Detail

      • setDisableLazyLoad

        void setDisableLazyLoad​(boolean disableLazyLoad)
        Set the disableLazyLoad state.
      • addBean

        void addBean​(E bean)
        Add a bean to the list/set with modifyListen notification.
      • removeBean

        void removeBean​(E bean)
        Remove a bean to the list/set with modifyListen notification.
      • reset

        void reset​(EntityBean ownerBean,
                   String propertyName)
        Reset the collection back to an empty state ready for reloading.

        This is done as part of bean refresh.

      • isSkipSave

        boolean isSkipSave()
        Return true if the collection is uninitialised or is empty without any held modifications.

        Returning true means can safely skip cascade save for this bean collection.

      • holdsModifications

        boolean holdsModifications()
        Return true if the collection holds modifications.
      • checkEmptyLazyLoad

        boolean checkEmptyLazyLoad()
        Check after the lazy load that the underlying collection is not null (handle case where join to many not outer).

        That is, if the collection was not loaded due to filterMany predicates etc then make sure the collection is set to empty.

      • getFilterMany

        ExpressionList<?> getFilterMany()
        Return the filter (if any) that was used in building this collection.

        This is so that the filter can be applied on refresh.

      • isRegisteredWithLoadContext

        boolean isRegisteredWithLoadContext()
        Return true if the collection has been registered with the batch loading context.
      • setLoader

        void setLoader​(BeanCollectionLoader beanLoader)
        Set the loader that will be used to lazy/query load this collection.

        This is effectively the batch loading context this collection is registered with.

      • setReadOnly

        void setReadOnly​(boolean readOnly)
        Set to true if you want the BeanCollection to be treated as read only. This means no elements can be added or removed etc.
      • isReadOnly

        boolean isReadOnly()
        Return true if the collection should be treated as readOnly and no elements can be added or removed etc.
      • internalAdd

        void internalAdd​(Object bean)
        Add the bean to the collection.

        This is disallowed for BeanMap.

      • size

        int size()
        Return the number of elements in the List Set or Map.
      • isEmpty

        boolean isEmpty()
        Return true if the List Set or Map is empty.
      • getActualEntries

        Collection<?> getActualEntries()
        Returns the underlying entries so for Maps this is a collection of Map.Entry.

        For maps this returns the entrySet as we need the keys of the map.

      • isPopulated

        boolean isPopulated()
        return true if there are real rows held. Return false is this is using Deferred fetch to lazy load the rows and the rows have not yet been fetched.
      • isReference

        boolean isReference()
        Return true if this is a reference (lazy loading) bean collection. This is the same as !isPopulated();
      • setModifyListening

        void setModifyListening​(BeanCollection.ModifyListenMode modifyListenMode)
        Set modify listening on or off. This is used to keep track of objects that have been added to or removed from the list set or map.

        This is required only for ManyToMany collections. The additions and deletions are used to insert or delete entries from the intersection table. Otherwise modifyListening is false.

      • modifyAddition

        void modifyAddition​(E bean)
        Add an object to the additions list.

        This will potentially end up as an insert into a intersection table for a ManyToMany.

      • modifyRemoval

        void modifyRemoval​(Object bean)
        Add an object to the deletions list.

        This will potentially end up as an delete from an intersection table for a ManyToMany.

      • getModifyAdditions

        Set<EgetModifyAdditions()
        Return the list of objects added to the list set or map. These will used to insert rows into the intersection table of a ManyToMany.
      • getModifyRemovals

        Set<EgetModifyRemovals()
        Return the list of objects removed from the list set or map. These will used to delete rows from the intersection table of a ManyToMany.
      • modifyReset

        void modifyReset()
        Reset the set of additions and deletions. This is called after the additions and removals have been processed.
      • wasTouched

        boolean wasTouched()
        Has been modified by an addition or removal.