Top Description Inners Fields Constructors Methods
org.hibernate.collection.internal

public Class PersistentMap

extends AbstractPersistentCollection
implements Map
Class Inheritance
All Implemented Interfaces
java.util.Map
Known Direct Subclasses
org.hibernate.collection.internal.PersistentSortedMap
Imports
java.io.Serializable, java.sql.ResultSet, .SQLException, java.util.ArrayList, .Collection, .HashMap, .Iterator, .List, .Map, .Set, org.hibernate.HibernateException, org.hibernate.engine.spi.SessionImplementor, .SharedSessionContractImplementor, org.hibernate.loader.CollectionAliases, org.hibernate.persister.collection.CollectionPersister, org.hibernate.type.Type

A persistent wrapper for a java.util.Map. Underlying collection is a HashMap.
Author
Gavin King
See Also
java.util.HashMap

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv abstract class
pack-priv class
pack-priv class
pack-priv class
PersistentMap.EntrySetProxy

a wrapper for Map.Entry sets

pack-priv class
pack-priv class
pack-priv class

Field Summary

Modifier and TypeField and Description
private transient List<Object[]>
protected Map<K, V>
Inherited from org.hibernate.collection.internal.AbstractPersistentCollection:
elementRemovedUNKNOWN

Constructor Summary

AccessConstructor and Description
public
PersistentMap()

Empty constructor.

public
PersistentMap(SharedSessionContractImplementor
The session to which this map will belong.
session
)

Instantiates a lazy map (the underlying map is un-initialized).

public
PersistentMap(SessionImplementor
The session to which this map will belong.
session
)

Deprecated PersistentMap(SharedSessionContractImplementor) should be used instead.
Instantiates a lazy map (the underlying map is un-initialized).
public
PersistentMap(SharedSessionContractImplementor
The session to which this map will belong.
session
,
Map<K, V>
The underlying map data.
map
)

Instantiates a non-lazy map (the underlying map is constructed from the incoming map reference).

public
PersistentMap(SessionImplementor
The session to which this map will belong.
session
,
Map<K, V>
The underlying map data.
map
)

Deprecated PersistentMap(SharedSessionContractImplementor, Map) should be used instead.
Instantiates a non-lazy map (the underlying map is constructed from the incoming map reference).

Method Summary

Modifier and TypeMethod and Description
public void
beforeInitialize(CollectionPersister
The underlying collection persister.
persister
,
int
The anticipated size of the collection after initialization is complete.
anticipatedSize
)

Implements org.hibernate.collection.spi.PersistentCollection.beforeInitialize.

Called before any elements are read into the collection, allowing appropriate initializations to occur.
public void
clear()

Implements java.util.Map.clear.

Removes all of the mappings from this map (optional operation).
public boolean
containsKey(Object
key whose presence in this map is to be tested
key
)

Implements java.util.Map.containsKey.

Returns true if this map contains a mapping for the specified key.
public boolean
containsValue(Object
value whose presence in this map is to be tested
value
)

Implements java.util.Map.containsValue.

Returns true if this map maps one or more keys to the specified value.
public Serializable
disassemble(CollectionPersister
The collection persister
persister
)

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

Disassemble the collection to get it ready for the cache
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 Set<E>
entrySet()

Implements java.util.Map.entrySet.

Returns a Set view of the mappings contained in this map.
public boolean
equals(Object
object to be compared for equality with this map
other
)

Overrides java.lang.Object.equals.

Implements java.util.Map.equals.

Compares the specified object with this map for equality.
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
get(Object
the key whose associated value is to be returned
key
)

Implements java.util.Map.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
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.internal.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 int
hashCode()

Overrides java.lang.Object.hashCode.

Implements java.util.Map.hashCode.

Returns the hash code value for this map.
public void
initializeFromCache(CollectionPersister
The collection persister
persister
,
Serializable
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 boolean
isEmpty()

Implements java.util.Map.isEmpty.

Returns true if this map contains no key-value mappings.
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 Set<E>
keySet()

Implements java.util.Map.keySet.

Returns a Set view of the keys contained in this map.
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?
public Object
put(Object
key with which the specified value is to be associated
key
,
Object
value to be associated with the specified key
value
)

Implements java.util.Map.put.

Associates the specified value with the specified key in this map (optional operation).
public void
putAll(Map<K, V>
mappings to be stored in this map
puts
)

Implements java.util.Map.putAll.

Copies all of the mappings from the specified map to this map (optional operation).
public Object
readFrom(ResultSet
The JDBC ResultSet
rs
,
CollectionPersister
The collection role
persister
,
CollectionAliases
The aliases used for the columns making up the collection
descriptor
,
Object
The collection owner
owner
)

Implements org.hibernate.collection.spi.PersistentCollection.readFrom.

Read a row from the JDBC result set
public Object
remove(Object
key whose mapping is to be removed from the map
key
)

Implements java.util.Map.remove.

Removes the mapping for a key from this map if it is present (optional operation).
public int
size()

Implements java.util.Map.size.

Returns the number of key-value mappings in this map.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public Collection<E>
values()

Implements java.util.Map.values.

Returns a Collection view of the values contained in this map.
Inherited from org.hibernate.collection.internal.AbstractPersistentCollection:
afterInitializeafterRowInsertbeginReadclearDirtyclearOperationQueuedirtyforceInitializationgetCachedSizegetIdentifiergetKeygetOrphansgetOwnergetQueuedOrphansgetRolegetSessiongetSnapshotgetStoredSnapshotgetValuehasQueuedOperationsidentityRemoveidentityRemoveinitializeisClearQueueEnabledisConnectedToSessionisDirectlyAccessibleisDirtyisElementRemovedisInitializedisInverseCollectionisInverseCollectionNoOrphanDeleteisInverseOneToManyOrNoOrphanDeleteisOperationQueueEnabledisPutQueueEnabledisRowUpdatePossibleisUnreferencedneedsRecreateperformQueuedOperationspostActionpreInsertprepareForPossibleLoadingOutsideTransactionqueuedAdditionIteratorqueueOperationreadreadElementByIndexreadElementExistencereadIndexExistencereadSizereplaceQueuedOperationValuessetCurrentSessionsetDirectlyAccessiblesetInitializedsetOwnersetSnapshotunsetSessionwasInitializedwrite