Class DefaultPersistenceContext
- java.lang.Object
-
- io.ebeaninternal.server.transaction.DefaultPersistenceContext
-
- All Implemented Interfaces:
PersistenceContext
public final class DefaultPersistenceContext extends Object implements PersistenceContext
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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.ebean.bean.PersistenceContext
PersistenceContext.WithOption
-
-
Constructor Summary
Constructors Constructor Description DefaultPersistenceContext()
Create a new PersistenceContext.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clear the PersistenceContext.void
clear(Class<?> rootType)
Clear all the references for a given type of entity bean.void
clear(Class<?> rootType, Object id)
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.Object
get(Class<?> rootType, Object id)
Return an object given its type and unique id.PersistenceContext.WithOption
getWithOption(Class<?> rootType, Object id)
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)
Set an object into the PersistenceContext.Object
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.String
toString()
-
-
-
Constructor Detail
-
DefaultPersistenceContext
public DefaultPersistenceContext()
Create a new PersistenceContext.
-
-
Method Detail
-
put
public void put(Class<?> rootType, Object id, Object bean)
Set an object into the PersistenceContext.- Specified by:
put
in interfacePersistenceContext
-
putIfAbsent
public Object putIfAbsent(Class<?> rootType, Object id, Object bean)
Description copied from interface:PersistenceContext
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.
- Specified by:
putIfAbsent
in interfacePersistenceContext
-
get
public Object get(Class<?> rootType, Object id)
Return an object given its type and unique id.- Specified by:
get
in interfacePersistenceContext
-
getWithOption
public PersistenceContext.WithOption getWithOption(Class<?> rootType, Object id)
Description copied from interface:PersistenceContext
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).- Specified by:
getWithOption
in interfacePersistenceContext
-
size
public int size(Class<?> rootType)
Return the number of beans of the given type in the persistence context.- Specified by:
size
in interfacePersistenceContext
-
clear
public void clear()
Clear the PersistenceContext.- Specified by:
clear
in interfacePersistenceContext
-
clear
public void clear(Class<?> rootType)
Description copied from interface:PersistenceContext
Clear all the references for a given type of entity bean.- Specified by:
clear
in interfacePersistenceContext
-
deleted
public void deleted(Class<?> rootType, Object id)
Description copied from interface:PersistenceContext
Clear the reference as a result of an entity being deleted.- Specified by:
deleted
in interfacePersistenceContext
-
clear
public void clear(Class<?> rootType, Object id)
Description copied from interface:PersistenceContext
Clear the reference to a specific entity bean.- Specified by:
clear
in interfacePersistenceContext
-
-