FileDocCategorySizeDatePackage
PersistenceContext.javaAPI DocHibernate 3.2.513402Wed Jun 06 16:33:32 BST 2007org.hibernate.engine

PersistenceContext

public interface PersistenceContext
Holds the state of the persistence context, including the first-level cache, entries, snapshots, proxies, etc.
author
Gavin King

Fields Summary
Constructors Summary
Methods Summary
public voidaddCollectionHolder(org.hibernate.collection.PersistentCollection holder)
Register a PersistentCollection object for an array. Associates a holder with an array - MUST be called after loading array, since the array instance is not created until endLoad().

public voidaddEntity(EntityKey key, java.lang.Object entity)
Add a canonical mapping from entity key to entity instance

public voidaddEntity(EntityUniqueKey euk, java.lang.Object entity)
Add an entity to the cache by unique key

public EntityEntryaddEntity(java.lang.Object entity, Status status, java.lang.Object[] loadedState, EntityKey entityKey, java.lang.Object version, org.hibernate.LockMode lockMode, boolean existsInDatabase, org.hibernate.persister.entity.EntityPersister persister, boolean disableVersionIncrement, boolean lazyPropertiesAreUnfetched)
Adds an entity to the internal caches.

public EntityEntryaddEntry(java.lang.Object entity, Status status, java.lang.Object[] loadedState, java.lang.Object rowId, java.io.Serializable id, java.lang.Object version, org.hibernate.LockMode lockMode, boolean existsInDatabase, org.hibernate.persister.entity.EntityPersister persister, boolean disableVersionIncrement, boolean lazyPropertiesAreUnfetched)
Generates an appropriate EntityEntry instance and adds it to the event source's internal caches.

public CollectionEntryaddInitializedCollection(org.hibernate.persister.collection.CollectionPersister persister, org.hibernate.collection.PersistentCollection collection, java.io.Serializable id)
add a collection we just pulled out of the cache (does not need initializing)

public voidaddInitializedDetachedCollection(org.hibernate.persister.collection.CollectionPersister collectionPersister, org.hibernate.collection.PersistentCollection collection)
add an (initialized) collection that was created by another session and passed into update() (ie. one with a snapshot and existing state on the database)

public voidaddNewCollection(org.hibernate.persister.collection.CollectionPersister persister, org.hibernate.collection.PersistentCollection collection)
Add a new collection (ie. a newly created one, just instantiated by the application, with no database state or snapshot)

param
collection The collection to be associated with the persistence context

public voidaddNonLazyCollection(org.hibernate.collection.PersistentCollection collection)
Register a collection for non-lazy loading at the end of the two-phase load

public voidaddNullProperty(EntityKey ownerKey, java.lang.String propertyName)
Record the fact that the association belonging to the keyed entity is null.

public voidaddProxy(EntityKey key, java.lang.Object proxy)
Add a proxy to the session cache

public voidaddUninitializedCollection(org.hibernate.persister.collection.CollectionPersister persister, org.hibernate.collection.PersistentCollection collection, java.io.Serializable id)
add a collection we just loaded up (still needs initializing)

public voidaddUninitializedDetachedCollection(org.hibernate.persister.collection.CollectionPersister persister, org.hibernate.collection.PersistentCollection collection)
add a detached uninitialized collection

public voidaddUnownedCollection(CollectionKey key, org.hibernate.collection.PersistentCollection collection)
Add a collection which has no owner loaded

public voidafterLoad()
Call this after finishing a two-phase load

public voidafterTransactionCompletion()
Called after transactions end

public voidbeforeLoad()
Call this before begining a two-phase load

public voidcheckUniqueness(EntityKey key, java.lang.Object object)
Attempts to check whether the given key represents an entity already loaded within the current session.

param
object The entity reference against which to perform the uniqueness check.
throws
HibernateException

public voidclear()
Clear the state of the persistence context

public booleancontainsCollection(org.hibernate.collection.PersistentCollection collection)
Is the given collection associated with this persistence context?

public booleancontainsEntity(EntityKey key)
Is there an entity with the given key in the persistence context

public booleancontainsProxy(java.lang.Object proxy)
Is the given proxy associated with this persistence context?

public intdecrementCascadeLevel()
Called after cascading

public BatchFetchQueuegetBatchFetchQueue()
Get the BatchFetchQueue, instantiating one if necessary.

public java.lang.Object[]getCachedDatabaseSnapshot(EntityKey key)

public intgetCascadeLevel()
How deep are we cascaded?

public org.hibernate.collection.PersistentCollectiongetCollection(CollectionKey collectionKey)
Get the collection instance associated with the CollectionKey

public java.util.MapgetCollectionEntries()
Get the mapping from collection instance to collection entry

public CollectionEntrygetCollectionEntry(org.hibernate.collection.PersistentCollection coll)
Get the collection entry for a persistent collection

public CollectionEntrygetCollectionEntryOrNull(java.lang.Object collection)
Get the collection entry for a collection passed to filter, which might be a collection wrapper, an array, or an unwrapped collection. Return null if there is no entry.

public org.hibernate.collection.PersistentCollectiongetCollectionHolder(java.lang.Object array)
Get the PersistentCollection object for an array

public java.lang.ObjectgetCollectionOwner(java.io.Serializable key, org.hibernate.persister.collection.CollectionPersister collectionPersister)
Get the entity that owns this persistent collection

public java.util.MapgetCollectionsByKey()
Get the mapping from collection key to collection instance

public java.lang.Object[]getDatabaseSnapshot(java.io.Serializable id, org.hibernate.persister.entity.EntityPersister persister)
Get the current state of the entity as known to the underlying database, or null if there is no corresponding row

public java.util.MapgetEntitiesByKey()
Get the mapping from key value to entity instance

public java.lang.ObjectgetEntity(EntityKey key)
Get the entity instance associated with the given EntityKey

public java.lang.ObjectgetEntity(EntityUniqueKey euk)
Get an entity cached by unique key

public java.util.MapgetEntityEntries()
Get the mapping from entity instance to entity entry

public EntityEntrygetEntry(java.lang.Object entity)
Retreive the EntityEntry representation of the given entity.

param
entity The entity for which to locate the EntityEntry.
return
The EntityEntry for the given entity.

public java.lang.ObjectgetIndexInOwner(java.lang.String entity, java.lang.String property, java.lang.Object childObject, java.util.Map mergeMap)
Search the persistence context for an index of the child object, given a collection role

public org.hibernate.engine.loading.LoadContextsgetLoadContexts()
Retrieve this persistence context's managed load context.

return
The load context

public java.lang.Object[]getNaturalIdSnapshot(java.io.Serializable id, org.hibernate.persister.entity.EntityPersister persister)
Get the values of the natural id fields as known to the underlying database, or null if the entity has no natural id or there is no corresponding row.

public java.util.HashSetgetNullifiableEntityKeys()
Retrieve the set of EntityKeys representing nullifiable references

public java.io.SerializablegetOwnerId(java.lang.String entity, java.lang.String property, java.lang.Object childObject, java.util.Map mergeMap)
Search the persistence context for an owner for the child object, given a collection role

public java.lang.ObjectgetProxy(EntityKey key)
Get an existing proxy by key

public SessionImplementorgetSession()
Get the session to which this persistence context is bound.

return
The session.

public java.io.SerializablegetSnapshot(org.hibernate.collection.PersistentCollection coll)
Get the snapshot of the pre-flush collection state

public booleanhasNonReadOnlyEntities()

return
false if we know for certain that all the entities are read-only

public intincrementCascadeLevel()
Called before cascading

public voidinitializeNonLazyCollections()
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)

public booleanisEntryFor(java.lang.Object entity)
Is there an EntityEntry for this instance?

public booleanisFlushing()
Is a flush cycle currently in process?

public booleanisPropertyNull(EntityKey ownerKey, java.lang.String propertyName)
Is the association property belonging to the keyed entity null?

public booleanisStateless()

public java.lang.ObjectnarrowProxy(java.lang.Object proxy, org.hibernate.persister.entity.EntityPersister persister, EntityKey key, java.lang.Object object)
If the existing proxy is insufficiently "narrow" (derived), instantiate a new proxy and overwrite the registration of the old one. This breaks == and occurs only for "class" proxies rather than "interface" proxies. Also init the proxy to point to the given target implementation if necessary.

param
proxy The proxy instance to be narrowed.
param
persister The persister for the proxied entity.
param
key The internal cache key for the proxied entity.
param
object (optional) the actual proxied entity instance.
return
An appropriately narrowed instance.
throws
HibernateException

public java.lang.ObjectproxyFor(org.hibernate.persister.entity.EntityPersister persister, EntityKey key, java.lang.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. Init the proxy to the target implementation, if necessary.

public java.lang.ObjectproxyFor(java.lang.Object impl)
Return the existing proxy associated with the given EntityKey, or the argument (the entity associated with the key) if no proxy exists. (slower than the form above)

public booleanreassociateIfUninitializedProxy(java.lang.Object value)
Takes the given object and, if it represents a proxy, reassociates it with this event source.

param
value The possible proxy to be reassociated.
return
Whether the passed value represented an actual proxy which got initialized.
throws
MappingException

public voidreassociateProxy(java.lang.Object value, java.io.Serializable id)
If a deleted entity instance is re-saved, and it has a proxy, we need to reset the identifier of the proxy

public org.hibernate.collection.PersistentCollectionremoveCollectionHolder(java.lang.Object array)
Remove the mapping of collection to holder during eviction of the owning entity

public java.lang.ObjectremoveEntity(EntityKey key)
Remove an entity from the session cache, also clear up other state associated with the entity, all except for the EntityEntry

public EntityEntryremoveEntry(java.lang.Object entity)
Remove an entity entry from the session cache

public java.lang.ObjectremoveProxy(EntityKey key)
Remove a proxy from the session cache

public voidreplaceDelayedEntityIdentityInsertKeys(EntityKey oldKey, java.io.Serializable generatedId)

public voidsetEntryStatus(EntityEntry entry, Status status)
Set the status of an entry

public voidsetFlushing(boolean flushing)
Called before and after the flushcycle

public voidsetReadOnly(java.lang.Object entity, boolean readOnly)
Set the object to read only and discard it's snapshot

public java.lang.StringtoString()
Returns a string representation of the object.

return
a string representation of the object.

public java.lang.Objectunproxy(java.lang.Object maybeProxy)
Get the entity instance underlying the given proxy, throwing an exception if the proxy is uninitialized. If the given object is not a proxy, simply return the argument.

public java.lang.ObjectunproxyAndReassociate(java.lang.Object maybeProxy)
Possibly unproxy the given reference and reassociate it with the current session.

param
maybeProxy The reference to be unproxied if it currently represents a proxy.
return
The unproxied instance.
throws
HibernateException

public org.hibernate.collection.PersistentCollectionuseUnownedCollection(CollectionKey key)
Get and remove a collection whose owner is not yet loaded, when its owner is being loaded