public final class DefaultPersistenceContext extends Object implements 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 PersistanceContext.
PersistenceContext.WithOption| Constructor and Description |
|---|
DefaultPersistenceContext()
Create a new PersistanceContext.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clear the PersistenceContext.
|
void |
clear(Class<?> beanType)
Clear all the references for a given type of entity bean.
|
void |
clear(Class<?> beanType,
Object id)
Clear the reference to a specific entity bean.
|
void |
deleted(Class<?> beanType,
Object id)
Clear the reference as a result of an entity being deleted.
|
Object |
get(Class<?> beanType,
Object id)
Return an object given its type and unique id.
|
PersistenceContext.WithOption |
getWithOption(Class<?> beanType,
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(Object id,
Object bean)
Set an object into the PersistanceContext.
|
Object |
putIfAbsent(Object id,
Object bean)
Put the entity bean into the PersistanceContext if one is not already
present (for this id).
|
int |
size(Class<?> beanType)
Return the number of beans of the given type in the persistence context.
|
String |
toString() |
public DefaultPersistenceContext()
public void put(Object id, Object bean)
put in interface PersistenceContextpublic Object putIfAbsent(Object id, Object bean)
PersistenceContextReturns an existing entity bean (if one is already there) and otherwise returns null.
putIfAbsent in interface PersistenceContextpublic Object get(Class<?> beanType, Object id)
get in interface PersistenceContextpublic PersistenceContext.WithOption getWithOption(Class<?> beanType, Object id)
PersistenceContextgetWithOption in interface PersistenceContextpublic int size(Class<?> beanType)
size in interface PersistenceContextpublic void clear()
clear in interface PersistenceContextpublic void clear(Class<?> beanType)
PersistenceContextclear in interface PersistenceContextpublic void deleted(Class<?> beanType, Object id)
PersistenceContextdeleted in interface PersistenceContextpublic void clear(Class<?> beanType, Object id)
PersistenceContextclear in interface PersistenceContextCopyright © 2014. All Rights Reserved.