public interface PersistenceContext
Modifier and Type | Interface and Description |
---|---|
static interface |
PersistenceContext.NaturalIdHelper
Provides centralized access to natural-id-related functionality.
|
Modifier and Type | Method and Description |
---|---|
void |
addChildParent(Object child,
Object parent)
Add a child/parent relation to cache for cascading op
|
void |
addCollectionHolder(PersistentCollection holder)
Register a PersistentCollection object for an array.
|
void |
addEntity(EntityKey key,
Object entity)
Add a canonical mapping from entity key to entity instance
|
void |
addEntity(EntityUniqueKey euk,
Object entity)
Add an entity to the cache by unique key
|
EntityEntry |
addEntity(Object entity,
Status status,
Object[] loadedState,
EntityKey entityKey,
Object version,
LockMode lockMode,
boolean existsInDatabase,
EntityPersister persister,
boolean disableVersionIncrement,
boolean lazyPropertiesAreUnfetched)
Adds an entity to the internal caches.
|
EntityEntry |
addEntry(Object entity,
Status status,
Object[] loadedState,
Object rowId,
Serializable id,
Object version,
LockMode lockMode,
boolean existsInDatabase,
EntityPersister persister,
boolean disableVersionIncrement,
boolean lazyPropertiesAreUnfetched)
Generates an appropriate EntityEntry instance and adds it
to the event source's internal caches.
|
CollectionEntry |
addInitializedCollection(CollectionPersister persister,
PersistentCollection collection,
Serializable id)
add a collection we just pulled out of the cache (does not need initializing)
|
void |
addInitializedDetachedCollection(CollectionPersister collectionPersister,
PersistentCollection collection)
add an (initialized) collection that was created by another session and passed
into update() (ie.
|
void |
addNewCollection(CollectionPersister persister,
PersistentCollection collection)
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(CollectionPersister persister,
PersistentCollection collection,
Serializable id)
add a collection we just loaded up (still needs initializing)
|
void |
addUninitializedDetachedCollection(CollectionPersister persister,
PersistentCollection collection)
add a detached uninitialized collection
|
void |
addUnownedCollection(CollectionKey key,
PersistentCollection collection)
Add a collection which has no owner loaded
|
void |
afterLoad()
Call this after finishing a two-phase load
|
void |
afterTransactionCompletion()
Called after transactions end
|
void |
beforeLoad()
Call this before begining a two-phase load
|
void |
checkUniqueness(EntityKey key,
Object object)
Attempts to check whether the given key represents an entity already loaded within the
current session.
|
void |
clear()
Clear the state of the persistence context
|
boolean |
containsCollection(PersistentCollection collection)
Is the given collection associated with this persistence context?
|
boolean |
containsEntity(EntityKey key)
Is there an entity with the given key in the persistence context
|
boolean |
containsProxy(Object proxy)
Is the given proxy associated with this persistence context?
|
int |
decrementCascadeLevel()
Called after cascading
|
BatchFetchQueue |
getBatchFetchQueue()
Get the
BatchFetchQueue , instantiating one if necessary. |
Object[] |
getCachedDatabaseSnapshot(EntityKey key)
Get the current database state of the entity, using the cached state snapshot if one is available.
|
int |
getCascadeLevel()
How deep are we cascaded?
|
PersistentCollection |
getCollection(CollectionKey collectionKey)
Get the collection instance associated with the CollectionKey
|
Map |
getCollectionEntries()
Get the mapping from collection instance to collection entry
|
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
|
Object |
getCollectionOwner(Serializable key,
CollectionPersister collectionPersister)
Get the entity that owns this persistent collection
|
Map |
getCollectionsByKey()
Get the mapping from collection key to collection instance
|
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()
Get the mapping from key value to entity instance
|
Object |
getEntity(EntityKey key)
Get the entity instance associated with the given key
|
Object |
getEntity(EntityUniqueKey euk)
Get an entity cached by unique key
|
Map |
getEntityEntries()
Get the mapping from entity instance to entity entry
|
EntityEntry |
getEntry(Object entity)
Retrieve the
EntityEntry representation of the given entity. |
Object |
getIndexInOwner(String entity,
String property,
Object childObject,
Map mergeMap)
Search the persistence context for an index of the child object,
given a collection role
|
LoadContexts |
getLoadContexts()
Retrieve this persistence context's managed load context.
|
Serializable |
getLoadedCollectionOwnerIdOrNull(PersistentCollection collection)
Get the ID for the entity that owned this persistent collection when it was loaded
|
Object |
getLoadedCollectionOwnerOrNull(PersistentCollection collection)
Get the entity that owned this persistent collection when it was loaded
|
PersistenceContext.NaturalIdHelper |
getNaturalIdHelper()
Access to the natural-id helper for this persistence context
|
Object[] |
getNaturalIdSnapshot(Serializable id,
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.
|
HashSet |
getNullifiableEntityKeys()
Retrieve the set of EntityKeys representing nullifiable references
|
Serializable |
getOwnerId(String entity,
String property,
Object childObject,
Map mergeMap)
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()
Get the session to which this persistence context is bound.
|
Serializable |
getSnapshot(PersistentCollection coll)
Get the snapshot of the pre-flush collection state
|
boolean |
hasNonReadOnlyEntities() |
int |
incrementCascadeLevel()
Called before cascading
|
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 |
isDefaultReadOnly()
Will entities and proxies that are loaded into this persistence
context be made read-only by default?
To determine the read-only/modifiable setting for a particular entity
or proxy:
|
boolean |
isEntryFor(Object entity)
Is there an
EntityEntry registration for this entity instance? |
boolean |
isFlushing()
Is a flush cycle currently in process?
|
boolean |
isLoadFinished()
Is in a two-phase load?
|
boolean |
isPropertyNull(EntityKey ownerKey,
String propertyName)
Is the association property belonging to the keyed entity null?
|
boolean |
isReadOnly(Object entityOrProxy)
Is the entity or proxy read-only?
To determine the default read-only/modifiable setting used for entities and proxies that are loaded into the
session use
Session.isDefaultReadOnly() |
boolean |
isStateless() |
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
|
void |
registerInsertedKey(EntityPersister persister,
Serializable id)
Register keys inserted during the current transaction
|
void |
removeChildParent(Object child)
Remove child/parent relation from cache
|
PersistentCollection |
removeCollectionHolder(Object array)
Remove the mapping of collection to holder during eviction
of the owning entity
|
Object |
removeEntity(EntityKey key)
Remove an entity.
|
EntityEntry |
removeEntry(Object entity)
Remove an entity entry from the session cache
|
Object |
removeProxy(EntityKey key)
Remove a proxy from the session cache
|
void |
replaceDelayedEntityIdentityInsertKeys(EntityKey oldKey,
Serializable generatedId) |
void |
setDefaultReadOnly(boolean readOnly)
Change the default for entities and proxies loaded into this persistence
context from modifiable to read-only mode, or from modifiable to read-only
mode.
|
void |
setEntryStatus(EntityEntry entry,
Status status)
Set the status of an entry
|
void |
setFlushing(boolean flushing)
Called before and after the flushcycle
|
void |
setReadOnly(Object entityOrProxy,
boolean readOnly)
Set an unmodified persistent object to read-only mode, or a read-only
object to modifiable mode.
|
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)
Take ownership of a previously unowned collection, if one.
|
boolean |
wasInsertedDuringTransaction(EntityPersister persister,
Serializable id)
Allows callers to check to see if the identified entity was inserted during the current transaction.
|
boolean isStateless()
SessionImplementor getSession()
LoadContexts getLoadContexts()
void addUnownedCollection(CollectionKey key, PersistentCollection collection)
key
- The collection key under which to add the collectioncollection
- The collection to addPersistentCollection useUnownedCollection(CollectionKey key)
null
if no such
collection was previous added () or was previously removed.
This should indicate the owner is being loaded and we are ready to "link" them.key
- The collection key for which to locate a collection collectionnull
BatchFetchQueue getBatchFetchQueue()
BatchFetchQueue
, instantiating one if necessary.void clear()
boolean hasNonReadOnlyEntities()
void setEntryStatus(EntityEntry entry, Status status)
entry
- The entry for which to set the statusstatus
- The new statusvoid afterTransactionCompletion()
Object[] getDatabaseSnapshot(Serializable id, EntityPersister persister)
id
- The identifier of the entity for which to grab a snapshotpersister
- The persister of the entity.getCachedDatabaseSnapshot(org.hibernate.engine.spi.EntityKey)
Object[] getCachedDatabaseSnapshot(EntityKey key)
key
- The entity keyObject[] getNaturalIdSnapshot(Serializable id, EntityPersister persister)
id
- The identifier of the entity for which to grab a snapshotpersister
- The persister of the entity.void addEntity(EntityKey key, Object entity)
key
- The key under which to add an entityentity
- The entity instance to addObject getEntity(EntityKey key)
key
- The key under which to look for an entitynull
boolean containsEntity(EntityKey key)
key
- The key under which to look for an entitytrue
indicates an entity was found; otherwise false
Object removeEntity(EntityKey key)
EntityEntry
key
- The key whose matching entity should be removedvoid addEntity(EntityUniqueKey euk, Object entity)
euk
- The unique (non-primary) key under which to add an entityentity
- The entity instanceObject getEntity(EntityUniqueKey euk)
euk
- The unique (non-primary) key under which to look for an entityEntityEntry getEntry(Object entity)
EntityEntry
representation of the given entity.entity
- The entity instance for which to locate the corresponding entryEntityEntry removeEntry(Object entity)
entity
- The entity instance for which to remove the corresponding entryboolean isEntryFor(Object entity)
EntityEntry
registration for this entity instance?entity
- The entity instance for which to check for an entrytrue
indicates a matching entry was found.CollectionEntry getCollectionEntry(PersistentCollection coll)
coll
- The persistent collection instance for which to locate the collection entryEntityEntry addEntity(Object entity, Status status, Object[] loadedState, EntityKey entityKey, Object version, LockMode lockMode, boolean existsInDatabase, EntityPersister persister, boolean disableVersionIncrement, boolean lazyPropertiesAreUnfetched)
EntityEntry addEntry(Object entity, Status status, Object[] loadedState, Object rowId, Serializable id, Object version, LockMode lockMode, boolean existsInDatabase, EntityPersister persister, boolean disableVersionIncrement, boolean lazyPropertiesAreUnfetched)
boolean containsCollection(PersistentCollection collection)
boolean containsProxy(Object proxy)
boolean reassociateIfUninitializedProxy(Object value) throws MappingException
value
- The possible proxy to be reassociated.MappingException
void reassociateProxy(Object value, Serializable id) throws MappingException
MappingException
Object unproxy(Object maybeProxy) throws HibernateException
HibernateException
Object unproxyAndReassociate(Object maybeProxy) throws HibernateException
maybeProxy
- The reference to be unproxied if it currently represents a proxy.HibernateException
void checkUniqueness(EntityKey key, Object object) throws HibernateException
object
- The entity reference against which to perform the uniqueness check.HibernateException
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
Object proxyFor(EntityPersister persister, EntityKey key, Object impl) throws HibernateException
HibernateException
Object proxyFor(Object impl) throws HibernateException
HibernateException
Object getCollectionOwner(Serializable key, CollectionPersister collectionPersister) throws MappingException
MappingException
Object getLoadedCollectionOwnerOrNull(PersistentCollection collection)
collection
- The persistent collectionSerializable getLoadedCollectionOwnerIdOrNull(PersistentCollection collection)
collection
- The persistent collectionvoid addUninitializedCollection(CollectionPersister persister, PersistentCollection collection, Serializable id)
void addUninitializedDetachedCollection(CollectionPersister persister, PersistentCollection collection)
void addNewCollection(CollectionPersister persister, PersistentCollection collection) throws HibernateException
collection
- The collection to be associated with the persistence contextHibernateException
void addInitializedDetachedCollection(CollectionPersister collectionPersister, PersistentCollection collection) throws HibernateException
HibernateException
CollectionEntry addInitializedCollection(CollectionPersister persister, PersistentCollection collection, Serializable id) throws HibernateException
HibernateException
PersistentCollection getCollection(CollectionKey collectionKey)
void addNonLazyCollection(PersistentCollection collection)
void initializeNonLazyCollections() throws HibernateException
HibernateException
PersistentCollection getCollectionHolder(Object array)
void addCollectionHolder(PersistentCollection holder)
PersistentCollection removeCollectionHolder(Object array)
Serializable getSnapshot(PersistentCollection coll)
CollectionEntry getCollectionEntryOrNull(Object collection)
HashSet getNullifiableEntityKeys()
Map getEntitiesByKey()
Map getEntityEntries()
Map getCollectionEntries()
Map getCollectionsByKey()
int getCascadeLevel()
int incrementCascadeLevel()
int decrementCascadeLevel()
boolean isFlushing()
void setFlushing(boolean flushing)
void beforeLoad()
void afterLoad()
boolean isLoadFinished()
String toString()
Serializable getOwnerId(String entity, String property, Object childObject, Map mergeMap)
Object getIndexInOwner(String entity, String property, Object childObject, Map mergeMap)
void addNullProperty(EntityKey ownerKey, String propertyName)
boolean isPropertyNull(EntityKey ownerKey, String propertyName)
boolean isDefaultReadOnly()
isReadOnly(Object)
,
Session.isReadOnly(Object)
,
Session.isDefaultReadOnly()
void setDefaultReadOnly(boolean readOnly)
readOnly
- true, the default for loaded entities/proxies is read-only;
false, the default for loaded entities/proxies is modifiableTo override this session's read-only/modifiable setting for entities
and proxies loaded by a Query:
,
Query.setReadOnly(boolean)
,
Session.setDefaultReadOnly(boolean)
boolean isReadOnly(Object entityOrProxy)
Session.isDefaultReadOnly()
entityOrProxy
- an entity or proxytrue
if the object is read-only; otherwise false
to indicate that the object is
modifiable.void setReadOnly(Object entityOrProxy, boolean readOnly)
entityOrProxy
- an entity or proxyreadOnly
- if true
, the entity or proxy is made read-only; otherwise, the entity or proxy is made
modifiable.Session.setDefaultReadOnly(boolean)
,
Session.setReadOnly(java.lang.Object, boolean)
,
Query.setReadOnly(boolean)
void replaceDelayedEntityIdentityInsertKeys(EntityKey oldKey, Serializable generatedId)
void addChildParent(Object child, Object parent)
child
- The child of the relationshipparent
- The parent of the relationshipvoid removeChildParent(Object child)
child
- The child to be removed.void registerInsertedKey(EntityPersister persister, Serializable id)
persister
- The entity persisterid
- The idboolean wasInsertedDuringTransaction(EntityPersister persister, Serializable id)
persister
- The entity persisterid
- The idPersistenceContext.NaturalIdHelper getNaturalIdHelper()
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.