Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 342922 - Unwanted insert statement generated when using ElementCollection with lazy loading.
Summary: Unwanted insert statement generated when using ElementCollection with lazy lo...
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-15 02:42 EDT by Vikram Bhatia CLA
Modified: 2022-06-09 10:23 EDT (History)
1 user (show)

See Also:


Attachments
Testcase Source (4.82 KB, application/zip)
2011-04-15 02:45 EDT, Vikram Bhatia CLA
no flags Details
Proposed Fix inclusing testcase. (65.29 KB, patch)
2011-04-23 07:38 EDT, Vikram Bhatia CLA
no flags Details | Diff
Fix for testcase to run along with App Servers (665 bytes, patch)
2011-04-26 13:01 EDT, Vikram Bhatia CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vikram Bhatia CLA 2011-04-15 02:42:13 EDT
Build Identifier: 

An unwanted insert statement generated when using ElementCollection with lazy loading and weaving enabled.

Reproducible: Always

Steps to Reproduce:
1. Unzip enclosed testcase source and compile it.
2. Change persistence.xml to point to the database.
3. Execute test.CreateDatabase class to create all necessary tables.
4. Execute sql/testdata.sql to create test data for reproducing this issue.
5. Execute test.Test class passing -javaagent:eclipselink.jar to enable weaving to notice an extra row which does not get deleted from table SR_EC_SHIPMENT_CARGNAT.
Comment 1 Vikram Bhatia CLA 2011-04-15 02:45:18 EDT
Created attachment 193325 [details]
Testcase Source
Comment 2 Vikram Bhatia CLA 2011-04-15 02:46:18 EDT
The issue is the databaseCount of the DirectCollectionChangeRecord is
incremented prior to recording the removal from the collection.  The code
however assumes that the element has already been removed from the collection
as it would have been for DeferredChangeTracking.

Working on probable fix currently.
Comment 3 Vikram Bhatia CLA 2011-04-23 07:38:08 EDT
Created attachment 193952 [details]
Proposed Fix inclusing testcase.
Comment 4 Vikram Bhatia CLA 2011-04-25 15:53:51 EDT
Fixed in EL trunk
At revision: 9259
Comment 5 Vikram Bhatia CLA 2011-04-25 15:54:55 EDT
Added a flag to CollectionChangeEvent to identify if the change has already been applied to the collection before raising collection change event ADD or REMOVE. The flag will be passed as true from IndirectList, IndirectSet and IndirectMap whereas false from DirectCollectionMapping while merging the object. 
Changed ContainerPolicy and its subclasses to pass the flag in createChangeEvent method.
Comment 6 Vikram Bhatia CLA 2011-04-26 12:21:14 EDT
Reopening the bug as the testcase added for this bug does not work when run along with Application Servers (WLS/WAS/JBoss/GlassFish).
Comment 7 Vikram Bhatia CLA 2011-04-26 13:01:19 EDT
Created attachment 194080 [details]
Fix for testcase to run along with App Servers
Comment 8 Vikram Bhatia CLA 2011-04-27 06:38:02 EDT
Fixed test case to run with application servers.
At Revision: r9261
Comment 9 Eclipse Webmaster CLA 2022-06-09 10:17:12 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 10 Eclipse Webmaster CLA 2022-06-09 10:23:08 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink