[ 
https://issues.apache.org/jira/browse/OPENJPA-3047?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18139483#comment-18139483
 ] 

ASF subversion and git services commented on OPENJPA-3047:
----------------------------------------------------------

Commit e52fb651e9db81493748b0422e2e76110e8fe2c0 in openjpa's branch 
refs/heads/master from Richard Zowalla
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=e52fb651e ]

[OPENJPA-3047] Update each table by key when a bulk update sets columns of 
several tables (#276)

* [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.

* [OPENJPA-3047] Count entities, not changed rows per table, when a bulk update 
sets columns of several tables on MySQL and MariaDB

* [OPENJPA-3047] Use Map<Path, Value> for the fields of a bulk update

Type the bulk update fields as Map<Path, Value> instead of raw maps and
Object entries in JDBCStoreQuery and DBDictionary.toTableUpdate.

> 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)

Reply via email to