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

Bug 351657

Summary: Tenant discriminator column not included in update SQL on multitenant entity with secondary table
Product: z_Archived Reporter: Larry D <larryd>
Component: EclipselinkAssignee: Project Inbox <eclipselink.orm-inbox>
Status: CLOSED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: guy.pelletier, tom.ware
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Eclipse project and test code to reproduce the problem none

Description Larry D CLA 2011-07-10 10:58:09 EDT
Created attachment 199389 [details]
Eclipse project and test code to reproduce the problem

I have decided to use the new multitenant feature as a way to Internationalize some entities. My idea was to create a multitenant entity with a secondary table, where the secondary table would contain the language discriminator column and the other i18n attributes. I specified that the language discriminator should be part of the primary key. 

This created on database level two tables:
"Primary table" (Id as primary key);
"Secondary table I18N"
     (Id and language as composite primary key)
     (Id as foreign key referencing "Primary table".Id);

I have created manually a new row in the "Secondary table I18N" with a different language. 
The select and delete statements worked as expected, but the generated update statement updated all rows with the same ID, regardless of language.
In my test case, on UPDATE EclipseLink creates the following SQL statements:
     UPDATE CODE SET ENTITYVERSION = ? WHERE ((ID = ?) AND (ENTITYVERSION = ?))
     UPDATE Code_I18n SET NAMEI18N = ? WHERE (ID = ?)
The second update statement in my opinion should look like:
     UPDATE Code_I18n SET NAMEI18N = ? WHERE ((ID = ?) AND (languageCode = ?))

I have tested with:
eclipselink-2.3.0.v20110604-r9504
eclipselink-2.3.1.v20110709-r9695
eclipselink-2.4.0.v20110709-r9697
Comment 1 Guy Pelletier CLA 2011-07-14 11:03:23 EDT
This is as designed. Specifiying the discriminator column as a 'primaryKey=true' tags it as a primary key field on the database only (and used with DDL generation) and does not make it part of the object's id. 

Meaning, with the single update statement, languageCode is redundant at this point since you are dealing with one object (read using the tenant discriminator column) which is tied to the secondary table by its object id.
Comment 2 Guy Pelletier CLA 2011-07-15 10:57:25 EDT
Closing as invalid since it is as designed.
Comment 3 Eclipse Webmaster CLA 2022-06-09 10:04:53 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink