[hibernate-issues] [Hibernate-JIRA] Created: (HHH-2485) The PersistentSet recognized as dirty because the PersistentSet.getSnapshot method uses wrong object as key for clonedSet

Csaba Krizsan (JIRA) noreply at atlassian.com
Sat Mar 10 05:20:10 EST 2007


The PersistentSet recognized as dirty because the PersistentSet.getSnapshot method uses wrong object as key for clonedSet
-------------------------------------------------------------------------------------------------------------------------

         Key: HHH-2485
         URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2485
     Project: Hibernate3
        Type: Bug

  Components: core  
    Versions: 3.2.2    
 Environment: Hibernate version 3.x HSQLDB (db platform independent bug)
    Reporter: Csaba Krizsan
 Attachments: hibernate-persistentset-test.zip

The org.hibernate.collection.PersisitentSet.getSnapshot method uses the copied object as key in clonedSet therefore the equalsSnapshot method does not find the copied object in clonedSet (it uses the original object as key)

	public Serializable getSnapshot(CollectionPersister persister) 
	throws HibernateException {
		EntityMode entityMode = getSession().getEntityMode();
		
		//if (set==null) return new Set(session);
		HashMap clonedSet = new HashMap( set.size() );
		Iterator iter = set.iterator();
		while ( iter.hasNext() ) {
			Object copied = persister.getElementType()
					.deepCopy( iter.next(), entityMode, persister.getFactory() );
			clonedSet.put(copied, copied);  // <--- BUG The key should be the object returned by iter.next()
		}
		return clonedSet;
	}

Please fix it using the original object as key during adding the copied object into clonedSet.

I have attached a test, which creates a parent-child relation which uses <set>.

The testGet  method loads the records, prints them and calls session.flush().
The flush() recognizes that the set is dirty because of the aforementioned bug.

In the settest.log file you can see that the set gets dirty during flush.

10:50:55,187 [main] DEBUG .AbstractFlushingEventListener  - flushing session 
10:50:55,187 [main] DEBUG .AbstractFlushingEventListener  - processing flush-time cascades 
10:50:55,187 [main] DEBUG .AbstractFlushingEventListener  - dirty checking collections 
10:50:55,187 [main] DEBUG engine.CollectionEntry          - Collection dirty: [com.webage.test.hibernate.Parent.children#1] 

Please fix it

Thanks in advance



-- 
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