Top Description Inners Fields Constructors Methods
org.hibernate.collection

public Class PersistentMap

extends AbstractPersistentCollection
implements Map
Class Inheritance
All Implemented Interfaces
java.util.Map
Known Direct Subclasses
org.hibernate.collection.PersistentSortedMap
Imports
java.io.Serializable, java.sql.ResultSet, .SQLException, java.util.ArrayList, .Collection, .HashMap, .Iterator, .List, .Map, .Set, org.hibernate.EntityMode, .HibernateException, org.hibernate.engine.SessionImplementor, 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 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
protected Map<K, V>
Inherited from org.hibernate.collection.AbstractPersistentCollection:
UNKNOWN

Constructor Summary

AccessConstructor and Description
public
PersistentMap()

Empty constructor.

public
PersistentMap(SessionImplementor
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
,
Map<K, V>
The underlying map data.
map
)

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 initilization is complete.
anticipatedSize
)

Implements org.hibernate.collection.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 persister)

Implements org.hibernate.collection.PersistentCollection.disassemble.

Disassemble the collection, ready for the cache
public boolean
public Iterator<E>
entries(CollectionPersister persister)

Implements org.hibernate.collection.PersistentCollection.entries.

Iterate all collection entries, during update of the database
public boolean
entryExists(Object entry, int i)

Implements org.hibernate.collection.PersistentCollection.entryExists.

Does an element exist at this entry 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 persister)

Implements org.hibernate.collection.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 persister, boolean indexIsFormula)

Implements org.hibernate.collection.PersistentCollection.getDeletes.

Get all the elements that need deleting
public Object
getElement(Object entry)

Implements org.hibernate.collection.PersistentCollection.getElement.

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

Implements org.hibernate.collection.PersistentCollection.getIndex.

Get the index of the given collection entry
public Collection<E>
public Serializable
getSnapshot(CollectionPersister persister)

Implements org.hibernate.collection.PersistentCollection.getSnapshot.

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

Implements org.hibernate.collection.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 persister, Serializable disassembled, Object owner)

Implements org.hibernate.collection.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
public boolean
isWrapper(Object collection)

Implements org.hibernate.collection.PersistentCollection.isWrapper.

Is this the wrapper for the given underlying 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 entry, int i, Type elemType)

Implements org.hibernate.collection.PersistentCollection.needsInserting.

Do we need to insert this element?
public boolean
needsUpdating(Object entry, int i, Type elemType)

Implements org.hibernate.collection.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 rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)

Implements org.hibernate.collection.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.AbstractPersistentCollection:
afterInitializeafterRowInsertbeginReadclearDirtydirtyendReadforceInitializationgetCachedSizegetIdentifiergetKeygetOrphansgetOwnergetQueuedOrphansgetRolegetSessiongetSnapshotgetStoredSnapshotgetValuehasQueuedOperationsidentityRemoveinitializeisClearQueueEnabledisDirectlyAccessibleisDirtyisOperationQueueEnabledisPutQueueEnabledisRowUpdatePossibleisUnreferencedneedsRecreateperformQueuedOperationspostActionpreInsertqueuedAdditionIteratorqueueOperationreadreadElementByIndexreadElementExistencereadIndexExistencereadSizesetCurrentSessionsetDirectlyAccessiblesetInitializedsetOwnersetSnapshotunsetSessionwasInitializedwrite