Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 364546

Summary: Enhancement: Updates to a value in an element collection map keyed by entity results in delete/insert instead of an update.
Product: z_Archived Reporter: Vikram Bhatia <vikram.jeet.bhatia>
Component: EclipselinkAssignee: Project Inbox <eclipselink.orm-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: gabriel, martin.grebac
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Vikram Bhatia CLA 2011-11-23 04:02:14 EST
ElementCollection Map of basic values keyed by entity. 

Updating a value of a Map entry seems to be causing EL to remove the
old row in the collection table and insert a new one with the new value instead of updating it in the collection table.

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 in the collection table.

Bug 364248 reports two problems. First one has been fixed. However, the other is a performance enhancement.
Comment 1 Eclipse Webmaster CLA 2022-06-09 10:04:48 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 2 Eclipse Webmaster CLA 2022-06-09 10:09:39 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink