[
https://issues.apache.org/jira/browse/OPENJPA-3036?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18133922#comment-18133922
]
ASF subversion and git services commented on OPENJPA-3036:
----------------------------------------------------------
Commit 221937e887b502b1d8d2b7facc90971dcf53f544 in openjpa's branch
refs/heads/master from Richard Zowalla
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=221937e88 ]
[OPENJPA-3036] Match the keys of a bulk update or delete in a derived table on
MySQL (#242)
MySQL rejects an UPDATE or DELETE whose WHERE clause has a subquery that
reads the changed table (error 1093). When the bulk statement has a
subquery, collect the primary keys of the matching rows in a derived
table, which MySQL materializes before changing any row, so the subquery
still sees the state before the statement. The new dictionary property
AllowsBulkTargetInSubselect turns this on; it is false for MySQL.
> MySQL: bulk UPDATE with a subquery on the same table
> ----------------------------------------------------
>
> Key: OPENJPA-3036
> URL: https://issues.apache.org/jira/browse/OPENJPA-3036
> Project: OpenJPA
> Issue Type: Sub-task
> Reporter: Richard Zowalla
> Priority: Major
> Fix For: 4.2.0
>
>
> MySQL does not allow the updated table in a subquery of the same statement:
> {noformat}You can't specify target table 't0' for update in FROM clause
> {prepstmnt UPDATE PRODUCT_TABLE t0 INNER JOIN PRODUCT_DETAILS t2 ON t0.ID =
> t2.ID SET t0.QUANTITY = (t0.QUANTITY * ?) WHERE (EXISTS (SELECT t1.ID FROM
> PRODUCT_TABLE t1 WHERE (t0.ID = ?)))} [code=1093]{noformat}
> The usual way around it is to wrap the subquery in a derived table.
> Failing test: {{Client.subquery}}.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)