Ticket #346 (new defect)
Merge needlessly/dangerously copies immutable fields.
| Reported by: | jmoore | Owned by: | jmoore |
|---|---|---|---|
| Priority: | critical | Milestone: | Blocked |
| Component: | Model | Version: | 3.0-M1 |
| Keywords: | collections, links, hibernate, merge, proxies, unloading, corruption | Cc: | callan |
Description (last modified by jmoore) (diff)
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.
