[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2344?page=c...
]
Niklas Therning commented on HHH-2344:
--------------------------------------
We're having the same problem in 3.2.0GA with put(). Our work around is to call size()
on the map before doing the put(). It used to work fine with 3.0.
Persistent collection queued operation ignored with lazy inverse
one-to-many collection.
----------------------------------------------------------------------------------------
Key: HHH-2344
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2344
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.1
Environment: Hibernate 3.2.1
Reporter: Sebastien Robert
I load an Object that contains a lazy inverse collection (one-to-many).
Hibernate wrap my collection with a PersistentMap
There is objects in the collection in the database but in my case the PersistentMap is
not yet initialized.
I perform a remove operation on the persistentMap with a known key of one of the
objects.
The map is not initialized (and the relation is an inverse one-to-many) so the map queue
the removeOperation.
I perform a get operation with the same key and the value is still returned.
If we look closer at what happened in the PersistentMap, it's look like this.
//*****
public Object remove(Object key) {
if ( isPutQueueEnabled() ) { // This returned true, the
// map
is not yet
//
initialized
Object old = readElementByIndex( key ); // This method triggered
// an
initialization of the
//
map.
//
Queued operation are
//
processed in the after
//
init method
queueOperation( new Remove( key, old ) ); // The remove operation
//
is queued.
return old;
}
....
//*******
When i perform the get operation on the map the map is now initialized. The get is
processed by the underlying map and the value is returned. The queued operation is
completely ignored.
Currently i fixed my code by performing a containsKey before the remove . The containsKey
initialize the map and then the remove do not queue the operation. But by looking at all
the PersistentCollection it seem that i may have the same problem using put and remove
with other persistentCollection.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira