|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.hibernate.engine.PersistenceContext
A PersistenceContext represents the state of persistent "stuff" which Hibernate is tracking. This includes persistent entities, collections, as well as proxies generated.
There is meant to be a one-to-one correspondence between a SessionImpl and a PersistentContext. The SessionImpl uses the PersistentContext to track the current state of its context. Event-listeners then use the PersistentContext to drive their processing.
Field Summary | |
static Object |
NO_ROW
|
Constructor Summary | |
PersistenceContext(SessionImplementor session)
Constructs a PersistentContext, bound to the given session. |
Method Summary | |
void |
addCollectionHolder(PersistentCollection holder)
Register a PersistentCollection object for an array. |
void |
addEntity(EntityKey key,
Object object)
|
void |
addEntity(EntityUniqueKey euk,
Object entity)
Add an entity to the cache by unique key |
EntityEntry |
addEntity(Object object,
Status status,
Object[] loadedState,
Serializable id,
Object version,
LockMode lockMode,
boolean existsInDatabase,
EntityPersister persister,
boolean disableVersionIncrement)
Adds an entity to the internal caches. |
EntityEntry |
addEntry(Object object,
Status status,
Object[] loadedState,
Object rowId,
Serializable id,
Object version,
LockMode lockMode,
boolean existsInDatabase,
EntityPersister persister,
boolean disableVersionIncrement)
Generates an appropriate EntityEntry instance and adds it to the event source's internal caches. |
CollectionEntry |
addInitializedCollection(PersistentCollection collection,
CollectionPersister persister,
Serializable id,
EntityMode em)
add a collection we just pulled out of the cache (does not need initializing) |
void |
addInitializedDetachedCollection(PersistentCollection collection,
CollectionSnapshot cs,
EntityMode em)
add an (initialized) collection that was created by another session and passed into update() (ie. |
void |
addNewCollection(PersistentCollection collection,
CollectionPersister persister)
Add a new collection (ie. |
void |
addNonLazyCollection(PersistentCollection collection)
Register a collection for non-lazy loading at the end of the two-phase load |
void |
addNullProperty(EntityKey ownerKey,
String propertyName)
Record the fact that the association belonging to the keyed entity is null. |
void |
addProxy(EntityKey key,
Object proxy)
Add a proxy to the session cache |
void |
addUninitializedCollection(PersistentCollection collection,
CollectionPersister persister,
Serializable id,
EntityMode em)
add a collection we just loaded up (still needs initializing) |
void |
addUninitializedDetachedCollection(PersistentCollection collection,
CollectionPersister persister,
Serializable id,
EntityMode em)
add a detached uninitialized collection |
void |
addUnownedCollection(CollectionKey key,
PersistentCollection collection)
|
void |
afterLoad()
Call this after finishing a two-phase load |
void |
afterTransactionCompletion()
|
void |
beforeLoad()
Call this before begining a two-phase load |
void |
checkUniqueness(Serializable id,
EntityPersister persister,
Object object)
Attempts to check whether the given key represents an entity already loaded within the current session. |
void |
clear()
|
void |
clearNullProperties()
|
boolean |
containsEntity(EntityKey key)
|
boolean |
containsProxy(Object object)
|
int |
decrementCascadeLevel()
|
BatchFetchQueue |
getBatchFetchQueue()
Get the BatchFetchQueue, instantiating one if necessary. |
Object[] |
getCachedDatabaseSnapshot(EntityKey key)
|
int |
getCascadeLevel()
Do we already know that the entity does not exist in the database? |
PersistentCollection |
getCollection(CollectionKey collectionKey)
Get the collection instance associated with the CollectionKey |
Map |
getCollectionEntries()
|
CollectionEntry |
getCollectionEntry(PersistentCollection coll)
Get the collection entry for a persistent collection |
CollectionEntry |
getCollectionEntryOrNull(Object collection)
Get the collection entry for a collection passed to filter, which might be a collection wrapper, an array, or an unwrapped collection. |
PersistentCollection |
getCollectionHolder(Object array)
Get the PersistentCollection object for an array |
CollectionLoadContext |
getCollectionLoadContext()
|
Object |
getCollectionOwner(Serializable key,
CollectionPersister collectionPersister)
Get the entity that owns this persistent collection |
Map |
getCollectionsByKey()
|
Object[] |
getDatabaseSnapshot(Serializable id,
EntityPersister persister)
Get the current state of the entity as known to the underlying database, or null if there is no corresponding row |
Map |
getEntitiesByKey()
|
Object |
getEntity(EntityKey key)
Get the entity instance associated with the given EntityKey |
Object |
getEntity(EntityUniqueKey euk)
Get an entity cached by unique key |
Map |
getEntityEntries()
|
EntityEntry |
getEntry(Object object)
Retreive the EntityEntry representation of the given entity. |
Object |
getIndexInOwner(String role,
Object childObject)
Search the persistence context for an index of the child object, given a collection role |
Serializable |
getLoadedCollectionKey(PersistentCollection coll)
Get the pre-flush identifier of the collection |
LockMode |
getLockMode(Object entity)
|
HashSet |
getNullifiableEntityKeys()
Retrieve the set of EntityKeys representing nullifiable references |
Serializable |
getOwnerId(String role,
Object childObject)
Search the persistence context for an owner for the child object, given a collection role |
Object |
getProxy(EntityKey key)
Get an existing proxy by key |
SessionImplementor |
getSession()
|
Serializable |
getSnapshot(PersistentCollection coll)
Get the snapshot of the pre-flush collection state |
boolean |
hasNonReadOnlyEntities()
|
int |
incrementCascadeLevel()
|
void |
initializeNonLazyCollections()
Force initialization of all non-lazy collections encountered during the current two-phase load (actually, this is a no-op, unless this is the "outermost" load) |
boolean |
isEntryFor(Object object)
Is there an EntityEntry for this instance? |
boolean |
isFlushing()
|
boolean |
isInverseCollection(PersistentCollection collection)
Is this the "inverse" end of a bidirectional association? |
boolean |
isPropertyNull(EntityKey ownerKey,
String propertyName)
Is the association property belonging to the keyed entity null? |
Object |
narrowProxy(Object proxy,
EntityPersister persister,
EntityKey key,
Object object)
If the existing proxy is insufficiently "narrow" (derived), instantiate a new proxy and overwrite the registration of the old one. |
Object |
proxyFor(EntityPersister persister,
EntityKey key,
Object impl)
Return the existing proxy associated with the given EntityKey, or the third argument (the entity associated with the key) if no proxy exists. |
Object |
proxyFor(Object impl)
Return the existing proxy associated with the given EntityKey, or the argument (the entity associated with the key) if no proxy exists. |
boolean |
reassociateIfUninitializedProxy(Object value)
Takes the given object and, if it represents a proxy, reassociates it with this event source. |
void |
reassociateProxy(Object value,
Serializable id)
If a deleted entity instance is re-saved, and it has a proxy, we need to reset the identifier of the proxy |
PersistentCollection |
removeCollectionHolder(Object array)
|
Object |
removeEntity(EntityKey key)
Remove an entity from the session cache, also clear up other state associated with the entity, all except for the EntityEntry |
EntityEntry |
removeEntry(Object object)
Remove an entity entry from the session cache |
Object |
removeProxy(EntityKey key)
Remove a proxy from the session cache |
void |
setEntryStatus(EntityEntry entry,
Status status)
|
void |
setFlushing(boolean flushing)
|
void |
setLockMode(Object entity,
LockMode lockMode)
|
void |
setNullifiableEntityKeys(HashSet nullifiables)
|
String |
toString()
Returns a string representation of the object. |
Object |
unproxy(Object maybeProxy)
Get the entity instance underlying the given proxy, throwing an exception if the proxy is uninitialized. |
Object |
unproxyAndReassociate(Object maybeProxy)
Possibly unproxy the given reference and reassociate it with the current session. |
PersistentCollection |
useUnownedCollection(CollectionKey key)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final Object NO_ROW
Constructor Detail |
public PersistenceContext(SessionImplementor session)
session
- The session "owning" this context.Method Detail |
public SessionImplementor getSession()
public CollectionLoadContext getCollectionLoadContext()
public void addUnownedCollection(CollectionKey key, PersistentCollection collection)
public PersistentCollection useUnownedCollection(CollectionKey key)
public BatchFetchQueue getBatchFetchQueue()
public void clear()
public boolean hasNonReadOnlyEntities()
public void setEntryStatus(EntityEntry entry, Status status)
public void afterTransactionCompletion()
public Object[] getDatabaseSnapshot(Serializable id, EntityPersister persister) throws HibernateException
HibernateException
public Object[] getCachedDatabaseSnapshot(EntityKey key)
public void addEntity(EntityKey key, Object object)
public Object getEntity(EntityKey key)
public boolean containsEntity(EntityKey key)
public Object removeEntity(EntityKey key)
public Object getEntity(EntityUniqueKey euk)
public void addEntity(EntityUniqueKey euk, Object entity)
public EntityEntry getEntry(Object object)
object
- The entity for which to locate the EntityEntry.
public EntityEntry removeEntry(Object object)
public boolean isEntryFor(Object object)
public CollectionEntry getCollectionEntry(PersistentCollection coll)
public EntityEntry addEntity(Object object, Status status, Object[] loadedState, Serializable id, Object version, LockMode lockMode, boolean existsInDatabase, EntityPersister persister, boolean disableVersionIncrement)
public EntityEntry addEntry(Object object, Status status, Object[] loadedState, Object rowId, Serializable id, Object version, LockMode lockMode, boolean existsInDatabase, EntityPersister persister, boolean disableVersionIncrement)
public LockMode getLockMode(Object entity)
public void setLockMode(Object entity, LockMode lockMode)
public boolean containsProxy(Object object)
public boolean reassociateIfUninitializedProxy(Object value) throws MappingException
value
- The possible proxy to be reassociated.
MappingException
public void reassociateProxy(Object value, Serializable id) throws MappingException
MappingException
public Object unproxy(Object maybeProxy) throws HibernateException
HibernateException
public Object unproxyAndReassociate(Object maybeProxy) throws HibernateException
maybeProxy
- The reference to be unproxied if it currently represents a proxy.
HibernateException
public void checkUniqueness(Serializable id, EntityPersister persister, Object object) throws HibernateException
id
- The key to be checked.object
- The entity reference against which to perform the uniqueness check.
HibernateException
public Object narrowProxy(Object proxy, EntityPersister persister, EntityKey key, Object object) throws HibernateException
proxy
- The proxy instance to be narrowed.persister
- The persister for the proxied entity.key
- The internal cache key for the proxied entity.object
- (optional) the actual proxied entity instance.
HibernateException
public Object proxyFor(EntityPersister persister, EntityKey key, Object impl) throws HibernateException
HibernateException
public Object proxyFor(Object impl) throws HibernateException
HibernateException
public Object getCollectionOwner(Serializable key, CollectionPersister collectionPersister) throws MappingException
MappingException
public void addUninitializedCollection(PersistentCollection collection, CollectionPersister persister, Serializable id, EntityMode em)
public void addUninitializedDetachedCollection(PersistentCollection collection, CollectionPersister persister, Serializable id, EntityMode em)
public void addNewCollection(PersistentCollection collection, CollectionPersister persister) throws HibernateException
collection
- The collection to be associated with the persistence context
HibernateException
public void addInitializedDetachedCollection(PersistentCollection collection, CollectionSnapshot cs, EntityMode em) throws HibernateException
HibernateException
public CollectionEntry addInitializedCollection(PersistentCollection collection, CollectionPersister persister, Serializable id, EntityMode em) throws HibernateException
HibernateException
public PersistentCollection getCollection(CollectionKey collectionKey)
public void addNonLazyCollection(PersistentCollection collection)
public void initializeNonLazyCollections() throws HibernateException
HibernateException
public PersistentCollection getCollectionHolder(Object array)
public void addCollectionHolder(PersistentCollection holder)
public PersistentCollection removeCollectionHolder(Object array)
public Serializable getSnapshot(PersistentCollection coll)
public Serializable getLoadedCollectionKey(PersistentCollection coll)
public boolean isInverseCollection(PersistentCollection collection)
public CollectionEntry getCollectionEntryOrNull(Object collection)
public Object getProxy(EntityKey key)
public void addProxy(EntityKey key, Object proxy)
public Object removeProxy(EntityKey key)
public HashSet getNullifiableEntityKeys()
public void setNullifiableEntityKeys(HashSet nullifiables)
public Map getEntitiesByKey()
public Map getEntityEntries()
public Map getCollectionEntries()
public Map getCollectionsByKey()
public int getCascadeLevel()
public int incrementCascadeLevel()
public int decrementCascadeLevel()
public boolean isFlushing()
public void setFlushing(boolean flushing)
public void beforeLoad()
public void afterLoad()
public String toString()
public Serializable getOwnerId(String role, Object childObject)
public Object getIndexInOwner(String role, Object childObject)
public void addNullProperty(EntityKey ownerKey, String propertyName)
public boolean isPropertyNull(EntityKey ownerKey, String propertyName)
public void clearNullProperties()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |