Top Description Fields Constructors Methods
org.hibernate.collection.spi

public Class PersistentArrayHolder<E>

extends AbstractPersistentCollection<E>
Class Inheritance
Annotations
@Incubating
Imports
java.io.Serializable, java.lang.reflect.Array, java.util.ArrayList, .Collection, .Collections, .Iterator, .List, org.hibernate.HibernateException, .Incubating, org.hibernate.engine.spi.SharedSessionContractImplementor, org.hibernate.internal.CoreLogging, .CoreMessageLogger, org.hibernate.metamodel.mapping.PluralAttributeMapping, org.hibernate.persister.collection.CollectionPersister, org.hibernate.type.Type

A dummy collection wrapper for an array. Lazy initialization is not supported. The use of arrays to represent persistent collections in Hibernate is discouraged.

API Note

Incubating in terms of making this non-internal. These contracts will be getting cleaned up in following releases.

Author
Gavin King

Field Summary

Modifier and TypeField and Description
protected Object
private transient Class<?>
private static final CoreMessageLogger
Inherited from org.hibernate.collection.spi.AbstractPersistentCollection:
elementRemovedUNKNOWN

Constructor Summary

AccessConstructor and Description
public
PersistentArrayHolder(SharedSessionContractImplementor
The session
session
,
Object
The array (the persistent "collection").
array
)

Constructs a PersistentCollection instance for holding an array.

public
PersistentArrayHolder(SharedSessionContractImplementor
The session
session
,
CollectionPersister
The persister for the array
persister
)

Constructs a PersistentCollection instance for holding an array.

Method Summary

Modifier and TypeMethod and Description
public Object
disassemble(CollectionPersister
The collection persister
persister
)

Implements org.hibernate.collection.spi.PersistentCollection.disassemble.

Disassemble the collection to get it ready for the cache
public Iterator<E>

Returns:

The iterator
elements
()

Get an iterator over the array elements

public boolean
public boolean
public Iterator<E>
entries(CollectionPersister
The collection persister.
persister
)

Implements org.hibernate.collection.spi.PersistentCollection.entries.

Iterate all collection entries, during update of the database
public boolean
entryExists(Object
The object to check if it exists as a collection element
entry
,
int
Unused
i
)

Implements org.hibernate.collection.spi.PersistentCollection.entryExists.

Does the given element/entry exist in the collection?
public boolean
equalsSnapshot(CollectionPersister
The collection persister
persister
)

Implements org.hibernate.collection.spi.PersistentCollection.equalsSnapshot.

Does the current state exactly match the snapshot?
public Object
public Iterator<E>
getDeletes(CollectionPersister
The collection persister
persister
,
boolean
For indexed collections, tells whether the index is a formula (calculated value) mapping
indexIsFormula
)

Implements org.hibernate.collection.spi.PersistentCollection.getDeletes.

Get all the elements that need deleting
public Object
getElement(Object
The object instance for which to get the collection element instance.
entry
)

Implements org.hibernate.collection.spi.PersistentCollection.getElement.

Get the value of the given collection entry.
public Object
getIndex(Object
The collection entry/element
entry
,
int
The assumed index
i
,
CollectionPersister
it was more elegant before we added this...
persister
)

Implements org.hibernate.collection.spi.PersistentCollection.getIndex.

Get the index of the given collection entry
public Collection<E>
getOrphans(Serializable
The snapshot state
snapshot
,
String
The name of the entity that are the elements of the collection
entityName
)

Implements abstract org.hibernate.collection.spi.AbstractPersistentCollection.getOrphans.

Implements org.hibernate.collection.spi.PersistentCollection.getOrphans.

get all "orphaned" elements
public Serializable
getSnapshot(CollectionPersister
The collection persister
persister
)

Implements org.hibernate.collection.spi.PersistentCollection.getSnapshot.

Return a new snapshot of the current state of the collection
public Object
getSnapshotElement(Object
The entry
entry
,
int
The index
i
)

Implements org.hibernate.collection.spi.PersistentCollection.getSnapshotElement.

Get the snapshot value of the given collection entry
public Object
public void
public void
initializeFromCache(CollectionPersister
The collection persister
persister
,
Object
The disassembled cached state
disassembled
,
Object
The collection owner
owner
)

Implements org.hibernate.collection.spi.PersistentCollection.initializeFromCache.

Read the state of the collection from a disassembled cached value
public void
injectLoadedState(PluralAttributeMapping attributeMapping, List<E> loadingState)

Implements org.hibernate.collection.spi.PersistentCollection.injectLoadedState.

Inject the state loaded for a collection instance.
public boolean
isDirectlyAccessible()

Overrides org.hibernate.collection.spi.AbstractPersistentCollection.isDirectlyAccessible.

Implements org.hibernate.collection.spi.PersistentCollection.isDirectlyAccessible.

Could the application possibly have a direct reference to the underlying collection implementation?
public boolean
isSnapshotEmpty(Serializable
The snapshot to check
snapshot
)

Implements org.hibernate.collection.spi.PersistentCollection.isSnapshotEmpty.

Is the snapshot empty?
public boolean
isWrapper(Object
The collection to check whether this is wrapping it
collection
)

Implements org.hibernate.collection.spi.PersistentCollection.isWrapper.

Is this the wrapper for the given collection instance?
public boolean
needsInserting(Object
The collection element to check
entry
,
int
The index (for indexed collections)
i
,
Type
The type for the element
elemType
)

Implements org.hibernate.collection.spi.PersistentCollection.needsInserting.

Do we need to insert this element?
public boolean
needsUpdating(Object
The collection element to check
entry
,
int
The index (for indexed collections)
i
,
Type
The type for the element
elemType
)

Implements org.hibernate.collection.spi.PersistentCollection.needsUpdating.

Do we need to update this element?
Inherited from org.hibernate.collection.spi.AbstractPersistentCollection:
afterInitializeafterRowInsertbeforeInitializebeginReadclearDirtyclearOperationQueuedirtyelementByIndexelementExistsforceInitializationgetCachedSizegetIdentifiergetKeygetOrphansgetOwnergetQueuedOrphansgetRolegetSessiongetSizegetSnapshotgetStoredSnapshothasQueuedOperationsidentityRemoveinitializeisClearQueueEnabledisConnectedToSessionisDirtyisElementRemovedisInitializedisInitializingisInverseCollectionisInverseCollectionNoOrphanDeleteisInverseOneToManyOrNoOrphanDeleteisOperationQueueEnabledisPutQueueEnabledisRowUpdatePossibleisUnreferencedneedsRecreateperformQueuedOperationspostActionpreInsertprepareForPossibleLoadingOutsideTransactionqueuedAdditionIteratorqueueOperationreadreadElementByIndexreadElementExistencereadIndexExistencereadSizereplaceQueuedOperationValuessetCurrentSessionsetDirectlyAccessiblesetInitializedsetOwnersetSnapshotunsetSessionwasInitializedwrite

Field Detail

arrayback to summary
protected Object array
elementClassback to summary
private transient Class<?> elementClass
LOGback to summary
private static final CoreMessageLogger LOG

Hides org.hibernate.collection.spi.AbstractPersistentCollection.LOG.

Constructor Detail

PersistentArrayHolderback to summary
public PersistentArrayHolder(SharedSessionContractImplementor session, Object array)

Constructs a PersistentCollection instance for holding an array.

Parameters
session:SharedSessionContractImplementor

The session

array:Object

The array (the persistent "collection").

PersistentArrayHolderback to summary
public PersistentArrayHolder(SharedSessionContractImplementor session, CollectionPersister persister)

Constructs a PersistentCollection instance for holding an array.

Parameters
session:SharedSessionContractImplementor

The session

persister:CollectionPersister

The persister for the array

Method Detail

disassembleback to summary
public Object disassemble(CollectionPersister persister) throws HibernateException

Implements org.hibernate.collection.spi.PersistentCollection.disassemble.

Doc from org.hibernate.collection.spi.PersistentCollection.disassemble.

Disassemble the collection to get it ready for the cache

Parameters
persister:CollectionPersister

The collection persister

Returns:Object

The disassembled state

Annotations
@Override
elementsback to summary
public Iterator<E> elements()

Get an iterator over the array elements

Returns:Iterator<E>

The iterator

Annotations
@SuppressWarnings:unchecked
emptyback to summary
public boolean empty()

Implements abstract org.hibernate.collection.spi.AbstractPersistentCollection.empty.

Implements org.hibernate.collection.spi.PersistentCollection.empty.

Doc from org.hibernate.collection.spi.PersistentCollection.empty.

Is the collection empty? (don't try to initialize the collection)

Returns:boolean

false if the collection is non-empty; true otherwise.

Annotations
@Override
endReadback to summary
public boolean endRead()

Overrides org.hibernate.collection.spi.AbstractPersistentCollection.endRead.

Implements org.hibernate.collection.spi.PersistentCollection.endRead.

Doc from org.hibernate.collection.spi.PersistentCollection.endRead.

Called after reading all rows from the JDBC result set. Pairs with beginRead

Annotations
@Override
entriesback to summary
public Iterator<E> entries(CollectionPersister persister)

Implements org.hibernate.collection.spi.PersistentCollection.entries.

Doc from org.hibernate.collection.spi.PersistentCollection.entries.

Iterate all collection entries, during update of the database

Parameters
persister:CollectionPersister

The collection persister.

Returns:Iterator<E>

The iterator

Annotations
@Override
entryExistsback to summary
public boolean entryExists(Object entry, int i)

Implements org.hibernate.collection.spi.PersistentCollection.entryExists.

Doc from org.hibernate.collection.spi.PersistentCollection.entryExists.

Does the given element/entry exist in the collection?

Parameters
entry:Object

The object to check if it exists as a collection element

i:int

Unused

Returns:boolean

true if the given entry is a collection element

Annotations
@Override
equalsSnapshotback to summary
public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException

Implements org.hibernate.collection.spi.PersistentCollection.equalsSnapshot.

Doc from org.hibernate.collection.spi.PersistentCollection.equalsSnapshot.

Does the current state exactly match the snapshot?

Parameters
persister:CollectionPersister

The collection persister

Returns:boolean

true if the current state and the snapshot state match.

Annotations
@Override
getArrayback to summary
public Object getArray()
Annotations
@SuppressWarnings:UnusedDeclaration
getDeletesback to summary
public Iterator<E> getDeletes(CollectionPersister persister, boolean indexIsFormula) throws HibernateException

Implements org.hibernate.collection.spi.PersistentCollection.getDeletes.

Doc from org.hibernate.collection.spi.PersistentCollection.getDeletes.

Get all the elements that need deleting

Parameters
persister:CollectionPersister

The collection persister

indexIsFormula:boolean

For indexed collections, tells whether the index is a formula (calculated value) mapping

Returns:Iterator<E>

An iterator over the elements to delete

Annotations
@Override
getElementback to summary
public Object getElement(Object entry)

Implements org.hibernate.collection.spi.PersistentCollection.getElement.

Doc from org.hibernate.collection.spi.PersistentCollection.getElement.

Get the value of the given collection entry. Generally the given entry parameter value will just be returned. Might get a different value for a duplicate entries in a Set.

Parameters
entry:Object

The object instance for which to get the collection element instance.

Returns:Object

The corresponding object that is part of the collection elements.

Annotations
@Override
getIndexback to summary
public Object getIndex(Object entry, int i, CollectionPersister persister)

Implements org.hibernate.collection.spi.PersistentCollection.getIndex.

Doc from org.hibernate.collection.spi.PersistentCollection.getIndex.

Get the index of the given collection entry

Parameters
entry:Object

The collection entry/element

i:int

The assumed index

persister:CollectionPersister

it was more elegant before we added this...

Returns:Object

The index value

Annotations
@Override
getOrphansback to summary
public Collection<E> getOrphans(Serializable snapshot, String entityName) throws HibernateException

Implements abstract org.hibernate.collection.spi.AbstractPersistentCollection.getOrphans.

Implements org.hibernate.collection.spi.PersistentCollection.getOrphans.

Doc from org.hibernate.collection.spi.PersistentCollection.getOrphans.

get all "orphaned" elements

Parameters
snapshot:Serializable

The snapshot state

entityName:String

The name of the entity that are the elements of the collection

Returns:Collection<E>

The orphans

Annotations
@Override
getSnapshotback to summary
public Serializable getSnapshot(CollectionPersister persister) throws HibernateException

Implements org.hibernate.collection.spi.PersistentCollection.getSnapshot.

Doc from org.hibernate.collection.spi.PersistentCollection.getSnapshot.

Return a new snapshot of the current state of the collection

Parameters
persister:CollectionPersister

The collection persister

Returns:Serializable

The snapshot

Annotations
@Override
getSnapshotElementback to summary
public Object getSnapshotElement(Object entry, int i)

Implements org.hibernate.collection.spi.PersistentCollection.getSnapshotElement.

Doc from org.hibernate.collection.spi.PersistentCollection.getSnapshotElement.

Get the snapshot value of the given collection entry

Parameters
entry:Object

The entry

i:int

The index

Returns:Object

The snapshot state for that element

Annotations
@Override
getValueback to summary
public Object getValue()

Overrides org.hibernate.collection.spi.AbstractPersistentCollection.getValue.

Implements org.hibernate.collection.spi.PersistentCollection.getValue.

Doc from org.hibernate.collection.spi.PersistentCollection.getValue.

Return the user-visible collection (or array) instance

Returns:Object

The underlying collection/array

Annotations
@Override
initializeEmptyCollectionback to summary
public void initializeEmptyCollection(CollectionPersister persister)

Implements org.hibernate.collection.spi.PersistentCollection.initializeEmptyCollection.

Annotations
@Override
initializeFromCacheback to summary
public void initializeFromCache(CollectionPersister persister, Object disassembled, Object owner) throws HibernateException

Implements org.hibernate.collection.spi.PersistentCollection.initializeFromCache.

Doc from org.hibernate.collection.spi.PersistentCollection.initializeFromCache.

Read the state of the collection from a disassembled cached value

Parameters
persister:CollectionPersister

The collection persister

disassembled:Object

The disassembled cached state

owner:Object

The collection owner

Annotations
@Override
injectLoadedStateback to summary
public void injectLoadedState(PluralAttributeMapping attributeMapping, List<E> loadingState)

Implements org.hibernate.collection.spi.PersistentCollection.injectLoadedState.

Doc from org.hibernate.collection.spi.PersistentCollection.injectLoadedState.

Inject the state loaded for a collection instance.

Annotations
@Override
isDirectlyAccessibleback to summary
public boolean isDirectlyAccessible()

Overrides org.hibernate.collection.spi.AbstractPersistentCollection.isDirectlyAccessible.

Implements org.hibernate.collection.spi.PersistentCollection.isDirectlyAccessible.

Doc from org.hibernate.collection.spi.PersistentCollection.isDirectlyAccessible.

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

Returns:boolean

true indicates that the application might have access to the underlying collection/array.

Annotations
@Override
isSnapshotEmptyback to summary
public boolean isSnapshotEmpty(Serializable snapshot)

Implements org.hibernate.collection.spi.PersistentCollection.isSnapshotEmpty.

Doc from org.hibernate.collection.spi.PersistentCollection.isSnapshotEmpty.

Is the snapshot empty?

Parameters
snapshot:Serializable

The snapshot to check

Returns:boolean

true if the given snapshot is empty

Annotations
@Override
isWrapperback to summary
public boolean isWrapper(Object collection)

Implements org.hibernate.collection.spi.PersistentCollection.isWrapper.

Doc from org.hibernate.collection.spi.PersistentCollection.isWrapper.

Is this the wrapper for the given collection instance?

Parameters
collection:Object

The collection to check whether this is wrapping it

Returns:boolean

true if this is a wrapper around that given collection instance.

Annotations
@Override
needsInsertingback to summary
public boolean needsInserting(Object entry, int i, Type elemType) throws HibernateException

Implements org.hibernate.collection.spi.PersistentCollection.needsInserting.

Doc from org.hibernate.collection.spi.PersistentCollection.needsInserting.

Do we need to insert this element?

Parameters
entry:Object

The collection element to check

i:int

The index (for indexed collections)

elemType:Type

The type for the element

Returns:boolean

true if the element needs inserting

Annotations
@Override
needsUpdatingback to summary
public boolean needsUpdating(Object entry, int i, Type elemType) throws HibernateException

Implements org.hibernate.collection.spi.PersistentCollection.needsUpdating.

Doc from org.hibernate.collection.spi.PersistentCollection.needsUpdating.

Do we need to update this element?

Parameters
entry:Object

The collection element to check

i:int

The index (for indexed collections)

elemType:Type

The type for the element

Returns:boolean

true if the element needs updating

Annotations
@Override