[hibernate-dev] Possible to confirm that versioning is broken forPersistentSets?

Josh Moore josh.moore at gmx.de
Wed Sep 13 09:43:30 EDT 2006


Steve Ebersole wrote:
> Without having had a chance yet to look, what exactly are the proposed
> changes in regards to lists and bags?

The changes are identical to PersistentSet omitting the add* methods. 
I.e. clear, remove, removeAll, and retainAll all use the idiom:
  initialize(true)
  if ( list.clear() )
  {
     list.clear() )
     dirty();
     return true;
  } else {
      return false;
  }


> As for the code snippet and question, you'd need to find out why the
> collection is considered dirty on merge...

Ok. Good to know it's not expected behavior. I know that it's initially 
dirty due to CollectionType.replaceElements usage of the 
PersistenCollection rather than raw collection. And there are only two 
places where AbstractPersistentCollection.clearDirty() is called:

(1) postAction -- this is too late, and
(2) new CollectionEntry() -- specifically (note the comment):

	"public CollectionEntry(...
	//...
	
	collection.clearDirty(); //a newly wrapped collection is NOT dirty (or 
we get unnecessary version updates)"

		
But these CollectionEntries are created in 
DefaultMergeEventListener.entityIsDetached(231). Too early, really.






More information about the hibernate-dev mailing list