[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2344) Persistent collection queued operation ignored with lazy inverse one-to-many collection.

Yajun Shi (JIRA) noreply at atlassian.com
Mon May 21 18:49:04 EDT 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2344?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_27003 ] 

Yajun Shi commented on HHH-2344:
--------------------------------

Please validate the following KB:

Title: Persistent collection queued operation ignored with lazy inverse one-to-many collection

There is an known issue since Hibernate 3.2.0 that queued operations of a persistent collection with a lazy inverse one-to-many relationship can be possibly ignored. For example, a remove operation will be queued if it is performed on an uninitialized persistentMap with an known key of one of the objects. A get operation with the same key afterwards will trigger the initialization of the map but the queued operation is ignored and the value is returned. The problem can occur as well when the put operation is performed on a persistentCollection.

The workaround can be either call containsKey() or size() before the collection is modified.


> 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
>          Issue Type: Bug
>          Components: core
>    Affects 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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list