public abstract class AbstractPersistentCollection extends Object implements Serializable, PersistentCollection
PersistentCollection
Modifier and Type | Class and Description |
---|---|
protected class |
AbstractPersistentCollection.AbstractValueDelayedOperation |
protected static interface |
AbstractPersistentCollection.DelayedOperation
Contract for operations which are part of a collection's operation queue.
|
protected class |
AbstractPersistentCollection.IteratorProxy |
static interface |
AbstractPersistentCollection.LazyInitializationWork<T>
TBH not sure why this is public
|
protected class |
AbstractPersistentCollection.ListIteratorProxy |
protected class |
AbstractPersistentCollection.ListProxy |
protected class |
AbstractPersistentCollection.SetProxy |
protected static interface |
AbstractPersistentCollection.ValueDelayedOperation |
Modifier and Type | Field and Description |
---|---|
protected boolean |
elementRemoved |
protected static Object |
UNKNOWN |
Modifier | Constructor and Description |
---|---|
|
AbstractPersistentCollection()
Not called by Hibernate, but used by non-JDK serialization,
eg.
|
protected |
AbstractPersistentCollection(SessionImplementor session)
Deprecated.
|
protected |
AbstractPersistentCollection(SharedSessionContractImplementor session) |
Modifier and Type | Method and Description |
---|---|
boolean |
afterInitialize()
Called after initializing from cache
|
void |
afterRowInsert(CollectionPersister persister,
Object entry,
int i)
Called after inserting a row, to fetch the natively generated id
|
void |
beginRead()
Called just before reading any rows from the JDBC result set
|
void |
clearDirty()
Clear the dirty flag, after flushing changes
to the database.
|
void |
clearOperationQueue() |
void |
dirty()
Mark the collection as dirty
|
abstract boolean |
empty()
Is the collection empty? (don't try to initialize the collection)
|
boolean |
endRead()
Called after reading all rows from the JDBC result set
|
void |
forceInitialization()
To be called internally by the session, forcing immediate initialization.
|
protected int |
getCachedSize() |
Object |
getIdentifier(Object entry,
int i)
Get the identifier of the given collection entry.
|
Serializable |
getKey()
Get the current collection key value
|
protected static Collection |
getOrphans(Collection oldElements,
Collection currentElements,
String entityName,
SharedSessionContractImplementor session)
Given a collection of entity instances that used to
belong to the collection, and a collection of instances
that currently belong, return a collection of orphans
|
abstract Collection |
getOrphans(Serializable snapshot,
String entityName)
get all "orphaned" elements
|
Object |
getOwner()
Get the owning entity.
|
Collection |
getQueuedOrphans(String entityName)
Get the "queued" orphans
|
String |
getRole()
Get the current role name
|
SharedSessionContractImplementor |
getSession()
Get the session currently associated with this collection.
|
protected Serializable |
getSnapshot()
Get the current snapshot from the session
|
Serializable |
getStoredSnapshot()
Get the snapshot cached by the collection instance
|
Object |
getValue()
Return the user-visible collection (or array) instance
|
boolean |
hasQueuedOperations()
Does this instance have any "queued" operations?
|
static void |
identityRemove(Collection list,
Object entityInstance,
String entityName,
SessionImplementor session)
Deprecated.
identityRemove(Collection, Object, String, SharedSessionContractImplementor)
should be used instead. |
static void |
identityRemove(Collection list,
Object entityInstance,
String entityName,
SharedSessionContractImplementor session)
Removes entity entries that have an equal identifier with the incoming entity instance
|
protected void |
initialize(boolean writing)
Initialize the collection, if possible, wrapping any exceptions
in a runtime exception
|
protected boolean |
isClearQueueEnabled()
Is this collection in a state that would allow us to
"queue" clear? This is a special case, because of orphan
delete.
|
protected boolean |
isConnectedToSession() |
boolean |
isDirectlyAccessible()
Could the application possibly have a direct reference to
the underlying collection implementation?
|
boolean |
isDirty()
Is the collection dirty? Note that this is only
reliable during the flush cycle, after the
collection elements are dirty checked against
the snapshot.
|
boolean |
isElementRemoved() |
protected boolean |
isInitialized() |
protected boolean |
isInverseCollection()
Is this the "inverse" end of a bidirectional association?
|
protected boolean |
isInverseCollectionNoOrphanDelete()
Is this the "inverse" end of a bidirectional association with
no orphan delete enabled?
|
protected boolean |
isInverseOneToManyOrNoOrphanDelete()
Is this the "inverse" end of a bidirectional one-to-many, or
of a collection with no orphan delete?
|
protected boolean |
isOperationQueueEnabled()
Is this collection in a state that would allow us to
"queue" operations?
|
protected boolean |
isPutQueueEnabled()
Is this collection in a state that would allow us to
"queue" puts? This is a special case, because of orphan
delete.
|
boolean |
isRowUpdatePossible()
Can each element in the collection be mapped unequivocally to a single row in the database? Generally
bags and sets are the only collections that cannot be.
|
boolean |
isUnreferenced()
Is the collection unreferenced?
|
boolean |
needsRecreate(CollectionPersister persister)
Do we need to completely recreate this collection when it changes?
|
protected void |
performQueuedOperations()
After reading all existing elements from the database,
add the queued elements to the underlying collection.
|
void |
postAction()
After flushing, clear any "queued" additions, since the
database state is now synchronized with the memory state.
|
void |
preInsert(CollectionPersister persister)
Called before inserting rows, to ensure that any surrogate keys
are fully generated
|
protected void |
prepareForPossibleLoadingOutsideTransaction() |
Iterator |
queuedAdditionIterator()
Iterator over the "queued" additions
|
protected void |
queueOperation(AbstractPersistentCollection.DelayedOperation operation)
Queue an addition
|
protected void |
read()
Called by any read-only method of the collection interface
|
protected Object |
readElementByIndex(Object index) |
protected Boolean |
readElementExistence(Object element) |
protected Boolean |
readIndexExistence(Object index) |
protected boolean |
readSize()
Called by the
Collection.size() method |
void |
replaceQueuedOperationValues(CollectionPersister persister,
Map copyCache)
Replace entity instances with copy in
copyCache /. |
boolean |
setCurrentSession(SharedSessionContractImplementor session)
Associate the collection with the given session.
|
protected void |
setDirectlyAccessible(boolean directlyAccessible) |
protected void |
setInitialized() |
void |
setOwner(Object owner)
Set the reference to the owning entity
|
void |
setSnapshot(Serializable key,
String role,
Serializable snapshot)
After flushing, re-init snapshot state.
|
boolean |
unsetSession(SharedSessionContractImplementor currentSession)
Disassociate this collection from the given session.
|
boolean |
wasInitialized()
Is this instance initialized?
|
protected void |
write()
Called by any writer method of the collection interface
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
beforeInitialize, disassemble, entries, entryExists, equalsSnapshot, getDeletes, getElement, getIndex, getSnapshot, getSnapshotElement, initializeFromCache, isDirectlyProvidedCollection, isSnapshotEmpty, isWrapper, needsInserting, needsUpdating, readFrom
protected boolean elementRemoved
protected static final Object UNKNOWN
public AbstractPersistentCollection()
protected AbstractPersistentCollection(SharedSessionContractImplementor session)
@Deprecated protected AbstractPersistentCollection(SessionImplementor session)
AbstractPersistentCollection(SharedSessionContractImplementor)
should be used instead.public final String getRole()
PersistentCollection
getRole
in interface PersistentCollection
public final Serializable getKey()
PersistentCollection
getKey
in interface PersistentCollection
public final boolean isUnreferenced()
PersistentCollection
isUnreferenced
in interface PersistentCollection
true
if the collection is no longer referenced by an ownerpublic final boolean isDirty()
PersistentCollection
isDirty
in interface PersistentCollection
true
if the collection is dirtypublic boolean isElementRemoved()
isElementRemoved
in interface PersistentCollection
public final void clearDirty()
PersistentCollection
clearDirty
in interface PersistentCollection
public final void dirty()
PersistentCollection
dirty
in interface PersistentCollection
public final Serializable getStoredSnapshot()
PersistentCollection
getStoredSnapshot
in interface PersistentCollection
public abstract boolean empty()
PersistentCollection
empty
in interface PersistentCollection
false
if the collection is non-empty; true
otherwise.protected final void read()
protected boolean readSize()
Collection.size()
methodprotected int getCachedSize()
protected boolean isConnectedToSession()
protected boolean isInitialized()
protected final void write()
protected boolean isOperationQueueEnabled()
protected boolean isPutQueueEnabled()
protected boolean isClearQueueEnabled()
protected boolean isInverseCollection()
protected boolean isInverseCollectionNoOrphanDelete()
protected boolean isInverseOneToManyOrNoOrphanDelete()
protected final void queueOperation(AbstractPersistentCollection.DelayedOperation operation)
public final void replaceQueuedOperationValues(CollectionPersister persister, Map copyCache)
copyCache
/.copyCache
- - mapping from entity in the process of being
merged to managed copy.protected final void performQueuedOperations()
public void setSnapshot(Serializable key, String role, Serializable snapshot)
PersistentCollection
setSnapshot
in interface PersistentCollection
key
- The collection instance key (fk value).role
- The collection rolesnapshot
- The snapshot statepublic void postAction()
PersistentCollection
postAction
in interface PersistentCollection
public final void clearOperationQueue()
public Object getValue()
PersistentCollection
getValue
in interface PersistentCollection
public void beginRead()
PersistentCollection
beginRead
in interface PersistentCollection
public boolean endRead()
PersistentCollection
endRead
in interface PersistentCollection
public boolean afterInitialize()
PersistentCollection
afterInitialize
in interface PersistentCollection
protected final void initialize(boolean writing)
writing
- currently obsoleteLazyInitializationException
- if we cannot initializeprotected final void setInitialized()
protected final void setDirectlyAccessible(boolean directlyAccessible)
public boolean isDirectlyAccessible()
PersistentCollection
isDirectlyAccessible
in interface PersistentCollection
true
indicates that the application might have access to the underlying collection/array.public final boolean unsetSession(SharedSessionContractImplementor currentSession)
PersistentCollection
unsetSession
in interface PersistentCollection
currentSession
- The session we are disassociating from. Used for validations.protected void prepareForPossibleLoadingOutsideTransaction()
public final boolean setCurrentSession(SharedSessionContractImplementor session) throws HibernateException
PersistentCollection
setCurrentSession
in interface PersistentCollection
session
- The session to associate withHibernateException
- if the collection was already associated
with another open sessionpublic boolean needsRecreate(CollectionPersister persister)
PersistentCollection
needsRecreate
in interface PersistentCollection
persister
- The collection persistertrue
if a change requires a recreate.public final void forceInitialization() throws HibernateException
PersistentCollection
forceInitialization
in interface PersistentCollection
HibernateException
protected final Serializable getSnapshot()
public final boolean wasInitialized()
PersistentCollection
wasInitialized
in interface PersistentCollection
public boolean isRowUpdatePossible()
PersistentCollection
isRowUpdatePossible
in interface PersistentCollection
true
if the row for each element is knownpublic final boolean hasQueuedOperations()
PersistentCollection
hasQueuedOperations
in interface PersistentCollection
true
indicates there are pending, queued, delayed operationspublic final Iterator queuedAdditionIterator()
PersistentCollection
queuedAdditionIterator
in interface PersistentCollection
public final Collection getQueuedOrphans(String entityName)
PersistentCollection
getQueuedOrphans
in interface PersistentCollection
entityName
- The name of the entity that makes up the elementspublic void preInsert(CollectionPersister persister) throws HibernateException
PersistentCollection
preInsert
in interface PersistentCollection
persister
- The collection persisterHibernateException
public void afterRowInsert(CollectionPersister persister, Object entry, int i) throws HibernateException
PersistentCollection
afterRowInsert
in interface PersistentCollection
persister
- The collection persisterentry
- The collection element just insertedi
- The element position/indexHibernateException
public abstract Collection getOrphans(Serializable snapshot, String entityName) throws HibernateException
PersistentCollection
getOrphans
in interface PersistentCollection
snapshot
- The snapshot stateentityName
- The name of the entity that are the elements of the collectionHibernateException
public final SharedSessionContractImplementor getSession()
protected static Collection getOrphans(Collection oldElements, Collection currentElements, String entityName, SharedSessionContractImplementor session) throws HibernateException
HibernateException
public static void identityRemove(Collection list, Object entityInstance, String entityName, SharedSessionContractImplementor session)
list
- The list containing the entity instancesentityInstance
- The entity instance to match elements.entityName
- The entity namesession
- The session@Deprecated public static void identityRemove(Collection list, Object entityInstance, String entityName, SessionImplementor session)
identityRemove(Collection, Object, String, SharedSessionContractImplementor)
should be used instead.list
- The list containing the entity instancesentityInstance
- The entity instance to match elements.entityName
- The entity namesession
- The sessionpublic Object getIdentifier(Object entry, int i)
PersistentCollection
idbag
collection.getIdentifier
in interface PersistentCollection
entry
- The collection entry/elementi
- The assumed identifier (?)public Object getOwner()
PersistentCollection
getOwner
in interface PersistentCollection
public void setOwner(Object owner)
PersistentCollection
setOwner
in interface PersistentCollection
owner
- The ownerCopyright © 2019 JBoss by Red Hat. All rights reserved.