public abstract class

AbstractPersistentCollection

extends Object
implements Serializable PersistentCollection
java.lang.Object
   ↳ org.hibernate.collection.AbstractPersistentCollection
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Base class implementing PersistentCollection

Summary

Nested Classes
interface AbstractPersistentCollection.DelayedOperation  
Fields
protected static final Object UNKNOWN
Public Constructors
AbstractPersistentCollection()
Not called by Hibernate, but used by non-JDK serialization, eg.
Protected Constructors
AbstractPersistentCollection(SessionImplementor session)
Public Methods
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
final void clearDirty()
Clear the dirty flag, after flushing changes to the database.
final void dirty()
Mark the collection as dirty
abstract boolean empty()
Is the initialized collection empty?
boolean endRead()
Called after reading all rows from the JDBC result set
final void forceInitialization()
To be called internally by the session, forcing immediate initialization.
Object getIdentifier(Object entry, int i)
Get the index of the given collection entry
final Serializable getKey()
Get the current collection key value
abstract Collection getOrphans(Serializable snapshot, String entityName)
get all "orphaned" elements
Object getOwner()
Get the owning entity.
final Collection getQueuedOrphans(String entityName)
Iterate the "queued" additions
final String getRole()
Get the current role name
final SessionImplementor getSession()
Get the current session
final Serializable getStoredSnapshot()
Get the snapshot cached by the collection instance
Object getValue()
return the user-visible collection (or array) instance
final boolean hasQueuedOperations()
Does this instance have any "queued" additions?
boolean isDirectlyAccessible()
Could the application possibly have a direct reference to the underlying collection implementation?
final 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 isRowUpdatePossible()
final boolean isUnreferenced()
Is the collection unreferenced?
boolean needsRecreate(CollectionPersister persister)
Do we need to completely recreate this collection when it changes?
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
final Iterator queuedAdditionIterator()
Iterate the "queued" additions
final boolean setCurrentSession(SessionImplementor session)
Associate the collection with the given session.
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.
final boolean unsetSession(SessionImplementor currentSession)
Disassociate this collection from the given session.
final boolean wasInitialized()
Is this instance initialized?
Protected Methods
int getCachedSize()
static Collection getOrphans(Collection oldElements, Collection currentElements, String entityName, SessionImplementor 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
final Serializable getSnapshot()
Get the current snapshot from the session
final void initialize(boolean writing)
Initialize the collection, if possible, wrapping any exceptions in a runtime exception
boolean isClearQueueEnabled()
Is this collection in a state that would allow us to "queue" clear? This is a special case, because of orphan delete.
boolean isOperationQueueEnabled()
Is this collection in a state that would allow us to "queue" operations?
boolean isPutQueueEnabled()
Is this collection in a state that would allow us to "queue" puts? This is a special case, because of orphan delete.
final void performQueuedOperations()
After reading all existing elements from the database, add the queued elements to the underlying collection.
final void queueOperation(Object element)
Queue an addition
final void read()
Called by any read-only method of the collection interface
Object readElementByIndex(Object index)
Boolean readElementExistence(Object element)
Boolean readIndexExistence(Object index)
boolean readSize()
Called by the size() method
final void setDirectlyAccessible(boolean directlyAccessible)
final void setInitialized()
final void write()
Called by any writer method of the collection interface
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.hibernate.collection.PersistentCollection

Fields

protected static final Object UNKNOWN

Public Constructors

public AbstractPersistentCollection ()

Not called by Hibernate, but used by non-JDK serialization, eg. SOAP libraries.

Protected Constructors

protected AbstractPersistentCollection (SessionImplementor session)

Public Methods

public boolean afterInitialize ()

Called after initializing from cache

public void afterRowInsert (CollectionPersister persister, Object entry, int i)

Called after inserting a row, to fetch the natively generated id

public void beginRead ()

Called just before reading any rows from the JDBC result set

public final void clearDirty ()

Clear the dirty flag, after flushing changes to the database.

public final void dirty ()

Mark the collection as dirty

public abstract boolean empty ()

Is the initialized collection empty?

public boolean endRead ()

Called after reading all rows from the JDBC result set

public final void forceInitialization ()

To be called internally by the session, forcing immediate initialization.

public Object getIdentifier (Object entry, int i)

Get the index of the given collection entry

public final Serializable getKey ()

Get the current collection key value

public abstract Collection getOrphans (Serializable snapshot, String entityName)

get all "orphaned" elements

public Object getOwner ()

Get the owning entity. Note that the owner is only set during the flush cycle, and when a new collection wrapper is created while loading an entity.

public final Collection getQueuedOrphans (String entityName)

Iterate the "queued" additions

public final String getRole ()

Get the current role name

public final SessionImplementor getSession ()

Get the current session

public final Serializable getStoredSnapshot ()

Get the snapshot cached by the collection instance

public Object getValue ()

return the user-visible collection (or array) instance

public final boolean hasQueuedOperations ()

Does this instance have any "queued" additions?

public boolean isDirectlyAccessible ()

Could the application possibly have a direct reference to the underlying collection implementation?

public final 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.

public boolean isRowUpdatePossible ()

public final boolean isUnreferenced ()

Is the collection unreferenced?

public boolean needsRecreate (CollectionPersister persister)

Do we need to completely recreate this collection when it changes?

public void postAction ()

After flushing, clear any "queued" additions, since the database state is now synchronized with the memory state.

public void preInsert (CollectionPersister persister)

Called before inserting rows, to ensure that any surrogate keys are fully generated

public final Iterator queuedAdditionIterator ()

Iterate the "queued" additions

public final boolean setCurrentSession (SessionImplementor session)

Associate the collection with the given session.

Returns
  • false if the collection was already associated with the session
Throws
HibernateException if the collection was already associated with another open session

public void setOwner (Object owner)

Set the reference to the owning entity

public void setSnapshot (Serializable key, String role, Serializable snapshot)

After flushing, re-init snapshot state.

public final boolean unsetSession (SessionImplementor currentSession)

Disassociate this collection from the given session.

Returns
  • true if this was currently associated with the given session

public final boolean wasInitialized ()

Is this instance initialized?

Protected Methods

protected int getCachedSize ()

protected static Collection getOrphans (Collection oldElements, Collection currentElements, String entityName, SessionImplementor 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

protected final Serializable getSnapshot ()

Get the current snapshot from the session

protected final void initialize (boolean writing)

Initialize the collection, if possible, wrapping any exceptions in a runtime exception

Parameters
writing currently obsolete
Throws
LazyInitializationException if we cannot initialize

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 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.

protected final void performQueuedOperations ()

After reading all existing elements from the database, add the queued elements to the underlying collection.

protected final void queueOperation (Object element)

Queue an addition

protected final 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 size() method

protected final void setDirectlyAccessible (boolean directlyAccessible)

protected final void setInitialized ()

protected final void write ()

Called by any writer method of the collection interface