Class DefaultPersistenceContext

java.lang.Object
io.ebeaninternal.server.transaction.DefaultPersistenceContext
All Implemented Interfaces:
io.ebean.bean.PersistenceContext, SpiPersistenceContext

public final class DefaultPersistenceContext extends Object implements SpiPersistenceContext
Default implementation of PersistenceContext.

Ensures only one instance of a bean is used according to its type and unique id.

PersistenceContext lives on a Transaction and as such is expected to only have a single thread accessing it at a time. This is not expected to be used concurrently.

Duplicate beans are ones having the same type and unique id value. These are considered duplicates and replaced by the bean instance that was already loaded into the PersistenceContext.

  • Constructor Details

    • DefaultPersistenceContext

      public DefaultPersistenceContext()
      Create a new PersistenceContext.
  • Method Details

    • beginIterate

      public void beginIterate()
      Specified by:
      beginIterate in interface io.ebean.bean.PersistenceContext
    • endIterate

      public void endIterate()
      Specified by:
      endIterate in interface io.ebean.bean.PersistenceContext
    • put

      public void put(Class<?> rootType, Object id, Object bean)
      Specified by:
      put in interface io.ebean.bean.PersistenceContext
    • putIfAbsent

      public Object putIfAbsent(Class<?> rootType, Object id, Object bean)
      Specified by:
      putIfAbsent in interface io.ebean.bean.PersistenceContext
    • get

      public Object get(Class<?> rootType, Object id)
      Return an object given its type and unique id.
      Specified by:
      get in interface io.ebean.bean.PersistenceContext
    • getWithOption

      public io.ebean.bean.PersistenceContext.WithOption getWithOption(Class<?> rootType, Object id)
      Specified by:
      getWithOption in interface io.ebean.bean.PersistenceContext
    • size

      public int size(Class<?> rootType)
      Specified by:
      size in interface io.ebean.bean.PersistenceContext
    • clear

      public void clear()
      Specified by:
      clear in interface io.ebean.bean.PersistenceContext
    • clear

      public void clear(Class<?> rootType)
      Specified by:
      clear in interface io.ebean.bean.PersistenceContext
    • deleted

      public void deleted(Class<?> rootType, Object id)
      Specified by:
      deleted in interface io.ebean.bean.PersistenceContext
    • clear

      public void clear(Class<?> rootType, Object id)
      Specified by:
      clear in interface io.ebean.bean.PersistenceContext
    • dirtyBeans

      public List<Object> dirtyBeans(SpiBeanTypeManager manager)
      Description copied from interface: SpiPersistenceContext
      Return the list of dirty beans held by this persistence context.
      Specified by:
      dirtyBeans in interface SpiPersistenceContext
    • toString

      public String toString()
      Overrides:
      toString in class Object