| Summary: | Updates to a value in an element collection map keyed by entity results in entity deletion | ||||||
|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | Michael Keith <michael.keith> | ||||
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | gabriel, gordon.yorke, vikram.jeet.bhatia | ||||
| Version: | unspecified | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Created attachment 207373 [details]
Fix with testcase
Fixed in EclipseLink main trunk (2.4) with r10447. Bug 364546 has been filed as performance enhancement for tracking delete/insert problem instead of an update. (In reply to comment #3) > Bug 364546 has been filed as performance enhancement for tracking delete/insert > problem instead of an update. Hi, I've tested the fix and it seems like addition and update of element to the map does function properly. However, removal of an element from the map does not. The merge returns an object with the correct map. When you actually examine the database table, the element still exists in the map. The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |
ElementCollection Map of basic values keyed by entity. Updating a value of a Map entry seems to be causing EL to not only remove the old row in the collection table and insert a new one with the new value, but also to attempt to delete the entity from its table as well. Example of model: @Entity public class Department { @Id private int id; @ElementCollection @CollectionTable(name="EMP_SENIORITY") @MapKeyJoinColumn(name="EMP_ID") @Column(name="SENIORITY") private Map<Employee, Integer> seniorities; ... } Code example: myDept.getSeniorities().put(newEmp, 1); ... myDept.getSeniorities().put(newEmp, 2); When modifying the value, the second put() will cause the row in EMP_SENIORITY table to be removed and a new one to be inserted, but will also then go on to try to remove the newEmp Employee row in the EMPLOYEE table.