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

Bug 328307

Summary: Intermittent multiple assignments to same column
Product: z_Archived Reporter: Joseph Chiu <joseph>
Component: EclipselinkAssignee: Vikram Bhatia <vikram.jeet.bhatia>
Status: CLOSED INVALID QA Contact:
Severity: major    
Priority: P2 CC: eclipse, julo, tom.ware, vikram.jeet.bhatia
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
TAR-GZ of Source file and README.txt which shows the error none

Description Joseph Chiu CLA 2010-10-20 21:14:14 EDT
Build Identifier: 2.1.1.v20100817-r8050

When persisting changes, sometimes the same column shows up twice in the same UPDATE query:

Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.1.v20100817-r8050): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: multiple assignments to same column "cv"
Error Code: 0
Call: UPDATE FOORESULT SET CV = ?, CV = ?, LASTUPDATED = ? WHERE ((ID = ?) AND (LASTUPDATED = ?))
        bind => [2.93, 2.93, 2010-10-20 17:46:30.722615, 1, 2010-10-20 17:46:29.806275]
Query: UpdateObjectQuery(lzk.FooResult@1cef4f7)
        at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:333)

The problem appears intermittently.  It seems to be related to the @Embeddedable's.

It seems that the problem is tied to each run invocation.  Either the failure occurs for all attempts to update; or passes.

Reproducible: Sometimes

Steps to Reproduce:
I will attach a gzip'd tar file witih a stripped down set of soure code that replicates the problem.  

After installing Postgres 8.4., the steps to reproduce are:


$ ./creatuser.sh elissue
$ ./createdb.sh elissue
$ mvn test
$ mvn test
$ ... repeat until failure exception is thrown.  

As shown in the included README.txt, I had to run the test program 4 times to cause the error to appear.
Comment 1 Joseph Chiu CLA 2010-10-20 21:17:19 EDT
Created attachment 181351 [details]
TAR-GZ of Source file and README.txt which shows the error
Comment 2 Levon Karayan CLA 2010-10-22 19:37:37 EDT
Since it's intermittent, this is a rather concerning issue.   I'm worried that production code is failing and a developer could have inadvertently ate the exception or we missed it in monitoring.   You got my vote.
Comment 3 Tom Ware CLA 2010-11-01 11:30:28 EDT
Setting target and priority.  See the following page for details about these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines
Comment 4 Joseph Chiu CLA 2011-01-25 19:11:43 EST
I had previously stated my impression that either the problem occurs always for a program run, or it does not occur at all.  I was wrong about that:

In one example, I had the program run over a small batch of work, and within the same "session" (only one EntityManagerFactory, and one EntityManager created from that factory), the error occurred once, amidst four successful updates.  (Each update being wrapped by a beginTransaction and commitTransaction.)
Comment 5 Joseph Chiu CLA 2011-01-25 19:23:30 EST
BTW, this bug continues to exist in 2.1.2v20101206-r8635, not just 2.1.1.v20100817-r8050
Comment 6 Vikram Bhatia CLA 2012-09-06 07:29:15 EDT
Workaround
----------
Clone the embeddable object instead of re-using the fetched embeddable object
for different embeddable field in same entity.

// KeyPair fooVal = cr.getRV().min(fooLimit).max(KeyPair.BIG_ZERO);

KeyPair fooVal2 = cr.getRV().min(fooLimit).max(KeyPair.BIG_ZERO);
KeyPair fooVal = new KeyPair(fooVal2.getKey(), fooVal2.getVal());
Comment 7 Vikram Bhatia CLA 2012-09-10 09:49:49 EDT
As per JPA 2.0 Specifications, Section 2.5

2.5 Embeddable Classes
Embedded objects belong strictly to their owning entity, and are not sharable
across persistent entities. Attempting to share an embedded object across
entities has undefined semantics.


So, embedded objects cannot be shared.
Comment 8 Julius Stroffek CLA 2012-12-26 18:29:40 EST
I ran into this problem as well.

Originally, I tought that the issue is deterministic. However, trying to find out cases where the issue pops up and when it does not I ran into cases where the issue randomly appears.
Comment 9 Julius Stroffek CLA 2012-12-26 18:50:25 EST
I ran into this and while repeating the same thing the query generated for entity update is:
UPDATE agm.task SET actual_release = ?, planned_release = ?, task_resolution = ? WHERE (entity_id = ?)

The query that is generated in case of failure (while doing the same stuff with the same entities) is
UPDATE agm.task SET actual_release = ?, actual_release = ?, task_resolution = ? WHERE (entity_id = ?)

Looks like the naming of columns does not work well for some cases for embedded entities.

I'll try to do more troubleshooting.
Comment 10 Julius Stroffek CLA 2012-12-26 18:54:48 EST
Hmmm... sometime the duplicate columns are even the other way round...

UPDATE agm.task SET planned_release = ?, planned_release = ?, task_resolution = ? WHERE (entity_id = ?)
Comment 11 Eclipse Webmaster CLA 2022-06-09 10:09:48 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink