[
https://issues.apache.org/jira/browse/OPENJPA-3099?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18152989#comment-18152989
]
ASF subversion and git services commented on OPENJPA-3099:
----------------------------------------------------------
Commit add2ad51022f0cf157f3c3a4a1035a15a20808c3 in openjpa's branch
refs/heads/master from Richard Zowalla
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=add2ad510 ]
[OPENJPA-3099] Join the related entity of TYPE() of a single-valued path (#327)
* [OPENJPA-3099] Join the related entity of TYPE() of a single-valued path
TYPE() of a path such as l.order did not join the table of the related
entity, so the discriminator was read from an unjoined alias: a bulk
delete or update with such a condition changed every row, and a select
returned duplicates or failed with an aggregate. TYPE() now joins the
relation, and a type literal in a condition no longer puts the table of
its entity in the FROM clause. TYPE(x) <> X outside a table-per-class
hierarchy is no longer written as an equality, and SELECT TYPE() of a
path returns the base class for its discriminator value and null for a
missing relation.
* [OPENJPA-3099] Remove @Test from the parameterized helper of TestBulkUpdate
JUnit cannot resolve the int parameter of simpleBulkUpdate(int), which
simpleBulkUpdate() calls for each value.
* [OPENJPA-3099] Run simpleBulkUpdate of TestBulkUpdate as a parameterized test
Replace the loop over 1 to 4 with @ParameterizedTest and @ValueSource,
so that each number of entities is reported as its own test.
> TYPE() of a single-valued path is not joined: bulk DELETE deletes all rows,
> SELECT fails
> -----------------------------------------------------------------------------------------
>
> Key: OPENJPA-3099
> URL: https://issues.apache.org/jira/browse/OPENJPA-3099
> Project: OpenJPA
> Issue Type: Bug
> Reporter: Richard Zowalla
> Assignee: Richard Zowalla
> Priority: Major
> Fix For: 4.3.0
>
>
> TYPE() applied to a relation path adds the table of the related entity to the
> FROM clause without the join condition. With BulkRangeLine -> BulkRangeOrder
> (SINGLE_TABLE, subclass BulkRangeRushOrder), 4 orders of which 2 are rush
> orders, 2 lines each:
> {code}
> DELETE FROM BulkRangeLine l WHERE TYPE(l.order) = BulkRangeRushOrder
> {code}
> issues on Derby
> {code}
> DELETE FROM BRG_LINE WHERE ID IN (SELECT DISTINCT t1.ID FROM BRG_ORDER t0,
> BRG_LINE t1 WHERE (t0.ORDER_TYPE = 'BulkRangeRushOrder'))
> {code}
> The cross join matches every line, so all 8 lines are deleted instead of the
> 4 lines of the rush orders. MySQL produces the same cross join (DELETE t1
> FROM BRG_ORDER t0, BRG_LINE t1 ...).
> The same condition in a SELECT is not joined either and fails on Derby:
> {code}
> SELECT COUNT(l) FROM BulkRangeLine l WHERE TYPE(l.order) = BulkRangeRushOrder
> {code}
> Column reference 'T0.ID' is invalid ... \{SELECT t0.ID, COUNT(t1.ID) FROM
> BRG_ORDER t0, BRG_LINE t1 WHERE (t0.ORDER_TYPE = 'BulkRangeRushOrder')}
> Expected: the path is joined (t1.ORDER_ID = t0.ID), 4 lines are deleted, and
> the count is 4.
> Reproduced on master (86e153ab7) with the entities of
> TestBulkSingleTableRange (OPENJPA-3094); found while working on OPENJPA-3098.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)