Task #346 (closed)
Merge needlessly/dangerously copies immutable fields.
|Reported by:||jamoore||Owned by:||jamoore|
|Keywords:||collections, links, hibernate, merge, proxies, unloading, corruption||Cc:||cxallan|
Description (last modified by jmoore)
Was: Passing non-proxied one-to-manys to server can return empty (non-null) collection (See comments below)
Several model objects have methods for adding items to collection-valued fields:
* Pixels.addThumbnail(Thumbnail) * Project.linkDataset(Dataset)
These calls add the argument to their own collection and then call the reverse method on the arguments:
* Thumnail.setPixels(Pixels) * ProjectDatasetLink.setProject(Project)
The collections are ignored by Hibernate, and only the reverse methods have an effect. This is known behavior.
However, when one uses only the reverse methods (e.g. setPixels(Pixels)) and the Pixels instance is not a proxy (e.g. pixels.isLoaded()==true) then the Pixels instance which is returned by the IUpdate.saveAndReturnObject() method is neither unloaded, nor is the collection nulled, nor does it contain the newly added Thumbnail which could easily lead to data corruption.
Change History (13)
comment:9 Changed 15 years ago by jmoore
- Description modified (diff)
- Keywords hibernate merge added
- Summary changed from Passing non-proxied one-to-manys to server can return empty (non-null) collection to Merge needlessly/dangerously copies immutable fields.