Richard Zowalla created OPENJPA-3099:
----------------------------------------
Summary: 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
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)