[ 
https://issues.apache.org/jira/browse/OPENJPA-3098?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Maxim Solodovnik resolved OPENJPA-3098.
---------------------------------------
    Resolution: Fixed

> MySQL and MariaDB: bulk DELETE whose WHERE clause uses a relation also 
> deletes the rows of the joined table
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-3098
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-3098
>             Project: OpenJPA
>          Issue Type: Bug
>            Reporter: Richard Zowalla
>            Assignee: Richard Zowalla
>            Priority: Major
>             Fix For: 4.3.0
>
>
> On MySQL and MariaDB a JPQL bulk delete whose WHERE clause navigates a 
> relation deletes the matching rows of the joined table too. For
> {code}
> DELETE FROM BulkRangeLine l WHERE l.order.status = :status
> {code}
> OpenJPA issues
> {code}
> DELETE t0, t1 FROM BRG_LINE t0 INNER JOIN BRG_ORDER t1 ON t0.ORDER_ID = t1.ID 
> WHERE (t1.STATUS = ?)
> {code}
> MySQL's multi-table DELETE removes the rows from every table in the target 
> list, so the orders that match are deleted together with their lines, and 
> executeUpdate() returns the sum (3 instead of 2 in the test).
> AbstractMySQLDictionary sets requiresTargetForDelete, and 
> DBDictionary.getDeleteTargets() lists all table aliases of the select (since 
> OPENJPA-597). Only the table of the entity of the statement must be a target: 
> DELETE t0 FROM BRG_LINE t0 INNER JOIN BRG_ORDER t1 ...
> Found by TestBulkSingleTableRange.deleteLinesByOrderStatus (OPENJPA-3094), 
> which fails on MySQL 8.4/9.7 and MariaDB 10.11/12.3 in the scheduled 
> Databases run: https://github.com/apache/openjpa/actions/runs/45111674759



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to