[
https://issues.apache.org/jira/browse/OPENJPA-3047?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18139131#comment-18139131
]
ASF subversion and git services commented on OPENJPA-3047:
----------------------------------------------------------
Commit 32cff804fe6330726692507054b6d87e7b198ed0 in openjpa's branch
refs/heads/OPENJPA-3047 from Richard Zowalla
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=32cff804f ]
[OPENJPA-3047] Update each table by key when a bulk update sets columns of
several tables
A bulk update that set a column of a joined superclass table or of a
secondary table was issued as one UPDATE of the primary table of the
entity, which fails because the column is not in that table. The same
happened for the version column of a joined subclass, which is in the
root table.
When the database cannot change the tables in one statement that joins
them under their aliases, select the primary keys of the matching rows
once and issue one UPDATE per table restricted to those keys, so no
statement sees the changes of another. Databases that update the joined
tables in one statement, such as MySQL, keep the SQL they generate.
On those databases the values are written without table aliases, so a
value that reads a column of another table than the one it is written
to, such as SET e.quantity = e.power with quantity in the superclass
table, is now executed in-memory instead of failing with an SQL error.
> Bulk UPDATE of a column in a joined superclass or a secondary table fails on
> Derby and H2
> -----------------------------------------------------------------------------------------
>
> Key: OPENJPA-3047
> URL: https://issues.apache.org/jira/browse/OPENJPA-3047
> Project: OpenJPA
> Issue Type: Sub-task
> Reporter: Richard Zowalla
> Priority: Major
>
> Two bulk UPDATE cases fail:
> * Setting a column of a joined superclass through a subclass, e.g. {{UPDATE
> Engine e SET e.quantity = ...}} where {{quantity}} is mapped in the
> superclass table, fails on Derby: {{'QUANTITY' is not a column in table
> 'ENGINE'}}.
> * Setting a column of a secondary table, e.g. {{UPDATE Product e SET e.detail
> = ...}}, fails on Derby and H2, which use the unaliased {{UPDATE PRODUCT SET
> detail = ...}} form against the primary table.
> Found while working on OPENJPA-3036.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)