Module io.ebean.api
Package io.ebean.bean

Interface PersistenceContext


public interface PersistenceContext
Holds entity beans by there type and id.

This is used to ensure only one instance for a given entity type and id is used to build object graphs from queries and lazy loading.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
    Wrapper on a bean to also indicate if a bean has been deleted.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Signalizes the PersistenceContext, the begin for large query iteration.
    void
    Clear all the references.
    void
    clear(Class<?> rootType)
    Clear all the references for a given type of entity bean.
    void
    clear(Class<?> rootType, Object uid)
    Clear the reference to a specific entity bean.
    void
    deleted(Class<?> rootType, Object id)
    Clear the reference as a result of an entity being deleted.
    void
    Signalizes the PersistenceContext, the end for large query iteration.
    get(Class<?> rootType, Object uid)
    Return an object given its type and unique id.
    getWithOption(Class<?> rootType, Object uid)
    Get the bean from the persistence context also checked to see if it had been previously deleted (if so then you also can't hit the L2 cache to fetch the bean for this particular persistence context).
    void
    put(Class<?> rootType, Object id, Object bean)
    Put the entity bean into the PersistenceContext.
    putIfAbsent(Class<?> rootType, Object id, Object bean)
    Put the entity bean into the PersistenceContext if one is not already present (for this id).
    int
    size(Class<?> rootType)
    Return the number of beans of the given type in the persistence context.
  • Method Details

    • put

      void put(Class<?> rootType, Object id, Object bean)
      Put the entity bean into the PersistenceContext.
    • putIfAbsent

      Object putIfAbsent(Class<?> rootType, Object id, Object bean)
      Put the entity bean into the PersistenceContext if one is not already present (for this id).

      Returns an existing entity bean (if one is already there) and otherwise returns null.

    • get

      Object get(Class<?> rootType, Object uid)
      Return an object given its type and unique id.
    • getWithOption

      PersistenceContext.WithOption getWithOption(Class<?> rootType, Object uid)
      Get the bean from the persistence context also checked to see if it had been previously deleted (if so then you also can't hit the L2 cache to fetch the bean for this particular persistence context).
    • clear

      void clear()
      Clear all the references.
    • clear

      void clear(Class<?> rootType)
      Clear all the references for a given type of entity bean.
    • clear

      void clear(Class<?> rootType, Object uid)
      Clear the reference to a specific entity bean.
    • deleted

      void deleted(Class<?> rootType, Object id)
      Clear the reference as a result of an entity being deleted.
    • size

      int size(Class<?> rootType)
      Return the number of beans of the given type in the persistence context.
    • beginIterate

      void beginIterate()
      Signalizes the PersistenceContext, the begin for large query iteration.
    • endIterate

      void endIterate()
      Signalizes the PersistenceContext, the end for large query iteration.